From bb0395b4645cb916a53721945ad8dc1796ee0f85 Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:58:02 +0200 Subject: [PATCH 01/21] check GER and index of synced L1InfoRoot matches with sc values (#3551) --- etherman/etherman.go | 11 +++ sequencer/finalizer.go | 120 ++++++++++++++++++++++------- sequencer/interfaces.go | 7 +- sequencer/mock_etherman.go | 73 +++++++++++++++++- sequencer/sequencer.go | 4 +- state/pgstatestorage/l1infotree.go | 2 +- 6 files changed, 183 insertions(+), 34 deletions(-) diff --git a/etherman/etherman.go b/etherman/etherman.go index 75c50e1ddc..7c14e5cc6e 100644 --- a/etherman/etherman.go +++ b/etherman/etherman.go @@ -1940,6 +1940,17 @@ func (etherMan *Client) EstimateGas(ctx context.Context, from common.Address, to }) } +// DepositCount returns deposits count +func (etherman *Client) DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) { + var opts *bind.CallOpts + if blockNumber != nil { + opts = new(bind.CallOpts) + opts.BlockNumber = new(big.Int).SetUint64(*blockNumber) + } + + return etherman.GlobalExitRootManager.DepositCount(opts) +} + // CheckTxWasMined check if a tx was already mined func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error) { receipt, err := etherMan.EthClient.TransactionReceipt(ctx, txHash) diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index 46a0d7cb53..a87cc29042 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -10,6 +10,7 @@ import ( "time" "github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer" + ethermanTypes "github.com/0xPolygonHermez/zkevm-node/etherman" "github.com/0xPolygonHermez/zkevm-node/event" "github.com/0xPolygonHermez/zkevm-node/hex" "github.com/0xPolygonHermez/zkevm-node/log" @@ -38,7 +39,7 @@ type finalizer struct { workerIntf workerInterface poolIntf txPool stateIntf stateInterface - etherman etherman + etherman ethermanInterface wipBatch *Batch wipL2Block *L2Block batchConstraints state.BatchConstraintsCfg @@ -87,7 +88,7 @@ func newFinalizer( workerIntf workerInterface, poolIntf txPool, stateIntf stateInterface, - etherman etherman, + etherman ethermanInterface, sequencerAddr common.Address, isSynced func(ctx context.Context) bool, batchConstraints state.BatchConstraintsCfg, @@ -220,18 +221,95 @@ func (f *finalizer) updateFlushIDs(newPendingFlushID, newStoredFlushID uint64) { f.storedFlushIDCond.L.Unlock() } -func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { - firstL1InfoRootUpdate := true - skipFirstSleep := true +func (f *finalizer) checkValidL1InfoRoot(ctx context.Context, l1InfoRoot state.L1InfoTreeExitRootStorageEntry) (bool, error) { + // Check L1 block hash matches + l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil) + if err != nil { + return false, fmt.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err) + } + + l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber)) + if err != nil { + return false, fmt.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err) + } + + if l1BlockState.BlockHash != l1BlockEth.Hash() { + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, l1Block: %d. L1 block hash %s doesn't match block hash on ethereum %s (L1 reorg?)", + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) + log.Warnf(warnmsg) + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + + return false, nil + } + + // Check l1InfoRootIndex and GER matches. We retrieve the info of the last l1InfoTree event in the block, since in the case we have several l1InfoTree events + // in the same block, the function checkL1InfoTreeUpdate retrieves only the last one and skips the others + log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash) + blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber) + if err != nil { + return false, err + } + + //Get L1InfoTree events of the L1 block where the l1InforRoot we need to check was synced + lastGER := state.ZeroHash + for _, block := range blocks { + blockEventsOrder := eventsOrder[block.BlockHash] + for _, order := range blockEventsOrder { + if order.Name == ethermanTypes.L1InfoTreeOrder { + lastGER = block.L1InfoTree[order.Pos].GlobalExitRoot + log.Debugf("l1InfoTree event, pos: %d, GER: %s", order.Pos, lastGER) + } + } + } - if f.cfg.L1InfoTreeCheckInterval.Duration.Seconds() == 999999 { //nolint:gomnd + // Get the deposit count in the moment when the L1InfoRoot was synced + depositCount, err := f.etherman.DepositCount(ctx, &l1InfoRoot.BlockNumber) + if err != nil { + return false, err + } + // l1InfoTree index starts at 0, therefore we need to subtract 1 to the depositCount to get the last index at that moment + index := uint32(depositCount.Uint64()) + if index > 0 { // we check this as protection, but depositCount should be greater that 0 in this context + index-- + } else { + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. DepositCount value returned by the smartcontrat is 0 and that isn't possible in this context", + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber) + log.Warn(warnmsg) + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + + return false, nil + } + + log.Debugf("checking valid l1InfoRoot, index: %d, GER: %s, l1Block: %d, scIndex: %d, scGER: %s", + l1InfoRoot.BlockNumber, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, index, lastGER) + + if (l1InfoRoot.GlobalExitRoot.GlobalExitRoot != lastGER) || (l1InfoRoot.L1InfoTreeIndex != index) { + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. It doesn't match with smartcontract l1InfoRoot, index: %d, GER: %s", + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, index, lastGER) + log.Warn(warnmsg) + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + + return false, nil + } + + return true, nil +} + +func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { + broadcastL1InfoTreeValid := func() { if !f.lastL1InfoTreeValid { f.lastL1InfoTreeCond.L.Lock() f.lastL1InfoTreeValid = true f.lastL1InfoTreeCond.Broadcast() f.lastL1InfoTreeCond.L.Unlock() } + } + + firstL1InfoRootUpdate := true + skipFirstSleep := true + if f.cfg.L1InfoTreeCheckInterval.Duration.Seconds() == 0 { //nolint:gomnd + broadcastL1InfoTreeValid() return } @@ -255,7 +333,7 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { l1InfoRoot, err := f.stateIntf.GetLatestL1InfoRoot(ctx, maxBlockNumber) if err != nil { - log.Errorf("error checking latest L1InfoRoot, error: %v", err) + log.Errorf("error getting latest l1InfoRoot, error: %v", err) continue } @@ -265,27 +343,18 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { } if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { - log.Infof("received new L1InfoRoot, l1InfoTreeIndex: %d, l1InfoTreeRoot: %s, l1Block: %d", - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.BlockNumber) + log.Infof("received new l1InfoRoot %s, index: %d, l1Block: %d", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) - // Sanity check l1BlockState (l1InfoRoot.BlockNumber) blockhash matches blockhash on ethereum. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree) + // Check if new l1InfoRoot is valid. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree) if l1InfoRoot.BlockNumber > 0 { - l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil) + valid, err := f.checkValidL1InfoRoot(ctx, l1InfoRoot) if err != nil { - log.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err) + log.Errorf("error validating new l1InfoRoot, index: %d, error: %v", l1InfoRoot.L1InfoTreeIndex, err) continue } - l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber)) - if err != nil { - log.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err) - continue - } - if l1BlockState.BlockHash != l1BlockEth.Hash() { - warnmsg := fmt.Sprintf("invalid l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?). Stopping syncing l1IntroTreeIndex", - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) - log.Warn(warnmsg) - f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + if !valid { + log.Warnf("invalid l1InfoRoot %s, index: %d, l1Block: %d. Stopping syncing l1InfoTreeIndex", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) return } } @@ -296,12 +365,7 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { f.lastL1InfoTree = l1InfoRoot f.lastL1InfoTreeMux.Unlock() - if !f.lastL1InfoTreeValid { - f.lastL1InfoTreeCond.L.Lock() - f.lastL1InfoTreeValid = true - f.lastL1InfoTreeCond.Broadcast() - f.lastL1InfoTreeCond.L.Unlock() - } + broadcastL1InfoTreeValid() } } } diff --git a/sequencer/interfaces.go b/sequencer/interfaces.go index afe49bceb9..10c58980ac 100644 --- a/sequencer/interfaces.go +++ b/sequencer/interfaces.go @@ -5,6 +5,7 @@ import ( "math/big" "time" + ethermanTypes "github.com/0xPolygonHermez/zkevm-node/etherman" "github.com/0xPolygonHermez/zkevm-node/pool" "github.com/0xPolygonHermez/zkevm-node/state" "github.com/ethereum/go-ethereum/common" @@ -30,12 +31,14 @@ type txPool interface { GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) } -// etherman contains the methods required to interact with ethereum. -type etherman interface { +// ethermanInterface contains the methods required to interact with ethereum. +type ethermanInterface interface { TrustedSequencer() (common.Address, error) GetLatestBatchNumber() (uint64, error) GetLatestBlockNumber(ctx context.Context) (uint64, error) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) + GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]ethermanTypes.Block, map[common.Hash][]ethermanTypes.Order, error) + DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) } // stateInterface gathers the methods required to interact with the state. diff --git a/sequencer/mock_etherman.go b/sequencer/mock_etherman.go index 3169ca6f3f..f51eb11d09 100644 --- a/sequencer/mock_etherman.go +++ b/sequencer/mock_etherman.go @@ -8,16 +8,48 @@ import ( common "github.com/ethereum/go-ethereum/common" + etherman "github.com/0xPolygonHermez/zkevm-node/etherman" + mock "github.com/stretchr/testify/mock" types "github.com/ethereum/go-ethereum/core/types" ) -// EthermanMock is an autogenerated mock type for the etherman type +// EthermanMock is an autogenerated mock type for the ethermanInterface type type EthermanMock struct { mock.Mock } +// DepositCount provides a mock function with given fields: ctx, blockNumber +func (_m *EthermanMock) DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) { + ret := _m.Called(ctx, blockNumber) + + if len(ret) == 0 { + panic("no return value specified for DepositCount") + } + + var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *uint64) (*big.Int, error)); ok { + return rf(ctx, blockNumber) + } + if rf, ok := ret.Get(0).(func(context.Context, *uint64) *big.Int); ok { + r0 = rf(ctx, blockNumber) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *uint64) error); ok { + r1 = rf(ctx, blockNumber) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetLatestBatchNumber provides a mock function with given fields: func (_m *EthermanMock) GetLatestBatchNumber() (uint64, error) { ret := _m.Called() @@ -74,6 +106,45 @@ func (_m *EthermanMock) GetLatestBlockNumber(ctx context.Context) (uint64, error return r0, r1 } +// GetRollupInfoByBlockRange provides a mock function with given fields: ctx, fromBlock, toBlock +func (_m *EthermanMock) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error) { + ret := _m.Called(ctx, fromBlock, toBlock) + + if len(ret) == 0 { + panic("no return value specified for GetRollupInfoByBlockRange") + } + + var r0 []etherman.Block + var r1 map[common.Hash][]etherman.Order + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)); ok { + return rf(ctx, fromBlock, toBlock) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, *uint64) []etherman.Block); ok { + r0 = rf(ctx, fromBlock, toBlock) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]etherman.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, *uint64) map[common.Hash][]etherman.Order); ok { + r1 = rf(ctx, fromBlock, toBlock) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(map[common.Hash][]etherman.Order) + } + } + + if rf, ok := ret.Get(2).(func(context.Context, uint64, *uint64) error); ok { + r2 = rf(ctx, fromBlock, toBlock) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // HeaderByNumber provides a mock function with given fields: ctx, number func (_m *EthermanMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { ret := _m.Called(ctx, number) diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index e98c367fc1..64b5711fae 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -27,7 +27,7 @@ type Sequencer struct { pool txPool stateIntf stateInterface eventLog *event.EventLog - etherman etherman + etherman ethermanInterface worker *Worker finalizer *finalizer @@ -42,7 +42,7 @@ type Sequencer struct { } // New init sequencer -func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman etherman, eventLog *event.EventLog) (*Sequencer, error) { +func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman ethermanInterface, eventLog *event.EventLog) (*Sequencer, error) { addr, err := etherman.TrustedSequencer() if err != nil { return nil, fmt.Errorf("failed to get trusted sequencer address, error: %v", err) diff --git a/state/pgstatestorage/l1infotree.go b/state/pgstatestorage/l1infotree.go index ed3fe2dd38..83c869cf5a 100644 --- a/state/pgstatestorage/l1infotree.go +++ b/state/pgstatestorage/l1infotree.go @@ -53,7 +53,7 @@ func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumbe const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index FROM state.exit_root WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1 - ORDER BY l1_info_tree_index DESC` + ORDER BY l1_info_tree_index DESC LIMIT 1` entry := state.L1InfoTreeExitRootStorageEntry{} From 52e966793ddcffc5c477eef39dff827b01a66f20 Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Fri, 12 Apr 2024 12:27:22 -0300 Subject: [PATCH 02/21] apply txIndex fix to StoreTransactions; add migration to fix wrong txIndexes (#3556) --- db/migrations/state/0019.sql | 25 ++++++ db/migrations/state/0019_test.go | 145 +++++++++++++++++++++++++++++++ state/transaction.go | 5 +- 3 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 db/migrations/state/0019.sql create mode 100644 db/migrations/state/0019_test.go diff --git a/db/migrations/state/0019.sql b/db/migrations/state/0019.sql new file mode 100644 index 0000000000..bd982feab1 --- /dev/null +++ b/db/migrations/state/0019.sql @@ -0,0 +1,25 @@ +-- +migrate Up + +-- the update below fix the wrong receipt TX indexes +WITH map_fix_tx_index AS ( + SELECT t.l2_block_num AS block_num + , t.hash AS tx_hash + , r.tx_index AS current_index + , (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index + FROM state.receipt r + INNER JOIN state."transaction" t + ON t.hash = r.tx_hash +) +UPDATE state.receipt AS r + SET tx_index = m.correct_index + FROM map_fix_tx_index m + WHERE m.block_num = r.block_num + AND m.tx_hash = r.tx_hash + AND m.current_index = r.tx_index + AND m.current_index != m.correct_index; + + +-- +migrate Down + +-- no action is needed, the data fixed by the +-- migrate up must remain fixed \ No newline at end of file diff --git a/db/migrations/state/0019_test.go b/db/migrations/state/0019_test.go new file mode 100644 index 0000000000..7205998d60 --- /dev/null +++ b/db/migrations/state/0019_test.go @@ -0,0 +1,145 @@ +package migrations_test + +import ( + "database/sql" + "testing" + + "github.com/0xPolygonHermez/zkevm-node/hex" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +type migrationTest0019TestCase struct { + Name string + Block migrationTest0019TestCaseBlock +} + +type migrationTest0019TestCaseBlock struct { + Transactions []migrationTest0019TestCaseTransaction +} + +type migrationTest0019TestCaseTransaction struct { + CurrentIndex uint +} + +type migrationTest0019 struct { + TestCases []migrationTest0019TestCase +} + +func (m migrationTest0019) InsertData(db *sql.DB) error { + const addBlock0 = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES (0, now(), '0x0')" + if _, err := db.Exec(addBlock0); err != nil { + return err + } + + const addBatch0 = ` + 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)` + if _, err := db.Exec(addBatch0); err != nil { + return err + } + + const addL2Block = "INSERT INTO state.l2block (block_num, block_hash, header, uncles, parent_hash, state_root, received_at, batch_num, created_at) VALUES ($1, $2, '{}', '{}', '0x0', '0x0', now(), 0, now())" + const addTransaction = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num, effective_percentage, l2_hash) VALUES ($1, 'ABCDEF', '{}', $2, 255, $1)" + const addReceipt = "INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address) VALUES ($1, 1, null, 1, 1234, 1234, 1, $2, $3, '')" + + txUnique := 0 + for tci, testCase := range m.TestCases { + blockNum := uint64(tci + 1) + blockHash := common.HexToHash(hex.EncodeUint64(blockNum)).String() + if _, err := db.Exec(addL2Block, blockNum, blockHash); err != nil { + return err + } + for _, tx := range testCase.Block.Transactions { + txUnique++ + txHash := common.HexToHash(hex.EncodeUint64(uint64(txUnique))).String() + if _, err := db.Exec(addTransaction, txHash, blockNum); err != nil { + return err + } + if _, err := db.Exec(addReceipt, txHash, blockNum, tx.CurrentIndex); err != nil { + return err + } + } + } + + return nil +} + +func (m migrationTest0019) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { + const getReceiptsByBlock = "SELECT r.tx_index FROM state.receipt r WHERE r.block_num = $1 ORDER BY r.tx_index" + + for tci := range m.TestCases { + blockNum := uint64(tci + 1) + + rows, err := db.Query(getReceiptsByBlock, blockNum) + require.NoError(t, err) + + var expectedIndex = uint(0) + var txIndex uint + for rows.Next() { + err := rows.Scan(&txIndex) + require.NoError(t, err) + require.Equal(t, expectedIndex, txIndex) + expectedIndex++ + } + } +} + +func (m migrationTest0019) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { + m.RunAssertsAfterMigrationUp(t, db) +} + +func TestMigration0019(t *testing.T) { + runMigrationTest(t, 19, migrationTest0019{ + TestCases: []migrationTest0019TestCase{ + { + Name: "single tx with correct index", + Block: migrationTest0019TestCaseBlock{ + Transactions: []migrationTest0019TestCaseTransaction{ + {CurrentIndex: 0}, + }, + }, + }, + { + Name: "multiple txs indexes are correct", + Block: migrationTest0019TestCaseBlock{ + Transactions: []migrationTest0019TestCaseTransaction{ + {CurrentIndex: 0}, + {CurrentIndex: 1}, + {CurrentIndex: 2}, + }, + }, + }, + { + Name: "single tx with wrong tx index", + Block: migrationTest0019TestCaseBlock{ + Transactions: []migrationTest0019TestCaseTransaction{ + {CurrentIndex: 3}, + }, + }, + }, + { + Name: "multiple txs missing 0 index", + Block: migrationTest0019TestCaseBlock{ + Transactions: []migrationTest0019TestCaseTransaction{ + {CurrentIndex: 1}, + {CurrentIndex: 2}, + {CurrentIndex: 3}, + {CurrentIndex: 4}, + }, + }, + }, + { + Name: "multiple has index 0 but also txs index gap", + Block: migrationTest0019TestCaseBlock{ + Transactions: []migrationTest0019TestCaseTransaction{ + {CurrentIndex: 0}, + {CurrentIndex: 2}, + {CurrentIndex: 4}, + {CurrentIndex: 6}, + }, + }, + }, + }, + }) +} diff --git a/state/transaction.go b/state/transaction.go index faa063731d..f3045ebe40 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -141,7 +141,7 @@ func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, proce } // firstTxToInsert := len(existingTxs) - + txIndex := 0 for i := 0; i < len(processedTxs); i++ { processedTx := processedTxs[i] // if the transaction has an intrinsic invalid tx error it means @@ -169,7 +169,7 @@ func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, proce header.BlockInfoRoot = processedBlock.BlockInfoRoot transactions := []*types.Transaction{&processedTx.Tx} - receipt := GenerateReceipt(header.Number, processedTx, uint(i), forkID) + receipt := GenerateReceipt(header.Number, processedTx, uint(txIndex), forkID) if !CheckLogOrder(receipt.Logs) { return fmt.Errorf("error: logs received from executor are not in order") } @@ -193,6 +193,7 @@ func (s *State) StoreTransactions(ctx context.Context, batchNumber uint64, proce if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil { return err } + txIndex++ } } return nil From d9ec8f0c89f3d61830fe70ce4216539b52d1e569 Mon Sep 17 00:00:00 2001 From: Alonso Rodriguez Date: Mon, 15 Apr 2024 12:31:41 +0200 Subject: [PATCH 03/21] Feature/#3549 reorgs improvement (#3553) * New reorg function * mocks * linter * Synchronizer tests * new elderberry smc docker image * new image * logs * fix json rpc * fix * Test sync from empty block * Regular reorg case tested * linter * remove empty block + fix LatestSyncedBlockEmpty * Improve check reorgs when no block is received during the call * fix RPC error code for eth_estimateGas and eth_call for reverted tx and no return value; fix e2e test; * fix test * Extra unit test * fix reorg until genesis * disable parallel synchronization --------- Co-authored-by: tclemos --- .../local/local.genesis.config.json | 12 +- docs/running_local.md | 2 +- etherman/etherman.go | 4 +- jsonrpc/endpoints_eth.go | 8 +- jsonrpc/endpoints_eth_test.go | 2 +- .../common/syncinterfaces/etherman.go | 1 + .../mocks/etherman_full_interface.go | 56 + ...ent_ethereum_compatible_l2_block_getter.go | 98 ++ synchronizer/synchronizer.go | 174 ++- synchronizer/synchronizer_test.go | 1165 ++++++++++++++++- test/e2e/jsonrpc2_test.go | 117 +- 11 files changed, 1489 insertions(+), 150 deletions(-) create mode 100644 synchronizer/common/syncinterfaces/mocks/zkevm_client_ethereum_compatible_l2_block_getter.go diff --git a/config/environments/local/local.genesis.config.json b/config/environments/local/local.genesis.config.json index 93620d4f9a..f0e5ecf89b 100644 --- a/config/environments/local/local.genesis.config.json +++ b/config/environments/local/local.genesis.config.json @@ -14,8 +14,8 @@ "contractName": "PolygonZkEVMDeployer", "balance": "0", "nonce": "4", - "address": "0x51dbd54FCCb6b3A07738fd3E156D588e71f79973", - "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220964619cee0e0baf94c6f8763f013be157da5d54c89e5cff4a8caf4266e13f13a64736f6c63430008140033", + "address": "0xFbD07134824dDEa24E4ae414c18ecbFa98169A24", + "bytecode": "0x60806040526004361061006e575f3560e01c8063715018a61161004c578063715018a6146100e25780638da5cb5b146100f6578063e11ae6cb1461011f578063f2fde38b14610132575f80fd5b80632b79805a146100725780634a94d487146100875780636d07dbf81461009a575b5f80fd5b610085610080366004610908565b610151565b005b6100856100953660046109a2565b6101c2565b3480156100a5575f80fd5b506100b96100b43660046109f5565b610203565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ed575f80fd5b50610085610215565b348015610101575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff166100b9565b61008561012d366004610a15565b610228565b34801561013d575f80fd5b5061008561014c366004610a61565b61028e565b61015961034a565b5f6101658585856103ca565b90506101718183610527565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101ca61034a565b6101d583838361056a565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b905f90a1505050565b5f61020e8383610598565b9392505050565b61021d61034a565b6102265f6105a4565b565b61023061034a565b5f61023c8484846103ca565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b61029661034a565b73ffffffffffffffffffffffffffffffffffffffff811661033e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610347816105a4565b50565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610226576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610335565b5f83471015610435576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610335565b81515f0361049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610335565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff811661020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610335565b606061020e83835f6040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610618565b6060610590848484604051806060016040528060298152602001610b0860299139610618565b949350505050565b5f61020e83833061072d565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610335565b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516106d29190610a9c565b5f6040518083038185875af1925050503d805f811461070c576040519150601f19603f3d011682016040523d82523d5f602084013e610711565b606091505b509150915061072287838387610756565b979650505050505050565b5f604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156107eb5782515f036107e45773ffffffffffffffffffffffffffffffffffffffff85163b6107e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610335565b5081610590565b61059083838151156108005781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103359190610ab7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112610870575f80fd5b813567ffffffffffffffff8082111561088b5761088b610834565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108d1576108d1610834565b816040528381528660208588010111156108e9575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f805f806080858703121561091b575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115610940575f80fd5b61094c88838901610861565b93506060870135915080821115610961575f80fd5b5061096e87828801610861565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff8116811461099d575f80fd5b919050565b5f805f606084860312156109b4575f80fd5b6109bd8461097a565b9250602084013567ffffffffffffffff8111156109d8575f80fd5b6109e486828701610861565b925050604084013590509250925092565b5f8060408385031215610a06575f80fd5b50508035926020909101359150565b5f805f60608486031215610a27575f80fd5b8335925060208401359150604084013567ffffffffffffffff811115610a4b575f80fd5b610a5786828701610861565b9150509250925092565b5f60208284031215610a71575f80fd5b61020e8261097a565b5f5b83811015610a94578181015183820152602001610a7c565b50505f910152565b5f8251610aad818460208701610a7a565b9190910192915050565b602081525f8251806020840152610ad5816040850160208701610a7a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220330b94dc698c4d290bf55c23f13b473cde6a6bae0030cb902de18af54e35839f64736f6c63430008140033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" } @@ -24,8 +24,8 @@ "contractName": "ProxyAdmin", "balance": "0", "nonce": "1", - "address": "0xe34Fe58DDa5b8c6D547E4857E987633aa86a5e90", - "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220c9867ffac53151bdb1305d8f5e3e883cd83e5270c7ec09cdc24e837b2e65239064736f6c63430008140033", + "address": "0xfADB60b5059e31614e02083fF6C021a24C31c891", + "bytecode": "0x608060405260043610610079575f3560e01c80639623609d1161004c5780639623609d1461012357806399a88ec414610136578063f2fde38b14610155578063f3b7dead14610174575f80fd5b8063204e1c7a1461007d578063715018a6146100c55780637eff275e146100db5780638da5cb5b146100fa575b5f80fd5b348015610088575f80fd5b5061009c6100973660046105e8565b610193565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d0575f80fd5b506100d9610244565b005b3480156100e6575f80fd5b506100d96100f536600461060a565b610257565b348015610105575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff1661009c565b6100d961013136600461066e565b6102e0565b348015610141575f80fd5b506100d961015036600461060a565b610371565b348015610160575f80fd5b506100d961016f3660046105e8565b6103cd565b34801561017f575f80fd5b5061009c61018e3660046105e8565b610489565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b5f60405180830381855afa9150503d805f8114610215576040519150601f19603f3d011682016040523d82523d5f602084013e61021a565b606091505b509150915081610228575f80fd5b8080602001905181019061023c919061075b565b949350505050565b61024c6104d3565b6102555f610553565b565b61025f6104d3565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b5f604051808303815f87803b1580156102c6575f80fd5b505af11580156102d8573d5f803e3d5ffd5b505050505050565b6102e86104d3565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061033e9086908690600401610776565b5f604051808303818588803b158015610355575f80fd5b505af1158015610367573d5f803e3d5ffd5b5050505050505050565b6103796104d3565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102af565b6103d56104d3565b73ffffffffffffffffffffffffffffffffffffffff811661047d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61048681610553565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610255576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610474565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff81168114610486575f80fd5b5f602082840312156105f8575f80fd5b8135610603816105c7565b9392505050565b5f806040838503121561061b575f80fd5b8235610626816105c7565b91506020830135610636816105c7565b809150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f805f60608486031215610680575f80fd5b833561068b816105c7565b9250602084013561069b816105c7565b9150604084013567ffffffffffffffff808211156106b7575f80fd5b818601915086601f8301126106ca575f80fd5b8135818111156106dc576106dc610641565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561072257610722610641565b8160405282815289602084870101111561073a575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f6020828403121561076b575f80fd5b8151610603816105c7565b73ffffffffffffffffffffffffffffffffffffffff831681525f602060408184015283518060408501525f5b818110156107be578581018301518582016060015282016107a2565b505f6060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea26469706673582212203083a4ccc2e42eed60bd19037f2efa77ed086dc7a5403f75bebb995dcba2221c64736f6c63430008140033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" } @@ -62,7 +62,7 @@ "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" } }, @@ -89,7 +89,7 @@ "accountName": "keyless Deployer", "balance": "0", "nonce": "1", - "address": "0x28BB4e66addE1f042B77E04cf7D3784C1dcDBbA3" + "address": "0x694AB5383a002a4796f95530c14Cf0C25ec3EA03" }, { "accountName": "deployer", diff --git a/docs/running_local.md b/docs/running_local.md index 1fd926bea8..49a4eb1a98 100644 --- a/docs/running_local.md +++ b/docs/running_local.md @@ -192,7 +192,7 @@ To configure your Metamask to use your local environment, follow these steps: | Address | Description | |---|---| | 0x8dAF17A20c9DBA35f005b6324F493785D239719d | Polygon ZKEVM | -| 0x40E0576c0A7dff9dc460B29ba73e79aBf73dD2a9 | Polygon Bridge | +| 0xFe12ABaa190Ef0c8638Ee0ba9F828BF41368Ca0E | Polygon Bridge | | 0x5FbDB2315678afecb367f032d93F642f64180aa3 | Pol token | | 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318 | Polygon GlobalExitRootManager | | 0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e | Polygon RollupManager | diff --git a/etherman/etherman.go b/etherman/etherman.go index 7c14e5cc6e..0d48318f3d 100644 --- a/etherman/etherman.go +++ b/etherman/etherman.go @@ -282,7 +282,7 @@ func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvi rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr) if err != nil { log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err) - // TODO return error after the upgrade + return nil, err } log.Debug("rollupID: ", rollupID) @@ -1635,7 +1635,7 @@ func (etherMan *Client) forceSequencedBatchesEvent(ctx context.Context, vLog typ if err != nil { return err } - // TODO completar los datos de forcedBlockHas, forcedGer y forcedTimestamp + // TODO complete data forcedBlockHash, forcedGer y forcedTimestamp // Read the tx for this batch. tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) diff --git a/jsonrpc/endpoints_eth.go b/jsonrpc/endpoints_eth.go index aadb844b22..2a3ba32b86 100644 --- a/jsonrpc/endpoints_eth.go +++ b/jsonrpc/endpoints_eth.go @@ -68,8 +68,6 @@ func (e *EthEndpoints) Call(arg *types.TxArgs, blockArg *types.BlockNumberOrHash return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { if arg == nil { return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) - } else if blockArg == nil { - return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 1", nil, false) } block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) if respErr != nil { @@ -113,6 +111,9 @@ func (e *EthEndpoints) Call(arg *types.TxArgs, blockArg *types.BlockNumberOrHash if result.Reverted() { data := make([]byte, len(result.ReturnValue)) copy(data, result.ReturnValue) + if len(data) == 0 { + return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) + } return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, result.Err.Error(), data) } else if result.Failed() { return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) @@ -191,6 +192,9 @@ func (e *EthEndpoints) EstimateGas(arg *types.TxArgs, blockArg *types.BlockNumbe if errors.Is(err, runtime.ErrExecutionReverted) { data := make([]byte, len(returnValue)) copy(data, returnValue) + if len(data) == 0 { + return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) + } return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data) } else if err != nil { return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) diff --git a/jsonrpc/endpoints_eth_test.go b/jsonrpc/endpoints_eth_test.go index ec50c6ea86..5da1d6a380 100644 --- a/jsonrpc/endpoints_eth_test.go +++ b/jsonrpc/endpoints_eth_test.go @@ -504,7 +504,7 @@ func TestCall(t *testing.T) { latest, }, expectedResult: nil, - expectedError: types.NewRPCError(types.RevertedErrorCode, "execution reverted"), + expectedError: types.NewRPCError(types.DefaultErrorCode, "execution reverted"), setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { nonce := uint64(7) m.DbTx.On("Rollback", context.Background()).Return(nil).Once() diff --git a/synchronizer/common/syncinterfaces/etherman.go b/synchronizer/common/syncinterfaces/etherman.go index 24e5dbda69..3d5959ade2 100644 --- a/synchronizer/common/syncinterfaces/etherman.go +++ b/synchronizer/common/syncinterfaces/etherman.go @@ -18,6 +18,7 @@ type EthermanFullInterface interface { GetTrustedSequencerURL() (string, error) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) GetLatestVerifiedBatchNum() (uint64, error) + GetFinalizedBlockNumber(ctx context.Context) (uint64, error) } type EthermanGetLatestBatchNumber interface { diff --git a/synchronizer/common/syncinterfaces/mocks/etherman_full_interface.go b/synchronizer/common/syncinterfaces/mocks/etherman_full_interface.go index fe6e6c3df6..a904419575 100644 --- a/synchronizer/common/syncinterfaces/mocks/etherman_full_interface.go +++ b/synchronizer/common/syncinterfaces/mocks/etherman_full_interface.go @@ -87,6 +87,62 @@ func (_c *EthermanFullInterface_EthBlockByNumber_Call) RunAndReturn(run func(con return _c } +// GetFinalizedBlockNumber provides a mock function with given fields: ctx +func (_m *EthermanFullInterface) GetFinalizedBlockNumber(ctx context.Context) (uint64, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetFinalizedBlockNumber") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (uint64, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) uint64); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EthermanFullInterface_GetFinalizedBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFinalizedBlockNumber' +type EthermanFullInterface_GetFinalizedBlockNumber_Call struct { + *mock.Call +} + +// GetFinalizedBlockNumber is a helper method to define mock.On call +// - ctx context.Context +func (_e *EthermanFullInterface_Expecter) GetFinalizedBlockNumber(ctx interface{}) *EthermanFullInterface_GetFinalizedBlockNumber_Call { + return &EthermanFullInterface_GetFinalizedBlockNumber_Call{Call: _e.mock.On("GetFinalizedBlockNumber", ctx)} +} + +func (_c *EthermanFullInterface_GetFinalizedBlockNumber_Call) Run(run func(ctx context.Context)) *EthermanFullInterface_GetFinalizedBlockNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *EthermanFullInterface_GetFinalizedBlockNumber_Call) Return(_a0 uint64, _a1 error) *EthermanFullInterface_GetFinalizedBlockNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanFullInterface_GetFinalizedBlockNumber_Call) RunAndReturn(run func(context.Context) (uint64, error)) *EthermanFullInterface_GetFinalizedBlockNumber_Call { + _c.Call.Return(run) + return _c +} + // GetLatestBatchNumber provides a mock function with given fields: func (_m *EthermanFullInterface) GetLatestBatchNumber() (uint64, error) { ret := _m.Called() diff --git a/synchronizer/common/syncinterfaces/mocks/zkevm_client_ethereum_compatible_l2_block_getter.go b/synchronizer/common/syncinterfaces/mocks/zkevm_client_ethereum_compatible_l2_block_getter.go new file mode 100644 index 0000000000..58c2af0dff --- /dev/null +++ b/synchronizer/common/syncinterfaces/mocks/zkevm_client_ethereum_compatible_l2_block_getter.go @@ -0,0 +1,98 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_syncinterfaces + +import ( + context "context" + big "math/big" + + mock "github.com/stretchr/testify/mock" + + types "github.com/ethereum/go-ethereum/core/types" +) + +// ZKEVMClientEthereumCompatibleL2BlockGetter is an autogenerated mock type for the ZKEVMClientEthereumCompatibleL2BlockGetter type +type ZKEVMClientEthereumCompatibleL2BlockGetter struct { + mock.Mock +} + +type ZKEVMClientEthereumCompatibleL2BlockGetter_Expecter struct { + mock *mock.Mock +} + +func (_m *ZKEVMClientEthereumCompatibleL2BlockGetter) EXPECT() *ZKEVMClientEthereumCompatibleL2BlockGetter_Expecter { + return &ZKEVMClientEthereumCompatibleL2BlockGetter_Expecter{mock: &_m.Mock} +} + +// BlockByNumber provides a mock function with given fields: ctx, number +func (_m *ZKEVMClientEthereumCompatibleL2BlockGetter) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) { + ret := _m.Called(ctx, number) + + if len(ret) == 0 { + panic("no return value specified for BlockByNumber") + } + + var r0 *types.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) (*types.Block, error)); ok { + return rf(ctx, number) + } + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) *types.Block); ok { + r0 = rf(ctx, number) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *big.Int) error); ok { + r1 = rf(ctx, number) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BlockByNumber' +type ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call struct { + *mock.Call +} + +// BlockByNumber is a helper method to define mock.On call +// - ctx context.Context +// - number *big.Int +func (_e *ZKEVMClientEthereumCompatibleL2BlockGetter_Expecter) BlockByNumber(ctx interface{}, number interface{}) *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call { + return &ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call{Call: _e.mock.On("BlockByNumber", ctx, number)} +} + +func (_c *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call) Run(run func(ctx context.Context, number *big.Int)) *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*big.Int)) + }) + return _c +} + +func (_c *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call) Return(_a0 *types.Block, _a1 error) *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call) RunAndReturn(run func(context.Context, *big.Int) (*types.Block, error)) *ZKEVMClientEthereumCompatibleL2BlockGetter_BlockByNumber_Call { + _c.Call.Return(run) + return _c +} + +// NewZKEVMClientEthereumCompatibleL2BlockGetter creates a new instance of ZKEVMClientEthereumCompatibleL2BlockGetter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewZKEVMClientEthereumCompatibleL2BlockGetter(t interface { + mock.TestingT + Cleanup(func()) +}) *ZKEVMClientEthereumCompatibleL2BlockGetter { + mock := &ZKEVMClientEthereumCompatibleL2BlockGetter{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index d0b786e527..7ba6ce8fa4 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -165,7 +165,7 @@ func NewSynchronizer( res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks) switch cfg.L1SynchronizationMode { case ParallelMode: - log.Info("L1SynchronizationMode is parallel") + log.Fatal("L1SynchronizationMode is parallel. Not yet suported, please use sequential mode to sync") res.l1SyncOrchestration = newL1SyncParallel(ctx, cfg, etherManForL1, res, runInDevelopmentMode) case SequentialMode: log.Info("L1SynchronizationMode is sequential") @@ -522,7 +522,7 @@ func sanityCheckForGenesisBlockRollupInfo(blocks []etherman.Block, order map[com // lastEthBlockSynced -> last block synced in the db func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. - block, err := s.checkReorg(lastEthBlockSynced) + block, err := s.newCheckReorg(lastEthBlockSynced, nil) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs") @@ -552,7 +552,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc lastKnownBlock := header.Number // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. - block, err := s.checkReorg(lastEthBlockSynced) + block, err := s.newCheckReorg(lastEthBlockSynced, nil) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs") @@ -568,7 +568,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc var fromBlock uint64 if lastEthBlockSynced.BlockNumber > 0 { - fromBlock = lastEthBlockSynced.BlockNumber + 1 + fromBlock = lastEthBlockSynced.BlockNumber } for { @@ -590,8 +590,39 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return lastEthBlockSynced, err } + var initBlockReceived *etherman.Block + if len(blocks) != 0 { + initBlockReceived = &blocks[0] + // First position of the array must be deleted + blocks = removeBlockElement(blocks, 0) + } else { + // Reorg detected + log.Infof("Reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", fromBlock) + prevBlock, err := s.state.GetPreviousBlock(s.ctx, 1, nil) + if errors.Is(err, state.ErrNotFound) { + log.Warn("error checking reorg: previous block not found in db: ", err) + prevBlock = &state.Block{} + } else if err != nil { + log.Error("error getting previousBlock from db. Error: ", err) + return lastEthBlockSynced, err + } + blockReorged, err := s.newCheckReorg(prevBlock, nil) + if err != nil { + log.Error("error checking reorgs in previous blocks. Error: ", err) + return lastEthBlockSynced, err + } + if blockReorged == nil { + blockReorged = prevBlock + } + err = s.resetState(blockReorged.BlockNumber) + if err != nil { + log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) + return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") + } + return blockReorged, nil + } // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange - block, err := s.checkReorg(lastEthBlockSynced) + block, err := s.newCheckReorg(lastEthBlockSynced, initBlockReceived) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs") @@ -619,47 +650,35 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc ReceivedAt: blocks[len(blocks)-1].ReceivedAt, } for i := range blocks { - log.Debug("Position: ", i, ". BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) + log.Info("Position: ", i, ". New block. BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) } } - fromBlock = toBlock + 1 if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 { waitDuration = s.cfg.SyncInterval.Duration break } - if len(blocks) == 0 { // If there is no events in the checked blocks range and lastKnownBlock > fromBlock. - // Store the latest block of the block range. Get block info and process the block - fb, err := s.etherMan.EthBlockByNumber(s.ctx, toBlock) - if err != nil { - return lastEthBlockSynced, err - } - b := etherman.Block{ - BlockNumber: fb.NumberU64(), - BlockHash: fb.Hash(), - ParentHash: fb.ParentHash(), - ReceivedAt: time.Unix(int64(fb.Time()), 0), - } - err = s.ProcessBlockRange([]etherman.Block{b}, order) - if err != nil { - return lastEthBlockSynced, err - } - block := state.Block{ - BlockNumber: fb.NumberU64(), - BlockHash: fb.Hash(), - ParentHash: fb.ParentHash(), - ReceivedAt: time.Unix(int64(fb.Time()), 0), - } - lastEthBlockSynced = &block - log.Debug("Storing empty block. BlockNumber: ", b.BlockNumber, ". BlockHash: ", b.BlockHash) - } + + fromBlock = toBlock } return lastEthBlockSynced, nil } +func removeBlockElement(slice []etherman.Block, s int) []etherman.Block { + ret := make([]etherman.Block, 0) + ret = append(ret, slice[:s]...) + return append(ret, slice[s+1:]...) +} + // ProcessBlockRange process the L1 events and stores the information in the db func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { + // Check the latest finalized block in L1 + finalizedBlockNumber, err := s.etherMan.GetFinalizedBlockNumber(s.ctx) + if err != nil { + log.Errorf("error getting finalized block number in L1. Error: %v", err) + return err + } // New info has to be included into the db using the state for i := range blocks { // Begin db transaction @@ -674,6 +693,9 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma ParentHash: blocks[i].ParentHash, ReceivedAt: blocks[i].ReceivedAt, } + if blocks[i].BlockNumber <= finalizedBlockNumber { + b.Checked = true + } // Add block information err = s.state.AddBlock(s.ctx, &b, dbTx) if err != nil { @@ -694,7 +716,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) } else { forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) - log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, "forkId: ", forkId) + log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, ". forkId: ", forkId) } forkIdTyped := actions.ForkIdType(forkId) // Process event received from l1 @@ -795,7 +817,8 @@ If hash or hash parent don't match, reorg detected and the function will return must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check hash and has parent. This operation has to be done until a match is found. */ -func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, error) { +// TODO This function will be deprecated +func (s *ClientSynchronizer) oldCheckReorg(latestBlock *state.Block) (*state.Block, error) { //nolint:unused // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. latestEthBlockSynced := *latestBlock reorgedBlock := *latestBlock @@ -865,6 +888,89 @@ func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, return nil, nil } +func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { + // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. + latestStoredEthBlock := *latestStoredBlock + reorgedBlock := *latestStoredBlock + var depth uint64 + block := syncedBlock + for { + if block == nil { + log.Infof("[checkReorg function] Checking Block %d in L1", reorgedBlock.BlockNumber) + b, err := s.etherMan.EthBlockByNumber(s.ctx, reorgedBlock.BlockNumber) + if err != nil { + log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", reorgedBlock.BlockNumber, err) + return nil, err + } + block = ðerman.Block{ + BlockNumber: b.Number().Uint64(), + BlockHash: b.Hash(), + ParentHash: b.ParentHash(), + } + } else { + log.Infof("[checkReorg function] Using block %d from GetRollupInfoByBlockRange", block.BlockNumber) + } + log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.BlockNumber, block.BlockHash.String()) + log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) + if block.BlockNumber != reorgedBlock.BlockNumber { + err := fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", + reorgedBlock.BlockNumber, block.BlockNumber) + log.Error("error: ", err) + return nil, err + } + // Compare hashes + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.BlockNumber { + log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) + log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) + log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) + log.Debug("[checkReorg function] => latestBlockHashParent: ", reorgedBlock.ParentHash) + log.Debug("[checkReorg function] => BlockNumber: ", reorgedBlock.BlockNumber, block.BlockNumber) + log.Debug("[checkReorg function] => BlockHash: ", block.BlockHash) + log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash) + depth++ + log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) + // Reorg detected. Getting previous block + dbTx, err := s.state.BeginStateTransaction(s.ctx) + if err != nil { + log.Errorf("error creating db transaction to get prevoius blocks") + return nil, err + } + lb, err := s.state.GetPreviousBlock(s.ctx, depth, dbTx) + errC := dbTx.Commit(s.ctx) + if errC != nil { + log.Errorf("error committing dbTx, err: %v", errC) + rollbackErr := dbTx.Rollback(s.ctx) + if rollbackErr != nil { + log.Errorf("error rolling back state. RollbackErr: %v", rollbackErr) + return nil, rollbackErr + } + log.Errorf("error committing dbTx, err: %v", errC) + return nil, errC + } + if errors.Is(err, state.ErrNotFound) { + log.Warn("error checking reorg: previous block not found in db. Reorg reached the genesis block: %v.Genesis block can't be reorged, using genesis block as starting point. Error: %v", reorgedBlock, err) + return &reorgedBlock, nil + } else if err != nil { + log.Error("error getting previousBlock from db. Error: ", err) + return nil, err + } + reorgedBlock = *lb + } else { + log.Debugf("checkReorg: Block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) + break + } + // This forces to get the block from L1 in the next iteration of the loop + block = nil + } + if latestStoredEthBlock.BlockHash != reorgedBlock.BlockHash { + latestStoredBlock = &reorgedBlock + log.Info("Reorg detected in block: ", latestStoredEthBlock.BlockNumber, " last block OK: ", latestStoredBlock.BlockNumber) + return latestStoredBlock, nil + } + log.Debugf("No reorg detected in block: %d. BlockHash: %s", latestStoredEthBlock.BlockNumber, latestStoredEthBlock.BlockHash.String()) + return nil, nil +} + // Stop function stops the synchronizer func (s *ClientSynchronizer) Stop() { s.cancelCtx() diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 349e509788..b9a56549c3 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -2,6 +2,7 @@ package synchronizer import ( context "context" + "math" "math/big" "testing" "time" @@ -154,9 +155,12 @@ func TestForcedBatchEtrog(t *testing.T) { Run(func(args mock.Arguments) { ctx := args[0].(context.Context) parentHash := common.HexToHash("0x111") - ethHeader := ðTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} - ethBlock := ethTypes.NewBlockWithHeader(ethHeader) - lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} m.State. On("GetForkIDByBatchNumber", mock.Anything). @@ -164,7 +168,7 @@ func TestForcedBatchEtrog(t *testing.T) { Maybe() m.State. On("GetLastBlock", ctx, m.DbTx). - Return(lastBlock, nil). + Return(lastBlock0, nil). Once() m.State. @@ -200,14 +204,14 @@ func TestForcedBatchEtrog(t *testing.T) { Return(nil) m.Etherman. - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). - Return(ethBlock, nil). + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). Once() n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. On("HeaderByNumber", mock.Anything, n). - Return(ethHeader, nil). + Return(ethHeader1, nil). Once() t := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) @@ -226,7 +230,7 @@ func TestForcedBatchEtrog(t *testing.T) { } forceb := []etherman.ForcedBatch{{ - BlockNumber: lastBlock.BlockNumber, + BlockNumber: lastBlock1.BlockNumber, ForcedBatchNumber: 1, Sequencer: sequencedBatch.Coinbase, GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, @@ -234,16 +238,21 @@ func TestForcedBatchEtrog(t *testing.T) { ForcedAt: time.Unix(int64(sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), }} - ethermanBlock := etherman.Block{ + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: t, + BlockHash: ethBlock0.Hash(), + } + ethermanBlock1 := etherman.Block{ BlockNumber: 1, ReceivedAt: t, - BlockHash: ethBlock.Hash(), + BlockHash: ethBlock1.Hash(), SequencedBatches: [][]etherman.SequencedBatch{{sequencedBatch}}, ForcedBatches: forceb, } - blocks := []etherman.Block{ethermanBlock} + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} order := map[common.Hash][]etherman.Order{ - ethBlock.Hash(): { + ethBlock1.Hash(): { { Name: etherman.ForcedBatchesOrder, Pos: 0, @@ -255,21 +264,16 @@ func TestForcedBatchEtrog(t *testing.T) { }, } - fromBlock := ethBlock.NumberU64() + 1 + fromBlock := ethBlock0.NumberU64() toBlock := fromBlock + cfg.SyncChunkSize - if toBlock > ethHeader.Number.Uint64() { - toBlock = ethHeader.Number.Uint64() + if toBlock > ethBlock1.NumberU64() { + toBlock = ethBlock1.NumberU64() } m.Etherman. On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). Return(blocks, order, nil). Once() - m.Etherman. - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). - Return(ethBlock, nil). - Once() - m.ZKEVMClient. On("BatchNumber", ctx). Return(uint64(1), nil) @@ -280,10 +284,11 @@ func TestForcedBatchEtrog(t *testing.T) { Once() stateBlock := &state.Block{ - BlockNumber: ethermanBlock.BlockNumber, - BlockHash: ethermanBlock.BlockHash, - ParentHash: ethermanBlock.ParentHash, - ReceivedAt: ethermanBlock.ReceivedAt, + BlockNumber: ethermanBlock1.BlockNumber, + BlockHash: ethermanBlock1.BlockHash, + ParentHash: ethermanBlock1.ParentHash, + ReceivedAt: ethermanBlock1.ReceivedAt, + Checked: true, } executionResponse := executor.ProcessBatchResponseV2{ @@ -295,13 +300,18 @@ func TestForcedBatchEtrog(t *testing.T) { Return(&executionResponse, nil). Times(1) + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock1.NumberU64(), nil). + Once() + m.State. On("AddBlock", ctx, stateBlock, m.DbTx). Return(nil). Once() fb := []state.ForcedBatch{{ - BlockNumber: lastBlock.BlockNumber, + BlockNumber: lastBlock1.BlockNumber, ForcedBatchNumber: 1, Sequencer: sequencedBatch.Coinbase, GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, @@ -336,7 +346,7 @@ func TestForcedBatchEtrog(t *testing.T) { BatchNumber: sequencedBatch.BatchNumber, TxHash: sequencedBatch.TxHash, Coinbase: sequencedBatch.Coinbase, - BlockNumber: ethermanBlock.BlockNumber, + BlockNumber: ethermanBlock1.BlockNumber, TimestampBatchEtrog: &t, L1InfoRoot: &forcedGER, } @@ -409,21 +419,20 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { Run(func(args mock.Arguments) { ctx := args[0].(context.Context) parentHash := common.HexToHash("0x111") - ethHeader := ðTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} - ethBlock := ethTypes.NewBlockWithHeader(ethHeader) - lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} m.State. On("GetForkIDByBatchNumber", mock.Anything). Return(uint64(1), nil). Maybe() - m.State. - On("GetForkIDByBlockNumber", mock.Anything). - Return(uint64(1), nil). - Maybe() m.State. On("GetLastBlock", ctx, m.DbTx). - Return(lastBlock, nil). + Return(lastBlock0, nil). Once() m.State. @@ -461,15 +470,15 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { Return(nil). Once() + n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). - Return(ethBlock, nil). + On("HeaderByNumber", ctx, n). + Return(ethHeader1, nil). Once() - n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. - On("HeaderByNumber", ctx, n). - Return(ethHeader, nil). + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). Once() sequencedForceBatch := etherman.SequencedForceBatch{ @@ -485,7 +494,7 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { } forceb := []etherman.ForcedBatch{{ - BlockNumber: lastBlock.BlockNumber, + BlockNumber: lastBlock1.BlockNumber, ForcedBatchNumber: 1, Sequencer: sequencedForceBatch.Coinbase, GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, @@ -493,14 +502,21 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { ForcedAt: time.Unix(int64(sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), }} - ethermanBlock := etherman.Block{ - BlockHash: ethBlock.Hash(), + ethermanBlock0 := etherman.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + ethermanBlock1 := etherman.Block{ + BlockNumber: ethBlock1.NumberU64(), + BlockHash: ethBlock1.Hash(), + ParentHash: ethBlock1.ParentHash(), SequencedForceBatches: [][]etherman.SequencedForceBatch{{sequencedForceBatch}}, ForcedBatches: forceb, } - blocks := []etherman.Block{ethermanBlock} + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} order := map[common.Hash][]etherman.Order{ - ethBlock.Hash(): { + ethBlock1.Hash(): { { Name: etherman.ForcedBatchesOrder, Pos: 0, @@ -512,10 +528,10 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { }, } - fromBlock := ethBlock.NumberU64() + 1 + fromBlock := ethBlock0.NumberU64() toBlock := fromBlock + cfg.SyncChunkSize - if toBlock > ethHeader.Number.Uint64() { - toBlock = ethHeader.Number.Uint64() + if toBlock > ethBlock1.NumberU64() { + toBlock = ethBlock1.NumberU64() } m.Etherman. On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). @@ -523,8 +539,8 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { Once() m.Etherman. - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). - Return(ethBlock, nil). + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock1.NumberU64(), nil). Once() m.State. @@ -533,10 +549,11 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { Once() stateBlock := &state.Block{ - BlockNumber: ethermanBlock.BlockNumber, - BlockHash: ethermanBlock.BlockHash, - ParentHash: ethermanBlock.ParentHash, - ReceivedAt: ethermanBlock.ReceivedAt, + BlockNumber: ethermanBlock1.BlockNumber, + BlockHash: ethermanBlock1.BlockHash, + ParentHash: ethermanBlock1.ParentHash, + ReceivedAt: ethermanBlock1.ReceivedAt, + Checked: true, } m.State. @@ -544,8 +561,13 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { Return(nil). Once() + m.State. + On("GetForkIDByBlockNumber", stateBlock.BlockNumber). + Return(uint64(9), nil). + Once() + fb := []state.ForcedBatch{{ - BlockNumber: lastBlock.BlockNumber, + BlockNumber: lastBlock1.BlockNumber, ForcedBatchNumber: 1, Sequencer: sequencedForceBatch.Coinbase, GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, @@ -577,7 +599,7 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { processingContext := state.ProcessingContext{ BatchNumber: sequencedForceBatch.BatchNumber, Coinbase: sequencedForceBatch.Coinbase, - Timestamp: ethBlock.ReceivedAt, + Timestamp: ethBlock1.ReceivedAt, GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, ForcedBatchNum: &f, BatchL2Data: &sequencedForceBatch.PolygonRollupBaseEtrogBatchData.Transactions, @@ -592,7 +614,7 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { TxHash: sequencedForceBatch.TxHash, Coinbase: sequencedForceBatch.Coinbase, SequencerAddr: sequencedForceBatch.Coinbase, - BlockNumber: ethermanBlock.BlockNumber, + BlockNumber: ethermanBlock1.BlockNumber, } m.State. @@ -616,7 +638,10 @@ func TestSequenceForcedBatchIncaberry(t *testing.T) { m.DbTx. On("Commit", ctx). - Run(func(args mock.Arguments) { sync.Stop() }). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). Return(nil). Once() }). @@ -890,3 +915,1029 @@ func expectedCallsForsyncTrustedState(t *testing.T, m *mocks, sync *ClientSynchr Return(nil). Once() } + +func TestReorg(t *testing.T) { + genesis := state.Genesis{ + BlockNumber: uint64(0), + } + cfg := Config{ + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 3, + L1SynchronizationMode: SequentialMode, + SyncBlockProtection: "latest", + } + + m := mocks{ + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + State: mock_syncinterfaces.NewStateFullInterface(t), + Pool: mock_syncinterfaces.NewPoolInterface(t), + DbTx: syncMocks.NewDbTxMock(t), + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + } + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err) + + // state preparation + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + forkIdInterval := state.ForkIDInterval{ + ForkId: 9, + FromBatchNumber: 0, + ToBatchNumber: math.MaxUint64, + } + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + + m.State. + On("BeginStateTransaction", ctxMatchBy). + Run(func(args mock.Arguments) { + ctx := args[0].(context.Context) + parentHash := common.HexToHash("0x111") + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1bis := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) + ethHeader2bis := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) + ethHeader3bis := ðTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2bis.Hash()} + ethBlock3bis := ethTypes.NewBlockWithHeader(ethHeader3bis) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + ethHeader2 := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + ethHeader3 := ðTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + + m.State. + On("GetForkIDByBatchNumber", mock.Anything). + Return(uint64(9), nil). + Maybe() + m.State. + On("GetLastBlock", ctx, m.DbTx). + Return(lastBlock1, nil). + Once() + + m.State. + On("GetLastBatchNumber", ctx, m.DbTx). + Return(uint64(10), nil). + Once() + + m.State. + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("GetLatestBatchNumber"). + Return(uint64(10), nil) + + var nilDbTx pgx.Tx + m.State. + On("GetLastBatchNumber", ctx, nilDbTx). + Return(uint64(10), nil) + + m.Etherman. + On("GetLatestVerifiedBatchNum"). + Return(uint64(10), nil) + + m.State. + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + Return(nil) + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3bis, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + + ethermanBlock1bis := etherman.Block{ + BlockNumber: 1, + ReceivedAt: ti, + BlockHash: ethBlock1bis.Hash(), + ParentHash: ethBlock1bis.ParentHash(), + } + ethermanBlock2bis := etherman.Block{ + BlockNumber: 2, + ReceivedAt: ti, + BlockHash: ethBlock2bis.Hash(), + ParentHash: ethBlock2bis.ParentHash(), + } + blocks := []etherman.Block{ethermanBlock1bis, ethermanBlock2bis} + order := map[common.Hash][]etherman.Order{} + + fromBlock := ethBlock1.NumberU64() + toBlock := fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock3.NumberU64() { + toBlock = ethBlock3.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + var depth uint64 = 1 + stateBlock0 := &state.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, m.DbTx). + Return(stateBlock0, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + m.State. + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + Return(nil). + Once() + + m.EthTxManager. + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3bis, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: ti, + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + ethermanBlock3bis := etherman.Block{ + BlockNumber: 3, + ReceivedAt: ti, + BlockHash: ethBlock3bis.Hash(), + ParentHash: ethBlock3bis.ParentHash(), + } + fromBlock = 0 + blocks2 := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis, ethermanBlock3bis} + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks2, order, nil). + Once() + + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock2bis.NumberU64(), nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock1bis := &state.Block{ + BlockNumber: ethermanBlock1bis.BlockNumber, + BlockHash: ethermanBlock1bis.BlockHash, + ParentHash: ethermanBlock1bis.ParentHash, + ReceivedAt: ethermanBlock1bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock1bis, m.DbTx). + Return(nil). + Once() + + m.State. + On("GetStoredFlushID", ctx). + Return(uint64(1), cProverIDExecution, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock2bis := &state.Block{ + BlockNumber: ethermanBlock2bis.BlockNumber, + BlockHash: ethermanBlock2bis.BlockHash, + ParentHash: ethermanBlock2bis.ParentHash, + ReceivedAt: ethermanBlock2bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock2bis, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock3bis := &state.Block{ + BlockNumber: ethermanBlock3bis.BlockNumber, + BlockHash: ethermanBlock3bis.BlockHash, + ParentHash: ethermanBlock3bis.ParentHash, + ReceivedAt: ethermanBlock3bis.ReceivedAt, + Checked: false, + } + m.State. + On("AddBlock", ctx, stateBlock3bis, m.DbTx). + Return(nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil) + + m.DbTx. + On("Commit", ctx). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). + Return(nil). + Once() + }). + Return(m.DbTx, nil). + Once() + + err = sync.Sync() + require.NoError(t, err) +} + +func TestLatestSyncedBlockEmpty(t *testing.T) { + genesis := state.Genesis{ + BlockNumber: uint64(0), + } + cfg := Config{ + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 3, + L1SynchronizationMode: SequentialMode, + SyncBlockProtection: "latest", + } + + m := mocks{ + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + State: mock_syncinterfaces.NewStateFullInterface(t), + Pool: mock_syncinterfaces.NewPoolInterface(t), + DbTx: syncMocks.NewDbTxMock(t), + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + } + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err) + + // state preparation + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + forkIdInterval := state.ForkIDInterval{ + ForkId: 9, + FromBatchNumber: 0, + ToBatchNumber: math.MaxUint64, + } + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + + m.State. + On("BeginStateTransaction", ctxMatchBy). + Run(func(args mock.Arguments) { + ctx := args[0].(context.Context) + parentHash := common.HexToHash("0x111") + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + ethHeader2 := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + ethHeader3 := ðTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + + m.State. + On("GetForkIDByBatchNumber", mock.Anything). + Return(uint64(9), nil). + Maybe() + m.State. + On("GetLastBlock", ctx, m.DbTx). + Return(lastBlock1, nil). + Once() + + m.State. + On("GetLastBatchNumber", ctx, m.DbTx). + Return(uint64(10), nil). + Once() + + m.State. + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("GetLatestBatchNumber"). + Return(uint64(10), nil) + + var nilDbTx pgx.Tx + m.State. + On("GetLastBatchNumber", ctx, nilDbTx). + Return(uint64(10), nil) + + m.Etherman. + On("GetLatestVerifiedBatchNum"). + Return(uint64(10), nil) + + m.State. + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + Return(nil) + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + blocks := []etherman.Block{} + order := map[common.Hash][]etherman.Order{} + + fromBlock := ethBlock1.NumberU64() + toBlock := fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock3.NumberU64() { + toBlock = ethBlock3.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + var depth uint64 = 1 + stateBlock0 := &state.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, nil). + Return(stateBlock0, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + m.State. + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + Return(nil). + Once() + + m.EthTxManager. + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: ti, + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + blocks = []etherman.Block{ethermanBlock0} + fromBlock = 0 + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock3.NumberU64(), nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). + Return(uint64(1), nil). + Once() + }). + Return(m.DbTx, nil). + Once() + + err = sync.Sync() + require.NoError(t, err) +} + +func TestRegularReorg(t *testing.T) { + genesis := state.Genesis{ + BlockNumber: uint64(0), + } + cfg := Config{ + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 3, + L1SynchronizationMode: SequentialMode, + SyncBlockProtection: "latest", + } + + m := mocks{ + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + State: mock_syncinterfaces.NewStateFullInterface(t), + Pool: mock_syncinterfaces.NewPoolInterface(t), + DbTx: syncMocks.NewDbTxMock(t), + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + } + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err) + + // state preparation + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + forkIdInterval := state.ForkIDInterval{ + ForkId: 9, + FromBatchNumber: 0, + ToBatchNumber: math.MaxUint64, + } + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + + m.State. + On("BeginStateTransaction", ctxMatchBy). + Run(func(args mock.Arguments) { + ctx := args[0].(context.Context) + parentHash := common.HexToHash("0x111") + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1bis := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) + ethHeader2bis := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + ethHeader2 := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil) + + m.State. + On("GetForkIDByBatchNumber", mock.Anything). + Return(uint64(9), nil). + Maybe() + m.State. + On("GetLastBlock", ctx, m.DbTx). + Return(lastBlock1, nil). + Once() + + m.State. + On("GetLastBatchNumber", ctx, m.DbTx). + Return(uint64(10), nil). + Once() + + m.State. + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("GetLatestBatchNumber"). + Return(uint64(10), nil) + + var nilDbTx pgx.Tx + m.State. + On("GetLastBatchNumber", ctx, nilDbTx). + Return(uint64(10), nil) + + m.Etherman. + On("GetLatestVerifiedBatchNum"). + Return(uint64(10), nil) + + m.State. + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + Return(nil) + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader2bis, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1bis, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + var depth uint64 = 1 + stateBlock0 := &state.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, m.DbTx). + Return(stateBlock0, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + m.State. + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + Return(nil). + Once() + + m.EthTxManager. + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader2bis, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: ti, + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + ethermanBlock1bis := etherman.Block{ + BlockNumber: 1, + ReceivedAt: ti, + BlockHash: ethBlock1bis.Hash(), + ParentHash: ethBlock1bis.ParentHash(), + } + ethermanBlock2bis := etherman.Block{ + BlockNumber: 2, + ReceivedAt: ti, + BlockHash: ethBlock2bis.Hash(), + ParentHash: ethBlock2bis.ParentHash(), + } + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis} + order := map[common.Hash][]etherman.Order{} + + fromBlock := ethBlock0.NumberU64() + toBlock := fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock2.NumberU64() { + toBlock = ethBlock2.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock2bis.NumberU64(), nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock1bis := &state.Block{ + BlockNumber: ethermanBlock1bis.BlockNumber, + BlockHash: ethermanBlock1bis.BlockHash, + ParentHash: ethermanBlock1bis.ParentHash, + ReceivedAt: ethermanBlock1bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock1bis, m.DbTx). + Return(nil). + Once() + + m.State. + On("GetStoredFlushID", ctx). + Return(uint64(1), cProverIDExecution, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock2bis := &state.Block{ + BlockNumber: ethermanBlock2bis.BlockNumber, + BlockHash: ethermanBlock2bis.BlockHash, + ParentHash: ethermanBlock2bis.ParentHash, + ReceivedAt: ethermanBlock2bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock2bis, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). + Return(nil). + Once() + }). + Return(m.DbTx, nil). + Once() + + err = sync.Sync() + require.NoError(t, err) +} + +func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { + genesis := state.Genesis{ + BlockNumber: uint64(0), + } + cfg := Config{ + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 3, + L1SynchronizationMode: SequentialMode, + SyncBlockProtection: "latest", + } + + m := mocks{ + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + State: mock_syncinterfaces.NewStateFullInterface(t), + Pool: mock_syncinterfaces.NewPoolInterface(t), + DbTx: syncMocks.NewDbTxMock(t), + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + } + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err) + + // state preparation + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + forkIdInterval := state.ForkIDInterval{ + ForkId: 9, + FromBatchNumber: 0, + ToBatchNumber: math.MaxUint64, + } + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + + m.State. + On("BeginStateTransaction", ctxMatchBy). + Run(func(args mock.Arguments) { + ctx := args[0].(context.Context) + parentHash := common.HexToHash("0x111") + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + ethHeader1bis := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 0, GasUsed: 10} + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) + ethHeader2 := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + ethHeader3 := ðTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + lastBlock2 := &state.Block{BlockHash: ethBlock2.Hash(), BlockNumber: ethBlock2.Number().Uint64(), ParentHash: ethBlock2.ParentHash()} + + m.State. + On("GetForkIDByBatchNumber", mock.Anything). + Return(uint64(9), nil). + Maybe() + m.State. + On("GetLastBlock", ctx, m.DbTx). + Return(lastBlock2, nil). + Once() + + m.State. + On("GetLastBatchNumber", ctx, m.DbTx). + Return(uint64(10), nil). + Once() + + m.State. + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("GetLatestBatchNumber"). + Return(uint64(10), nil) + + var nilDbTx pgx.Tx + m.State. + On("GetLastBatchNumber", ctx, nilDbTx). + Return(uint64(10), nil) + + m.Etherman. + On("GetLatestVerifiedBatchNum"). + Return(uint64(10), nil) + + m.State. + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + Return(nil) + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). + Return(ethBlock2, nil). + Once() + + blocks := []etherman.Block{} + order := map[common.Hash][]etherman.Order{} + + fromBlock := ethBlock2.NumberU64() + toBlock := fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock3.NumberU64() { + toBlock = ethBlock3.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + var depth uint64 = 1 + stateBlock1 := &state.Block{ + BlockNumber: ethBlock1.NumberU64(), + BlockHash: ethBlock1.Hash(), + ParentHash: ethBlock1.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, nil). + Return(stateBlock1, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1bis, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock0 := &state.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, m.DbTx). + Return(stateBlock0, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + m.State. + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + Return(nil). + Once() + + m.EthTxManager. + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader3, nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: ti, + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + ethermanBlock1bis := etherman.Block{ + BlockNumber: 1, + ReceivedAt: ti, + BlockHash: ethBlock1.Hash(), + ParentHash: ethBlock1.ParentHash(), + } + blocks = []etherman.Block{ethermanBlock0, ethermanBlock1bis} + fromBlock = 0 + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock3.NumberU64(), nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock1bis := &state.Block{ + BlockNumber: ethermanBlock1bis.BlockNumber, + BlockHash: ethermanBlock1bis.BlockHash, + ParentHash: ethermanBlock1bis.ParentHash, + ReceivedAt: ethermanBlock1bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock1bis, m.DbTx). + Return(nil). + Once() + + m.State. + On("GetStoredFlushID", ctx). + Return(uint64(1), cProverIDExecution, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). + Return(uint64(1), nil). + Once() + }). + Return(m.DbTx, nil). + Once() + + err = sync.Sync() + require.NoError(t, err) +} diff --git a/test/e2e/jsonrpc2_test.go b/test/e2e/jsonrpc2_test.go index b2a3a2598f..fcd883a956 100644 --- a/test/e2e/jsonrpc2_test.go +++ b/test/e2e/jsonrpc2_test.go @@ -456,22 +456,27 @@ func TestCallMissingParameters(t *testing.T) { expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 0"}, }, { - name: "params has only first parameter", - params: []interface{}{map[string]interface{}{"value": "0x1"}}, - expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 1"}, + name: "params has only first parameter", + params: []interface{}{map[string]interface{}{"value": "0x1", "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92267"}}, }, } for _, network := range networks { - log.Infof("Network %s", network.Name) - for _, testCase := range testCases { + t.Logf("Network %s", network.Name) + for tc, testCase := range testCases { + t.Logf("testCase %d", tc) t.Run(network.Name+testCase.name, func(t *testing.T) { response, err := client.JSONRPCCall(network.URL, "eth_call", testCase.params...) require.NoError(t, err) - require.NotNil(t, response.Error) - require.Nil(t, response.Result) - require.Equal(t, testCase.expectedError.Code, response.Error.Code) - require.Equal(t, testCase.expectedError.Message, response.Error.Message) + if (testCase.expectedError != types.ErrorObject{}) { + require.NotNil(t, response.Error) + require.Nil(t, response.Result) + require.Equal(t, testCase.expectedError.Code, response.Error.Code) + require.Equal(t, testCase.expectedError.Message, response.Error.Message) + } else { + require.Nil(t, response.Error) + require.NotNil(t, response.Result) + } }) } } @@ -620,24 +625,39 @@ func TestEstimateGas(t *testing.T) { txToMsg, err := sc.Increment(auth) require.NoError(t, err) - // add funds to address 0x000...001 used in the test - nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil) - require.NoError(t, err) - value := big.NewInt(1000) - require.NoError(t, err) - tx = ethTypes.NewTx(ðTypes.LegacyTx{ - Nonce: nonce, - To: state.Ptr(common.HexToAddress("0x1")), - Value: value, - Gas: 24000, - GasPrice: gasPrice, - }) - signedTx, err := auth.Signer(auth.From, tx) - require.NoError(t, err) - err = ethereumClient.SendTransaction(ctx, signedTx) - require.NoError(t, err) - err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined) - require.NoError(t, err) + // addresses the test needs to have balance + addressesToAddBalance := map[common.Address]*big.Int{ + // add funds to address 0x111...111 which is the default address + // when estimating TXs without specifying the sender + common.HexToAddress("0x1111111111111111111111111111111111111111"): big.NewInt(3000000000000000), + + // add funds to address 0x000...001 + common.HexToAddress("0x1"): big.NewInt(1000), + } + + for addr, value := range addressesToAddBalance { + nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil) + require.NoError(t, err) + value := value + require.NoError(t, err) + tx = ethTypes.NewTx(ðTypes.LegacyTx{ + Nonce: nonce, + To: state.Ptr(addr), + Value: value, + Gas: 24000, + GasPrice: gasPrice, + }) + signedTx, err := auth.Signer(auth.From, tx) + require.NoError(t, err) + err = ethereumClient.SendTransaction(ctx, signedTx) + require.NoError(t, err) + err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined) + require.NoError(t, err) + + balance, err := ethereumClient.BalanceAt(ctx, addr, nil) + require.NoError(t, err) + log.Debugf("%v balance: %v", addr.String(), balance.String()) + } type testCase struct { name string @@ -670,19 +690,15 @@ func TestEstimateGas(t *testing.T) { name: "with gasPrice set and without from address", address: nil, setGasPrice: true, - expectedError: types.NewRPCError(-32000, "gas required exceeds allowance"), + expectedError: nil, + }, + { + name: "with gasPrice and value set and address with enough balance", + address: state.Ptr(auth.From), + value: state.Ptr(int64(1)), + setGasPrice: true, + expectedError: types.NewRPCError(-32000, "execution reverted"), }, - // TODO: This test is failing due to geth bug - // we can uncomment it when updating geth version - // on l1 image, it's returning error code -32000 when - // it should be returning error code 3 due to execution message - // { - // name: "with gasPrice and value set and address with enough balance", - // address: state.Ptr(auth.From), - // value: state.Ptr(int64(1)), - // setGasPrice: true, - // expectedError: types.NewRPCError(3, "execution reverted"), - // }, { name: "with gasPrice and value set and address without enough balance", address: state.Ptr(common.HexToAddress("0x1")), @@ -697,13 +713,21 @@ func TestEstimateGas(t *testing.T) { setGasPrice: true, expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), }, - { - name: "with gasPrice and value set and without from address", - address: nil, - value: state.Ptr(int64(-1)), - setGasPrice: true, - expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), - }, + // TODO = Review the test below in future versions of geth. + // + // Geth is returning -32000, "insufficient funds for transfer" + // zkEVM is returning 3, "execution reverted" + // + // Since the tx has value, the method increment is not payable + // and the default account has balance, the tx should revert + // + // { + // name: "with gasPrice and value set and without from address", + // address: nil, + // value: state.Ptr(int64(-1)), + // setGasPrice: true, + // expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), + // }, { name: "without gasPrice set and address with enough balance", address: state.Ptr(auth.From), @@ -746,7 +770,6 @@ func TestEstimateGas(t *testing.T) { if testCase.value != nil { v := *testCase.value if v == -1 { //set the value as acc balance + 1 to force overflow - msg.Value = common.Big0.Add(balance, common.Big1) } else { msg.Value = big.NewInt(0).SetInt64(v) From cfeb68dac219e4c2c229a967221ae88c5025b4bf Mon Sep 17 00:00:00 2001 From: agnusmor <100322135+agnusmor@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:30:03 +0200 Subject: [PATCH 04/21] Fix adding tx that matches with tx that is being processed (#3559) * fix adding tx that matches (same addr and nonce) tx that is being processing * fix generate mocks * fix updateCurrentNonceBalance --- sequencer/addrqueue.go | 4 ++++ sequencer/finalizer.go | 4 ++-- sequencer/worker.go | 20 ++++++++++++++++++++ test/Makefile | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/sequencer/addrqueue.go b/sequencer/addrqueue.go index 177521c449..9c0d8d996e 100644 --- a/sequencer/addrqueue.go +++ b/sequencer/addrqueue.go @@ -211,6 +211,10 @@ func (a *addrQueue) updateCurrentNonceBalance(nonce *uint64, balance *big.Int) ( if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce { log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr) a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx + } else if oldReadyTx != nil { // if oldReadyTx doesn't have a valid nonce then we add it to the txsToDelete + reason := runtime.ErrIntrinsicInvalidNonce.Error() + oldReadyTx.FailedReason = &reason + txsToDelete = append(txsToDelete, oldReadyTx) } return a.readyTx, oldReadyTx, txsToDelete diff --git a/sequencer/finalizer.go b/sequencer/finalizer.go index a87cc29042..48ebf80d6f 100644 --- a/sequencer/finalizer.go +++ b/sequencer/finalizer.go @@ -345,8 +345,8 @@ func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { log.Infof("received new l1InfoRoot %s, index: %d, l1Block: %d", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) - // Check if new l1InfoRoot is valid. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree) - if l1InfoRoot.BlockNumber > 0 { + // Check if new l1InfoRoot is valid. We skip it if l1InfoTreeIndex is 0 (it's a special case) + if l1InfoRoot.L1InfoTreeIndex > 0 { valid, err := f.checkValidL1InfoRoot(ctx, l1InfoRoot) if err != nil { log.Errorf("error validating new l1InfoRoot, index: %d, error: %v", l1InfoRoot.L1InfoTreeIndex, err) diff --git a/sequencer/worker.go b/sequencer/worker.go index a99f956fed..0d0b378872 100644 --- a/sequencer/worker.go +++ b/sequencer/worker.go @@ -23,6 +23,7 @@ type Worker struct { state stateInterface batchConstraints state.BatchConstraintsCfg readyTxsCond *timeoutCond + wipTx *TxTracker } // NewWorker creates an init a worker @@ -60,6 +61,12 @@ func (w *Worker) AddTxTracker(ctx context.Context, tx *TxTracker) (replacedTx *T return nil, pool.ErrOutOfCounters } + if (w.wipTx != nil) && (w.wipTx.FromStr == tx.FromStr) && (w.wipTx.Nonce == tx.Nonce) { + log.Infof("adding tx %s (nonce %d) from address %s that matches current processing tx %s (nonce %d), rejecting it as duplicated nonce", tx.Hash, tx.Nonce, tx.From, w.wipTx.Hash, w.wipTx.Nonce) + w.workerMutex.Unlock() + return nil, ErrDuplicatedNonce + } + addr, found := w.pool[tx.FromStr] if !found { // Unlock the worker to let execute other worker functions while creating the new AddrQueue @@ -174,6 +181,8 @@ func (w *Worker) MoveTxToNotReady(txHash common.Hash, from common.Address, actua defer w.workerMutex.Unlock() log.Debugf("move tx %s to notReady (from: %s, actualNonce: %d, actualBalance: %s)", txHash.String(), from.String(), actualNonce, actualBalance.String()) + w.resetWipTx(txHash) + addrQueue, found := w.pool[from.String()] if found { // Sanity check. The txHash must be the readyTx @@ -195,6 +204,8 @@ func (w *Worker) DeleteTx(txHash common.Hash, addr common.Address) { w.workerMutex.Lock() defer w.workerMutex.Unlock() + w.resetWipTx(txHash) + addrQueue, found := w.pool[addr.String()] if found { deletedReadyTx := addrQueue.deleteTx(txHash) @@ -293,6 +304,8 @@ func (w *Worker) GetBestFittingTx(resources state.BatchResources) (*TxTracker, e w.workerMutex.Lock() defer w.workerMutex.Unlock() + w.wipTx = nil + if w.txSortedList.len() == 0 { return nil, ErrTransactionsListEmpty } @@ -342,6 +355,7 @@ func (w *Worker) GetBestFittingTx(resources state.BatchResources) (*TxTracker, e if foundAt != -1 { log.Debugf("best fitting tx %s found at index %d with gasPrice %d", tx.HashStr, foundAt, tx.GasPrice) + w.wipTx = tx return tx, nil } else { return nil, ErrNoFittingTransaction @@ -382,3 +396,9 @@ func (w *Worker) addTxToSortedList(readyTx *TxTracker) { w.readyTxsCond.L.Unlock() } } + +func (w *Worker) resetWipTx(txHash common.Hash) { + if (w.wipTx != nil) && (w.wipTx.Hash == txHash) { + w.wipTx = nil + } +} diff --git a/test/Makefile b/test/Makefile index 339301c3d4..93fc7bb06b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -686,7 +686,7 @@ generate-mocks-sequencer: ## Generates mocks for sequencer , using mockery tool export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=StateMock --filename=mock_state.go export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=txPool --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=PoolMock --filename=mock_pool.go export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../sequencer --outpkg=sequencer --structname=DbTxMock --filename=mock_dbtx.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=etherman --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go .PHONY: generate-mocks-sequencesender generate-mocks-sequencesender: ## Generates mocks for sequencesender , using mockery tool From b9f7fbf18875ab45104fd276f6cfe07896963ba7 Mon Sep 17 00:00:00 2001 From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:01:40 +0200 Subject: [PATCH 05/21] synchronizer: check l1blocks (#3546) * wip * run on background L1block checker * fix lint and documentation * fix conflict * add unittest * more unittest * fix lint * increase timeout for async unittest * fix unittest * rename GetResponse for GetResult and fix uniitest * add a second gorutines for check the newest blocks * more unittest * add unittest and run also preCheck on launch * by default Precheck from FINALIZED and SAFE * fix unittest, apply PR comments * changes suggested by ARR552 in integration method * fix documentation * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * fix unittest * fix PR comments * fix error * checkReorgAndExecuteReset can't be call with lastEthBlockSynced=nil * add parentHash to error * fix error * merge 3553 fix unittest * fix unittest * fix wrong merge * adapt parallel reorg detection to flow * fix unit tests * fix log * allow use sync parallel mode --------- Co-authored-by: Alonso --- config/default.go | 8 + docs/config-file/node-config-doc.html | 2 +- docs/config-file/node-config-doc.md | 165 ++++++++-- docs/config-file/node-config-schema.json | 51 +++ state/interfaces.go | 2 + state/mocks/mock_storage.go | 121 +++++++ state/pgstatestorage/block.go | 49 +++ state/pgstatestorage/pgstatestorage_test.go | 21 ++ synchronizer/common/reorg_error.go | 44 +++ .../syncinterfaces/async_l1_block_checker.go | 40 +++ .../common/syncinterfaces/etherman.go | 3 +- .../mocks/async_l1_block_checker.go | 196 ++++++++++++ .../mocks/l1_block_checker_integrator.go | 176 +++++++++++ .../mocks/state_full_interface.go | 181 +++++++++++ synchronizer/common/syncinterfaces/state.go | 3 + synchronizer/config.go | 32 ++ synchronizer/l1_check_block/async.go | 183 +++++++++++ synchronizer/l1_check_block/async_test.go | 138 ++++++++ synchronizer/l1_check_block/check_l1block.go | 146 +++++++++ .../l1_check_block/check_l1block_test.go | 128 ++++++++ synchronizer/l1_check_block/common.go | 5 + synchronizer/l1_check_block/integration.go | 205 ++++++++++++ .../l1_check_block/integration_test.go | 298 ++++++++++++++++++ .../l1_check_block/mocks/l1_block_checker.go | 82 +++++ .../l1_check_block/mocks/l1_requester.go | 98 ++++++ .../mocks/safe_l1_block_number_fetcher.go | 139 ++++++++ .../state_for_l1_block_checker_integration.go | 100 ++++++ .../l1_check_block/mocks/state_interfacer.go | 149 +++++++++ .../mocks/state_pre_check_interfacer.go | 101 ++++++ .../mocks/sync_check_reorger.go | 111 +++++++ .../l1_check_block/pre_check_l1block.go | 139 ++++++++ .../l1_check_block/pre_check_l1block_test.go | 144 +++++++++ synchronizer/l1_check_block/safe_l1_block.go | 120 +++++++ .../l1_check_block/safe_l1_block_test.go | 113 +++++++ .../l1_rollup_info_consumer.go | 14 +- synchronizer/synchronizer.go | 286 ++++++++++------- synchronizer/synchronizer_test.go | 115 +++++-- test/Makefile | 7 +- test/e2e/jsonrpc2_test.go | 5 +- 39 files changed, 3757 insertions(+), 163 deletions(-) create mode 100644 synchronizer/common/reorg_error.go create mode 100644 synchronizer/common/syncinterfaces/async_l1_block_checker.go create mode 100644 synchronizer/common/syncinterfaces/mocks/async_l1_block_checker.go create mode 100644 synchronizer/common/syncinterfaces/mocks/l1_block_checker_integrator.go create mode 100644 synchronizer/l1_check_block/async.go create mode 100644 synchronizer/l1_check_block/async_test.go create mode 100644 synchronizer/l1_check_block/check_l1block.go create mode 100644 synchronizer/l1_check_block/check_l1block_test.go create mode 100644 synchronizer/l1_check_block/common.go create mode 100644 synchronizer/l1_check_block/integration.go create mode 100644 synchronizer/l1_check_block/integration_test.go create mode 100644 synchronizer/l1_check_block/mocks/l1_block_checker.go create mode 100644 synchronizer/l1_check_block/mocks/l1_requester.go create mode 100644 synchronizer/l1_check_block/mocks/safe_l1_block_number_fetcher.go create mode 100644 synchronizer/l1_check_block/mocks/state_for_l1_block_checker_integration.go create mode 100644 synchronizer/l1_check_block/mocks/state_interfacer.go create mode 100644 synchronizer/l1_check_block/mocks/state_pre_check_interfacer.go create mode 100644 synchronizer/l1_check_block/mocks/sync_check_reorger.go create mode 100644 synchronizer/l1_check_block/pre_check_l1block.go create mode 100644 synchronizer/l1_check_block/pre_check_l1block_test.go create mode 100644 synchronizer/l1_check_block/safe_l1_block.go create mode 100644 synchronizer/l1_check_block/safe_l1_block_test.go diff --git a/config/default.go b/config/default.go index 9b7ec56291..0fd148ea16 100644 --- a/config/default.go +++ b/config/default.go @@ -106,6 +106,14 @@ SyncBlockProtection = "safe" # latest, finalized, safe L1SynchronizationMode = "sequential" L1SyncCheckL2BlockHash = true L1SyncCheckL2BlockNumberhModulus = 30 + [Synchronizer.L1BlockCheck] + Enable = true + L1SafeBlockPoint = "finalized" + L1SafeBlockOffset = 0 + ForceCheckBeforeStart = true + PreCheckEnable = true + L1PreSafeBlockPoint = "safe" + L1PreSafeBlockOffset = 0 [Synchronizer.L1ParallelSynchronization] MaxClients = 10 MaxPendingNoProcessedBlocks = 25 diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 34bd2d4ed1..42256dc0e7 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -16,7 +16,7 @@
"300ms"
 

Default: 500Type: number

MaxRequestsPerIPAndSecond defines how much requests a single IP can
send within a single second


Default: ""Type: string

SequencerNodeURI is used allow Non-Sequencer nodes
to relay transactions to the Sequencer node


Default: 0Type: integer

MaxCumulativeGasUsed is the max gas allowed per batch


WebSockets configuration
Default: trueType: boolean

Enabled defines if the WebSocket requests are enabled or disabled


Default: "0.0.0.0"Type: string

Host defines the network adapter that will be used to serve the WS requests


Default: 8546Type: integer

Port defines the port to serve the endpoints via WS


Default: 104857600Type: integer

ReadLimit defines the maximum size of a message read from the client (in bytes)


Default: trueType: boolean

EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.


Default: falseType: boolean

BatchRequestsEnabled defines if the Batch requests are enabled or disabled


Default: 20Type: integer

BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request


Type: array of integer

L2Coinbase defines which address is going to receive the fees

Must contain a minimum of 20 items

Must contain a maximum of 20 items

Each item of this array must be:


Default: 10000Type: integer

MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit


Default: 10000Type: integer

MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit


Default: 60000Type: integer

MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit


Default: trueType: boolean

EnableHttpLog allows the user to enable or disable the logs related to the HTTP
requests to be captured by the server.


ZKCountersLimits defines the ZK Counter limits
Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Configuration of service `Syncrhonizer`. For this service is also really important the value of `IsTrustedSequencer` because depending of this values is going to ask to a trusted node for trusted transactions or not
Default: "1s"Type: string

SyncInterval is the delay interval between reading new rollup information


Examples:

"1m"
 
"300ms"
-

Default: 100Type: integer

SyncChunkSize is the number of blocks to sync on each chunk


Default: ""Type: string

TrustedSequencerURL is the rpc url to connect and sync the trusted state


Default: "safe"Type: string

SyncBlockProtection specify the state to sync (lastest, finalized or safe)


Default: trueType: boolean

L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)


Default: 30Type: integer

L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)


Default: "sequential"Type: enum (of string)

L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute

Must be one of:

  • "sequential"
  • "parallel"

L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel')
Default: 10Type: integer

MaxClients Number of clients used to synchronize with L1


Default: 25Type: integer

MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients


Default: "5s"Type: string

RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized


Examples:

"1m"
+

Default: 100Type: integer

SyncChunkSize is the number of blocks to sync on each chunk


Default: ""Type: string

TrustedSequencerURL is the rpc url to connect and sync the trusted state


Default: "safe"Type: string

SyncBlockProtection specify the state to sync (lastest, finalized or safe)


Default: trueType: boolean

L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)


Default: 30Type: integer

L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)


Default: trueType: boolean

Enable if is true then the check l1 Block Hash is active


Default: "finalized"Type: enum (of string)

L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: trueType: boolean

ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks


Default: trueType: boolean

PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock


Default: "safe"Type: enum (of string)

L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: "sequential"Type: enum (of string)

L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute

Must be one of:

  • "sequential"
  • "parallel"

L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel')
Default: 10Type: integer

MaxClients Number of clients used to synchronize with L1


Default: 25Type: integer

MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients


Default: "5s"Type: string

RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized


Examples:

"1m"
 
"300ms"
 

Consumer Configuration for the consumer of rollup information from L1
Default: "5s"Type: string

AceptableInacctivityTime is the expected maximum time that the consumer
could wait until new data is produced. If the time is greater it emmit a log to warn about
that. The idea is keep working the consumer as much as possible, so if the producer is not
fast enought then you could increse the number of parallel clients to sync with L1


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index 046008f0af..aecef0265b 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1342,6 +1342,7 @@ because depending of this values is going to ask to a trusted node for trusted t
 | - [SyncBlockProtection](#Synchronizer_SyncBlockProtection )                           | No      | string           | No         | -          | SyncBlockProtection specify the state to sync (lastest, finalized or safe)                                                                                                                                                                              |
 | - [L1SyncCheckL2BlockHash](#Synchronizer_L1SyncCheckL2BlockHash )                     | No      | boolean          | No         | -          | L1SyncCheckL2BlockHash if is true when a batch is closed is force to check  L2Block hash against trustedNode (only apply for permissionless)                                                                                                            |
 | - [L1SyncCheckL2BlockNumberhModulus](#Synchronizer_L1SyncCheckL2BlockNumberhModulus ) | No      | integer          | No         | -          | L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) | +| - [L1BlockCheck](#Synchronizer_L1BlockCheck ) | No | object | No | - | - | | - [L1SynchronizationMode](#Synchronizer_L1SynchronizationMode ) | No | enum (of string) | No | - | L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute | | - [L1ParallelSynchronization](#Synchronizer_L1ParallelSynchronization ) | No | object | No | - | L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel') | | - [L2Synchronization](#Synchronizer_L2Synchronization ) | No | object | No | - | L2Synchronization Configuration for L2 synchronization | @@ -1443,7 +1444,135 @@ a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) L1SyncCheckL2BlockNumberhModulus=30 ``` -### 9.7. `Synchronizer.L1SynchronizationMode` +### 9.7. `[Synchronizer.L1BlockCheck]` + +**Type:** : `object` + +| Property | Pattern | Type | Deprecated | Definition | Title/Description | +| ---------------------------------------------------------------------------- | ------- | ---------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| - [Enable](#Synchronizer_L1BlockCheck_Enable ) | No | boolean | No | - | Enable if is true then the check l1 Block Hash is active | +| - [L1SafeBlockPoint](#Synchronizer_L1BlockCheck_L1SafeBlockPoint ) | No | enum (of string) | No | - | L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest | +| - [L1SafeBlockOffset](#Synchronizer_L1BlockCheck_L1SafeBlockOffset ) | No | integer | No | - | L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block | +| - [ForceCheckBeforeStart](#Synchronizer_L1BlockCheck_ForceCheckBeforeStart ) | No | boolean | No | - | ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks | +| - [PreCheckEnable](#Synchronizer_L1BlockCheck_PreCheckEnable ) | No | boolean | No | - | PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock | +| - [L1PreSafeBlockPoint](#Synchronizer_L1BlockCheck_L1PreSafeBlockPoint ) | No | enum (of string) | No | - | L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest | +| - [L1PreSafeBlockOffset](#Synchronizer_L1BlockCheck_L1PreSafeBlockOffset ) | No | integer | No | - | L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block | + +#### 9.7.1. `Synchronizer.L1BlockCheck.Enable` + +**Type:** : `boolean` + +**Default:** `true` + +**Description:** Enable if is true then the check l1 Block Hash is active + +**Example setting the default value** (true): +``` +[Synchronizer.L1BlockCheck] +Enable=true +``` + +#### 9.7.2. `Synchronizer.L1BlockCheck.L1SafeBlockPoint` + +**Type:** : `enum (of string)` + +**Default:** `"finalized"` + +**Description:** L1SafeBlockPoint is the point that a block is considered safe enough to be checked +it can be: finalized, safe,pending or latest + +**Example setting the default value** ("finalized"): +``` +[Synchronizer.L1BlockCheck] +L1SafeBlockPoint="finalized" +``` + +Must be one of: +* "finalized" +* "safe" +* "latest" + +#### 9.7.3. `Synchronizer.L1BlockCheck.L1SafeBlockOffset` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point +it can be positive or negative +Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block + +**Example setting the default value** (0): +``` +[Synchronizer.L1BlockCheck] +L1SafeBlockOffset=0 +``` + +#### 9.7.4. `Synchronizer.L1BlockCheck.ForceCheckBeforeStart` + +**Type:** : `boolean` + +**Default:** `true` + +**Description:** ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks + +**Example setting the default value** (true): +``` +[Synchronizer.L1BlockCheck] +ForceCheckBeforeStart=true +``` + +#### 9.7.5. `Synchronizer.L1BlockCheck.PreCheckEnable` + +**Type:** : `boolean` + +**Default:** `true` + +**Description:** PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock + +**Example setting the default value** (true): +``` +[Synchronizer.L1BlockCheck] +PreCheckEnable=true +``` + +#### 9.7.6. `Synchronizer.L1BlockCheck.L1PreSafeBlockPoint` + +**Type:** : `enum (of string)` + +**Default:** `"safe"` + +**Description:** L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked +it can be: finalized, safe,pending or latest + +**Example setting the default value** ("safe"): +``` +[Synchronizer.L1BlockCheck] +L1PreSafeBlockPoint="safe" +``` + +Must be one of: +* "finalized" +* "safe" +* "latest" + +#### 9.7.7. `Synchronizer.L1BlockCheck.L1PreSafeBlockOffset` + +**Type:** : `integer` + +**Default:** `0` + +**Description:** L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point +it can be positive or negative +Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block + +**Example setting the default value** (0): +``` +[Synchronizer.L1BlockCheck] +L1PreSafeBlockOffset=0 +``` + +### 9.8. `Synchronizer.L1SynchronizationMode` **Type:** : `enum (of string)` @@ -1463,7 +1592,7 @@ Must be one of: * "sequential" * "parallel" -### 9.8. `[Synchronizer.L1ParallelSynchronization]` +### 9.9. `[Synchronizer.L1ParallelSynchronization]` **Type:** : `object` **Description:** L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel') @@ -1481,7 +1610,7 @@ Must be one of: | - [RollupInfoRetriesSpacing](#Synchronizer_L1ParallelSynchronization_RollupInfoRetriesSpacing ) | No | string | No | - | Duration | | - [FallbackToSequentialModeOnSynchronized](#Synchronizer_L1ParallelSynchronization_FallbackToSequentialModeOnSynchronized ) | No | boolean | No | - | FallbackToSequentialModeOnSynchronized if true switch to sequential mode if the system is synchronized | -#### 9.8.1. `Synchronizer.L1ParallelSynchronization.MaxClients` +#### 9.9.1. `Synchronizer.L1ParallelSynchronization.MaxClients` **Type:** : `integer` @@ -1495,7 +1624,7 @@ Must be one of: MaxClients=10 ``` -#### 9.8.2. `Synchronizer.L1ParallelSynchronization.MaxPendingNoProcessedBlocks` +#### 9.9.2. `Synchronizer.L1ParallelSynchronization.MaxPendingNoProcessedBlocks` **Type:** : `integer` @@ -1510,7 +1639,7 @@ sugested twice of NumberOfParallelOfEthereumClients MaxPendingNoProcessedBlocks=25 ``` -#### 9.8.3. `Synchronizer.L1ParallelSynchronization.RequestLastBlockPeriod` +#### 9.9.3. `Synchronizer.L1ParallelSynchronization.RequestLastBlockPeriod` **Title:** Duration @@ -1538,7 +1667,7 @@ This value only apply when the system is synchronized RequestLastBlockPeriod="5s" ``` -#### 9.8.4. `[Synchronizer.L1ParallelSynchronization.PerformanceWarning]` +#### 9.9.4. `[Synchronizer.L1ParallelSynchronization.PerformanceWarning]` **Type:** : `object` **Description:** Consumer Configuration for the consumer of rollup information from L1 @@ -1548,7 +1677,7 @@ RequestLastBlockPeriod="5s" | - [AceptableInacctivityTime](#Synchronizer_L1ParallelSynchronization_PerformanceWarning_AceptableInacctivityTime ) | No | string | No | - | Duration | | - [ApplyAfterNumRollupReceived](#Synchronizer_L1ParallelSynchronization_PerformanceWarning_ApplyAfterNumRollupReceived ) | No | integer | No | - | ApplyAfterNumRollupReceived is the number of iterations to
start checking the time waiting for new rollup info data | -##### 9.8.4.1. `Synchronizer.L1ParallelSynchronization.PerformanceWarning.AceptableInacctivityTime` +##### 9.9.4.1. `Synchronizer.L1ParallelSynchronization.PerformanceWarning.AceptableInacctivityTime` **Title:** Duration @@ -1577,7 +1706,7 @@ fast enought then you could increse the number of parallel clients to sync with AceptableInacctivityTime="5s" ``` -##### 9.8.4.2. `Synchronizer.L1ParallelSynchronization.PerformanceWarning.ApplyAfterNumRollupReceived` +##### 9.9.4.2. `Synchronizer.L1ParallelSynchronization.PerformanceWarning.ApplyAfterNumRollupReceived` **Type:** : `integer` @@ -1592,7 +1721,7 @@ start checking the time waiting for new rollup info data ApplyAfterNumRollupReceived=10 ``` -#### 9.8.5. `Synchronizer.L1ParallelSynchronization.RequestLastBlockTimeout` +#### 9.9.5. `Synchronizer.L1ParallelSynchronization.RequestLastBlockTimeout` **Title:** Duration @@ -1618,7 +1747,7 @@ ApplyAfterNumRollupReceived=10 RequestLastBlockTimeout="5s" ``` -#### 9.8.6. `Synchronizer.L1ParallelSynchronization.RequestLastBlockMaxRetries` +#### 9.9.6. `Synchronizer.L1ParallelSynchronization.RequestLastBlockMaxRetries` **Type:** : `integer` @@ -1632,7 +1761,7 @@ RequestLastBlockTimeout="5s" RequestLastBlockMaxRetries=3 ``` -#### 9.8.7. `Synchronizer.L1ParallelSynchronization.StatisticsPeriod` +#### 9.9.7. `Synchronizer.L1ParallelSynchronization.StatisticsPeriod` **Title:** Duration @@ -1658,7 +1787,7 @@ RequestLastBlockMaxRetries=3 StatisticsPeriod="5m0s" ``` -#### 9.8.8. `Synchronizer.L1ParallelSynchronization.TimeOutMainLoop` +#### 9.9.8. `Synchronizer.L1ParallelSynchronization.TimeOutMainLoop` **Title:** Duration @@ -1684,7 +1813,7 @@ StatisticsPeriod="5m0s" TimeOutMainLoop="5m0s" ``` -#### 9.8.9. `Synchronizer.L1ParallelSynchronization.RollupInfoRetriesSpacing` +#### 9.9.9. `Synchronizer.L1ParallelSynchronization.RollupInfoRetriesSpacing` **Title:** Duration @@ -1710,7 +1839,7 @@ TimeOutMainLoop="5m0s" RollupInfoRetriesSpacing="5s" ``` -#### 9.8.10. `Synchronizer.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized` +#### 9.9.10. `Synchronizer.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized` **Type:** : `boolean` @@ -1724,7 +1853,7 @@ RollupInfoRetriesSpacing="5s" FallbackToSequentialModeOnSynchronized=false ``` -### 9.9. `[Synchronizer.L2Synchronization]` +### 9.10. `[Synchronizer.L2Synchronization]` **Type:** : `object` **Description:** L2Synchronization Configuration for L2 synchronization @@ -1735,7 +1864,7 @@ FallbackToSequentialModeOnSynchronized=false | - [ReprocessFullBatchOnClose](#Synchronizer_L2Synchronization_ReprocessFullBatchOnClose ) | No | boolean | No | - | ReprocessFullBatchOnClose if is true when a batch is closed is force to reprocess again | | - [CheckLastL2BlockHashOnCloseBatch](#Synchronizer_L2Synchronization_CheckLastL2BlockHashOnCloseBatch ) | No | boolean | No | - | CheckLastL2BlockHashOnCloseBatch if is true when a batch is closed is force to check the last L2Block hash | -#### 9.9.1. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches` +#### 9.10.1. `Synchronizer.L2Synchronization.AcceptEmptyClosedBatches` **Type:** : `boolean` @@ -1750,7 +1879,7 @@ if true, the synchronizer will accept empty batches and process them. AcceptEmptyClosedBatches=false ``` -#### 9.9.2. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose` +#### 9.10.2. `Synchronizer.L2Synchronization.ReprocessFullBatchOnClose` **Type:** : `boolean` @@ -1764,7 +1893,7 @@ AcceptEmptyClosedBatches=false ReprocessFullBatchOnClose=false ``` -#### 9.9.3. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch` +#### 9.10.3. `Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch` **Type:** : `boolean` diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json index 916aaf18b1..e95dc565b8 100644 --- a/docs/config-file/node-config-schema.json +++ b/docs/config-file/node-config-schema.json @@ -532,6 +532,57 @@ "description": "L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check\na modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)", "default": 30 }, + "L1BlockCheck": { + "properties": { + "Enable": { + "type": "boolean", + "description": "Enable if is true then the check l1 Block Hash is active", + "default": true + }, + "L1SafeBlockPoint": { + "type": "string", + "enum": [ + "finalized", + "safe", + "latest" + ], + "description": "L1SafeBlockPoint is the point that a block is considered safe enough to be checked\nit can be: finalized, safe,pending or latest", + "default": "finalized" + }, + "L1SafeBlockOffset": { + "type": "integer", + "description": "L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point\nit can be positive or negative\nExample: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block", + "default": 0 + }, + "ForceCheckBeforeStart": { + "type": "boolean", + "description": "ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks", + "default": true + }, + "PreCheckEnable": { + "type": "boolean", + "description": "PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock", + "default": true + }, + "L1PreSafeBlockPoint": { + "type": "string", + "enum": [ + "finalized", + "safe", + "latest" + ], + "description": "L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked\nit can be: finalized, safe,pending or latest", + "default": "safe" + }, + "L1PreSafeBlockOffset": { + "type": "integer", + "description": "L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point\nit can be positive or negative\nExample: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block", + "default": 0 + } + }, + "additionalProperties": false, + "type": "object" + }, "L1SynchronizationMode": { "type": "string", "enum": [ diff --git a/state/interfaces.go b/state/interfaces.go index 1524553240..cc3c96d8fd 100644 --- a/state/interfaces.go +++ b/state/interfaces.go @@ -25,6 +25,7 @@ type storage interface { GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*Block, error) + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*Block, error) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error) @@ -164,4 +165,5 @@ type storage interface { UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error) GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error) + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) } diff --git a/state/mocks/mock_storage.go b/state/mocks/mock_storage.go index 24b5f7abef..696294d465 100644 --- a/state/mocks/mock_storage.go +++ b/state/mocks/mock_storage.go @@ -5729,6 +5729,66 @@ func (_c *StorageMock_GetPreviousBlock_Call) RunAndReturn(run func(context.Conte return _c } +// GetPreviousBlockToBlockNumber provides a mock function with given fields: ctx, blockNumber, dbTx +func (_m *StorageMock) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + ret := _m.Called(ctx, blockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetPreviousBlockToBlockNumber") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) (*state.Block, error)); ok { + return rf(ctx, blockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Block); ok { + r0 = rf(ctx, blockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, blockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StorageMock_GetPreviousBlockToBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousBlockToBlockNumber' +type StorageMock_GetPreviousBlockToBlockNumber_Call struct { + *mock.Call +} + +// GetPreviousBlockToBlockNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +// - dbTx pgx.Tx +func (_e *StorageMock_Expecter) GetPreviousBlockToBlockNumber(ctx interface{}, blockNumber interface{}, dbTx interface{}) *StorageMock_GetPreviousBlockToBlockNumber_Call { + return &StorageMock_GetPreviousBlockToBlockNumber_Call{Call: _e.mock.On("GetPreviousBlockToBlockNumber", ctx, blockNumber, dbTx)} +} + +func (_c *StorageMock_GetPreviousBlockToBlockNumber_Call) Run(run func(ctx context.Context, blockNumber uint64, dbTx pgx.Tx)) *StorageMock_GetPreviousBlockToBlockNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *StorageMock_GetPreviousBlockToBlockNumber_Call) Return(_a0 *state.Block, _a1 error) *StorageMock_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageMock_GetPreviousBlockToBlockNumber_Call) RunAndReturn(run func(context.Context, uint64, pgx.Tx) (*state.Block, error)) *StorageMock_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(run) + return _c +} + // GetProcessingContext provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *StorageMock) GetProcessingContext(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.ProcessingContext, error) { ret := _m.Called(ctx, batchNumber, dbTx) @@ -7012,6 +7072,67 @@ func (_c *StorageMock_GetTxsOlderThanNL1BlocksUntilTxHash_Call) RunAndReturn(run return _c } +// GetUncheckedBlocks provides a mock function with given fields: ctx, fromBlockNumber, toBlockNumber, dbTx +func (_m *StorageMock) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) { + ret := _m.Called(ctx, fromBlockNumber, toBlockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetUncheckedBlocks") + } + + var r0 []*state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)); ok { + return rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) []*state.Block); ok { + r0 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StorageMock_GetUncheckedBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUncheckedBlocks' +type StorageMock_GetUncheckedBlocks_Call struct { + *mock.Call +} + +// GetUncheckedBlocks is a helper method to define mock.On call +// - ctx context.Context +// - fromBlockNumber uint64 +// - toBlockNumber uint64 +// - dbTx pgx.Tx +func (_e *StorageMock_Expecter) GetUncheckedBlocks(ctx interface{}, fromBlockNumber interface{}, toBlockNumber interface{}, dbTx interface{}) *StorageMock_GetUncheckedBlocks_Call { + return &StorageMock_GetUncheckedBlocks_Call{Call: _e.mock.On("GetUncheckedBlocks", ctx, fromBlockNumber, toBlockNumber, dbTx)} +} + +func (_c *StorageMock_GetUncheckedBlocks_Call) Run(run func(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx)) *StorageMock_GetUncheckedBlocks_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(uint64), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *StorageMock_GetUncheckedBlocks_Call) Return(_a0 []*state.Block, _a1 error) *StorageMock_GetUncheckedBlocks_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageMock_GetUncheckedBlocks_Call) RunAndReturn(run func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)) *StorageMock_GetUncheckedBlocks_Call { + _c.Call.Return(run) + return _c +} + // GetVerifiedBatch provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *StorageMock) GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) { ret := _m.Called(ctx, batchNumber, dbTx) diff --git a/state/pgstatestorage/block.go b/state/pgstatestorage/block.go index 768b384df1..7c657a6e3b 100644 --- a/state/pgstatestorage/block.go +++ b/state/pgstatestorage/block.go @@ -63,6 +63,35 @@ func (p *PostgresStorage) GetFirstUncheckedBlock(ctx context.Context, fromBlockN return &block, err } +func (p *PostgresStorage) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) { + const getUncheckedBlocksSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND block_num<=$2 AND checked=false ORDER BY block_num" + + q := p.getExecQuerier(dbTx) + + rows, err := q.Query(ctx, getUncheckedBlocksSQL, fromBlockNumber, toBlockNumber) + if err != nil { + return nil, err + } + defer rows.Close() + + var blocks []*state.Block + for rows.Next() { + var ( + blockHash string + parentHash string + block state.Block + ) + err := rows.Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + if err != nil { + return nil, err + } + block.BlockHash = common.HexToHash(blockHash) + block.ParentHash = common.HexToHash(parentHash) + blocks = append(blocks, &block) + } + return blocks, nil +} + // GetPreviousBlock gets the offset previous L1 block respect to latest. func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) { var ( @@ -83,6 +112,26 @@ func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, d return &block, err } +// GetPreviousBlockToBlockNumber gets the previous L1 block respect blockNumber. +func (p *PostgresStorage) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + var ( + blockHash string + parentHash string + block state.Block + ) + const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num < $1 ORDER BY block_num DESC LIMIT 1 " + + q := p.getExecQuerier(dbTx) + + err := q.QueryRow(ctx, getPreviousBlockSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + if errors.Is(err, pgx.ErrNoRows) { + return nil, state.ErrNotFound + } + block.BlockHash = common.HexToHash(blockHash) + block.ParentHash = common.HexToHash(parentHash) + return &block, err +} + // GetBlockByNumber returns the L1 block with the given number. func (p *PostgresStorage) GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { var ( diff --git a/state/pgstatestorage/pgstatestorage_test.go b/state/pgstatestorage/pgstatestorage_test.go index 7502dae736..47fdf1c7c7 100644 --- a/state/pgstatestorage/pgstatestorage_test.go +++ b/state/pgstatestorage/pgstatestorage_test.go @@ -1795,3 +1795,24 @@ func TestUpdateCheckedBlockByNumber(t *testing.T) { require.NoError(t, err) require.False(t, b1.Checked) } + +func TestGetUncheckedBlocks(t *testing.T) { + var err error + blockNumber := uint64(61001) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) + require.NoError(t, err) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) + require.NoError(t, err) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) + require.NoError(t, err) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 3, Checked: false}, nil) + require.NoError(t, err) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 4, Checked: false}, nil) + require.NoError(t, err) + + blocks, err := testState.GetUncheckedBlocks(context.Background(), blockNumber, blockNumber+3, nil) + require.NoError(t, err) + require.Equal(t, 2, len(blocks)) + require.Equal(t, uint64(blockNumber+1), blocks[0].BlockNumber) + require.Equal(t, uint64(blockNumber+3), blocks[1].BlockNumber) +} diff --git a/synchronizer/common/reorg_error.go b/synchronizer/common/reorg_error.go new file mode 100644 index 0000000000..e60dcfb22c --- /dev/null +++ b/synchronizer/common/reorg_error.go @@ -0,0 +1,44 @@ +package common + +import "fmt" + +// ReorgError is an error that is raised when a reorg is detected +type ReorgError struct { + // BlockNumber is the block number that caused the reorg + BlockNumber uint64 + Err error +} + +// NewReorgError creates a new ReorgError +func NewReorgError(blockNumber uint64, err error) *ReorgError { + return &ReorgError{ + BlockNumber: blockNumber, + Err: err, + } +} + +func (e *ReorgError) Error() string { + return fmt.Sprintf("%s blockNumber: %d", e.Err.Error(), e.BlockNumber) +} + +// IsReorgError checks if an error is a ReorgError +func IsReorgError(err error) bool { + _, ok := err.(*ReorgError) + return ok +} + +// GetReorgErrorBlockNumber returns the block number that caused the reorg +func GetReorgErrorBlockNumber(err error) uint64 { + if reorgErr, ok := err.(*ReorgError); ok { + return reorgErr.BlockNumber + } + return 0 +} + +// GetReorgError returns the error that caused the reorg +func GetReorgError(err error) error { + if reorgErr, ok := err.(*ReorgError); ok { + return reorgErr.Err + } + return nil +} diff --git a/synchronizer/common/syncinterfaces/async_l1_block_checker.go b/synchronizer/common/syncinterfaces/async_l1_block_checker.go new file mode 100644 index 0000000000..b95903901a --- /dev/null +++ b/synchronizer/common/syncinterfaces/async_l1_block_checker.go @@ -0,0 +1,40 @@ +package syncinterfaces + +import ( + "context" + "fmt" + + "github.com/0xPolygonHermez/zkevm-node/state" +) + +type IterationResult struct { + Err error + ReorgDetected bool + BlockNumber uint64 + ReorgMessage string +} + +func (ir *IterationResult) String() string { + if ir.Err == nil { + if ir.ReorgDetected { + return fmt.Sprintf("IterationResult{ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage) + } else { + return "IterationResult{None}" + } + } else { + return fmt.Sprintf("IterationResult{Err: %s, ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.Err.Error(), ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage) + } +} + +type AsyncL1BlockChecker interface { + Run(ctx context.Context, onFinish func()) + RunSynchronous(ctx context.Context) IterationResult + Stop() + GetResult() *IterationResult +} + +type L1BlockCheckerIntegrator interface { + OnStart(ctx context.Context) error + OnResetState(ctx context.Context) + CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) +} diff --git a/synchronizer/common/syncinterfaces/etherman.go b/synchronizer/common/syncinterfaces/etherman.go index 3d5959ade2..fdbdd669f8 100644 --- a/synchronizer/common/syncinterfaces/etherman.go +++ b/synchronizer/common/syncinterfaces/etherman.go @@ -14,10 +14,11 @@ type EthermanFullInterface interface { HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error) GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error) EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error) - GetLatestBatchNumber() (uint64, error) GetTrustedSequencerURL() (string, error) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) GetLatestVerifiedBatchNum() (uint64, error) + + EthermanGetLatestBatchNumber GetFinalizedBlockNumber(ctx context.Context) (uint64, error) } diff --git a/synchronizer/common/syncinterfaces/mocks/async_l1_block_checker.go b/synchronizer/common/syncinterfaces/mocks/async_l1_block_checker.go new file mode 100644 index 0000000000..67b38de348 --- /dev/null +++ b/synchronizer/common/syncinterfaces/mocks/async_l1_block_checker.go @@ -0,0 +1,196 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_syncinterfaces + +import ( + context "context" + + syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + mock "github.com/stretchr/testify/mock" +) + +// AsyncL1BlockChecker is an autogenerated mock type for the AsyncL1BlockChecker type +type AsyncL1BlockChecker struct { + mock.Mock +} + +type AsyncL1BlockChecker_Expecter struct { + mock *mock.Mock +} + +func (_m *AsyncL1BlockChecker) EXPECT() *AsyncL1BlockChecker_Expecter { + return &AsyncL1BlockChecker_Expecter{mock: &_m.Mock} +} + +// GetResult provides a mock function with given fields: +func (_m *AsyncL1BlockChecker) GetResult() *syncinterfaces.IterationResult { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetResult") + } + + var r0 *syncinterfaces.IterationResult + if rf, ok := ret.Get(0).(func() *syncinterfaces.IterationResult); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*syncinterfaces.IterationResult) + } + } + + return r0 +} + +// AsyncL1BlockChecker_GetResult_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetResult' +type AsyncL1BlockChecker_GetResult_Call struct { + *mock.Call +} + +// GetResult is a helper method to define mock.On call +func (_e *AsyncL1BlockChecker_Expecter) GetResult() *AsyncL1BlockChecker_GetResult_Call { + return &AsyncL1BlockChecker_GetResult_Call{Call: _e.mock.On("GetResult")} +} + +func (_c *AsyncL1BlockChecker_GetResult_Call) Run(run func()) *AsyncL1BlockChecker_GetResult_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *AsyncL1BlockChecker_GetResult_Call) Return(_a0 *syncinterfaces.IterationResult) *AsyncL1BlockChecker_GetResult_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *AsyncL1BlockChecker_GetResult_Call) RunAndReturn(run func() *syncinterfaces.IterationResult) *AsyncL1BlockChecker_GetResult_Call { + _c.Call.Return(run) + return _c +} + +// Run provides a mock function with given fields: ctx, onFinish +func (_m *AsyncL1BlockChecker) Run(ctx context.Context, onFinish func()) { + _m.Called(ctx, onFinish) +} + +// AsyncL1BlockChecker_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run' +type AsyncL1BlockChecker_Run_Call struct { + *mock.Call +} + +// Run is a helper method to define mock.On call +// - ctx context.Context +// - onFinish func() +func (_e *AsyncL1BlockChecker_Expecter) Run(ctx interface{}, onFinish interface{}) *AsyncL1BlockChecker_Run_Call { + return &AsyncL1BlockChecker_Run_Call{Call: _e.mock.On("Run", ctx, onFinish)} +} + +func (_c *AsyncL1BlockChecker_Run_Call) Run(run func(ctx context.Context, onFinish func())) *AsyncL1BlockChecker_Run_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(func())) + }) + return _c +} + +func (_c *AsyncL1BlockChecker_Run_Call) Return() *AsyncL1BlockChecker_Run_Call { + _c.Call.Return() + return _c +} + +func (_c *AsyncL1BlockChecker_Run_Call) RunAndReturn(run func(context.Context, func())) *AsyncL1BlockChecker_Run_Call { + _c.Call.Return(run) + return _c +} + +// RunSynchronous provides a mock function with given fields: ctx +func (_m *AsyncL1BlockChecker) RunSynchronous(ctx context.Context) syncinterfaces.IterationResult { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for RunSynchronous") + } + + var r0 syncinterfaces.IterationResult + if rf, ok := ret.Get(0).(func(context.Context) syncinterfaces.IterationResult); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(syncinterfaces.IterationResult) + } + + return r0 +} + +// AsyncL1BlockChecker_RunSynchronous_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunSynchronous' +type AsyncL1BlockChecker_RunSynchronous_Call struct { + *mock.Call +} + +// RunSynchronous is a helper method to define mock.On call +// - ctx context.Context +func (_e *AsyncL1BlockChecker_Expecter) RunSynchronous(ctx interface{}) *AsyncL1BlockChecker_RunSynchronous_Call { + return &AsyncL1BlockChecker_RunSynchronous_Call{Call: _e.mock.On("RunSynchronous", ctx)} +} + +func (_c *AsyncL1BlockChecker_RunSynchronous_Call) Run(run func(ctx context.Context)) *AsyncL1BlockChecker_RunSynchronous_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *AsyncL1BlockChecker_RunSynchronous_Call) Return(_a0 syncinterfaces.IterationResult) *AsyncL1BlockChecker_RunSynchronous_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *AsyncL1BlockChecker_RunSynchronous_Call) RunAndReturn(run func(context.Context) syncinterfaces.IterationResult) *AsyncL1BlockChecker_RunSynchronous_Call { + _c.Call.Return(run) + return _c +} + +// Stop provides a mock function with given fields: +func (_m *AsyncL1BlockChecker) Stop() { + _m.Called() +} + +// AsyncL1BlockChecker_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type AsyncL1BlockChecker_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *AsyncL1BlockChecker_Expecter) Stop() *AsyncL1BlockChecker_Stop_Call { + return &AsyncL1BlockChecker_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *AsyncL1BlockChecker_Stop_Call) Run(run func()) *AsyncL1BlockChecker_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *AsyncL1BlockChecker_Stop_Call) Return() *AsyncL1BlockChecker_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *AsyncL1BlockChecker_Stop_Call) RunAndReturn(run func()) *AsyncL1BlockChecker_Stop_Call { + _c.Call.Return(run) + return _c +} + +// NewAsyncL1BlockChecker creates a new instance of AsyncL1BlockChecker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewAsyncL1BlockChecker(t interface { + mock.TestingT + Cleanup(func()) +}) *AsyncL1BlockChecker { + mock := &AsyncL1BlockChecker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/common/syncinterfaces/mocks/l1_block_checker_integrator.go b/synchronizer/common/syncinterfaces/mocks/l1_block_checker_integrator.go new file mode 100644 index 0000000000..0248874f26 --- /dev/null +++ b/synchronizer/common/syncinterfaces/mocks/l1_block_checker_integrator.go @@ -0,0 +1,176 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_syncinterfaces + +import ( + context "context" + + state "github.com/0xPolygonHermez/zkevm-node/state" + mock "github.com/stretchr/testify/mock" +) + +// L1BlockCheckerIntegrator is an autogenerated mock type for the L1BlockCheckerIntegrator type +type L1BlockCheckerIntegrator struct { + mock.Mock +} + +type L1BlockCheckerIntegrator_Expecter struct { + mock *mock.Mock +} + +func (_m *L1BlockCheckerIntegrator) EXPECT() *L1BlockCheckerIntegrator_Expecter { + return &L1BlockCheckerIntegrator_Expecter{mock: &_m.Mock} +} + +// CheckReorgWrapper provides a mock function with given fields: ctx, reorgFirstBlockOk, errReportedByReorgFunc +func (_m *L1BlockCheckerIntegrator) CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) { + ret := _m.Called(ctx, reorgFirstBlockOk, errReportedByReorgFunc) + + if len(ret) == 0 { + panic("no return value specified for CheckReorgWrapper") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *state.Block, error) (*state.Block, error)); ok { + return rf(ctx, reorgFirstBlockOk, errReportedByReorgFunc) + } + if rf, ok := ret.Get(0).(func(context.Context, *state.Block, error) *state.Block); ok { + r0 = rf(ctx, reorgFirstBlockOk, errReportedByReorgFunc) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *state.Block, error) error); ok { + r1 = rf(ctx, reorgFirstBlockOk, errReportedByReorgFunc) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// L1BlockCheckerIntegrator_CheckReorgWrapper_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckReorgWrapper' +type L1BlockCheckerIntegrator_CheckReorgWrapper_Call struct { + *mock.Call +} + +// CheckReorgWrapper is a helper method to define mock.On call +// - ctx context.Context +// - reorgFirstBlockOk *state.Block +// - errReportedByReorgFunc error +func (_e *L1BlockCheckerIntegrator_Expecter) CheckReorgWrapper(ctx interface{}, reorgFirstBlockOk interface{}, errReportedByReorgFunc interface{}) *L1BlockCheckerIntegrator_CheckReorgWrapper_Call { + return &L1BlockCheckerIntegrator_CheckReorgWrapper_Call{Call: _e.mock.On("CheckReorgWrapper", ctx, reorgFirstBlockOk, errReportedByReorgFunc)} +} + +func (_c *L1BlockCheckerIntegrator_CheckReorgWrapper_Call) Run(run func(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error)) *L1BlockCheckerIntegrator_CheckReorgWrapper_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*state.Block), args[2].(error)) + }) + return _c +} + +func (_c *L1BlockCheckerIntegrator_CheckReorgWrapper_Call) Return(_a0 *state.Block, _a1 error) *L1BlockCheckerIntegrator_CheckReorgWrapper_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *L1BlockCheckerIntegrator_CheckReorgWrapper_Call) RunAndReturn(run func(context.Context, *state.Block, error) (*state.Block, error)) *L1BlockCheckerIntegrator_CheckReorgWrapper_Call { + _c.Call.Return(run) + return _c +} + +// OnResetState provides a mock function with given fields: ctx +func (_m *L1BlockCheckerIntegrator) OnResetState(ctx context.Context) { + _m.Called(ctx) +} + +// L1BlockCheckerIntegrator_OnResetState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnResetState' +type L1BlockCheckerIntegrator_OnResetState_Call struct { + *mock.Call +} + +// OnResetState is a helper method to define mock.On call +// - ctx context.Context +func (_e *L1BlockCheckerIntegrator_Expecter) OnResetState(ctx interface{}) *L1BlockCheckerIntegrator_OnResetState_Call { + return &L1BlockCheckerIntegrator_OnResetState_Call{Call: _e.mock.On("OnResetState", ctx)} +} + +func (_c *L1BlockCheckerIntegrator_OnResetState_Call) Run(run func(ctx context.Context)) *L1BlockCheckerIntegrator_OnResetState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *L1BlockCheckerIntegrator_OnResetState_Call) Return() *L1BlockCheckerIntegrator_OnResetState_Call { + _c.Call.Return() + return _c +} + +func (_c *L1BlockCheckerIntegrator_OnResetState_Call) RunAndReturn(run func(context.Context)) *L1BlockCheckerIntegrator_OnResetState_Call { + _c.Call.Return(run) + return _c +} + +// OnStart provides a mock function with given fields: ctx +func (_m *L1BlockCheckerIntegrator) OnStart(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for OnStart") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// L1BlockCheckerIntegrator_OnStart_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnStart' +type L1BlockCheckerIntegrator_OnStart_Call struct { + *mock.Call +} + +// OnStart is a helper method to define mock.On call +// - ctx context.Context +func (_e *L1BlockCheckerIntegrator_Expecter) OnStart(ctx interface{}) *L1BlockCheckerIntegrator_OnStart_Call { + return &L1BlockCheckerIntegrator_OnStart_Call{Call: _e.mock.On("OnStart", ctx)} +} + +func (_c *L1BlockCheckerIntegrator_OnStart_Call) Run(run func(ctx context.Context)) *L1BlockCheckerIntegrator_OnStart_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *L1BlockCheckerIntegrator_OnStart_Call) Return(_a0 error) *L1BlockCheckerIntegrator_OnStart_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *L1BlockCheckerIntegrator_OnStart_Call) RunAndReturn(run func(context.Context) error) *L1BlockCheckerIntegrator_OnStart_Call { + _c.Call.Return(run) + return _c +} + +// NewL1BlockCheckerIntegrator creates a new instance of L1BlockCheckerIntegrator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewL1BlockCheckerIntegrator(t interface { + mock.TestingT + Cleanup(func()) +}) *L1BlockCheckerIntegrator { + mock := &L1BlockCheckerIntegrator{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/common/syncinterfaces/mocks/state_full_interface.go b/synchronizer/common/syncinterfaces/mocks/state_full_interface.go index f4790bc695..fa570dbe7f 100644 --- a/synchronizer/common/syncinterfaces/mocks/state_full_interface.go +++ b/synchronizer/common/syncinterfaces/mocks/state_full_interface.go @@ -821,6 +821,66 @@ func (_c *StateFullInterface_GetBatchByNumber_Call) RunAndReturn(run func(contex return _c } +// GetBlockByNumber provides a mock function with given fields: ctx, blockNumber, dbTx +func (_m *StateFullInterface) GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + ret := _m.Called(ctx, blockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetBlockByNumber") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) (*state.Block, error)); ok { + return rf(ctx, blockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Block); ok { + r0 = rf(ctx, blockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, blockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StateFullInterface_GetBlockByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBlockByNumber' +type StateFullInterface_GetBlockByNumber_Call struct { + *mock.Call +} + +// GetBlockByNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +// - dbTx pgx.Tx +func (_e *StateFullInterface_Expecter) GetBlockByNumber(ctx interface{}, blockNumber interface{}, dbTx interface{}) *StateFullInterface_GetBlockByNumber_Call { + return &StateFullInterface_GetBlockByNumber_Call{Call: _e.mock.On("GetBlockByNumber", ctx, blockNumber, dbTx)} +} + +func (_c *StateFullInterface_GetBlockByNumber_Call) Run(run func(ctx context.Context, blockNumber uint64, dbTx pgx.Tx)) *StateFullInterface_GetBlockByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *StateFullInterface_GetBlockByNumber_Call) Return(_a0 *state.Block, _a1 error) *StateFullInterface_GetBlockByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StateFullInterface_GetBlockByNumber_Call) RunAndReturn(run func(context.Context, uint64, pgx.Tx) (*state.Block, error)) *StateFullInterface_GetBlockByNumber_Call { + _c.Call.Return(run) + return _c +} + // GetExitRootByGlobalExitRoot provides a mock function with given fields: ctx, ger, dbTx func (_m *StateFullInterface) GetExitRootByGlobalExitRoot(ctx context.Context, ger common.Hash, dbTx pgx.Tx) (*state.GlobalExitRoot, error) { ret := _m.Called(ctx, ger, dbTx) @@ -1805,6 +1865,66 @@ func (_c *StateFullInterface_GetPreviousBlock_Call) RunAndReturn(run func(contex return _c } +// GetPreviousBlockToBlockNumber provides a mock function with given fields: ctx, blockNumber, dbTx +func (_m *StateFullInterface) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + ret := _m.Called(ctx, blockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetPreviousBlockToBlockNumber") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) (*state.Block, error)); ok { + return rf(ctx, blockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Block); ok { + r0 = rf(ctx, blockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, blockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StateFullInterface_GetPreviousBlockToBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousBlockToBlockNumber' +type StateFullInterface_GetPreviousBlockToBlockNumber_Call struct { + *mock.Call +} + +// GetPreviousBlockToBlockNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +// - dbTx pgx.Tx +func (_e *StateFullInterface_Expecter) GetPreviousBlockToBlockNumber(ctx interface{}, blockNumber interface{}, dbTx interface{}) *StateFullInterface_GetPreviousBlockToBlockNumber_Call { + return &StateFullInterface_GetPreviousBlockToBlockNumber_Call{Call: _e.mock.On("GetPreviousBlockToBlockNumber", ctx, blockNumber, dbTx)} +} + +func (_c *StateFullInterface_GetPreviousBlockToBlockNumber_Call) Run(run func(ctx context.Context, blockNumber uint64, dbTx pgx.Tx)) *StateFullInterface_GetPreviousBlockToBlockNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *StateFullInterface_GetPreviousBlockToBlockNumber_Call) Return(_a0 *state.Block, _a1 error) *StateFullInterface_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StateFullInterface_GetPreviousBlockToBlockNumber_Call) RunAndReturn(run func(context.Context, uint64, pgx.Tx) (*state.Block, error)) *StateFullInterface_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(run) + return _c +} + // GetReorgedTransactions provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *StateFullInterface) GetReorgedTransactions(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]*types.Transaction, error) { ret := _m.Called(ctx, batchNumber, dbTx) @@ -1988,6 +2108,67 @@ func (_c *StateFullInterface_GetStoredFlushID_Call) RunAndReturn(run func(contex return _c } +// GetUncheckedBlocks provides a mock function with given fields: ctx, fromBlockNumber, toBlockNumber, dbTx +func (_m *StateFullInterface) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) { + ret := _m.Called(ctx, fromBlockNumber, toBlockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetUncheckedBlocks") + } + + var r0 []*state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)); ok { + return rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) []*state.Block); ok { + r0 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StateFullInterface_GetUncheckedBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUncheckedBlocks' +type StateFullInterface_GetUncheckedBlocks_Call struct { + *mock.Call +} + +// GetUncheckedBlocks is a helper method to define mock.On call +// - ctx context.Context +// - fromBlockNumber uint64 +// - toBlockNumber uint64 +// - dbTx pgx.Tx +func (_e *StateFullInterface_Expecter) GetUncheckedBlocks(ctx interface{}, fromBlockNumber interface{}, toBlockNumber interface{}, dbTx interface{}) *StateFullInterface_GetUncheckedBlocks_Call { + return &StateFullInterface_GetUncheckedBlocks_Call{Call: _e.mock.On("GetUncheckedBlocks", ctx, fromBlockNumber, toBlockNumber, dbTx)} +} + +func (_c *StateFullInterface_GetUncheckedBlocks_Call) Run(run func(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx)) *StateFullInterface_GetUncheckedBlocks_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(uint64), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *StateFullInterface_GetUncheckedBlocks_Call) Return(_a0 []*state.Block, _a1 error) *StateFullInterface_GetUncheckedBlocks_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StateFullInterface_GetUncheckedBlocks_Call) RunAndReturn(run func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)) *StateFullInterface_GetUncheckedBlocks_Call { + _c.Call.Return(run) + return _c +} + // OpenBatch provides a mock function with given fields: ctx, processingContext, dbTx func (_m *StateFullInterface) OpenBatch(ctx context.Context, processingContext state.ProcessingContext, dbTx pgx.Tx) error { ret := _m.Called(ctx, processingContext, dbTx) diff --git a/synchronizer/common/syncinterfaces/state.go b/synchronizer/common/syncinterfaces/state.go index 0aff583319..cafae4104e 100644 --- a/synchronizer/common/syncinterfaces/state.go +++ b/synchronizer/common/syncinterfaces/state.go @@ -28,6 +28,7 @@ type StateFullInterface interface { AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, dbTx pgx.Tx) error AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error @@ -75,4 +76,6 @@ type StateFullInterface interface { UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error) + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) } diff --git a/synchronizer/config.go b/synchronizer/config.go index 0f7d822a60..ef51d41308 100644 --- a/synchronizer/config.go +++ b/synchronizer/config.go @@ -1,6 +1,8 @@ package synchronizer import ( + "fmt" + "github.com/0xPolygonHermez/zkevm-node/config/types" "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync" ) @@ -22,6 +24,7 @@ type Config struct { // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` + L1BlockCheck L1BlockCheckConfig `mapstructure:"L1BlockCheck"` // L1SynchronizationMode define how to synchronize with L1: // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data // - sequential: Request data to L1 and execute @@ -32,6 +35,35 @@ type Config struct { L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` } +// L1BlockCheckConfig Configuration for L1 Block Checker +type L1BlockCheckConfig struct { + // Enable if is true then the check l1 Block Hash is active + Enable bool `mapstructure:"Enable"` + // L1SafeBlockPoint is the point that a block is considered safe enough to be checked + // it can be: finalized, safe,pending or latest + L1SafeBlockPoint string `mapstructure:"L1SafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` + // L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point + // it can be positive or negative + // Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block + L1SafeBlockOffset int `mapstructure:"L1SafeBlockOffset"` + // ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks + ForceCheckBeforeStart bool `mapstructure:"ForceCheckBeforeStart"` + + // PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock + PreCheckEnable bool `mapstructure:"PreCheckEnable"` + // L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked + // it can be: finalized, safe,pending or latest + L1PreSafeBlockPoint string `mapstructure:"L1PreSafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` + // L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point + // it can be positive or negative + // Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block + L1PreSafeBlockOffset int `mapstructure:"L1PreSafeBlockOffset"` +} + +func (c *L1BlockCheckConfig) String() string { + return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enable, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart) +} + // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') type L1ParallelSynchronizationConfig struct { // MaxClients Number of clients used to synchronize with L1 diff --git a/synchronizer/l1_check_block/async.go b/synchronizer/l1_check_block/async.go new file mode 100644 index 0000000000..4a2a45d924 --- /dev/null +++ b/synchronizer/l1_check_block/async.go @@ -0,0 +1,183 @@ +package l1_check_block + +import ( + "context" + "sync" + "time" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +) + +// L1BlockChecker is an interface that defines the method to check L1 blocks +type L1BlockChecker interface { + Step(ctx context.Context) error +} + +const ( + defaultPeriodTime = time.Second +) + +// AsyncCheck is a wrapper for L1BlockChecker to become asynchronous +type AsyncCheck struct { + checker L1BlockChecker + mutex sync.Mutex + lastResult *syncinterfaces.IterationResult + onFinishCall func() + periodTime time.Duration + // Wg is a wait group to wait for the result + Wg sync.WaitGroup + ctx context.Context + cancelCtx context.CancelFunc + isRunning bool +} + +// NewAsyncCheck creates a new AsyncCheck +func NewAsyncCheck(checker L1BlockChecker) *AsyncCheck { + return &AsyncCheck{ + checker: checker, + periodTime: defaultPeriodTime, + } +} + +// SetPeriodTime sets the period time between relaunch checker.Step +func (a *AsyncCheck) SetPeriodTime(periodTime time.Duration) { + a.periodTime = periodTime +} + +// Run is a method that starts the async check +func (a *AsyncCheck) Run(ctx context.Context, onFinish func()) { + a.mutex.Lock() + defer a.mutex.Unlock() + a.onFinishCall = onFinish + if a.isRunning { + log.Infof("%s L1BlockChecker: already running, changing onFinish call", logPrefix) + return + } + a.lastResult = nil + a.ctx, a.cancelCtx = context.WithCancel(ctx) + a.launchChecker(a.ctx) +} + +// Stop is a method that stops the async check +func (a *AsyncCheck) Stop() { + a.cancelCtx() + a.Wg.Wait() +} + +// RunSynchronous is a method that forces the check to be synchronous before starting the async check +func (a *AsyncCheck) RunSynchronous(ctx context.Context) syncinterfaces.IterationResult { + return a.executeIteration(ctx) +} + +// GetResult returns the last result of the check: +// - Nil -> still running +// - Not nil -> finished, and this is the result. You must call again Run to start a new check +func (a *AsyncCheck) GetResult() *syncinterfaces.IterationResult { + a.mutex.Lock() + defer a.mutex.Unlock() + return a.lastResult +} + +// https://stackoverflow.com/questions/32840687/timeout-for-waitgroup-wait +// waitTimeout waits for the waitgroup for the specified max timeout. +// Returns true if waiting timed out. +func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { + c := make(chan struct{}) + go func() { + defer close(c) + wg.Wait() + }() + select { + case <-c: + return false // completed normally + case <-time.After(timeout): + return true // timed out + } +} + +// GetResultBlockingUntilAvailable wait the time specific in timeout, if reach timeout returns current +// result, if not, wait until the result is available. +// if timeout is 0, it waits indefinitely +func (a *AsyncCheck) GetResultBlockingUntilAvailable(timeout time.Duration) *syncinterfaces.IterationResult { + if timeout == 0 { + a.Wg.Wait() + } else { + waitTimeout(&a.Wg, timeout) + } + return a.GetResult() +} + +func (a *AsyncCheck) setResult(result syncinterfaces.IterationResult) { + a.mutex.Lock() + defer a.mutex.Unlock() + a.lastResult = &result +} + +func (a *AsyncCheck) launchChecker(ctx context.Context) { + // add waitGroup to wait for a result + a.Wg.Add(1) + a.isRunning = true + go func() { + log.Infof("%s L1BlockChecker: starting background process", logPrefix) + for { + result := a.step(ctx) + if result != nil { + a.setResult(*result) + // Result is set wg is done + break + } + } + log.Infof("%s L1BlockChecker: finished background process", logPrefix) + a.Wg.Done() + a.mutex.Lock() + onFinishCall := a.onFinishCall + a.isRunning = false + a.mutex.Unlock() + // call onFinish function with no mutex + if onFinishCall != nil { + onFinishCall() + } + }() +} + +// step is a method that executes until executeItertion +// returns an error or a reorg +func (a *AsyncCheck) step(ctx context.Context) *syncinterfaces.IterationResult { + select { + case <-ctx.Done(): + log.Debugf("%s L1BlockChecker: context done", logPrefix) + return &syncinterfaces.IterationResult{Err: ctx.Err()} + default: + result := a.executeIteration(ctx) + if result.ReorgDetected { + return &result + } + log.Debugf("%s L1BlockChecker:returned %s waiting %s to relaunch", logPrefix, result.String(), a.periodTime) + time.Sleep(a.periodTime) + } + return nil +} + +// executeIteration executes a single iteration of the checker +func (a *AsyncCheck) executeIteration(ctx context.Context) syncinterfaces.IterationResult { + res := syncinterfaces.IterationResult{} + log.Debugf("%s calling checker.Step(...)", logPrefix) + res.Err = a.checker.Step(ctx) + log.Debugf("%s returned checker.Step(...) %w", logPrefix, res.Err) + if res.Err != nil { + log.Errorf("%s Fail check L1 Blocks: %w", logPrefix, res.Err) + if common.IsReorgError(res.Err) { + // log error + blockNumber := common.GetReorgErrorBlockNumber(res.Err) + log.Infof("%s Reorg detected at block %d", logPrefix, blockNumber) + // It keeps blocked until the channel is read + res.BlockNumber = blockNumber + res.ReorgDetected = true + res.ReorgMessage = res.Err.Error() + res.Err = nil + } + } + return res +} diff --git a/synchronizer/l1_check_block/async_test.go b/synchronizer/l1_check_block/async_test.go new file mode 100644 index 0000000000..21358b1c8f --- /dev/null +++ b/synchronizer/l1_check_block/async_test.go @@ -0,0 +1,138 @@ +package l1_check_block_test + +import ( + "context" + "fmt" + "sync" + "testing" + "time" + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + "github.com/stretchr/testify/require" +) + +var ( + errGenericToTestAsync = fmt.Errorf("error_async") + errReorgToTestAsync = common.NewReorgError(uint64(1234), fmt.Errorf("fake reorg to test")) + timeoutContextForAsyncTests = time.Second +) + +type mockChecker struct { + Wg *sync.WaitGroup + ErrorsToReturn []error +} + +func (m *mockChecker) Step(ctx context.Context) error { + defer m.Wg.Done() + err := m.ErrorsToReturn[0] + if len(m.ErrorsToReturn) > 0 { + m.ErrorsToReturn = m.ErrorsToReturn[1:] + } + return err +} + +// If checker.step() returns ok, the async object will relaunch the call +func TestAsyncRelaunchCheckerUntilReorgDetected(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + mockChecker.Wg.Add(4) + + sut.Run(ctx, nil) + + mockChecker.Wg.Wait() + result := sut.GetResultBlockingUntilAvailable(0) + require.NotNil(t, result) + require.Equal(t, uint64(1234), result.BlockNumber) + require.Equal(t, true, result.ReorgDetected) + require.Equal(t, nil, result.Err) +} + +func TestAsyncGetResultIsNilUntilStops(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + mockChecker.Wg.Add(4) + require.Nil(t, sut.GetResult(), "before start result is Nil") + + sut.Run(ctx, nil) + + require.Nil(t, sut.GetResult(), "after start result is Nil") + mockChecker.Wg.Wait() + result := sut.GetResultBlockingUntilAvailable(0) + require.NotNil(t, result) +} + +// RunSynchronous it returns the first result, doesnt mind if a reorg or not +func TestAsyncGRunSynchronousReturnTheFirstResult(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + mockChecker.Wg.Add(1) + + result := sut.RunSynchronous(ctx) + + require.NotNil(t, result) + require.Equal(t, uint64(0), result.BlockNumber) + require.Equal(t, false, result.ReorgDetected) + require.Equal(t, errGenericToTestAsync, result.Err) +} + +func TestAsyncGRunSynchronousDontAffectGetResult(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + mockChecker.Wg.Add(1) + + result := sut.RunSynchronous(ctx) + + require.NotNil(t, result) + require.Nil(t, sut.GetResult()) +} + +func TestAsyncStop(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + require.Nil(t, sut.GetResult(), "before start result is Nil") + mockChecker.Wg.Add(4) + sut.Run(ctx, nil) + sut.Stop() + sut.Stop() + + result := sut.GetResultBlockingUntilAvailable(0) + require.NotNil(t, result) + mockChecker.Wg = &sync.WaitGroup{} + mockChecker.Wg.Add(4) + mockChecker.ErrorsToReturn = []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync} + sut.Run(ctx, nil) + mockChecker.Wg.Wait() + result = sut.GetResultBlockingUntilAvailable(0) + require.NotNil(t, result) +} + +func TestAsyncMultipleRun(t *testing.T) { + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + sut := l1_check_block.NewAsyncCheck(mockChecker) + sut.SetPeriodTime(0) + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + defer cancel() + require.Nil(t, sut.GetResult(), "before start result is Nil") + mockChecker.Wg.Add(4) + sut.Run(ctx, nil) + sut.Run(ctx, nil) + sut.Run(ctx, nil) + result := sut.GetResultBlockingUntilAvailable(0) + require.NotNil(t, result) +} diff --git a/synchronizer/l1_check_block/check_l1block.go b/synchronizer/l1_check_block/check_l1block.go new file mode 100644 index 0000000000..cd1204c5b3 --- /dev/null +++ b/synchronizer/l1_check_block/check_l1block.go @@ -0,0 +1,146 @@ +package l1_check_block + +import ( + "context" + "errors" + "fmt" + "math/big" + "time" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/jackc/pgx/v4" +) + +// This object check old L1block to double-check that the L1block hash is correct +// - Get first not checked block +// - Get last block on L1 (safe/finalized/ or minus -n) + +// L1Requester is an interface for GETH client +type L1Requester interface { + HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) +} + +// StateInterfacer is an interface for the state +type StateInterfacer interface { + GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) + UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error +} + +// SafeL1BlockNumberFetcher is an interface for fetching the L1 block number reference point (safe, finalized,...) +type SafeL1BlockNumberFetcher interface { + GetSafeBlockNumber(ctx context.Context, l1Client L1Requester) (uint64, error) + Description() string +} + +// CheckL1BlockHash is a struct that implements a checker of L1Block hash +type CheckL1BlockHash struct { + L1Client L1Requester + State StateInterfacer + SafeBlockNumberFetcher SafeL1BlockNumberFetcher +} + +// NewCheckL1BlockHash creates a new CheckL1BlockHash +func NewCheckL1BlockHash(l1Client L1Requester, state StateInterfacer, safeBlockNumberFetcher SafeL1BlockNumberFetcher) *CheckL1BlockHash { + return &CheckL1BlockHash{ + L1Client: l1Client, + State: state, + SafeBlockNumberFetcher: safeBlockNumberFetcher, + } +} + +// Name is a method that returns the name of the checker +func (p *CheckL1BlockHash) Name() string { + return logPrefix + " main_checker: " +} + +// Step is a method that checks the L1 block hash, run until all blocks are checked and returns +func (p *CheckL1BlockHash) Step(ctx context.Context) error { + stateBlock, err := p.State.GetFirstUncheckedBlock(ctx, uint64(0), nil) + if errors.Is(err, state.ErrNotFound) { + log.Debugf("%s: No unchecked blocks to check", p.Name()) + return nil + } + if err != nil { + return err + } + if stateBlock == nil { + log.Warnf("%s: function CheckL1Block receive a nil pointer", p.Name()) + return nil + } + safeBlockNumber, err := p.SafeBlockNumberFetcher.GetSafeBlockNumber(ctx, p.L1Client) + if err != nil { + return err + } + log.Debugf("%s: checking from block (%s) %d first block to check: %d....", p.Name(), p.SafeBlockNumberFetcher.Description(), safeBlockNumber, stateBlock.BlockNumber) + return p.doAllBlocks(ctx, *stateBlock, safeBlockNumber) +} + +func (p *CheckL1BlockHash) doAllBlocks(ctx context.Context, firstStateBlock state.Block, safeBlockNumber uint64) error { + var err error + startTime := time.Now() + stateBlock := &firstStateBlock + numBlocksChecked := 0 + for { + lastStateBlockNumber := stateBlock.BlockNumber + if stateBlock.BlockNumber > safeBlockNumber { + log.Debugf("%s: block %d to check is not still safe enough (%s) %d ", p.Name(), stateBlock.BlockNumber, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, logPrefix) + return nil + } + err = p.doBlock(ctx, stateBlock) + if err != nil { + return err + } + numBlocksChecked++ + stateBlock, err = p.State.GetFirstUncheckedBlock(ctx, lastStateBlockNumber, nil) + if errors.Is(err, state.ErrNotFound) { + diff := time.Since(startTime) + log.Infof("%s: checked all blocks (%d) (using as safe Block Point(%s): %d) time:%s", p.Name(), numBlocksChecked, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, diff) + return nil + } + } +} + +func (p *CheckL1BlockHash) doBlock(ctx context.Context, stateBlock *state.Block) error { + err := CheckBlockHash(ctx, stateBlock, p.L1Client, p.Name()) + if err != nil { + return err + } + log.Infof("%s: L1Block: %d hash: %s is correct marking as checked", p.Name(), stateBlock.BlockNumber, + stateBlock.BlockHash.String()) + err = p.State.UpdateCheckedBlockByNumber(ctx, stateBlock.BlockNumber, true, nil) + if err != nil { + log.Errorf("%s: Error updating block %d as checked. err: %s", p.Name(), stateBlock.BlockNumber, err.Error()) + return err + } + return nil +} + +// CheckBlockHash is a method that checks the L1 block hash +func CheckBlockHash(ctx context.Context, stateBlock *state.Block, L1Client L1Requester, checkerName string) error { + if stateBlock == nil { + log.Warn("%s function CheckL1Block receive a nil pointer", checkerName) + return nil + } + l1Block, err := L1Client.HeaderByNumber(ctx, big.NewInt(int64(stateBlock.BlockNumber))) + if err != nil { + return err + } + if l1Block == nil { + err = fmt.Errorf("%s request of block: %d to L1 returns a nil", checkerName, stateBlock.BlockNumber) + log.Error(err.Error()) + return err + } + if l1Block.Hash() != stateBlock.BlockHash { + msg := fmt.Sprintf("%s Reorg detected at block %d l1Block.Hash=%s != stateBlock.Hash=%s. ", checkerName, stateBlock.BlockNumber, + l1Block.Hash().String(), stateBlock.BlockHash.String()) + if l1Block.ParentHash != stateBlock.ParentHash { + msg += fmt.Sprintf(" ParentHash are also different. l1Block.ParentHash=%s != stateBlock.ParentHash=%s", l1Block.ParentHash.String(), stateBlock.ParentHash.String()) + } + log.Errorf(msg) + return common.NewReorgError(stateBlock.BlockNumber, fmt.Errorf(msg)) + } + return nil +} diff --git a/synchronizer/l1_check_block/check_l1block_test.go b/synchronizer/l1_check_block/check_l1block_test.go new file mode 100644 index 0000000000..e5090140a3 --- /dev/null +++ b/synchronizer/l1_check_block/check_l1block_test.go @@ -0,0 +1,128 @@ +package l1_check_block_test + +import ( + "context" + "fmt" + "math/big" + "testing" + + "github.com/0xPolygonHermez/zkevm-node/state" + commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +type testData struct { + mockL1Client *mock_l1_check_block.L1Requester + mockState *mock_l1_check_block.StateInterfacer + mockBlockNumberFetch *mock_l1_check_block.SafeL1BlockNumberFetcher + sut *l1_check_block.CheckL1BlockHash + ctx context.Context + stateBlock *state.Block +} + +func newTestData(t *testing.T) *testData { + mockL1Client := mock_l1_check_block.NewL1Requester(t) + mockState := mock_l1_check_block.NewStateInterfacer(t) + mockBlockNumberFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) + mockBlockNumberFetch.EXPECT().Description().Return("mock").Maybe() + sut := l1_check_block.NewCheckL1BlockHash(mockL1Client, mockState, mockBlockNumberFetch) + require.NotNil(t, sut) + ctx := context.Background() + return &testData{ + mockL1Client: mockL1Client, + mockState: mockState, + mockBlockNumberFetch: mockBlockNumberFetch, + sut: sut, + ctx: ctx, + stateBlock: &state.Block{ + BlockNumber: 1234, + BlockHash: common.HexToHash("0xb07e1289b32edefd8f3c702d016fb73c81d5950b2ebc790ad9d2cb8219066b4c"), + }, + } +} + +func TestCheckL1BlockHashNoBlocksOnDB(t *testing.T) { + data := newTestData(t) + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, state.ErrNotFound) + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +func TestCheckL1BlockHashErrorGettingFirstUncheckedBlockFromDB(t *testing.T) { + data := newTestData(t) + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, fmt.Errorf("error")) + res := data.sut.Step(data.ctx) + require.Error(t, res) +} + +func TestCheckL1BlockHashErrorGettingGetSafeBlockNumber(t *testing.T) { + data := newTestData(t) + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(0), fmt.Errorf("error")) + res := data.sut.Step(data.ctx) + require.Error(t, res) +} + +// The first block to check is below the safe point, nothing to do +func TestCheckL1BlockHashSafePointIsInFuture(t *testing.T) { + data := newTestData(t) + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber-1, nil) + + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +func TestCheckL1BlockHashL1ClientReturnsANil(t *testing.T) { + data := newTestData(t) + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber+10, nil) + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(nil, nil) + res := data.sut.Step(data.ctx) + require.Error(t, res) +} + +// Check a block that is OK +func TestCheckL1BlockHashMatchHashUpdateCheckMarkOnDB(t *testing.T) { + data := newTestData(t) + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) + data.mockBlockNumberFetch.EXPECT().Description().Return("mock") + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) + l1Block := &types.Header{ + Number: big.NewInt(100), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) + data.mockState.EXPECT().UpdateCheckedBlockByNumber(data.ctx, data.stateBlock.BlockNumber, true, nil).Return(nil) + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, mock.Anything, nil).Return(nil, state.ErrNotFound) + + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +// The first block to check is equal to the safe point, must be processed +func TestCheckL1BlockHashMismatch(t *testing.T) { + data := newTestData(t) + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) + data.stateBlock.BlockHash = common.HexToHash("0x1234") // Wrong hash to trigger a mismatch + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) + l1Block := &types.Header{ + Number: big.NewInt(100), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) + + res := data.sut.Step(data.ctx) + require.Error(t, res) + resErr, ok := res.(*commonsync.ReorgError) + require.True(t, ok) + require.Equal(t, data.stateBlock.BlockNumber, resErr.BlockNumber) +} diff --git a/synchronizer/l1_check_block/common.go b/synchronizer/l1_check_block/common.go new file mode 100644 index 0000000000..a473c220a3 --- /dev/null +++ b/synchronizer/l1_check_block/common.go @@ -0,0 +1,5 @@ +package l1_check_block + +const ( + logPrefix = "checkL1block:" +) diff --git a/synchronizer/l1_check_block/integration.go b/synchronizer/l1_check_block/integration.go new file mode 100644 index 0000000000..82a962eb3f --- /dev/null +++ b/synchronizer/l1_check_block/integration.go @@ -0,0 +1,205 @@ +package l1_check_block + +import ( + "context" + "time" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + "github.com/jackc/pgx/v4" +) + +// StateForL1BlockCheckerIntegration is an interface for the state +type StateForL1BlockCheckerIntegration interface { + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +} + +// L1BlockCheckerIntegration is a struct that integrates the L1BlockChecker with the synchronizer +type L1BlockCheckerIntegration struct { + forceCheckOnStart bool + checker syncinterfaces.AsyncL1BlockChecker + preChecker syncinterfaces.AsyncL1BlockChecker + state StateForL1BlockCheckerIntegration + sync SyncCheckReorger + timeBetweenRetries time.Duration +} + +// SyncCheckReorger is an interface that defines the methods required from Synchronizer object +type SyncCheckReorger interface { + ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error + OnDetectedMismatchL1BlockReorg() +} + +// NewL1BlockCheckerIntegration creates a new L1BlockCheckerIntegration +func NewL1BlockCheckerIntegration(checker syncinterfaces.AsyncL1BlockChecker, preChecker syncinterfaces.AsyncL1BlockChecker, state StateForL1BlockCheckerIntegration, sync SyncCheckReorger, forceCheckOnStart bool, timeBetweenRetries time.Duration) *L1BlockCheckerIntegration { + return &L1BlockCheckerIntegration{ + forceCheckOnStart: forceCheckOnStart, + checker: checker, + preChecker: preChecker, + state: state, + sync: sync, + timeBetweenRetries: timeBetweenRetries, + } +} + +// OnStart is a method that is called before starting the synchronizer +func (v *L1BlockCheckerIntegration) OnStart(ctx context.Context) error { + if v.forceCheckOnStart { + log.Infof("%s Forcing L1BlockChecker check before start", logPrefix) + result := v.runCheckerSync(ctx, v.checker) + if result.ReorgDetected { + v.executeResult(ctx, result) + } else { + log.Infof("%s Forcing L1BlockChecker check:OK ", logPrefix) + if v.preChecker != nil { + log.Infof("%s Forcing L1BlockChecker preCheck before start", logPrefix) + result = v.runCheckerSync(ctx, v.preChecker) + if result.ReorgDetected { + v.executeResult(ctx, result) + } else { + log.Infof("%s Forcing L1BlockChecker preCheck:OK", logPrefix) + } + } + } + } + v.launch(ctx) + return nil +} + +func (v *L1BlockCheckerIntegration) runCheckerSync(ctx context.Context, checker syncinterfaces.AsyncL1BlockChecker) syncinterfaces.IterationResult { + for { + result := checker.RunSynchronous(ctx) + if result.Err == nil { + return result + } else { + time.Sleep(v.timeBetweenRetries) + } + } +} + +// OnStartL1Sync is a method that is called before starting the L1 sync +func (v *L1BlockCheckerIntegration) OnStartL1Sync(ctx context.Context) bool { + return v.checkBackgroundResult(ctx, "before start L1 sync") +} + +// OnStartL2Sync is a method that is called before starting the L2 sync +func (v *L1BlockCheckerIntegration) OnStartL2Sync(ctx context.Context) bool { + return v.checkBackgroundResult(ctx, "before start 2 sync") +} + +// OnResetState is a method that is called after a resetState +func (v *L1BlockCheckerIntegration) OnResetState(ctx context.Context) { + log.Infof("%s L1BlockChecker: after a resetState relaunch background process", logPrefix) + v.launch(ctx) +} + +// CheckReorgWrapper is a wrapper over reorg function of synchronizer. +// it checks the result of the function and the result of background process and decides which return +func (v *L1BlockCheckerIntegration) CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) { + resultBackground := v.getMergedResults() + if resultBackground != nil && resultBackground.ReorgDetected { + // Background process detected a reorg, decide which return + firstOkBlockBackgroundCheck, err := v.state.GetPreviousBlockToBlockNumber(ctx, resultBackground.BlockNumber, nil) + if err != nil { + log.Warnf("%s Error getting previous block to block number where a reorg have been detected %d: %s. So we reorgFunc values", logPrefix, resultBackground.BlockNumber, err) + return reorgFirstBlockOk, errReportedByReorgFunc + } + if reorgFirstBlockOk == nil || errReportedByReorgFunc != nil { + log.Infof("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function no. Returning it", logPrefix, + resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) + return firstOkBlockBackgroundCheck, nil + } + if firstOkBlockBackgroundCheck.BlockNumber < reorgFirstBlockOk.BlockNumber { + // Background process detected a reorg at oldest block + log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Returning from %d", + logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) + return firstOkBlockBackgroundCheck, nil + } else { + // Regular reorg function detected a reorg at oldest block + log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Executing from %d", + logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, reorgFirstBlockOk.BlockNumber) + return reorgFirstBlockOk, errReportedByReorgFunc + } + } + if resultBackground != nil && !resultBackground.ReorgDetected { + // Relaunch checker, if there is a reorg, It is going to be relaunched after (OnResetState) + v.launch(ctx) + } + // Background process doesnt have anything to we return the regular reorg function result + return reorgFirstBlockOk, errReportedByReorgFunc +} + +func (v *L1BlockCheckerIntegration) checkBackgroundResult(ctx context.Context, positionMessage string) bool { + log.Debugf("%s Checking L1BlockChecker %s", logPrefix, positionMessage) + result := v.getMergedResults() + if result != nil { + if result.ReorgDetected { + log.Warnf("%s Checking L1BlockChecker %s: reorg detected %s", logPrefix, positionMessage, result.String()) + v.executeResult(ctx, *result) + } + v.launch(ctx) + return result.ReorgDetected + } + return false +} + +func (v *L1BlockCheckerIntegration) getMergedResults() *syncinterfaces.IterationResult { + result := v.checker.GetResult() + var preResult *syncinterfaces.IterationResult + preResult = nil + if v.preChecker != nil { + preResult = v.preChecker.GetResult() + } + if preResult == nil { + return result + } + if result == nil { + return preResult + } + // result and preResult have values + if result.ReorgDetected && preResult.ReorgDetected { + // That is the common case, checker must detect oldest blocks than preChecker + if result.BlockNumber < preResult.BlockNumber { + return result + } + return preResult + } + if preResult.ReorgDetected { + return preResult + } + return result +} + +func (v *L1BlockCheckerIntegration) onFinishChecker() { + log.Infof("%s L1BlockChecker: finished background process, calling to synchronizer", logPrefix) + // Stop both processes + v.checker.Stop() + if v.preChecker != nil { + v.preChecker.Stop() + } + v.sync.OnDetectedMismatchL1BlockReorg() +} + +func (v *L1BlockCheckerIntegration) launch(ctx context.Context) { + log.Infof("%s L1BlockChecker: starting background process...", logPrefix) + v.checker.Run(ctx, v.onFinishChecker) + if v.preChecker != nil { + log.Infof("%s L1BlockChecker: starting background precheck process...", logPrefix) + v.preChecker.Run(ctx, v.onFinishChecker) + } +} + +func (v *L1BlockCheckerIntegration) executeResult(ctx context.Context, result syncinterfaces.IterationResult) bool { + if result.ReorgDetected { + for { + err := v.sync.ExecuteReorgFromMismatchBlock(result.BlockNumber, result.ReorgMessage) + if err == nil { + return true + } + log.Errorf("%s Error executing reorg: %s", logPrefix, err) + time.Sleep(v.timeBetweenRetries) + } + } + return false +} diff --git a/synchronizer/l1_check_block/integration_test.go b/synchronizer/l1_check_block/integration_test.go new file mode 100644 index 0000000000..de79c71351 --- /dev/null +++ b/synchronizer/l1_check_block/integration_test.go @@ -0,0 +1,298 @@ +package l1_check_block_test + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +var ( + genericErrorToTest = fmt.Errorf("error") +) + +type testDataIntegration struct { + mockChecker *mock_syncinterfaces.AsyncL1BlockChecker + mockPreChecker *mock_syncinterfaces.AsyncL1BlockChecker + mockState *mock_l1_check_block.StateForL1BlockCheckerIntegration + mockSync *mock_l1_check_block.SyncCheckReorger + sut *l1_check_block.L1BlockCheckerIntegration + ctx context.Context + resultOk syncinterfaces.IterationResult + resultError syncinterfaces.IterationResult + resultReorg syncinterfaces.IterationResult +} + +func newDataIntegration(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + return newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) +} + +func newDataIntegrationWithPreChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + res := newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) + res.mockPreChecker = mock_syncinterfaces.NewAsyncL1BlockChecker(t) + res.sut = l1_check_block.NewL1BlockCheckerIntegration(res.mockChecker, res.mockPreChecker, res.mockState, res.mockSync, forceCheckOnStart, time.Millisecond) + return res +} + +func newDataIntegrationOnlyMainChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + mockChecker := mock_syncinterfaces.NewAsyncL1BlockChecker(t) + mockSync := mock_l1_check_block.NewSyncCheckReorger(t) + mockState := mock_l1_check_block.NewStateForL1BlockCheckerIntegration(t) + sut := l1_check_block.NewL1BlockCheckerIntegration(mockChecker, nil, mockState, mockSync, forceCheckOnStart, time.Millisecond) + return &testDataIntegration{ + mockChecker: mockChecker, + mockPreChecker: nil, + mockSync: mockSync, + mockState: mockState, + sut: sut, + ctx: context.Background(), + resultReorg: syncinterfaces.IterationResult{ + ReorgDetected: true, + BlockNumber: 1234, + }, + resultOk: syncinterfaces.IterationResult{ + ReorgDetected: false, + }, + resultError: syncinterfaces.IterationResult{ + Err: genericErrorToTest, + ReorgDetected: false, + }, + } +} + +func TestIntegrationIfNoForceCheckOnlyLaunchBackgroudChecker(t *testing.T) { + data := newDataIntegration(t, false) + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +func TestIntegrationIfForceCheckRunsSynchronousOneTimeAndAfterLaunchBackgroudChecker(t *testing.T) { + data := newDataIntegration(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +func TestIntegrationIfSyncCheckReturnsReorgExecuteIt(t *testing.T) { + data := newDataIntegration(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), "").Return(nil) + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +func TestIntegrationIfSyncCheckReturnErrorRetry(t *testing.T) { + data := newDataIntegration(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultError).Once() + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk).Once() + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +func TestIntegrationIfSyncCheckReturnsReorgExecuteItAndFailsRetry(t *testing.T) { + data := newDataIntegration(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(genericErrorToTest).Once() + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +// OnStart if check and preCheck execute both, and launch both in background +func TestIntegrationCheckAndPreCheckOnStartForceCheck(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +// OnStart if mainChecker returns reorg doesnt need to run preCheck +func TestIntegrationCheckAndPreCheckOnStartMainCheckerReturnReorg(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +// If mainCheck is OK, but preCheck returns reorg, it should execute reorg +func TestIntegrationCheckAndPreCheckOnStartPreCheckerReturnReorg(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + err := data.sut.OnStart(data.ctx) + require.NoError(t, err) +} + +// The process is running on background, no results yet +func TestIntegrationCheckAndPreCheckOnOnCheckReorgRunningOnBackground(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(nil) + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.Nil(t, block) + require.NoError(t, err) +} + +func TestIntegrationCheckAndPreCheckOnOnCheckReorgOneProcessHaveResultOK(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(&data.resultOk) + data.mockPreChecker.EXPECT().GetResult().Return(nil) + // One have been stopped, so must relaunch both + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.Nil(t, block) + require.NoError(t, err) +} + +func TestIntegrationCheckAndPreCheckOnOnCheckReorgMainCheckerReorg(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(&data.resultReorg) + data.mockPreChecker.EXPECT().GetResult().Return(nil) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + BlockNumber: data.resultReorg.BlockNumber - 1, + }, nil) + // One have been stopped,but is going to be launched OnResetState call after the reset + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.NotNil(t, block) + require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) + require.NoError(t, err) +} + +func TestIntegrationCheckAndPreCheckOnOnCheckReorgPreCheckerReorg(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + BlockNumber: data.resultReorg.BlockNumber - 1, + }, nil) + // One have been stopped,but is going to be launched OnResetState call after the reset + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.NotNil(t, block) + require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) + require.NoError(t, err) +} + +func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest1(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + reorgMain := data.resultReorg + reorgMain.BlockNumber = 1235 + data.mockChecker.EXPECT().GetResult().Return(&reorgMain) + reorgPre := data.resultReorg + reorgPre.BlockNumber = 1236 + data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ + BlockNumber: 1234, + }, nil) + + // Both have been stopped,but is going to be launched OnResetState call after the reset + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.NotNil(t, block) + require.Equal(t, uint64(1234), block.BlockNumber) + require.NoError(t, err) +} + +func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest2(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + reorgMain := data.resultReorg + reorgMain.BlockNumber = 1236 + data.mockChecker.EXPECT().GetResult().Return(&reorgMain) + reorgPre := data.resultReorg + reorgPre.BlockNumber = 1235 + data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ + BlockNumber: 1234, + }, nil) + // Both have been stopped,but is going to be launched OnResetState call after the reset + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + require.NotNil(t, block) + require.Equal(t, uint64(1234), block.BlockNumber) + require.NoError(t, err) +} + +func TestIntegrationCheckReorgWrapperBypassReorgFuncIfNoBackgroundData(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(nil) + reorgFuncBlock := &state.Block{ + BlockNumber: 1234, + } + reorgFuncErr := fmt.Errorf("error") + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) + require.Equal(t, reorgFuncBlock, block) + require.Equal(t, reorgFuncErr, err) +} + +func TestIntegrationCheckReorgWrapperChooseOldestReorgFunc(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + BlockNumber: 1233, + }, nil) + + reorgFuncBlock := &state.Block{ + BlockNumber: 1230, + } + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) + require.Equal(t, reorgFuncBlock, block) + require.NoError(t, err) +} + +func TestIntegrationCheckReorgWrapperChooseOldestBackgroundCheck(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + BlockNumber: 1233, + }, nil) + + reorgFuncBlock := &state.Block{ + BlockNumber: 1240, + } + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) + require.Equal(t, uint64(1233), block.BlockNumber) + require.NoError(t, err) +} + +func TestIntegrationCheckReorgWrapperIgnoreReorgFuncIfError(t *testing.T) { + data := newDataIntegrationWithPreChecker(t, true) + data.mockChecker.EXPECT().GetResult().Return(nil) + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + BlockNumber: 1233, + }, nil) + + reorgFuncBlock := &state.Block{ + BlockNumber: 1230, + } + reorgFuncErr := fmt.Errorf("error") + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) + require.Equal(t, uint64(1233), block.BlockNumber) + require.NoError(t, err) +} diff --git a/synchronizer/l1_check_block/mocks/l1_block_checker.go b/synchronizer/l1_check_block/mocks/l1_block_checker.go new file mode 100644 index 0000000000..6f0eab9acb --- /dev/null +++ b/synchronizer/l1_check_block/mocks/l1_block_checker.go @@ -0,0 +1,82 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// L1BlockChecker is an autogenerated mock type for the L1BlockChecker type +type L1BlockChecker struct { + mock.Mock +} + +type L1BlockChecker_Expecter struct { + mock *mock.Mock +} + +func (_m *L1BlockChecker) EXPECT() *L1BlockChecker_Expecter { + return &L1BlockChecker_Expecter{mock: &_m.Mock} +} + +// Step provides a mock function with given fields: ctx +func (_m *L1BlockChecker) Step(ctx context.Context) error { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Step") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(ctx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// L1BlockChecker_Step_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Step' +type L1BlockChecker_Step_Call struct { + *mock.Call +} + +// Step is a helper method to define mock.On call +// - ctx context.Context +func (_e *L1BlockChecker_Expecter) Step(ctx interface{}) *L1BlockChecker_Step_Call { + return &L1BlockChecker_Step_Call{Call: _e.mock.On("Step", ctx)} +} + +func (_c *L1BlockChecker_Step_Call) Run(run func(ctx context.Context)) *L1BlockChecker_Step_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *L1BlockChecker_Step_Call) Return(_a0 error) *L1BlockChecker_Step_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *L1BlockChecker_Step_Call) RunAndReturn(run func(context.Context) error) *L1BlockChecker_Step_Call { + _c.Call.Return(run) + return _c +} + +// NewL1BlockChecker creates a new instance of L1BlockChecker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewL1BlockChecker(t interface { + mock.TestingT + Cleanup(func()) +}) *L1BlockChecker { + mock := &L1BlockChecker{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/l1_requester.go b/synchronizer/l1_check_block/mocks/l1_requester.go new file mode 100644 index 0000000000..713cc4a5ef --- /dev/null +++ b/synchronizer/l1_check_block/mocks/l1_requester.go @@ -0,0 +1,98 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + big "math/big" + + mock "github.com/stretchr/testify/mock" + + types "github.com/ethereum/go-ethereum/core/types" +) + +// L1Requester is an autogenerated mock type for the L1Requester type +type L1Requester struct { + mock.Mock +} + +type L1Requester_Expecter struct { + mock *mock.Mock +} + +func (_m *L1Requester) EXPECT() *L1Requester_Expecter { + return &L1Requester_Expecter{mock: &_m.Mock} +} + +// HeaderByNumber provides a mock function with given fields: ctx, number +func (_m *L1Requester) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { + ret := _m.Called(ctx, number) + + if len(ret) == 0 { + panic("no return value specified for HeaderByNumber") + } + + var r0 *types.Header + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) (*types.Header, error)); ok { + return rf(ctx, number) + } + if rf, ok := ret.Get(0).(func(context.Context, *big.Int) *types.Header); ok { + r0 = rf(ctx, number) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.Header) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *big.Int) error); ok { + r1 = rf(ctx, number) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// L1Requester_HeaderByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByNumber' +type L1Requester_HeaderByNumber_Call struct { + *mock.Call +} + +// HeaderByNumber is a helper method to define mock.On call +// - ctx context.Context +// - number *big.Int +func (_e *L1Requester_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *L1Requester_HeaderByNumber_Call { + return &L1Requester_HeaderByNumber_Call{Call: _e.mock.On("HeaderByNumber", ctx, number)} +} + +func (_c *L1Requester_HeaderByNumber_Call) Run(run func(ctx context.Context, number *big.Int)) *L1Requester_HeaderByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*big.Int)) + }) + return _c +} + +func (_c *L1Requester_HeaderByNumber_Call) Return(_a0 *types.Header, _a1 error) *L1Requester_HeaderByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *L1Requester_HeaderByNumber_Call) RunAndReturn(run func(context.Context, *big.Int) (*types.Header, error)) *L1Requester_HeaderByNumber_Call { + _c.Call.Return(run) + return _c +} + +// NewL1Requester creates a new instance of L1Requester. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewL1Requester(t interface { + mock.TestingT + Cleanup(func()) +}) *L1Requester { + mock := &L1Requester{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/safe_l1_block_number_fetcher.go b/synchronizer/l1_check_block/mocks/safe_l1_block_number_fetcher.go new file mode 100644 index 0000000000..abb043afb4 --- /dev/null +++ b/synchronizer/l1_check_block/mocks/safe_l1_block_number_fetcher.go @@ -0,0 +1,139 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + + l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + mock "github.com/stretchr/testify/mock" +) + +// SafeL1BlockNumberFetcher is an autogenerated mock type for the SafeL1BlockNumberFetcher type +type SafeL1BlockNumberFetcher struct { + mock.Mock +} + +type SafeL1BlockNumberFetcher_Expecter struct { + mock *mock.Mock +} + +func (_m *SafeL1BlockNumberFetcher) EXPECT() *SafeL1BlockNumberFetcher_Expecter { + return &SafeL1BlockNumberFetcher_Expecter{mock: &_m.Mock} +} + +// Description provides a mock function with given fields: +func (_m *SafeL1BlockNumberFetcher) Description() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// SafeL1BlockNumberFetcher_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type SafeL1BlockNumberFetcher_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *SafeL1BlockNumberFetcher_Expecter) Description() *SafeL1BlockNumberFetcher_Description_Call { + return &SafeL1BlockNumberFetcher_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *SafeL1BlockNumberFetcher_Description_Call) Run(run func()) *SafeL1BlockNumberFetcher_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SafeL1BlockNumberFetcher_Description_Call) Return(_a0 string) *SafeL1BlockNumberFetcher_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SafeL1BlockNumberFetcher_Description_Call) RunAndReturn(run func() string) *SafeL1BlockNumberFetcher_Description_Call { + _c.Call.Return(run) + return _c +} + +// GetSafeBlockNumber provides a mock function with given fields: ctx, l1Client +func (_m *SafeL1BlockNumberFetcher) GetSafeBlockNumber(ctx context.Context, l1Client l1_check_block.L1Requester) (uint64, error) { + ret := _m.Called(ctx, l1Client) + + if len(ret) == 0 { + panic("no return value specified for GetSafeBlockNumber") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, l1_check_block.L1Requester) (uint64, error)); ok { + return rf(ctx, l1Client) + } + if rf, ok := ret.Get(0).(func(context.Context, l1_check_block.L1Requester) uint64); ok { + r0 = rf(ctx, l1Client) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context, l1_check_block.L1Requester) error); ok { + r1 = rf(ctx, l1Client) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSafeBlockNumber' +type SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call struct { + *mock.Call +} + +// GetSafeBlockNumber is a helper method to define mock.On call +// - ctx context.Context +// - l1Client l1_check_block.L1Requester +func (_e *SafeL1BlockNumberFetcher_Expecter) GetSafeBlockNumber(ctx interface{}, l1Client interface{}) *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call { + return &SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call{Call: _e.mock.On("GetSafeBlockNumber", ctx, l1Client)} +} + +func (_c *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call) Run(run func(ctx context.Context, l1Client l1_check_block.L1Requester)) *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(l1_check_block.L1Requester)) + }) + return _c +} + +func (_c *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call) Return(_a0 uint64, _a1 error) *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call) RunAndReturn(run func(context.Context, l1_check_block.L1Requester) (uint64, error)) *SafeL1BlockNumberFetcher_GetSafeBlockNumber_Call { + _c.Call.Return(run) + return _c +} + +// NewSafeL1BlockNumberFetcher creates a new instance of SafeL1BlockNumberFetcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSafeL1BlockNumberFetcher(t interface { + mock.TestingT + Cleanup(func()) +}) *SafeL1BlockNumberFetcher { + mock := &SafeL1BlockNumberFetcher{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/state_for_l1_block_checker_integration.go b/synchronizer/l1_check_block/mocks/state_for_l1_block_checker_integration.go new file mode 100644 index 0000000000..32fbb30b86 --- /dev/null +++ b/synchronizer/l1_check_block/mocks/state_for_l1_block_checker_integration.go @@ -0,0 +1,100 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + pgx "github.com/jackc/pgx/v4" + + state "github.com/0xPolygonHermez/zkevm-node/state" +) + +// StateForL1BlockCheckerIntegration is an autogenerated mock type for the StateForL1BlockCheckerIntegration type +type StateForL1BlockCheckerIntegration struct { + mock.Mock +} + +type StateForL1BlockCheckerIntegration_Expecter struct { + mock *mock.Mock +} + +func (_m *StateForL1BlockCheckerIntegration) EXPECT() *StateForL1BlockCheckerIntegration_Expecter { + return &StateForL1BlockCheckerIntegration_Expecter{mock: &_m.Mock} +} + +// GetPreviousBlockToBlockNumber provides a mock function with given fields: ctx, blockNumber, dbTx +func (_m *StateForL1BlockCheckerIntegration) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + ret := _m.Called(ctx, blockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetPreviousBlockToBlockNumber") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) (*state.Block, error)); ok { + return rf(ctx, blockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Block); ok { + r0 = rf(ctx, blockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, blockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousBlockToBlockNumber' +type StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call struct { + *mock.Call +} + +// GetPreviousBlockToBlockNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +// - dbTx pgx.Tx +func (_e *StateForL1BlockCheckerIntegration_Expecter) GetPreviousBlockToBlockNumber(ctx interface{}, blockNumber interface{}, dbTx interface{}) *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call { + return &StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call{Call: _e.mock.On("GetPreviousBlockToBlockNumber", ctx, blockNumber, dbTx)} +} + +func (_c *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call) Run(run func(ctx context.Context, blockNumber uint64, dbTx pgx.Tx)) *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call) Return(_a0 *state.Block, _a1 error) *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call) RunAndReturn(run func(context.Context, uint64, pgx.Tx) (*state.Block, error)) *StateForL1BlockCheckerIntegration_GetPreviousBlockToBlockNumber_Call { + _c.Call.Return(run) + return _c +} + +// NewStateForL1BlockCheckerIntegration creates a new instance of StateForL1BlockCheckerIntegration. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStateForL1BlockCheckerIntegration(t interface { + mock.TestingT + Cleanup(func()) +}) *StateForL1BlockCheckerIntegration { + mock := &StateForL1BlockCheckerIntegration{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/state_interfacer.go b/synchronizer/l1_check_block/mocks/state_interfacer.go new file mode 100644 index 0000000000..4855ba5eb1 --- /dev/null +++ b/synchronizer/l1_check_block/mocks/state_interfacer.go @@ -0,0 +1,149 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + pgx "github.com/jackc/pgx/v4" + + state "github.com/0xPolygonHermez/zkevm-node/state" +) + +// StateInterfacer is an autogenerated mock type for the StateInterfacer type +type StateInterfacer struct { + mock.Mock +} + +type StateInterfacer_Expecter struct { + mock *mock.Mock +} + +func (_m *StateInterfacer) EXPECT() *StateInterfacer_Expecter { + return &StateInterfacer_Expecter{mock: &_m.Mock} +} + +// GetFirstUncheckedBlock provides a mock function with given fields: ctx, fromBlockNumber, dbTx +func (_m *StateInterfacer) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + ret := _m.Called(ctx, fromBlockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetFirstUncheckedBlock") + } + + var r0 *state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) (*state.Block, error)); ok { + return rf(ctx, fromBlockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, pgx.Tx) *state.Block); ok { + r0 = rf(ctx, fromBlockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, fromBlockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StateInterfacer_GetFirstUncheckedBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFirstUncheckedBlock' +type StateInterfacer_GetFirstUncheckedBlock_Call struct { + *mock.Call +} + +// GetFirstUncheckedBlock is a helper method to define mock.On call +// - ctx context.Context +// - fromBlockNumber uint64 +// - dbTx pgx.Tx +func (_e *StateInterfacer_Expecter) GetFirstUncheckedBlock(ctx interface{}, fromBlockNumber interface{}, dbTx interface{}) *StateInterfacer_GetFirstUncheckedBlock_Call { + return &StateInterfacer_GetFirstUncheckedBlock_Call{Call: _e.mock.On("GetFirstUncheckedBlock", ctx, fromBlockNumber, dbTx)} +} + +func (_c *StateInterfacer_GetFirstUncheckedBlock_Call) Run(run func(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx)) *StateInterfacer_GetFirstUncheckedBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(pgx.Tx)) + }) + return _c +} + +func (_c *StateInterfacer_GetFirstUncheckedBlock_Call) Return(_a0 *state.Block, _a1 error) *StateInterfacer_GetFirstUncheckedBlock_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StateInterfacer_GetFirstUncheckedBlock_Call) RunAndReturn(run func(context.Context, uint64, pgx.Tx) (*state.Block, error)) *StateInterfacer_GetFirstUncheckedBlock_Call { + _c.Call.Return(run) + return _c +} + +// UpdateCheckedBlockByNumber provides a mock function with given fields: ctx, blockNumber, newCheckedStatus, dbTx +func (_m *StateInterfacer) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error { + ret := _m.Called(ctx, blockNumber, newCheckedStatus, dbTx) + + if len(ret) == 0 { + panic("no return value specified for UpdateCheckedBlockByNumber") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, bool, pgx.Tx) error); ok { + r0 = rf(ctx, blockNumber, newCheckedStatus, dbTx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// StateInterfacer_UpdateCheckedBlockByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCheckedBlockByNumber' +type StateInterfacer_UpdateCheckedBlockByNumber_Call struct { + *mock.Call +} + +// UpdateCheckedBlockByNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +// - newCheckedStatus bool +// - dbTx pgx.Tx +func (_e *StateInterfacer_Expecter) UpdateCheckedBlockByNumber(ctx interface{}, blockNumber interface{}, newCheckedStatus interface{}, dbTx interface{}) *StateInterfacer_UpdateCheckedBlockByNumber_Call { + return &StateInterfacer_UpdateCheckedBlockByNumber_Call{Call: _e.mock.On("UpdateCheckedBlockByNumber", ctx, blockNumber, newCheckedStatus, dbTx)} +} + +func (_c *StateInterfacer_UpdateCheckedBlockByNumber_Call) Run(run func(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx)) *StateInterfacer_UpdateCheckedBlockByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(bool), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *StateInterfacer_UpdateCheckedBlockByNumber_Call) Return(_a0 error) *StateInterfacer_UpdateCheckedBlockByNumber_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StateInterfacer_UpdateCheckedBlockByNumber_Call) RunAndReturn(run func(context.Context, uint64, bool, pgx.Tx) error) *StateInterfacer_UpdateCheckedBlockByNumber_Call { + _c.Call.Return(run) + return _c +} + +// NewStateInterfacer creates a new instance of StateInterfacer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStateInterfacer(t interface { + mock.TestingT + Cleanup(func()) +}) *StateInterfacer { + mock := &StateInterfacer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/state_pre_check_interfacer.go b/synchronizer/l1_check_block/mocks/state_pre_check_interfacer.go new file mode 100644 index 0000000000..2bf5522f60 --- /dev/null +++ b/synchronizer/l1_check_block/mocks/state_pre_check_interfacer.go @@ -0,0 +1,101 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + + pgx "github.com/jackc/pgx/v4" + + state "github.com/0xPolygonHermez/zkevm-node/state" +) + +// StatePreCheckInterfacer is an autogenerated mock type for the StatePreCheckInterfacer type +type StatePreCheckInterfacer struct { + mock.Mock +} + +type StatePreCheckInterfacer_Expecter struct { + mock *mock.Mock +} + +func (_m *StatePreCheckInterfacer) EXPECT() *StatePreCheckInterfacer_Expecter { + return &StatePreCheckInterfacer_Expecter{mock: &_m.Mock} +} + +// GetUncheckedBlocks provides a mock function with given fields: ctx, fromBlockNumber, toBlockNumber, dbTx +func (_m *StatePreCheckInterfacer) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) { + ret := _m.Called(ctx, fromBlockNumber, toBlockNumber, dbTx) + + if len(ret) == 0 { + panic("no return value specified for GetUncheckedBlocks") + } + + var r0 []*state.Block + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)); ok { + return rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } + if rf, ok := ret.Get(0).(func(context.Context, uint64, uint64, pgx.Tx) []*state.Block); ok { + r0 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*state.Block) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uint64, uint64, pgx.Tx) error); ok { + r1 = rf(ctx, fromBlockNumber, toBlockNumber, dbTx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StatePreCheckInterfacer_GetUncheckedBlocks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUncheckedBlocks' +type StatePreCheckInterfacer_GetUncheckedBlocks_Call struct { + *mock.Call +} + +// GetUncheckedBlocks is a helper method to define mock.On call +// - ctx context.Context +// - fromBlockNumber uint64 +// - toBlockNumber uint64 +// - dbTx pgx.Tx +func (_e *StatePreCheckInterfacer_Expecter) GetUncheckedBlocks(ctx interface{}, fromBlockNumber interface{}, toBlockNumber interface{}, dbTx interface{}) *StatePreCheckInterfacer_GetUncheckedBlocks_Call { + return &StatePreCheckInterfacer_GetUncheckedBlocks_Call{Call: _e.mock.On("GetUncheckedBlocks", ctx, fromBlockNumber, toBlockNumber, dbTx)} +} + +func (_c *StatePreCheckInterfacer_GetUncheckedBlocks_Call) Run(run func(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx)) *StatePreCheckInterfacer_GetUncheckedBlocks_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(uint64), args[3].(pgx.Tx)) + }) + return _c +} + +func (_c *StatePreCheckInterfacer_GetUncheckedBlocks_Call) Return(_a0 []*state.Block, _a1 error) *StatePreCheckInterfacer_GetUncheckedBlocks_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StatePreCheckInterfacer_GetUncheckedBlocks_Call) RunAndReturn(run func(context.Context, uint64, uint64, pgx.Tx) ([]*state.Block, error)) *StatePreCheckInterfacer_GetUncheckedBlocks_Call { + _c.Call.Return(run) + return _c +} + +// NewStatePreCheckInterfacer creates a new instance of StatePreCheckInterfacer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewStatePreCheckInterfacer(t interface { + mock.TestingT + Cleanup(func()) +}) *StatePreCheckInterfacer { + mock := &StatePreCheckInterfacer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/mocks/sync_check_reorger.go b/synchronizer/l1_check_block/mocks/sync_check_reorger.go new file mode 100644 index 0000000000..bffd02cb87 --- /dev/null +++ b/synchronizer/l1_check_block/mocks/sync_check_reorger.go @@ -0,0 +1,111 @@ +// Code generated by mockery. DO NOT EDIT. + +package mock_l1_check_block + +import mock "github.com/stretchr/testify/mock" + +// SyncCheckReorger is an autogenerated mock type for the SyncCheckReorger type +type SyncCheckReorger struct { + mock.Mock +} + +type SyncCheckReorger_Expecter struct { + mock *mock.Mock +} + +func (_m *SyncCheckReorger) EXPECT() *SyncCheckReorger_Expecter { + return &SyncCheckReorger_Expecter{mock: &_m.Mock} +} + +// ExecuteReorgFromMismatchBlock provides a mock function with given fields: blockNumber, reason +func (_m *SyncCheckReorger) ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error { + ret := _m.Called(blockNumber, reason) + + if len(ret) == 0 { + panic("no return value specified for ExecuteReorgFromMismatchBlock") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint64, string) error); ok { + r0 = rf(blockNumber, reason) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteReorgFromMismatchBlock' +type SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call struct { + *mock.Call +} + +// ExecuteReorgFromMismatchBlock is a helper method to define mock.On call +// - blockNumber uint64 +// - reason string +func (_e *SyncCheckReorger_Expecter) ExecuteReorgFromMismatchBlock(blockNumber interface{}, reason interface{}) *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call { + return &SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call{Call: _e.mock.On("ExecuteReorgFromMismatchBlock", blockNumber, reason)} +} + +func (_c *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call) Run(run func(blockNumber uint64, reason string)) *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(string)) + }) + return _c +} + +func (_c *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call) Return(_a0 error) *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call) RunAndReturn(run func(uint64, string) error) *SyncCheckReorger_ExecuteReorgFromMismatchBlock_Call { + _c.Call.Return(run) + return _c +} + +// OnDetectedMismatchL1BlockReorg provides a mock function with given fields: +func (_m *SyncCheckReorger) OnDetectedMismatchL1BlockReorg() { + _m.Called() +} + +// SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnDetectedMismatchL1BlockReorg' +type SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call struct { + *mock.Call +} + +// OnDetectedMismatchL1BlockReorg is a helper method to define mock.On call +func (_e *SyncCheckReorger_Expecter) OnDetectedMismatchL1BlockReorg() *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call { + return &SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call{Call: _e.mock.On("OnDetectedMismatchL1BlockReorg")} +} + +func (_c *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call) Run(run func()) *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call) Return() *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call { + _c.Call.Return() + return _c +} + +func (_c *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call) RunAndReturn(run func()) *SyncCheckReorger_OnDetectedMismatchL1BlockReorg_Call { + _c.Call.Return(run) + return _c +} + +// NewSyncCheckReorger creates a new instance of SyncCheckReorger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSyncCheckReorger(t interface { + mock.TestingT + Cleanup(func()) +}) *SyncCheckReorger { + mock := &SyncCheckReorger{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/synchronizer/l1_check_block/pre_check_l1block.go b/synchronizer/l1_check_block/pre_check_l1block.go new file mode 100644 index 0000000000..431777f705 --- /dev/null +++ b/synchronizer/l1_check_block/pre_check_l1block.go @@ -0,0 +1,139 @@ +package l1_check_block + +// This make a pre-check of blocks but don't mark them as checked +// It checks blocks between a segment: example: +// real check point SAFE: +// pre check: (SAFE+1) -> (LATEST-32) +// It gets all pending blocks +// - Start cheking + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/jackc/pgx/v4" +) + +var ( + // ErrDeSync is an error that indicates that from the starting of verification to end something have been changed on state + ErrDeSync = errors.New("DeSync: a block hash is different from the state block hash") +) + +// StatePreCheckInterfacer is an interface for the state +type StatePreCheckInterfacer interface { + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) +} + +// PreCheckL1BlockHash is a struct that implements a checker of L1Block hash +type PreCheckL1BlockHash struct { + L1Client L1Requester + State StatePreCheckInterfacer + InitialSegmentBlockNumber SafeL1BlockNumberFetcher + EndSegmentBlockNumber SafeL1BlockNumberFetcher +} + +// NewPreCheckL1BlockHash creates a new CheckL1BlockHash +func NewPreCheckL1BlockHash(l1Client L1Requester, state StatePreCheckInterfacer, + initial, end SafeL1BlockNumberFetcher) *PreCheckL1BlockHash { + return &PreCheckL1BlockHash{ + L1Client: l1Client, + State: state, + InitialSegmentBlockNumber: initial, + EndSegmentBlockNumber: end, + } +} + +// Name is a method that returns the name of the checker +func (p *PreCheckL1BlockHash) Name() string { + return logPrefix + ":memory_check: " +} + +// Step is a method that checks the L1 block hash, run until all blocks are checked and returns +func (p *PreCheckL1BlockHash) Step(ctx context.Context) error { + from, err := p.InitialSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) + if err != nil { + return err + } + to, err := p.EndSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) + if err != nil { + return err + } + if from > to { + log.Warnf("%s: fromBlockNumber(%s) %d is greater than toBlockNumber(%s) %d, Check configuration", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to) + return nil + } + + blocksToCheck, err := p.State.GetUncheckedBlocks(ctx, from, to, nil) + if err != nil { + log.Warnf("%s can't get unchecked blocks, so it discard the reorg error", p.Name()) + return err + } + msg := fmt.Sprintf("%s: Checking blocks from (%s) %d to (%s) %d -> len(blocks)=%d", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck)) + if len(blocksToCheck) == 0 { + log.Debugf(msg) + return nil + } + log.Infof(msg) + startTime := time.Now() + for _, block := range blocksToCheck { + // check block + err = CheckBlockHash(ctx, block, p.L1Client, p.Name()) + if common.IsReorgError(err) { + // Double-check the state block that still is the same + log.Debugf("%s: Reorg detected at blockNumber: %d, checking that the block on State doesn't have change", p.Name(), block.BlockNumber) + isTheSame, errBlockIsTheSame := p.checkThatStateBlockIsTheSame(ctx, block) + if errBlockIsTheSame != nil { + log.Warnf("%s can't double-check that blockNumber %d haven't changed, so it discard the reorg error", p.Name(), block.BlockNumber) + return err + } + if !isTheSame { + log.Infof("%s: DeSync detected, blockNumber: %d is different now that when we started the check", p.Name(), block.BlockNumber) + return ErrDeSync + } + log.Infof("%s: Reorg detected and verified the state block, blockNumber: %d", p.Name(), block.BlockNumber) + return err + } + if err != nil { + return err + } + } + elapsed := time.Since(startTime) + log.Infof("%s: Checked blocks from (%s) %d to (%s) %d -> len(blocks):%d elapsed: %s", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck), elapsed.String()) + + return nil +} + +// CheckBlockHash is a method that checks the L1 block hash +// returns true if is the same +func (p *PreCheckL1BlockHash) checkThatStateBlockIsTheSame(ctx context.Context, block *state.Block) (bool, error) { + blocks, err := p.State.GetUncheckedBlocks(ctx, block.BlockNumber, block.BlockNumber, nil) + if err != nil { + log.Warnf("%s: Fails to get blockNumber %d in state .Err:%s", p.Name(), block.BlockNumber, err.Error()) + return false, err + } + if len(blocks) == 0 { + // The block is checked or deleted, so it is not the same + log.Debugf("%s: The blockNumber %d is no longer in the state (or checked or deleted)", p.Name(), block.BlockNumber) + return false, nil + } + stateBlock := blocks[0] + if stateBlock.BlockNumber != block.BlockNumber { + msg := fmt.Sprintf("%s: The blockNumber returned by state %d is different from the state blockNumber %d", + p.Name(), block.BlockNumber, stateBlock.BlockNumber) + log.Warn(msg) + return false, fmt.Errorf(msg) + } + if stateBlock.BlockHash != block.BlockHash { + msg := fmt.Sprintf("%s: The blockNumber %d differs the hash checked %s from current in state %s", + p.Name(), block.BlockNumber, block.BlockHash.String(), stateBlock.BlockHash.String()) + log.Warn(msg) + return false, nil + } + // The block is the same + return true, nil +} diff --git a/synchronizer/l1_check_block/pre_check_l1block_test.go b/synchronizer/l1_check_block/pre_check_l1block_test.go new file mode 100644 index 0000000000..39c359a513 --- /dev/null +++ b/synchronizer/l1_check_block/pre_check_l1block_test.go @@ -0,0 +1,144 @@ +package l1_check_block_test + +import ( + "context" + "math/big" + "testing" + + "github.com/0xPolygonHermez/zkevm-node/state" + commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/stretchr/testify/require" +) + +type testPreCheckData struct { + sut *l1_check_block.PreCheckL1BlockHash + mockL1Client *mock_l1_check_block.L1Requester + mockState *mock_l1_check_block.StatePreCheckInterfacer + mockInitialFetch *mock_l1_check_block.SafeL1BlockNumberFetcher + mockEndFetch *mock_l1_check_block.SafeL1BlockNumberFetcher + ctx context.Context + stateBlocks []*state.Block +} + +func newPreCheckData(t *testing.T) *testPreCheckData { + mockL1Client := mock_l1_check_block.NewL1Requester(t) + mockState := mock_l1_check_block.NewStatePreCheckInterfacer(t) + mockInitialFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) + mockEndFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) + sut := l1_check_block.NewPreCheckL1BlockHash(mockL1Client, mockState, mockInitialFetch, mockEndFetch) + return &testPreCheckData{ + sut: sut, + mockL1Client: mockL1Client, + mockState: mockState, + mockInitialFetch: mockInitialFetch, + mockEndFetch: mockEndFetch, + ctx: context.Background(), + stateBlocks: []*state.Block{ + { + BlockNumber: 1234, + BlockHash: common.HexToHash("0xd77dd3a9ee6f9202ca5a75024b7d9cbd3d7436b2910d450f88c261c0089c0cd9"), + }, + { + BlockNumber: 1237, + BlockHash: common.HexToHash("0x8faffac37f561c18917c33ff3540262ecfbe11a367b4e1c48181326cd8ba347f"), + }, + }, + } +} + +// If from > to, it ignore because there are no blocks to check +func TestPreCheckL1BlockFromGreaterThanTo(t *testing.T) { + data := newPreCheckData(t) + data.mockInitialFetch.EXPECT().Description().Return("initial") + data.mockEndFetch.EXPECT().Description().Return("end") + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1230), nil) + + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +// No blocks on state -> nothing to do +func TestPreCheckL1BlockNoBlocksOnState(t *testing.T) { + data := newPreCheckData(t) + data.mockInitialFetch.EXPECT().Description().Return("initial") + data.mockEndFetch.EXPECT().Description().Return("end") + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(nil, nil) + + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +func TestPreCheckL1BlockBlocksMatch(t *testing.T) { + data := newPreCheckData(t) + data.mockInitialFetch.EXPECT().Description().Return("initial") + data.mockEndFetch.EXPECT().Description().Return("end") + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) + l1Block1 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) + l1Block2 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + //data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[0:1], nil) + + res := data.sut.Step(data.ctx) + require.NoError(t, res) +} + +func TestPreCheckL1BlockBlocksMismatch(t *testing.T) { + data := newPreCheckData(t) + data.mockInitialFetch.EXPECT().Description().Return("initial") + data.mockEndFetch.EXPECT().Description().Return("end") + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) + l1Block1 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) + l1Block2 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[1:2], nil) + + res := data.sut.Step(data.ctx) + require.Error(t, res) + resErr, ok := res.(*commonsync.ReorgError) + require.True(t, ok, "The error must be ReorgError") + require.Equal(t, uint64(1237), resErr.BlockNumber) +} + +func TestPreCheckL1BlockBlocksMismatchButIsNoLongerInState(t *testing.T) { + data := newPreCheckData(t) + data.mockInitialFetch.EXPECT().Description().Return("initial") + data.mockEndFetch.EXPECT().Description().Return("end") + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) + l1Block1 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) + l1Block2 := &types.Header{ + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), + } + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(nil, nil) + + res := data.sut.Step(data.ctx) + require.ErrorIs(t, res, l1_check_block.ErrDeSync) +} diff --git a/synchronizer/l1_check_block/safe_l1_block.go b/synchronizer/l1_check_block/safe_l1_block.go new file mode 100644 index 0000000000..7b767b4900 --- /dev/null +++ b/synchronizer/l1_check_block/safe_l1_block.go @@ -0,0 +1,120 @@ +package l1_check_block + +import ( + "context" + "fmt" + "math/big" + + "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/ethereum/go-ethereum/rpc" +) + +// L1BlockPoint is an enum that represents the point of the L1 block +type L1BlockPoint int + +const ( + // FinalizedBlockNumber is the finalized block number + FinalizedBlockNumber L1BlockPoint = 3 + // SafeBlockNumber is the safe block number + SafeBlockNumber L1BlockPoint = 2 + // PendingBlockNumber is the pending block number + PendingBlockNumber L1BlockPoint = 1 + // LastBlockNumber is the last block number + LastBlockNumber L1BlockPoint = 0 +) + +// ToString converts a L1BlockPoint to a string +func (v L1BlockPoint) ToString() string { + switch v { + case FinalizedBlockNumber: + return "finalized" + case SafeBlockNumber: + return "safe" + case PendingBlockNumber: + return "pending" + case LastBlockNumber: + return "latest" + } + return "Unknown" +} + +// StringToL1BlockPoint converts a string to a L1BlockPoint +func StringToL1BlockPoint(s string) L1BlockPoint { + switch s { + case "finalized": + return FinalizedBlockNumber + case "safe": + return SafeBlockNumber + case "pending": + return PendingBlockNumber + case "latest": + return LastBlockNumber + default: + return FinalizedBlockNumber + } +} + +// ToGethRequest converts a L1BlockPoint to a big.Int used for request to GETH +func (v L1BlockPoint) ToGethRequest() *big.Int { + switch v { + case FinalizedBlockNumber: + return big.NewInt(int64(rpc.FinalizedBlockNumber)) + case PendingBlockNumber: + return big.NewInt(int64(rpc.PendingBlockNumber)) + case SafeBlockNumber: + return big.NewInt(int64(rpc.SafeBlockNumber)) + case LastBlockNumber: + return nil + } + return big.NewInt(int64(v)) +} + +// SafeL1BlockNumberFetch is a struct that implements a safe L1 block number fetch +type SafeL1BlockNumberFetch struct { + // SafeBlockPoint is the block number that is reference to l1 Block + SafeBlockPoint L1BlockPoint + // Offset is a vaule add to the L1 block + Offset int +} + +// NewSafeL1BlockNumberFetch creates a new SafeL1BlockNumberFetch +func NewSafeL1BlockNumberFetch(safeBlockPoint L1BlockPoint, offset int) *SafeL1BlockNumberFetch { + return &SafeL1BlockNumberFetch{ + SafeBlockPoint: safeBlockPoint, + Offset: offset, + } +} + +// Description returns a string representation of SafeL1BlockNumberFetch +func (p *SafeL1BlockNumberFetch) Description() string { + return fmt.Sprintf("%s/%d", p.SafeBlockPoint.ToString(), p.Offset) +} + +// GetSafeBlockNumber gets the safe block number from L1 +func (p *SafeL1BlockNumberFetch) GetSafeBlockNumber(ctx context.Context, requester L1Requester) (uint64, error) { + l1SafePointBlock, err := requester.HeaderByNumber(ctx, p.SafeBlockPoint.ToGethRequest()) + if err != nil { + log.Errorf("%s: Error getting L1 block %d. err: %s", logPrefix, p.String(), err.Error()) + return uint64(0), err + } + result := l1SafePointBlock.Number.Uint64() + if p.Offset < 0 { + if result < uint64(-p.Offset) { + result = 0 + } else { + result += uint64(p.Offset) + } + } else { + result = l1SafePointBlock.Number.Uint64() + uint64(p.Offset) + } + if p.SafeBlockPoint == LastBlockNumber { + result = min(result, l1SafePointBlock.Number.Uint64()) + } + + return result, nil +} + +// String returns a string representation of SafeL1BlockNumberFetch +func (p *SafeL1BlockNumberFetch) String() string { + return fmt.Sprintf("SafeBlockPoint: %s, Offset: %d", p.SafeBlockPoint.ToString(), p.Offset) +} diff --git a/synchronizer/l1_check_block/safe_l1_block_test.go b/synchronizer/l1_check_block/safe_l1_block_test.go new file mode 100644 index 0000000000..4d3167adcd --- /dev/null +++ b/synchronizer/l1_check_block/safe_l1_block_test.go @@ -0,0 +1,113 @@ +package l1_check_block_test + +import ( + "context" + "math/big" + "testing" + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" +) + +func TestGetSafeBlockNumber(t *testing.T) { + ctx := context.Background() + mockRequester := mock_l1_check_block.NewL1Requester(t) + //safeBlockPoint := big.NewInt(50) + offset := 10 + safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint("safe"), offset) + + mockRequester.EXPECT().HeaderByNumber(ctx, mock.Anything).Return(&types.Header{ + Number: big.NewInt(100), + }, nil) + blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) + assert.NoError(t, err) + expectedBlockNumber := uint64(100 + offset) + assert.Equal(t, expectedBlockNumber, blockNumber) +} + +func TestGetSafeBlockNumberMutliplesCases(t *testing.T) { + tests := []struct { + name string + blockPoint string + offset int + l1ReturnBlockNumber uint64 + expectedCallToGeth *big.Int + expectedBlockNumber uint64 + }{ + { + name: "SafeBlockNumber+10", + blockPoint: "safe", + offset: 10, + l1ReturnBlockNumber: 100, + expectedCallToGeth: big.NewInt(int64(rpc.SafeBlockNumber)), + expectedBlockNumber: 110, + }, + { + name: "FinalizedBlockNumber+10", + blockPoint: "finalized", + offset: 10, + l1ReturnBlockNumber: 100, + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + expectedBlockNumber: 110, + }, + { + name: "PendingBlockNumber+10", + blockPoint: "pending", + offset: 10, + l1ReturnBlockNumber: 100, + expectedCallToGeth: big.NewInt(int64(rpc.PendingBlockNumber)), + expectedBlockNumber: 110, + }, + { + name: "LastBlockNumber+10, can't add 10 to latest block number. So must return latest block number and ignore positive offset", + blockPoint: "latest", + offset: 10, + l1ReturnBlockNumber: 100, + expectedCallToGeth: nil, + expectedBlockNumber: 100, + }, + { + name: "FinalizedBlockNumber-1000. negative blockNumbers are not welcome. So must return 0", + blockPoint: "finalized", + offset: -1000, + l1ReturnBlockNumber: 100, + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + expectedBlockNumber: 0, + }, + { + name: "FinalizedBlockNumber(1000)-1000. is 0 ", + blockPoint: "finalized", + offset: -1000, + l1ReturnBlockNumber: 1000, + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + expectedBlockNumber: 0, + }, + { + name: "FinalizedBlockNumber(1001)-1000. is 1 ", + blockPoint: "finalized", + offset: -1000, + l1ReturnBlockNumber: 1001, + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + expectedBlockNumber: 1, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx := context.Background() + mockRequester := mock_l1_check_block.NewL1Requester(t) + safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(tt.blockPoint), tt.offset) + + mockRequester.EXPECT().HeaderByNumber(ctx, tt.expectedCallToGeth).Return(&types.Header{ + Number: big.NewInt(int64(tt.l1ReturnBlockNumber)), + }, nil) + blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) + assert.NoError(t, err) + assert.Equal(t, tt.expectedBlockNumber, blockNumber) + }) + } +} diff --git a/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go b/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go index 5a457acbf0..4dd78632fd 100644 --- a/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go +++ b/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go @@ -3,12 +3,14 @@ package l1_parallel_sync import ( "context" "errors" + "fmt" "sync" "time" "github.com/0xPolygonHermez/zkevm-node/etherman" "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/state" + syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" "github.com/ethereum/go-ethereum/common" types "github.com/ethereum/go-ethereum/core/types" ) @@ -22,7 +24,6 @@ var ( errContextCanceled = errors.New("consumer:context canceled") errConsumerStopped = errors.New("consumer:stopped by request") errConsumerStoppedBecauseIsSynchronized = errors.New("consumer:stopped because is synchronized") - errL1Reorg = errors.New("consumer: L1 reorg detected") errConsumerAndProducerDesynchronized = errors.New("consumer: consumer and producer are desynchronized") ) @@ -155,13 +156,12 @@ func checkPreviousBlocks(rollupInfo rollupInfoByBlockRangeResult, cachedBlock *s } if cachedBlock.BlockNumber == rollupInfo.previousBlockOfRange.NumberU64() { if cachedBlock.BlockHash != rollupInfo.previousBlockOfRange.Hash() { - log.Errorf("consumer: Previous block %d hash is not the same", cachedBlock.BlockNumber) - return errL1Reorg - } - if cachedBlock.ParentHash != rollupInfo.previousBlockOfRange.ParentHash() { - log.Errorf("consumer: Previous block %d parentHash is not the same", cachedBlock.BlockNumber) - return errL1Reorg + err := fmt.Errorf("consumer: Previous block %d hash is not the same. state.Hash:%s != l1.Hash:%s", + cachedBlock.BlockNumber, cachedBlock.BlockHash, rollupInfo.previousBlockOfRange.Hash()) + log.Errorf(err.Error()) + return syncCommon.NewReorgError(cachedBlock.BlockNumber, err) } + log.Infof("consumer: Verified previous block %d not the same: OK", cachedBlock.BlockNumber) } return nil diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 7ba6ce8fa4..d1e034fb76 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -16,6 +16,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/processor_manager" syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_parallel_sync" "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" @@ -77,6 +78,7 @@ type ClientSynchronizer struct { l1EventProcessors *processor_manager.L1EventProcessors syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor halter syncinterfaces.CriticalErrorHandler + asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator } // NewSynchronizer creates and initializes an instance of Synchronizer @@ -123,6 +125,31 @@ func NewSynchronizer( syncBlockProtection: syncBlockProtection, halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd } + if cfg.L1BlockCheck.Enable { + log.Infof("L1BlockChecker enabled: %s", cfg.L1BlockCheck.String()) + l1BlockChecker := l1_check_block.NewCheckL1BlockHash(ethMan, res.state, + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset)) + + var preCheckAsync syncinterfaces.AsyncL1BlockChecker + if cfg.L1BlockCheck.PreCheckEnable { + log.Infof("L1BlockChecker enabled precheck from: %s/%d to: %s/%d", + cfg.L1BlockCheck.L1SafeBlockPoint, cfg.L1BlockCheck.L1SafeBlockOffset, + cfg.L1BlockCheck.L1PreSafeBlockPoint, cfg.L1BlockCheck.L1PreSafeBlockOffset) + l1BlockPreChecker := l1_check_block.NewPreCheckL1BlockHash(ethMan, res.state, + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset), + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1PreSafeBlockPoint), cfg.L1BlockCheck.L1PreSafeBlockOffset), + ) + preCheckAsync = l1_check_block.NewAsyncCheck(l1BlockPreChecker) + } + + res.asyncL1BlockChecker = l1_check_block.NewL1BlockCheckerIntegration( + l1_check_block.NewAsyncCheck(l1BlockChecker), + preCheckAsync, + res.state, + res, + cfg.L1BlockCheck.ForceCheckBeforeStart, + time.Second) + } if !isTrustedSequencer { log.Info("Permissionless: creating and Initializing L2 synchronization components") @@ -165,7 +192,7 @@ func NewSynchronizer( res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks) switch cfg.L1SynchronizationMode { case ParallelMode: - log.Fatal("L1SynchronizationMode is parallel. Not yet suported, please use sequential mode to sync") + log.Info("L1SynchronizationMode is parallel") res.l1SyncOrchestration = newL1SyncParallel(ctx, cfg, etherManForL1, res, runInDevelopmentMode) case SequentialMode: log.Info("L1SynchronizationMode is sequential") @@ -251,6 +278,10 @@ func (s *ClientSynchronizer) Sync() error { // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block // Get the latest synced block. If there is no block on db, use genesis block log.Info("Sync started") + if s.asyncL1BlockChecker != nil { + _ = s.asyncL1BlockChecker.OnStart(s.ctx) + } + dbTx, err := s.state.BeginStateTransaction(s.ctx) if err != nil { log.Errorf("error creating db transaction to get latest block. Error: %v", err) @@ -402,6 +433,7 @@ func (s *ClientSynchronizer) Sync() error { continue } log.Infof("latestSequencedBatchNumber: %d, latestSyncedBatch: %d, lastVerifiedBatchNumber: %d", latestSequencedBatchNumber, latestSyncedBatch, lastVerifiedBatchNumber) + resetDone := false // Sync trusted state // latestSyncedBatch -> Last batch on DB // latestSequencedBatchNumber -> last batch on SMC @@ -409,6 +441,13 @@ func (s *ClientSynchronizer) Sync() error { startTrusted := time.Now() if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { log.Info("Syncing trusted state (permissionless)") + //Sync Trusted State + log.Debug("Doing reorg check before L2 sync") + resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) + if resetDone || err != nil { + log.Infof("Reset done before L2 sync") + continue + } err = s.syncTrustedState(latestSyncedBatch) metrics.FullTrustedSyncTime(time.Since(startTrusted)) if err != nil { @@ -417,10 +456,14 @@ func (s *ClientSynchronizer) Sync() error { if errors.Is(err, syncinterfaces.ErrFatalDesyncFromL1) { l1BlockNumber := err.(*l2_shared.DeSyncPermissionlessAndTrustedNodeError).L1BlockNumber log.Error("Trusted and permissionless desync! reseting to last common point: L1Block (%d-1)", l1BlockNumber) - err = s.resetState(l1BlockNumber - 1) - if err != nil { - log.Errorf("error resetting the state to a discrepancy block. Retrying... Err: %v", err) - continue + for { + resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) + if resetDone { + break + } else { + log.Error("reorg isn't done, retrying...") + time.Sleep(time.Second) + } } } else if errors.Is(err, syncinterfaces.ErrMissingSyncFromL1) { log.Info("Syncing from trusted node need data from L1") @@ -437,6 +480,11 @@ func (s *ClientSynchronizer) Sync() error { waitDuration = s.cfg.SyncInterval.Duration } //Sync L1Blocks + resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) + if resetDone || err != nil { + continue + } + startL1 := time.Now() if s.l1SyncOrchestration != nil && (latestSyncedBatch < latestSequencedBatchNumber || !s.cfg.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized) { log.Infof("Syncing L1 blocks in parallel lastEthBlockSynced=%d", lastEthBlockSynced.BlockNumber) @@ -451,6 +499,19 @@ func (s *ClientSynchronizer) Sync() error { lastEthBlockSynced, err = s.syncBlocksSequential(lastEthBlockSynced) } metrics.FullL1SyncTime(time.Since(startL1)) + if syncCommon.IsReorgError(err) { + log.Warnf("error syncing blocks: %s", err.Error()) + for { + resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) + if resetDone { + break + } else { + log.Error("reorg isn't done, retrying...") + time.Sleep(time.Second) + } + } + continue + } if err != nil { log.Warn("error syncing blocks: ", err) s.CleanTrustedState() @@ -521,22 +582,6 @@ func sanityCheckForGenesisBlockRollupInfo(blocks []etherman.Block, order map[com // This function syncs the node from a specific block to the latest // lastEthBlockSynced -> last block synced in the db func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. - block, err := s.newCheckReorg(lastEthBlockSynced, nil) - if err != nil { - log.Errorf("error checking reorgs. Retrying... Err: %v", err) - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") - } - if block != nil { - log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, block.BlockNumber) - err = s.resetState(block.BlockNumber) - if err != nil { - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) - s.l1SyncOrchestration.Reset(lastEthBlockSynced.BlockNumber) - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") - } - return block, nil - } log.Infof("Starting L1 sync orchestrator in parallel block: %d", lastEthBlockSynced.BlockNumber) return s.l1SyncOrchestration.Start(lastEthBlockSynced) } @@ -551,21 +596,6 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc } lastKnownBlock := header.Number - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. - block, err := s.newCheckReorg(lastEthBlockSynced, nil) - if err != nil { - log.Errorf("error checking reorgs. Retrying... Err: %v", err) - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") - } - if block != nil { - err = s.resetState(block.BlockNumber) - if err != nil { - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") - } - return block, nil - } - var fromBlock uint64 if lastEthBlockSynced.BlockNumber > 0 { fromBlock = lastEthBlockSynced.BlockNumber @@ -606,7 +636,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc log.Error("error getting previousBlock from db. Error: ", err) return lastEthBlockSynced, err } - blockReorged, err := s.newCheckReorg(prevBlock, nil) + blockReorged, err := s.checkReorg(prevBlock, nil) if err != nil { log.Error("error checking reorgs in previous blocks. Error: ", err) return lastEthBlockSynced, err @@ -622,7 +652,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return blockReorged, nil } // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange - block, err := s.newCheckReorg(lastEthBlockSynced, initBlockReceived) + block, err := s.checkReorg(lastEthBlockSynced, initBlockReceived) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs") @@ -803,12 +833,118 @@ func (s *ClientSynchronizer) resetState(blockNumber uint64) error { log.Error("error committing the resetted state. Error: ", err) return err } + if s.asyncL1BlockChecker != nil { + s.asyncL1BlockChecker.OnResetState(s.ctx) + } if s.l1SyncOrchestration != nil { - s.l1SyncOrchestration.Reset(blockNumber) + lastBlock, err := s.state.GetLastBlock(s.ctx, nil) + if err != nil { + log.Errorf("error getting last block synced from db. Error: %v", err) + s.l1SyncOrchestration.Reset(blockNumber) + } else { + s.l1SyncOrchestration.Reset(lastBlock.BlockNumber) + } } return nil } +// OnDetectedMismatchL1BlockReorg function will be called when a reorg is detected (asynchronous call) +func (s *ClientSynchronizer) OnDetectedMismatchL1BlockReorg() { + log.Infof("Detected Reorg in background at block (mismatch)") + if s.l1SyncOrchestration != nil && s.l1SyncOrchestration.IsProducerRunning() { + log.Errorf("Stop synchronizer: because L1 sync parallel aborting background process") + s.l1SyncOrchestration.Abort() + } +} + +// ExecuteReorgFromMismatchBlock function will reset the state to the block before the bad block +func (s *ClientSynchronizer) ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error { + log.Info("Detected reorg at block (mismatch): ", blockNumber, " reason: ", reason, " resetting the state to block:", blockNumber-1) + s.CleanTrustedState() + return s.resetState(blockNumber - 1) +} +func (s *ClientSynchronizer) detectedReorgBadBlockExecuteReset(lastEthBlockSynced *state.Block, badBlockNumber uint64) (bool, *state.Block, error) { + firstBlockOK, err := s.checkReorg(lastEthBlockSynced, nil) + if err != nil { + log.Warnf("error checking reorgs. using badBlock detected: %d Err: %v", badBlockNumber, err) + firstBlockOK = nil + } + if firstBlockOK != nil && firstBlockOK.BlockNumber >= badBlockNumber { + log.Warnf("Reorg detected firstBlockOk: %d. But oldest bad block detected: %d", firstBlockOK.BlockNumber, badBlockNumber) + firstBlockOK = nil + } + // We already known a bad block, reset from there + if firstBlockOK == nil { + firstBlockOK, err = s.state.GetPreviousBlockToBlockNumber(s.ctx, badBlockNumber, nil) + if err != nil { + log.Errorf("error getting previous block %d from db. Can't execute REORG. Error: %v", badBlockNumber, err) + return false, lastEthBlockSynced, err + } + } + newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, firstBlockOK) + if err != nil { + log.Errorf("error executing reorg. Retrying... Err: %v", err) + return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) + } + return true, newFirstBlock, nil +} + +// checkReorgAndExecuteReset function will check if there is a reorg and execute the reset +// returns true is reset have been done +func (s *ClientSynchronizer) checkReorgAndExecuteReset(lastEthBlockSynced *state.Block) (bool, *state.Block, error) { + var err error + + block, err := s.checkReorg(lastEthBlockSynced, nil) + if err != nil { + log.Errorf("error checking reorgs. Retrying... Err: %v", err) + return false, lastEthBlockSynced, fmt.Errorf("error checking reorgs") + } + if block != nil { + newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, block) + if err != nil { + log.Errorf("error executing reorg. Retrying... Err: %v", err) + return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) + } + return true, newFirstBlock, nil + } + + return false, lastEthBlockSynced, nil +} + +func (s *ClientSynchronizer) executeReorgFromFirstValidBlock(lastEthBlockSynced *state.Block, firstValidBlock *state.Block) (*state.Block, error) { + log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, firstValidBlock.BlockNumber) + s.CleanTrustedState() + err := s.resetState(firstValidBlock.BlockNumber) + if err != nil { + log.Errorf("error resetting the state to a previous block. Retrying... Err: %s", err.Error()) + return nil, fmt.Errorf("error resetting the state to a previous block. Err: %w", err) + } + newLastBlock, err := s.state.GetLastBlock(s.ctx, nil) + if err != nil { + log.Warnf("error getting last block synced from db, returning expected block %d. Error: %v", firstValidBlock.BlockNumber, err) + return firstValidBlock, nil + } + if newLastBlock.BlockNumber != firstValidBlock.BlockNumber { + log.Warnf("Doesnt match LastBlock on State and expecting one after a resetState. The block in state is %d and the expected block is %d", newLastBlock.BlockNumber, + firstValidBlock.BlockNumber) + return firstValidBlock, nil + } + return newLastBlock, nil +} + +func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { + if latestBlock == nil { + err := fmt.Errorf("lastEthBlockSynced is nil calling checkReorgAndExecuteReset") + log.Errorf("%s, it never have to happens", err.Error()) + return nil, err + } + block, errReturnedReorgFunction := s.newCheckReorg(latestBlock, syncedBlock) + if s.asyncL1BlockChecker != nil { + return s.asyncL1BlockChecker.CheckReorgWrapper(s.ctx, block, errReturnedReorgFunction) + } + return block, errReturnedReorgFunction +} + /* This function will check if there is a reorg. As input param needs the last ethereum block synced. Retrieve the block info from the blockchain @@ -817,76 +953,6 @@ If hash or hash parent don't match, reorg detected and the function will return must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check hash and has parent. This operation has to be done until a match is found. */ -// TODO This function will be deprecated -func (s *ClientSynchronizer) oldCheckReorg(latestBlock *state.Block) (*state.Block, error) { //nolint:unused - // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. - latestEthBlockSynced := *latestBlock - reorgedBlock := *latestBlock - var depth uint64 - for { - block, err := s.etherMan.EthBlockByNumber(s.ctx, reorgedBlock.BlockNumber) - if err != nil { - log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", reorgedBlock.BlockNumber, err) - return nil, err - } - log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.Number().Uint64(), block.Hash().String()) - log.Infof("[checkReorg function] latestBlockNumber: %d latestBlockHash already synced: %s", latestBlock.BlockNumber, latestBlock.BlockHash.String()) - if block.NumberU64() != reorgedBlock.BlockNumber { - err = fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", - reorgedBlock.BlockNumber, block.NumberU64()) - log.Error("error: ", err) - return nil, err - } - // Compare hashes - if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.RollupBlockNumber { - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash) - log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) - log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) - log.Debug("[checkReorg function] => latestBlockHashParent: ", latestBlock.ParentHash) - log.Debug("[checkReorg function] => BlockNumber: ", latestBlock.BlockNumber, block.NumberU64()) - log.Debug("[checkReorg function] => BlockHash: ", block.Hash()) - log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash()) - depth++ - log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) - // Reorg detected. Getting previous block - dbTx, err := s.state.BeginStateTransaction(s.ctx) - if err != nil { - log.Errorf("error creating db transaction to get prevoius blocks") - return nil, err - } - lb, err := s.state.GetPreviousBlock(s.ctx, depth, dbTx) - errC := dbTx.Commit(s.ctx) - if errC != nil { - log.Errorf("error committing dbTx, err: %v", errC) - rollbackErr := dbTx.Rollback(s.ctx) - if rollbackErr != nil { - log.Errorf("error rolling back state. RollbackErr: %v", rollbackErr) - return nil, rollbackErr - } - log.Errorf("error committing dbTx, err: %v", errC) - return nil, errC - } - if errors.Is(err, state.ErrNotFound) { - log.Warn("error checking reorg: previous block not found in db: ", err) - return &state.Block{}, nil - } else if err != nil { - log.Error("error getting previousBlock from db. Error: ", err) - return nil, err - } - reorgedBlock = *lb - } else { - log.Debugf("checkReorg: Block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.Hash() == reorgedBlock.BlockHash, block.ParentHash() == reorgedBlock.ParentHash) - break - } - } - if latestEthBlockSynced.BlockHash != reorgedBlock.BlockHash { - latestBlock = &reorgedBlock - log.Info("Reorg detected in block: ", latestEthBlockSynced.BlockNumber, " last block OK: ", latestBlock.BlockNumber) - return latestBlock, nil - } - log.Debugf("No reorg detected in block: %d. BlockHash: %s", latestEthBlockSynced.BlockNumber, latestEthBlockSynced.BlockHash.String()) - return nil, nil -} func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. @@ -919,7 +985,7 @@ func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, synce return nil, err } // Compare hashes - if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.BlockNumber { + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupManagerBlockNumber { log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index b9a56549c3..2d2bf83c50 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -129,6 +129,9 @@ func TestForcedBatchEtrog(t *testing.T) { SyncChunkSize: 10, L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, } m := mocks{ @@ -206,7 +209,7 @@ func TestForcedBatchEtrog(t *testing.T) { m.Etherman. On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). Return(ethBlock0, nil). - Once() + Times(2) n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. @@ -925,6 +928,9 @@ func TestReorg(t *testing.T) { SyncChunkSize: 3, L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, } m := mocks{ @@ -1012,6 +1018,16 @@ func TestReorg(t *testing.T) { On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). Return(nil) + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. On("HeaderByNumber", mock.Anything, n). @@ -1097,6 +1113,16 @@ func TestReorg(t *testing.T) { Return(nil). Once() + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + m.Etherman. On("HeaderByNumber", mock.Anything, n). Return(ethHeader3bis, nil). @@ -1197,17 +1223,13 @@ func TestReorg(t *testing.T) { Return(nil). Once() - m.ZKEVMClient. - On("BatchNumber", ctx). - Return(uint64(1), nil) - m.DbTx. On("Commit", ctx). + Return(nil). Run(func(args mock.Arguments) { sync.Stop() ctx.Done() }). - Return(nil). Once() }). Return(m.DbTx, nil). @@ -1226,6 +1248,9 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { SyncChunkSize: 3, L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, } m := mocks{ @@ -1307,6 +1332,16 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). Return(nil) + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. On("HeaderByNumber", mock.Anything, n). @@ -1369,6 +1404,11 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { Return(nil). Once() + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + m.ZKEVMClient. On("BatchNumber", ctx). Return(uint64(1), nil). @@ -1400,15 +1440,10 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { m.Etherman. On("GetFinalizedBlockNumber", ctx). Return(ethBlock3.NumberU64(), nil). - Once() - - m.ZKEVMClient. - On("BatchNumber", ctx). Run(func(args mock.Arguments) { sync.Stop() ctx.Done() }). - Return(uint64(1), nil). Once() }). Return(m.DbTx, nil). @@ -1427,6 +1462,9 @@ func TestRegularReorg(t *testing.T) { SyncChunkSize: 3, L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, } m := mocks{ @@ -1469,10 +1507,6 @@ func TestRegularReorg(t *testing.T) { lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} - m.ZKEVMClient. - On("BatchNumber", ctx). - Return(uint64(1), nil) - m.State. On("GetForkIDByBatchNumber", mock.Anything). Return(uint64(9), nil). @@ -1482,6 +1516,12 @@ func TestRegularReorg(t *testing.T) { Return(lastBlock1, nil). Once() + // After a ResetState get lastblock that must be block 0 + m.State. + On("GetLastBlock", ctx, nil). + Return(lastBlock0, nil). + Once() + m.State. On("GetLastBatchNumber", ctx, m.DbTx). Return(uint64(10), nil). @@ -1514,12 +1554,18 @@ func TestRegularReorg(t *testing.T) { On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). Return(nil) - n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. - On("HeaderByNumber", mock.Anything, n). - Return(ethHeader2bis, nil). + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). Once() + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + m.Etherman. On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). Return(ethBlock1bis, nil). @@ -1573,6 +1619,16 @@ func TestRegularReorg(t *testing.T) { Return(nil). Once() + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + m.Etherman. On("HeaderByNumber", mock.Anything, n). Return(ethHeader2bis, nil). @@ -1688,6 +1744,9 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { SyncChunkSize: 3, L1SynchronizationMode: SequentialMode, SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, } m := mocks{ @@ -1772,6 +1831,16 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). Return(nil) + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). + Return(ethBlock2, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + n := big.NewInt(rpc.LatestBlockNumber.Int64()) m.Etherman. On("HeaderByNumber", mock.Anything, n). @@ -1860,6 +1929,11 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { Return(nil). Once() + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + m.ZKEVMClient. On("BatchNumber", ctx). Return(uint64(1), nil). @@ -1924,15 +1998,10 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { m.DbTx. On("Commit", ctx). Return(nil). - Once() - - m.ZKEVMClient. - On("BatchNumber", ctx). Run(func(args mock.Arguments) { sync.Stop() ctx.Done() }). - Return(uint64(1), nil). Once() }). Return(m.DbTx, nil). diff --git a/test/Makefile b/test/Makefile index 93fc7bb06b..35cd659924 100644 --- a/test/Makefile +++ b/test/Makefile @@ -725,8 +725,11 @@ generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery rm -Rf ../synchronizer/actions/elderberry/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} - - + + rm -Rf ../synchronizer/l1_check_block/mocks + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l1_check_block --output ../synchronizer/l1_check_block/mocks --outpkg mock_l1_check_block ${COMMON_MOCKERY_PARAMS} + + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} diff --git a/test/e2e/jsonrpc2_test.go b/test/e2e/jsonrpc2_test.go index fcd883a956..f8a0113814 100644 --- a/test/e2e/jsonrpc2_test.go +++ b/test/e2e/jsonrpc2_test.go @@ -780,7 +780,10 @@ func TestEstimateGas(t *testing.T) { msg.GasPrice = gasPrice } - _, err = ethereumClient.EstimateGas(ctx, msg) + gas, err := ethereumClient.EstimateGas(ctx, msg) + t.Log("testCase: ", testCase.name) + t.Log("err: ", err) + t.Log("gas: ", gas) if testCase.expectedError != nil { rpcErr := err.(rpc.Error) errMsg := fmt.Sprintf("[%v] expected: %v %v found: %v %v", network.Name, testCase.expectedError.ErrorCode(), testCase.expectedError.Error(), rpcErr.ErrorCode(), rpcErr.Error()) From a144388758ede6a5c452e5f31344664d4ac3c6d0 Mon Sep 17 00:00:00 2001 From: Alonso Rodriguez Date: Wed, 17 Apr 2024 12:05:18 +0200 Subject: [PATCH 06/21] Fix + remove empty blocks (#3564) * Fix + remove empty blocks * unit test * linter --- db/migrations/state/0020.sql | 28 ++++ db/migrations/state/0020_test.go | 99 +++++++++++ synchronizer/synchronizer.go | 13 +- synchronizer/synchronizer_test.go | 270 ++++++++++++++++++++++++++++++ 4 files changed, 404 insertions(+), 6 deletions(-) create mode 100644 db/migrations/state/0020.sql create mode 100644 db/migrations/state/0020_test.go diff --git a/db/migrations/state/0020.sql b/db/migrations/state/0020.sql new file mode 100644 index 0000000000..1068b6f8da --- /dev/null +++ b/db/migrations/state/0020.sql @@ -0,0 +1,28 @@ +-- +migrate Up + +-- This migration will delete all empty blocks +DELETE FROM state.block +WHERE NOT EXISTS (SELECT * + FROM state.virtual_batch + WHERE state.virtual_batch.block_num = state.block.block_num) + AND NOT EXISTS (SELECT * + FROM state.verified_batch + WHERE state.verified_batch.block_num = state.block.block_num) + AND NOT EXISTS (SELECT * + FROM state.forced_batch + WHERE state.forced_batch.block_num = state.block.block_num) + AND NOT EXISTS (SELECT * + FROM state.exit_root + WHERE state.exit_root.block_num = state.block.block_num) + AND NOT EXISTS (SELECT * + FROM state.monitored_txs + WHERE state.monitored_txs.block_num = state.block.block_num) + AND NOT EXISTS (SELECT * + FROM state.fork_id + WHERE state.fork_id.block_num = state.block.block_num); + + + +-- +migrate Down + +-- no action is needed, the data must remain deleted as it is useless \ No newline at end of file diff --git a/db/migrations/state/0020_test.go b/db/migrations/state/0020_test.go new file mode 100644 index 0000000000..e58ea23381 --- /dev/null +++ b/db/migrations/state/0020_test.go @@ -0,0 +1,99 @@ +package migrations_test + +import ( + "database/sql" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// this migration changes length of the token name +type migrationTest0020 struct{} + +func (m migrationTest0020) InsertData(db *sql.DB) error { + addBlocks := ` + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(1, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b20', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fe', '2024-03-11 02:52:23.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(2, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b21', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f1', '2024-03-11 02:52:24.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(3, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b22', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f2', '2024-03-11 02:52:25.000', false); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(4, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b23', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f3', '2024-03-11 02:52:26.000', false); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(5, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b24', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f4', '2024-03-11 02:52:27.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(6, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b25', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f5', '2024-03-11 02:52:28.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(7, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b26', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f6', '2024-03-11 02:52:29.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(8, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b27', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f7', '2024-03-11 02:52:30.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(9, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b28', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f8', '2024-03-11 02:52:31.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(10, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b29', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f9', '2024-03-11 02:52:32.000', true); + INSERT INTO state.block + (block_num, block_hash, parent_hash, received_at, checked) + VALUES(11, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b2a', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fa', '2024-03-11 02:52:33.000', true); + INSERT INTO state.batch + (batch_num, global_exit_root, local_exit_root, state_root, acc_input_hash, "timestamp", coinbase, raw_txs_data, forced_batch_num, batch_resources, closing_reason, wip, checked) + VALUES(1, '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9', '0xa5bd7311fe00707809dd3aa718be2ea0cb363626b9db44172098515f07acf940', '2023-03-24 16:35:27.000', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', decode('','hex'), NULL, '{"Bytes": 0, "ZKCounters": {"GasUsed": 0, "UsedSteps": 0, "UsedBinaries": 0, "UsedMemAligns": 0, "UsedArithmetics": 0, "UsedKeccakHashes": 0, "UsedPoseidonHashes": 0, "UsedSha256Hashes_V2": 0, "UsedPoseidonPaddings": 0}}'::jsonb, '', false, true); + INSERT INTO state.virtual_batch + (batch_num, tx_hash, coinbase, block_num, sequencer_addr, timestamp_batch_etrog, l1_info_root) + VALUES(1, '0x4314ed5d8ad4812e88895942b2b4642af176d80a97c5489a16a7a5aeb08b51a6', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', 2, '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '2024-04-09 16:26:45.000', '0xcdb4258d7ccd8fd41c4a26fd8d9d1fadbc9c506e64d489170525a65e2ad3580b'); + INSERT INTO state.verified_batch + (batch_num, tx_hash, aggregator, state_root, block_num, is_trusted) + VALUES(1, '0x28e82f15ab7bac043598623c65a838c315d00ecb5d6e013c406d6bb889680592', '0x6329Fe417621925C81c16F9F9a18c203C21Af7ab', '0x80bd488b1e150b9b42611d038c7fdfa43a3e95b3a02e5c2d57074e73b583f8fd', 3, true); + INSERT INTO state.fork_id + (fork_id, from_batch_num, to_batch_num, "version", block_num) + VALUES(5, 813267, 1228916, 'v2.0.0-RC1-fork.5', 5); + INSERT INTO state.monitored_txs + ("owner", id, from_addr, to_addr, nonce, value, "data", gas, gas_price, status, history, block_num, created_at, updated_at, gas_offset) + VALUES('sequencer', 'sequence-from-2006249-to-2006252', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '0x519E42c24163192Dca44CD3fBDCEBF6be9130987', 58056, NULL, 'def57e540000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000006614ec3100000000000000000000000000000000000000000000000000000000001e9ce8000000000000000000000000148ee7da0000000300000000ee8306089a84ae0baa0082520894417a7ba2d8d0060ae6c54fd098590db854b9c1d58609184e72a0008082044d80802787e068e6fe23cda64eb868cefb7231a17449d508a77919f6c5408814aaab5f259d43a62eb50df0b2d5740552d3f95176a1f0e31cade590facf70b01c1129151bab0b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000000000000000000000000000000', 1474265, 25212431373, 'done', '{0x44423d538d6fc2f2e882fcd0d1952a735d81c824827b83936e6a5e52268a7d8e}', 7, '2024-04-09 09:26:36.235', '2024-04-09 09:38:24.377', 150000); + INSERT INTO state.exit_root + (id, block_num, "timestamp", mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index) + VALUES(379599, 8, '2024-04-09 09:43:59.000', decode('C90DCBC69719971625800AD619E5EEEFD0378317E26F0DDE9B30B3C7C84DBD78','hex'), decode('514D72BBF7C2AD8E4D15EC1186EBF077E98208479651B1C30C5AC7DA11BAB209','hex'), decode('B20FACBED4A2774CE33A0F68D9B6F9B4D9AD553DACD73705503910B141D2102E','hex'), decode('845E01F723E5C77DBE5A4889F299860FBECD8353BFD423D366851F3A90496334','hex'), decode('EDB0EF9C80E947C411FD9B8B23318708132F8A3BD15CD366499866EF91748FC8','hex'), 8032); + INSERT INTO state.forced_batch + (block_num, forced_batch_num, global_exit_root, timestamp, raw_txs_data, coinbase) + VALUES(10, 1, '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5ca', '2024-04-09 09:26:36.235', '0x3f86b09b', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9'); + ` + if _, err := db.Exec(addBlocks); err != nil { + return err + } + blockCount := `SELECT count(*) FROM state.block` + var count int + err := db.QueryRow(blockCount).Scan(&count) + if err != nil { + return err + } + if count != 11 { + return fmt.Errorf("error: initial wrong number of blocks") + } + return nil +} + +func (m migrationTest0020) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { + blockCount := `SELECT count(*) FROM state.block` + var count int + err := db.QueryRow(blockCount).Scan(&count) + assert.NoError(t, err) + assert.Equal(t, 6, count) +} + +func (m migrationTest0020) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +} + +func TestMigration0020(t *testing.T) { + runMigrationTest(t, 20, migrationTest0020{}) +} diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index d1e034fb76..946d74fdee 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -973,17 +973,18 @@ func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, synce BlockHash: b.Hash(), ParentHash: b.ParentHash(), } + if block.BlockNumber != reorgedBlock.BlockNumber { + err := fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", + reorgedBlock.BlockNumber, block.BlockNumber) + log.Error("error: ", err) + return nil, err + } } else { log.Infof("[checkReorg function] Using block %d from GetRollupInfoByBlockRange", block.BlockNumber) } log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.BlockNumber, block.BlockHash.String()) log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) - if block.BlockNumber != reorgedBlock.BlockNumber { - err := fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", - reorgedBlock.BlockNumber, block.BlockNumber) - log.Error("error: ", err) - return nil, err - } + // Compare hashes if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupManagerBlockNumber { log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index 2d2bf83c50..ef1ec076af 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -2010,3 +2010,273 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { err = sync.Sync() require.NoError(t, err) } + +func TestCallFromEmptyBlockAndReorg(t *testing.T) { + genesis := state.Genesis{ + BlockNumber: uint64(0), + } + cfg := Config{ + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + SyncChunkSize: 3, + L1SynchronizationMode: SequentialMode, + SyncBlockProtection: "latest", + L1BlockCheck: L1BlockCheckConfig{ + Enable: false, + }, + } + + m := mocks{ + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + State: mock_syncinterfaces.NewStateFullInterface(t), + Pool: mock_syncinterfaces.NewPoolInterface(t), + DbTx: syncMocks.NewDbTxMock(t), + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + } + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err) + + // state preparation + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + forkIdInterval := state.ForkIDInterval{ + ForkId: 9, + FromBatchNumber: 0, + ToBatchNumber: math.MaxUint64, + } + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + + m.State. + On("BeginStateTransaction", ctxMatchBy). + Run(func(args mock.Arguments) { + ctx := args[0].(context.Context) + parentHash := common.HexToHash("0x111") + ethHeader0 := ðTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + ethHeader1bis := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) + ethHeader2bis := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) + ethHeader1 := ðTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + ethHeader2 := ðTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + + m.State. + On("GetForkIDByBatchNumber", mock.Anything). + Return(uint64(9), nil). + Maybe() + m.State. + On("GetLastBlock", ctx, m.DbTx). + Return(lastBlock1, nil). + Once() + + m.State. + On("GetLastBatchNumber", ctx, m.DbTx). + Return(uint64(10), nil). + Once() + + m.State. + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("GetLatestBatchNumber"). + Return(uint64(10), nil) + + var nilDbTx pgx.Tx + m.State. + On("GetLastBatchNumber", ctx, nilDbTx). + Return(uint64(10), nil) + + m.Etherman. + On("GetLatestVerifiedBatchNum"). + Return(uint64(10), nil) + + m.State. + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + Return(nil) + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + Return(ethBlock1, nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader2bis, nil). + Once() + + // m.Etherman. + // On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + // Return(ethBlock1, nil). + // Once() + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + + ethermanBlock0 := etherman.Block{ + BlockNumber: 0, + ReceivedAt: ti, + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + } + ethermanBlock2bis := etherman.Block{ + BlockNumber: 2, + ReceivedAt: ti, + BlockHash: ethBlock2bis.Hash(), + ParentHash: ethBlock2bis.ParentHash(), + } + blocks := []etherman.Block{ethermanBlock2bis} + order := map[common.Hash][]etherman.Order{} + + fromBlock := ethBlock1.NumberU64() + toBlock := fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock2.NumberU64() { + toBlock = ethBlock2.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + var depth uint64 = 1 + stateBlock0 := &state.Block{ + BlockNumber: ethBlock0.NumberU64(), + BlockHash: ethBlock0.Hash(), + ParentHash: ethBlock0.ParentHash(), + ReceivedAt: ti, + } + m.State. + On("GetPreviousBlock", ctx, depth, m.DbTx). + Return(stateBlock0, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + m.State. + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + Return(nil). + Once() + + m.EthTxManager. + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + Return(nil). + Once() + + m.DbTx. + On("Commit", ctx). + Return(nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.ZKEVMClient. + On("BatchNumber", ctx). + Return(uint64(1), nil). + Once() + + m.Etherman. + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + Return(ethBlock0, nil). + Once() + + m.Etherman. + On("HeaderByNumber", mock.Anything, n). + Return(ethHeader2bis, nil). + Once() + + blocks = []etherman.Block{ethermanBlock0, ethermanBlock2bis} + fromBlock = ethBlock0.NumberU64() + toBlock = fromBlock + cfg.SyncChunkSize + if toBlock > ethBlock2.NumberU64() { + toBlock = ethBlock2.NumberU64() + } + m.Etherman. + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + Return(blocks, order, nil). + Once() + + m.Etherman. + On("GetFinalizedBlockNumber", ctx). + Return(ethBlock2bis.NumberU64(), nil). + Once() + + m.State. + On("BeginStateTransaction", ctx). + Return(m.DbTx, nil). + Once() + + stateBlock2bis := &state.Block{ + BlockNumber: ethermanBlock2bis.BlockNumber, + BlockHash: ethermanBlock2bis.BlockHash, + ParentHash: ethermanBlock2bis.ParentHash, + ReceivedAt: ethermanBlock2bis.ReceivedAt, + Checked: true, + } + m.State. + On("AddBlock", ctx, stateBlock2bis, m.DbTx). + Return(nil). + Once() + + m.State. + On("GetStoredFlushID", ctx). + Return(uint64(1), cProverIDExecution, nil). + Once() + + m.DbTx. + On("Commit", ctx). + Run(func(args mock.Arguments) { + sync.Stop() + ctx.Done() + }). + Return(nil). + Once() + }). + Return(m.DbTx, nil). + Once() + + err = sync.Sync() + require.NoError(t, err) +} From 6395e24379c35bc8d1f31674ad9503c8b4a85380 Mon Sep 17 00:00:00 2001 From: Alonso Rodriguez Date: Wed, 17 Apr 2024 15:22:38 +0200 Subject: [PATCH 07/21] Fix/#3565 reorg (#3566) * fix + logs * fix loop * Revert "fix + logs" This reverts commit 39ced69339f46f145aabdf03a93279b737d02bf0. --- synchronizer/synchronizer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 946d74fdee..0bb5bdd4db 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -600,9 +600,9 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc if lastEthBlockSynced.BlockNumber > 0 { fromBlock = lastEthBlockSynced.BlockNumber } + toBlock := fromBlock + s.cfg.SyncChunkSize for { - toBlock := fromBlock + s.cfg.SyncChunkSize if toBlock > lastKnownBlock.Uint64() { toBlock = lastKnownBlock.Uint64() } @@ -689,7 +689,8 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc break } - fromBlock = toBlock + fromBlock = lastEthBlockSynced.BlockNumber + toBlock = toBlock + s.cfg.SyncChunkSize } return lastEthBlockSynced, nil From 2d75bc04789f278e88eeded12d8e71f56f6c63b9 Mon Sep 17 00:00:00 2001 From: Alonso Rodriguez Date: Mon, 22 Apr 2024 13:31:09 +0200 Subject: [PATCH 08/21] fix L1InfoRoot when an error happens during the process of the L1 information (#3576) * fix * Comments + mock * avoid error from some L1providers when fromBlock is higher than toBlock * Revert some changes * comments * add L2BlockModulus to L1check * doc * fix dbTx = nil * fix unit tests --- config/default.go | 2 +- docs/config-file/node-config-doc.html | 2 +- docs/config-file/node-config-doc.md | 6 ++--- docs/config-file/node-config-schema.json | 2 +- state/l1infotree.go | 12 ++++++++++ state/reset.go | 7 +++++- state/state.go | 26 +++++++++++++++++++++- synchronizer/actions/check_l2block.go | 12 +++++++--- synchronizer/actions/check_l2block_test.go | 20 +++++++++++------ synchronizer/synchronizer.go | 14 +++++++++++- 10 files changed, 84 insertions(+), 19 deletions(-) diff --git a/config/default.go b/config/default.go index 0fd148ea16..1d41806e4e 100644 --- a/config/default.go +++ b/config/default.go @@ -105,7 +105,7 @@ TrustedSequencerURL = "" # If it is empty or not specified, then the value is re SyncBlockProtection = "safe" # latest, finalized, safe L1SynchronizationMode = "sequential" L1SyncCheckL2BlockHash = true -L1SyncCheckL2BlockNumberhModulus = 30 +L1SyncCheckL2BlockNumberhModulus = 600 [Synchronizer.L1BlockCheck] Enable = true L1SafeBlockPoint = "finalized" diff --git a/docs/config-file/node-config-doc.html b/docs/config-file/node-config-doc.html index 42256dc0e7..e21ad83563 100644 --- a/docs/config-file/node-config-doc.html +++ b/docs/config-file/node-config-doc.html @@ -16,7 +16,7 @@
"300ms"
 

Default: 500Type: number

MaxRequestsPerIPAndSecond defines how much requests a single IP can
send within a single second


Default: ""Type: string

SequencerNodeURI is used allow Non-Sequencer nodes
to relay transactions to the Sequencer node


Default: 0Type: integer

MaxCumulativeGasUsed is the max gas allowed per batch


WebSockets configuration
Default: trueType: boolean

Enabled defines if the WebSocket requests are enabled or disabled


Default: "0.0.0.0"Type: string

Host defines the network adapter that will be used to serve the WS requests


Default: 8546Type: integer

Port defines the port to serve the endpoints via WS


Default: 104857600Type: integer

ReadLimit defines the maximum size of a message read from the client (in bytes)


Default: trueType: boolean

EnableL2SuggestedGasPricePolling enables polling of the L2 gas price to block tx in the RPC with lower gas price.


Default: falseType: boolean

BatchRequestsEnabled defines if the Batch requests are enabled or disabled


Default: 20Type: integer

BatchRequestsLimit defines the limit of requests that can be incorporated into each batch request


Type: array of integer

L2Coinbase defines which address is going to receive the fees

Must contain a minimum of 20 items

Must contain a maximum of 20 items

Each item of this array must be:


Default: 10000Type: integer

MaxLogsCount is a configuration to set the max number of logs that can be returned
in a single call to the state, if zero it means no limit


Default: 10000Type: integer

MaxLogsBlockRange is a configuration to set the max range for block number when querying TXs
logs in a single call to the state, if zero it means no limit


Default: 60000Type: integer

MaxNativeBlockHashBlockRange is a configuration to set the max range for block number when querying
native block hashes in a single call to the state, if zero it means no limit


Default: trueType: boolean

EnableHttpLog allows the user to enable or disable the logs related to the HTTP
requests to be captured by the server.


ZKCountersLimits defines the ZK Counter limits
Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Default: 0Type: integer

Configuration of service `Syncrhonizer`. For this service is also really important the value of `IsTrustedSequencer` because depending of this values is going to ask to a trusted node for trusted transactions or not
Default: "1s"Type: string

SyncInterval is the delay interval between reading new rollup information


Examples:

"1m"
 
"300ms"
-

Default: 100Type: integer

SyncChunkSize is the number of blocks to sync on each chunk


Default: ""Type: string

TrustedSequencerURL is the rpc url to connect and sync the trusted state


Default: "safe"Type: string

SyncBlockProtection specify the state to sync (lastest, finalized or safe)


Default: trueType: boolean

L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)


Default: 30Type: integer

L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)


Default: trueType: boolean

Enable if is true then the check l1 Block Hash is active


Default: "finalized"Type: enum (of string)

L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: trueType: boolean

ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks


Default: trueType: boolean

PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock


Default: "safe"Type: enum (of string)

L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: "sequential"Type: enum (of string)

L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute

Must be one of:

  • "sequential"
  • "parallel"

L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel')
Default: 10Type: integer

MaxClients Number of clients used to synchronize with L1


Default: 25Type: integer

MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients


Default: "5s"Type: string

RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized


Examples:

"1m"
+

Default: 100Type: integer

SyncChunkSize is the number of blocks to sync on each chunk


Default: ""Type: string

TrustedSequencerURL is the rpc url to connect and sync the trusted state


Default: "safe"Type: string

SyncBlockProtection specify the state to sync (lastest, finalized or safe)


Default: trueType: boolean

L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)


Default: 600Type: integer

L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)


Default: trueType: boolean

Enable if is true then the check l1 Block Hash is active


Default: "finalized"Type: enum (of string)

L1SafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point
it can be positive or negative
Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: trueType: boolean

ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks


Default: trueType: boolean

PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock


Default: "safe"Type: enum (of string)

L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked
it can be: finalized, safe,pending or latest

Must be one of:

  • "finalized"
  • "safe"
  • "latest"

Default: 0Type: integer

L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point
it can be positive or negative
Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block


Default: "sequential"Type: enum (of string)

L1SynchronizationMode define how to synchronize with L1:
- parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data
- sequential: Request data to L1 and execute

Must be one of:

  • "sequential"
  • "parallel"

L1ParallelSynchronization Configuration for parallel mode (if L1SynchronizationMode equal to 'parallel')
Default: 10Type: integer

MaxClients Number of clients used to synchronize with L1


Default: 25Type: integer

MaxPendingNoProcessedBlocks Size of the buffer used to store rollup information from L1, must be >= to NumberOfEthereumClientsToSync
sugested twice of NumberOfParallelOfEthereumClients


Default: "5s"Type: string

RequestLastBlockPeriod is the time to wait to request the
last block to L1 to known if we need to retrieve more data.
This value only apply when the system is synchronized


Examples:

"1m"
 
"300ms"
 

Consumer Configuration for the consumer of rollup information from L1
Default: "5s"Type: string

AceptableInacctivityTime is the expected maximum time that the consumer
could wait until new data is produced. If the time is greater it emmit a log to warn about
that. The idea is keep working the consumer as much as possible, so if the producer is not
fast enought then you could increse the number of parallel clients to sync with L1


Examples:

"1m"
 
"300ms"
diff --git a/docs/config-file/node-config-doc.md b/docs/config-file/node-config-doc.md
index aecef0265b..925ac0f95c 100644
--- a/docs/config-file/node-config-doc.md
+++ b/docs/config-file/node-config-doc.md
@@ -1433,15 +1433,15 @@ L1SyncCheckL2BlockHash=true
 
 **Type:** : `integer`
 
-**Default:** `30`
+**Default:** `600`
 
 **Description:** L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check
 a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
 
-**Example setting the default value** (30):
+**Example setting the default value** (600):
 ```
 [Synchronizer]
-L1SyncCheckL2BlockNumberhModulus=30
+L1SyncCheckL2BlockNumberhModulus=600
 ```
 
 ### 9.7. `[Synchronizer.L1BlockCheck]`
diff --git a/docs/config-file/node-config-schema.json b/docs/config-file/node-config-schema.json
index e95dc565b8..517a846e4f 100644
--- a/docs/config-file/node-config-schema.json
+++ b/docs/config-file/node-config-schema.json
@@ -530,7 +530,7 @@
 				"L1SyncCheckL2BlockNumberhModulus": {
 					"type": "integer",
 					"description": "L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check\na modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)",
-					"default": 30
+					"default": 600
 				},
 				"L1BlockCheck": {
 					"properties": {
diff --git a/state/l1infotree.go b/state/l1infotree.go
index 8cac9ea5d7..8c081f880c 100644
--- a/state/l1infotree.go
+++ b/state/l1infotree.go
@@ -3,6 +3,7 @@ package state
 import (
 	"context"
 	"errors"
+	"fmt"
 
 	"github.com/0xPolygonHermez/zkevm-node/l1infotree"
 	"github.com/0xPolygonHermez/zkevm-node/log"
@@ -54,6 +55,14 @@ func (s *State) buildL1InfoTreeCacheIfNeed(ctx context.Context, dbTx pgx.Tx) err
 
 // AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error
 func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) {
+	var stateTx *StateTx
+	if dbTx != nil {
+		var ok bool
+		stateTx, ok = dbTx.(*StateTx)
+		if !ok {
+			return nil, fmt.Errorf("error casting dbTx to stateTx")
+		}
+	}
 	var newIndex uint32
 	gerIndex, err := s.GetLatestIndex(ctx, dbTx)
 	if err != nil && !errors.Is(err, ErrNotFound) {
@@ -73,6 +82,9 @@ func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTre
 		log.Error("error add new leaf to the L1InfoTree. Error: ", err)
 		return nil, err
 	}
+	if stateTx != nil {
+		stateTx.SetL1InfoTreeModified()
+	}
 	entry := L1InfoTreeExitRootStorageEntry{
 		L1InfoTreeLeaf:  *l1InfoTreeLeaf,
 		L1InfoTreeRoot:  root,
diff --git a/state/reset.go b/state/reset.go
index 655f5f3dd1..e1c5a72675 100644
--- a/state/reset.go
+++ b/state/reset.go
@@ -18,10 +18,15 @@ func (s *State) Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) erro
 		log.Error("error resetting L1BlockNumber. Error: ", err)
 		return err
 	}
+	s.ResetL1InfoTree()
+	return nil
+}
+
+// ResetL1InfoTree resets the L1InfoTree
+func (s *State) ResetL1InfoTree() {
 	// Discard L1InfoTree cache
 	// We can't rebuild cache, because we are inside a transaction, so we dont known
 	// is going to be a commit or a rollback. So is going to be rebuild on the next
 	// request that needs it.
 	s.l1InfoTree = nil
-	return nil
 }
diff --git a/state/state.go b/state/state.go
index a1a754242f..4c662035f8 100644
--- a/state/state.go
+++ b/state/state.go
@@ -62,13 +62,37 @@ func NewState(cfg Config, storage storage, executorClient executor.ExecutorServi
 	return state
 }
 
+// StateTx is the state transaction that extends the database tx
+type StateTx struct {
+	pgx.Tx
+	stateInstance      *State
+	L1InfoTreeModified bool
+}
+
 // BeginStateTransaction starts a state transaction
 func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) {
 	tx, err := s.Begin(ctx)
 	if err != nil {
 		return nil, err
 	}
-	return tx, nil
+	res := &StateTx{
+		Tx:            tx,
+		stateInstance: s,
+	}
+	return res, nil
+}
+
+// Rollback do the dbTx rollback + modifications in cache mechanism
+func (tx *StateTx) Rollback(ctx context.Context) error {
+	if tx.L1InfoTreeModified {
+		tx.stateInstance.ResetL1InfoTree()
+	}
+	return tx.Tx.Rollback(ctx)
+}
+
+// SetL1InfoTreeModified sets the flag to true to save that the L1InfoTree has been modified
+func (tx *StateTx) SetL1InfoTreeModified() {
+	tx.L1InfoTreeModified = true
 }
 
 // GetBalance from a given address
diff --git a/synchronizer/actions/check_l2block.go b/synchronizer/actions/check_l2block.go
index 14c9e5cb19..4a864e3a2f 100644
--- a/synchronizer/actions/check_l2block.go
+++ b/synchronizer/actions/check_l2block.go
@@ -36,13 +36,16 @@ type CheckL2BlockHash struct {
 func NewCheckL2BlockHash(state stateGetL2Block,
 	trustedClient trustedRPCGetL2Block,
 	initialL2BlockNumber uint64,
-	modulusBlockNumber uint64) *CheckL2BlockHash {
+	modulusBlockNumber uint64) (*CheckL2BlockHash, error) {
+	if modulusBlockNumber == 0 {
+		return nil, fmt.Errorf("error: modulusBlockNumber is zero")
+	}
 	return &CheckL2BlockHash{
 		state:                 state,
 		trustedClient:         trustedClient,
 		lastL2BlockChecked:    initialL2BlockNumber,
 		modulusL2BlockToCheck: modulusBlockNumber,
-	}
+	}, nil
 }
 
 // CheckL2Block checks the  L2Block hash between the local and the trusted
@@ -74,6 +77,9 @@ func (p *CheckL2BlockHash) GetNextL2BlockToCheck(lastLocalL2BlockNumber, minL2Bl
 		log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber)
 		return false, 0
 	}
+	if l2BlockNumber%p.modulusL2BlockToCheck != 0 {
+		return false, 0
+	}
 	return true, l2BlockNumber
 }
 
@@ -95,7 +101,7 @@ func (p *CheckL2BlockHash) GetL2Blocks(ctx context.Context, blockNumber uint64,
 	trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber)))
 	if err != nil {
 		log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error())
-		return nil, nil, err
+		return nil, nil, nil
 	}
 	return localL2Block, trustedL2Block, nil
 }
diff --git a/synchronizer/actions/check_l2block_test.go b/synchronizer/actions/check_l2block_test.go
index 28a8a503b7..cdbf61a981 100644
--- a/synchronizer/actions/check_l2block_test.go
+++ b/synchronizer/actions/check_l2block_test.go
@@ -32,12 +32,15 @@ func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) {
 		{1, 10, 10},
 		{9, 10, 10},
 		{10, 10, 20},
-		{0, 0, 1},
-		{1, 0, 2},
+		{0, 1, 1},
+		{1, 1, 2},
 	}
+	_, err := actions.NewCheckL2BlockHash(nil, nil, 1, 0)
+	require.Error(t, err)
 	for _, data := range values {
 		// Call the GetNextL2BlockToCheck method
-		checkL2Block := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus)
+		checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus)
+		require.NoError(t, err)
 		nextL2Block := checkL2Block.GetMinimumL2BlockToCheck()
 
 		// Assert the expected result
@@ -58,7 +61,9 @@ func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) Chec
 		mockState:   mock_syncinterfaces.NewStateFullInterface(t),
 		zKEVMClient: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t),
 	}
-	res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus)
+	var err error
+	res.sut, err = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus)
+	require.NoError(t, err)
 	return res
 }
 func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
@@ -77,7 +82,8 @@ func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
 	}
 
 	for _, data := range values {
-		checkL2Block := actions.NewCheckL2BlockHash(nil, nil, 0, 0)
+		checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, 0, 1)
+		require.NoError(t, err)
 		shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck)
 
 		assert.Equal(t, data.expectedShouldCheck, shouldCheck, data)
@@ -86,7 +92,7 @@ func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
 }
 
 func TestCheckL2BlockHashMatch(t *testing.T) {
-	data := newCheckL2BlocksTestData(t, 1, 10)
+	data := newCheckL2BlocksTestData(t, 1, 14)
 	lastL2Block := uint64(14)
 	lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
 	gethHeader := types.Header{
@@ -113,7 +119,7 @@ func TestCheckL2BlockHashMatch(t *testing.T) {
 }
 
 func TestCheckL2BlockHashMismatch(t *testing.T) {
-	data := newCheckL2BlocksTestData(t, 1, 10)
+	data := newCheckL2BlocksTestData(t, 1, 14)
 	lastL2Block := uint64(14)
 	lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
 	gethHeader := types.Header{
diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go
index 0bb5bdd4db..32558f4eff 100644
--- a/synchronizer/synchronizer.go
+++ b/synchronizer/synchronizer.go
@@ -183,7 +183,11 @@ func NewSynchronizer(
 				log.Errorf("error getting last L2Block number from state. Error: %v", err)
 				return nil, err
 			}
-			l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus)
+			l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus)
+			if err != nil {
+				log.Error("error creating new instance of checkL2BlockHash. Error: ", err)
+				return nil, err
+			}
 		} else {
 			log.Infof("Trusted Node can't check L2Block hash, ignoring parameter")
 		}
@@ -604,8 +608,13 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc
 
 	for {
 		if toBlock > lastKnownBlock.Uint64() {
+			log.Debug("Setting toBlock to the lastKnownBlock")
 			toBlock = lastKnownBlock.Uint64()
 		}
+		if fromBlock > toBlock {
+			log.Debug("FromBlock is higher than toBlock. Skipping...")
+			return lastEthBlockSynced, nil
+		}
 		log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64())
 		log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock)
 		// This function returns the rollup information contained in the ethereum blocks and an extra param called order.
@@ -730,6 +739,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma
 		// Add block information
 		err = s.state.AddBlock(s.ctx, &b, dbTx)
 		if err != nil {
+			// If any goes wrong we ensure that the state is rollbacked
 			log.Errorf("error storing block. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err)
 			rollbackErr := dbTx.Rollback(s.ctx)
 			if rollbackErr != nil {
@@ -766,6 +776,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma
 		log.Debug("Checking FlushID to commit L1 data to db")
 		err = s.checkFlushID(dbTx)
 		if err != nil {
+			// If any goes wrong we ensure that the state is rollbacked
 			log.Errorf("error checking flushID. Error: %v", err)
 			rollbackErr := dbTx.Rollback(s.ctx)
 			if rollbackErr != nil {
@@ -776,6 +787,7 @@ func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order ma
 		}
 		err = dbTx.Commit(s.ctx)
 		if err != nil {
+			// If any goes wrong we ensure that the state is rollbacked
 			log.Errorf("error committing state to store block. BlockNumber: %d, err: %v", blocks[i].BlockNumber, err)
 			rollbackErr := dbTx.Rollback(s.ctx)
 			if rollbackErr != nil {

From bc951bcb68a995e9744d7d63ce7f4a26e3358f25 Mon Sep 17 00:00:00 2001
From: agnusmor 
Date: Mon, 22 Apr 2024 10:11:26 +0200
Subject: [PATCH 09/21] added logs to analyze blocking issue when storing L2
 block

---
 sequencer/l2block.go | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sequencer/l2block.go b/sequencer/l2block.go
index c674bf4a18..c60dcd0ebd 100644
--- a/sequencer/l2block.go
+++ b/sequencer/l2block.go
@@ -413,6 +413,8 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		return err
 	}
 
+	log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum)
+
 	// Update txs status in the pool
 	for _, txResponse := range blockResponse.TransactionResponses {
 		// Change Tx status to selected
@@ -422,6 +424,8 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		}
 	}
 
+	log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum)
+
 	// Send L2 block to data streamer
 	err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
 	if err != nil {
@@ -429,6 +433,8 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
 	}
 
+	log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum)
+
 	for _, tx := range l2Block.transactions {
 		// Delete the tx from the pending list in the worker (addrQueue)
 		f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From)

From 7b6a0ac1a559a6f712bb7555720501629c22c8cd Mon Sep 17 00:00:00 2001
From: agnusmor 
Date: Mon, 22 Apr 2024 16:33:29 +0200
Subject: [PATCH 10/21] add debug logs for datastreamer

---
 sequencer/datastreamer.go |  2 ++
 sequencer/l2block.go      |  3 +++
 sequencer/sequencer.go    | 17 +++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go
index 700b8b3e02..bbbfe14496 100644
--- a/sequencer/datastreamer.go
+++ b/sequencer/datastreamer.go
@@ -1,6 +1,7 @@
 package sequencer
 
 import (
+	"github.com/0xPolygonHermez/zkevm-node/log"
 	"github.com/0xPolygonHermez/zkevm-node/state"
 )
 
@@ -42,6 +43,7 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce
 			l2Transactions = append(l2Transactions, l2Transaction)
 		}
 
+		log.Infof("sending l2block %d to datastream channel", blockResponse.BlockNumber)
 		f.dataToStream <- state.DSL2FullBlock{
 			DSL2Block: l2Block,
 			Txs:       l2Transactions,
diff --git a/sequencer/l2block.go b/sequencer/l2block.go
index c60dcd0ebd..3b5f10ca02 100644
--- a/sequencer/l2block.go
+++ b/sequencer/l2block.go
@@ -413,6 +413,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		return err
 	}
 
+	//TODO: remove this log
 	log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum)
 
 	// Update txs status in the pool
@@ -424,6 +425,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		}
 	}
 
+	//TODO: remove this log
 	log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum)
 
 	// Send L2 block to data streamer
@@ -433,6 +435,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error {
 		log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
 	}
 
+	//TODO: remove this log
 	log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum)
 
 	for _, tx := range l2Block.transactions {
diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go
index 64b5711fae..22201776ce 100644
--- a/sequencer/sequencer.go
+++ b/sequencer/sequencer.go
@@ -256,6 +256,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 			case state.DSL2FullBlock:
 				l2Block := data
 
+				//TODO: remove this log
+				log.Infof("start atomic op for l2block %d", l2Block.L2BlockNumber)
 				err = s.streamServer.StartAtomicOp()
 				if err != nil {
 					log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
@@ -267,6 +269,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 					Value: l2Block.L2BlockNumber,
 				}
 
+				//TODO: remove this log
+				log.Infof("add stream bookmark for l2block %d", l2Block.L2BlockNumber)
 				_, err = s.streamServer.AddStreamBookmark(bookMark.Encode())
 				if err != nil {
 					log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err)
@@ -281,6 +285,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 						Value: l2Block.L2BlockNumber - 1,
 					}
 
+					//TODO: remove this log
+					log.Infof("get previous l2block %d", l2Block.L2BlockNumber-1)
 					previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
 					if err != nil {
 						log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err)
@@ -303,12 +309,16 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 					ChainID:         uint32(chainID),
 				}
 
+				//TODO: remove this log
+				log.Infof("add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber)
 				_, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode())
 				if err != nil {
 					log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
 					continue
 				}
 
+				//TODO: remove this log
+				log.Infof("adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber)
 				for _, l2Transaction := range l2Block.Txs {
 					_, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode())
 					if err != nil {
@@ -323,18 +333,25 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) {
 					StateRoot:     l2Block.StateRoot,
 				}
 
+				//TODO: remove this log
+				log.Infof("add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber)
 				_, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode())
 				if err != nil {
 					log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
 					continue
 				}
 
+				//TODO: remove this log
+				log.Infof("commit atomic op for l2block %d", l2Block.L2BlockNumber)
 				err = s.streamServer.CommitAtomicOp()
 				if err != nil {
 					log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
 					continue
 				}
 
+				//TODO: remove this log
+				log.Infof("l2block %d sent to datastream", l2Block.L2BlockNumber)
+
 			// Stream a bookmark
 			case state.DSBookMark:
 				bookmark := data

From 94dc3054d2096068591c46c8390275a6d8b1b526 Mon Sep 17 00:00:00 2001
From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com>
Date: Tue, 23 Apr 2024 10:29:01 +0200
Subject: [PATCH 11/21] fix #3581 synchronizer panic synchronizing from trusted
 node (#3582)

---
 .../l2_shared/processor_trusted_batch_sync.go     |  4 ++++
 .../l2_sync/l2_shared/trusted_batches_retrieve.go | 15 +++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go b/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
index db4ddd15e0..d0f6557d1e 100644
--- a/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
+++ b/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
@@ -171,6 +171,10 @@ func (s *ProcessorTrustedBatchSync) AddPostChecker(checker PostClosedBatchChecke
 
 // ProcessTrustedBatch processes a trusted batch and return the new state
 func (s *ProcessorTrustedBatchSync) ProcessTrustedBatch(ctx context.Context, trustedBatch *types.Batch, status TrustedState, dbTx pgx.Tx, debugPrefix string) (*TrustedState, error) {
+	if trustedBatch == nil {
+		log.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix)
+		return nil, fmt.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix)
+	}
 	log.Debugf("%s Processing trusted batch: %v", debugPrefix, trustedBatch.Number)
 	stateCurrentBatch, statePreviousBatch := s.GetCurrentAndPreviousBatchFromCache(&status)
 	if s.l1SyncChecker != nil {
diff --git a/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go b/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
index 70311c6966..c3e36e59ae 100644
--- a/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
+++ b/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
@@ -109,6 +109,16 @@ func isSyncrhonizedTrustedState(lastTrustedStateBatchNumber uint64, latestSynced
 	return lastTrustedStateBatchNumber < latestSyncedBatch
 }
 
+func sanityCheckBatchReturnedByTrusted(batch *types.Batch, expectedBatchNumber uint64) error {
+	if batch == nil {
+		return fmt.Errorf("batch %d is nil", expectedBatchNumber)
+	}
+	if uint64(batch.Number) != expectedBatchNumber {
+		return fmt.Errorf("batch %d is not the expected batch %d", batch.Number, expectedBatchNumber)
+	}
+	return nil
+}
+
 func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, latestSyncedBatch uint64, lastTrustedStateBatchNumber uint64) error {
 	batchNumberToSync := max(latestSyncedBatch, s.firstBatchNumberToSync)
 	for batchNumberToSync <= lastTrustedStateBatchNumber {
@@ -120,6 +130,11 @@ func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, l
 			log.Warnf("%s failed to get batch %d from trusted state. Error: %v", debugPrefix, batchNumberToSync, err)
 			return err
 		}
+		err = sanityCheckBatchReturnedByTrusted(batchToSync, batchNumberToSync)
+		if err != nil {
+			log.Warnf("%s sanity check over Batch returned by Trusted-RPC failed: %v", debugPrefix, err)
+			return err
+		}
 
 		dbTx, err := s.state.BeginStateTransaction(ctx)
 		if err != nil {

From b45d78ed95573e472996dda58ab78c96e209e40f Mon Sep 17 00:00:00 2001
From: Joan Esteban <129153821+joanestebanr@users.noreply.github.com>
Date: Tue, 23 Apr 2024 15:13:59 +0200
Subject: [PATCH 12/21] synchronized: #3583  stop sync from l2 after no closed
 batch (#3584)

* stop processing trusted Node after first open batch
---
 .../l2_shared/processor_trusted_batch_sync.go |   4 +-
 .../tests/trusted_batches_retrieve_test.go    | 117 ++++++++++++++++++
 .../l2_shared/trusted_batches_retrieve.go     |   4 +
 3 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100644 synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go

diff --git a/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go b/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
index d0f6557d1e..5463555d94 100644
--- a/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
+++ b/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go
@@ -378,7 +378,9 @@ func (s *ProcessorTrustedBatchSync) GetModeForProcessBatch(trustedNodeBatch *typ
 	result.OldAccInputHash = statePreviousBatch.AccInputHash
 	result.Now = s.timeProvider.Now()
 	result.DebugPrefix = fmt.Sprintf("%s mode %s:", debugPrefix, result.Mode)
-
+	if result.BatchMustBeClosed {
+		result.DebugPrefix += " (must_be_closed)"
+	}
 	if isTrustedBatchEmptyAndClosed(trustedNodeBatch) {
 		if s.Cfg.AcceptEmptyClosedBatches {
 			log.Infof("%s Batch %v: TrustedBatch Empty and closed, accepted due configuration", result.DebugPrefix, trustedNodeBatch.Number)
diff --git a/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go b/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go
new file mode 100644
index 0000000000..f050fa565f
--- /dev/null
+++ b/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go
@@ -0,0 +1,117 @@
+package test_l2_shared
+
+import (
+	"context"
+	"math/big"
+	"testing"
+
+	"github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
+	"github.com/0xPolygonHermez/zkevm-node/state"
+	"github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
+	mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks"
+	"github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared"
+	l2sharedmocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared/mocks"
+	syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks"
+	"github.com/stretchr/testify/mock"
+	"github.com/stretchr/testify/require"
+)
+
+type testDataTrustedBatchRetrieve struct {
+	mockBatchProcessor *l2sharedmocks.BatchProcessor
+	mockZkEVMClient    *mock_syncinterfaces.ZKEVMClientTrustedBatchesGetter
+	mockState          *l2sharedmocks.StateInterface
+	mockSync           *mock_syncinterfaces.SynchronizerFlushIDManager
+	mockTimer          *common.MockTimerProvider
+	mockDbTx           *syncMocks.DbTxMock
+	TrustedStateMngr   *l2_shared.TrustedStateManager
+	sut                *l2_shared.TrustedBatchesRetrieve
+	ctx                context.Context
+}
+
+func newTestDataTrustedBatchRetrieve(t *testing.T) *testDataTrustedBatchRetrieve {
+	mockBatchProcessor := l2sharedmocks.NewBatchProcessor(t)
+	mockZkEVMClient := mock_syncinterfaces.NewZKEVMClientTrustedBatchesGetter(t)
+	mockState := l2sharedmocks.NewStateInterface(t)
+	mockSync := mock_syncinterfaces.NewSynchronizerFlushIDManager(t)
+	mockTimer := &common.MockTimerProvider{}
+	mockDbTx := syncMocks.NewDbTxMock(t)
+	TrustedStateMngr := l2_shared.NewTrustedStateManager(mockTimer, 0)
+	sut := l2_shared.NewTrustedBatchesRetrieve(mockBatchProcessor, mockZkEVMClient, mockState, mockSync, *TrustedStateMngr)
+	ctx := context.TODO()
+	return &testDataTrustedBatchRetrieve{
+		mockBatchProcessor: mockBatchProcessor,
+		mockZkEVMClient:    mockZkEVMClient,
+		mockState:          mockState,
+		mockSync:           mockSync,
+		mockTimer:          mockTimer,
+		mockDbTx:           mockDbTx,
+		TrustedStateMngr:   TrustedStateMngr,
+		sut:                sut,
+		ctx:                ctx,
+	}
+}
+
+const (
+	closedBatch    = true
+	notClosedBatch = false
+)
+
+// This test must do from 100 to 104.
+// But the batch 100 is open on TrustedNode so it stop processing
+func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatch(t *testing.T) {
+	data := newTestDataTrustedBatchRetrieve(t)
+	data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil)
+
+	expectationsForSyncTrustedStateIteration(t, 100, notClosedBatch, data)
+
+	err := data.sut.SyncTrustedState(data.ctx, 100, 104)
+	require.NoError(t, err)
+}
+
+// This must process 100 (that is closed)
+// and stop processing at 101 because is not yet close this batch
+func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase2(t *testing.T) {
+	data := newTestDataTrustedBatchRetrieve(t)
+	data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil)
+
+	expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data)
+	expectationsForSyncTrustedStateIteration(t, 101, notClosedBatch, data)
+
+	err := data.sut.SyncTrustedState(data.ctx, 100, 104)
+	require.NoError(t, err)
+}
+
+// This test must do from 100 to 102. Is for check manually that the logs
+// That is not tested but must not emit the log:
+//   - Batch 101 is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state
+func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase3(t *testing.T) {
+	data := newTestDataTrustedBatchRetrieve(t)
+	data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil)
+	expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data)
+	expectationsForSyncTrustedStateIteration(t, 101, closedBatch, data)
+	expectationsForSyncTrustedStateIteration(t, 102, notClosedBatch, data)
+
+	err := data.sut.SyncTrustedState(data.ctx, 100, 102)
+	require.NoError(t, err)
+}
+
+func expectationsForSyncTrustedStateIteration(t *testing.T, batchNumber uint64, closed bool, data *testDataTrustedBatchRetrieve) {
+	batch100 := &types.Batch{
+		Number: types.ArgUint64(batchNumber),
+		Closed: closed,
+	}
+	data.mockZkEVMClient.EXPECT().BatchByNumber(data.ctx, big.NewInt(0).SetUint64(batchNumber)).Return(batch100, nil)
+	data.mockState.EXPECT().BeginStateTransaction(data.ctx).Return(data.mockDbTx, nil)
+	// Get Previous Batch 99 from State
+	stateBatch99 := &state.Batch{
+		BatchNumber: batchNumber - 1,
+	}
+	data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber-1), data.mockDbTx).Return(stateBatch99, nil)
+	stateBatch100 := &state.Batch{
+		BatchNumber: batchNumber,
+	}
+	data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber), data.mockDbTx).Return(stateBatch100, nil)
+	data.mockBatchProcessor.EXPECT().ProcessTrustedBatch(data.ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil)
+	data.mockSync.EXPECT().CheckFlushID(mock.Anything).Return(nil)
+	data.mockDbTx.EXPECT().Commit(data.ctx).Return(nil)
+}
diff --git a/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go b/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
index c3e36e59ae..b4031b4653 100644
--- a/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
+++ b/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go
@@ -176,6 +176,10 @@ func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, l
 			s.TrustedStateMngr.Clear()
 		}
 		batchNumberToSync++
+		if !batchToSync.Closed && batchNumberToSync <= lastTrustedStateBatchNumber {
+			log.Infof("%s Batch %d is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state", debugPrefix, batchToSync.Number)
+			return nil
+		}
 	}
 
 	log.Infof("syncTrustedState: Trusted state fully synchronized from %d to %d", latestSyncedBatch, lastTrustedStateBatchNumber)

From 4dc6f3be0e7ceb990f24ff2df798fe96da2e5e84 Mon Sep 17 00:00:00 2001
From: dPunisher 
Date: Wed, 24 Apr 2024 11:55:02 +0200
Subject: [PATCH 13/21] Update datastream lib to the latest version with
 additional debug info

---
 go.mod | 3 +--
 go.sum | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/go.mod b/go.mod
index e3b99a3a5f..aae887f746 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/0xPolygonHermez/zkevm-node
 go 1.21
 
 require (
-	github.com/0xPolygonHermez/zkevm-data-streamer v0.1.18
+	github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240422135400-0df0d27226b3
 	github.com/didip/tollbooth/v6 v6.1.2
 	github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127
 	github.com/ethereum/go-ethereum v1.13.11
@@ -175,7 +175,6 @@ require (
 	github.com/0xPolygon/agglayer v0.0.1
 	github.com/0xPolygon/cdk-data-availability v0.0.5
 	github.com/fatih/color v1.16.0
-	github.com/joho/godotenv v1.5.1
 	github.com/prometheus/client_golang v1.18.0
 	golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
 )
diff --git a/go.sum b/go.sum
index aa214a13e8..28077173da 100644
--- a/go.sum
+++ b/go.sum
@@ -43,8 +43,8 @@ github.com/0xPolygon/agglayer v0.0.1 h1:J6/DUo9rNUncDifquanouRCo2g7g069yvz0aFtu7
 github.com/0xPolygon/agglayer v0.0.1/go.mod h1:UYp5O8THULoXVrUfzkRjVBzxHR5DxBdUN/Iq0EgxNxM=
 github.com/0xPolygon/cdk-data-availability v0.0.5 h1://vg1oR/5tw2XfEIorpP+wIxLfNUmoKrdmX8YZvBKX4=
 github.com/0xPolygon/cdk-data-availability v0.0.5/go.mod h1:aGwqHiJhL+mJbdepl3s58wsY18EuViDa9vZCpPuIYGw=
-github.com/0xPolygonHermez/zkevm-data-streamer v0.1.18 h1:InqeTcHrNbfj1OUfn2aFplFay7ibd7KhYqvmMZYZfn0=
-github.com/0xPolygonHermez/zkevm-data-streamer v0.1.18/go.mod h1:0QkAXcFa92mFJrCbN3UPUJGJYes851yEgYHLONnaosE=
+github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240422135400-0df0d27226b3 h1:g5IMJalQxVRNfnXrzQG7bx2COktaFBf1mNuF4SLuQss=
+github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240422135400-0df0d27226b3/go.mod h1:0QkAXcFa92mFJrCbN3UPUJGJYes851yEgYHLONnaosE=
 github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
 github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
 github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
@@ -492,8 +492,6 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
 github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
 github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
 github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
-github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
-github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
 github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=

From 578052e1e5c3b25648a2ebc60367daf77ced85db Mon Sep 17 00:00:00 2001
From: dPunisher 
Date: Wed, 24 Apr 2024 12:06:01 +0200
Subject: [PATCH 14/21] update dslib client interface

---
 tools/datastreamer/main.go | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go
index 41f3611f1f..975e4c7ecd 100644
--- a/tools/datastreamer/main.go
+++ b/tools/datastreamer/main.go
@@ -558,14 +558,13 @@ func decodeEntry(cliCtx *cli.Context) error {
 		os.Exit(1)
 	}
 
-	client.FromEntry = cliCtx.Uint64("entry")
-	err = client.ExecCommand(datastreamer.CmdEntry)
+	entry, err := client.ExecCommandGetEntry(cliCtx.Uint64("entry"))
 	if err != nil {
 		log.Error(err)
 		os.Exit(1)
 	}
 
-	printEntry(client.Entry)
+	printEntry(entry)
 	return nil
 }
 
@@ -597,35 +596,28 @@ func decodeL2Block(cliCtx *cli.Context) error {
 		Value: l2BlockNumber,
 	}
 
-	client.FromBookmark = bookMark.Encode()
-	err = client.ExecCommand(datastreamer.CmdBookmark)
+	firstEntry, err := client.ExecCommandGetBookmark(bookMark.Encode())
 	if err != nil {
 		log.Error(err)
 		os.Exit(1)
 	}
-
-	firstEntry := client.Entry
 	printEntry(firstEntry)
 
-	client.FromEntry = firstEntry.Number + 1
-	err = client.ExecCommand(datastreamer.CmdEntry)
+	secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1)
 	if err != nil {
 		log.Error(err)
 		os.Exit(1)
 	}
-
-	secondEntry := client.Entry
 	printEntry(secondEntry)
 
 	i := uint64(2) //nolint:gomnd
 	for secondEntry.Type == state.EntryTypeL2Tx {
-		client.FromEntry = firstEntry.Number + i
-		err = client.ExecCommand(datastreamer.CmdEntry)
+		entry, err := client.ExecCommandGetEntry(firstEntry.Number + i)
 		if err != nil {
 			log.Error(err)
 			os.Exit(1)
 		}
-		secondEntry = client.Entry
+		secondEntry = entry
 		printEntry(secondEntry)
 		i++
 	}

From 59f7ebb618e710619017db7a89501f407e43ad7b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= 
Date: Fri, 26 Apr 2024 08:07:18 +0200
Subject: [PATCH 15/21] Update the diff

---
 docs/diff/diff.html | 195056 ++++++++++++++++++++++++++++++++---------
 1 file changed, 151798 insertions(+), 43258 deletions(-)

diff --git a/docs/diff/diff.html b/docs/diff/diff.html
index 178e9ca43f..c78fe91488 100644
--- a/docs/diff/diff.html
+++ b/docs/diff/diff.html
@@ -54,7 +54,7 @@ 

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

- Files changed (107) + Files changed (137) hide show
@@ -210,8 +210,8 @@

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

{/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go - +6 - -0 + +15 + -1 @@ -294,7 +294,7 @@

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go - +139 + +152 -0 @@ -330,7 +330,7 @@

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

{/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go - +58 + +60 -0 @@ -371,6 +371,54 @@

zkEVM node vs CDK validium node

zkevm-node version: v0.6.0

+
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql + + +25 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go + + +145 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020.sql + + +28 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020_test.go + + +99 + -0 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go - +198 - -145 + +292 + -136
  • @@ -438,7 +486,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go - +40 + +42 -31 @@ -450,7 +498,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go - +7 + +16 -0 @@ -462,7 +510,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - +26 + +27 -2 @@ -498,8 +546,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod - +9 - -7 + +11 + -8 @@ -522,7 +570,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go - +29 + +40 -0 @@ -534,8 +582,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go - +4 - -1 + +10 + -3 @@ -546,8 +594,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go - +235 - -0 + +236 + -1 @@ -558,7 +606,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go - +37 + +48 -1 @@ -606,7 +654,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go - +2 + +3 -1 @@ -743,6 +791,30 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/addrqueue.go + + +4 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/datastreamer.go + + +1 + -0 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - +18 - -4 + +103 + -26 + +
    +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go + + +4 + -2
  • @@ -762,7 +846,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go - +2 + +11 + -0 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go + + +19 + -2 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/worker.go + + +20 -0 @@ -882,7 +990,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - +5 + +8 -1 @@ -894,8 +1002,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree.go - +7 - -8 + +18 + -7
  • @@ -906,7 +1014,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/block.go - +39 + +88 -8 @@ -918,8 +1026,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go - +1 - -1 + +2 + -2 @@ -930,7 +1038,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go - +81 + +87 -3 @@ -942,7 +1050,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - +418 + +476 -34 @@ -954,7 +1062,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - +9 + +14 -7 @@ -971,6 +1079,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go + + +25 + -1 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go - +8 - -6 + +11 + -8
  • @@ -1002,8 +1122,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - +8 - -5 + +16 + -7 @@ -1014,8 +1134,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go - +21 - -15 + +34 + -22 @@ -1043,6 +1163,42 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/reorg_error.go + + +44 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/async_l1_block_checker.go + + +40 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go + + +3 + -1 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go - +2 + +5 -0
    @@ -1074,11 +1230,155 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go - +2 + +34 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async.go + + +183 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async_test.go + + +138 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block.go + + +146 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block_test.go + + +128 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/common.go + + +5 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration.go + + +205 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration_test.go + + +298 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block.go + + +139 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block_test.go + + +144 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block.go + + +120 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block_test.go + + +113 -0
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go + + +6 + -7 + + +
  • zkevm-node version: v0.6.0

  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go + + +7 + -1 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go + + +117 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go + + +19 + -0 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - +131 - -47 + +396 + -126
  • @@ -1134,8 +1470,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - +43 - -23 + +1480 + -69 @@ -1206,7 +1542,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml - +53 + +55 -3 @@ -1247,6 +1583,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc2_test.go + + +74 + -48 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - +47 - -5 + +61 + -14
  • @@ -1307,6 +1655,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go + + +6 + -14 + + +
  • zkevm-node version: v0.6.0

    + - tmpEthMan, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil) + tmpEthMan, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil)
    @@ -17904,7 +18264,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil) + etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil)
    @@ -18089,7 +18449,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil) + ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil)
    @@ -18169,7 +18529,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da) + return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da, st)
    @@ -25811,7 +26171,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -102,6 +102,7 @@
    +
    @@ -102,9 +102,18 @@
    @@ -25874,19 +26234,129 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

  • - + 107 + +
    + - + L1SyncCheckL2BlockNumberhModulus = 30 +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + 108 +
      - L1SyncCheckL2BlockNumberhModulus = 30 + [Synchronizer.L1ParallelSynchronization] +
    + + + + 109 + + +
    +   + MaxClients = 10 +
    + + + + 110 + + +
    +   + MaxPendingNoProcessedBlocks = 25
    -
    @@ -160,6 +161,7 @@
    +
    @@ -160,6 +169,7 @@
    @@ -25961,7 +26431,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -174,6 +176,10 @@
    +
    @@ -174,6 +184,10 @@
    @@ -26138,13 +26608,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 108 + +
    + + + L1SyncCheckL2BlockNumberhModulus = 600 +
    + + + + 109 + + +
    + + + [Synchronizer.L1BlockCheck] +
    + + + + 110 + + +
    + + + Enable = true +
    + + + + 111 + + +
    + + + L1SafeBlockPoint = "finalized" +
    + + + + 112 + + +
    + + + L1SafeBlockOffset = 0 +
    + + + + 113 + + +
    + + + ForceCheckBeforeStart = true +
    + + + + 114 + + +
    + + + PreCheckEnable = true +
    + + + + 115 + + +
    + + + L1PreSafeBlockPoint = "safe" +
    + + + + 116 + + +
    + + + L1PreSafeBlockOffset = 0 +
    + + + + 117 + + +
    +   + [Synchronizer.L1ParallelSynchronization] +
    + + + + 118 +
      - L1SyncCheckL2BlockNumberhModulus = 30 + MaxClients = 10 +
    + + + + 119 + + +
    +   + MaxPendingNoProcessedBlocks = 25
    @@ -26154,7 +26734,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 161 + 169
    @@ -26164,7 +26744,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 162 + 170
    @@ -26174,7 +26754,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 163 + 171
    @@ -26184,7 +26764,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 164 + 172
    @@ -26194,7 +26774,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 165 + 173
    @@ -26204,7 +26784,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 166 + 174
    @@ -26214,7 +26794,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 167 + 175
    @@ -26229,7 +26809,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 176 + 184
    @@ -26239,7 +26819,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 177 + 185
    @@ -26249,7 +26829,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 178 + 186
    @@ -26259,7 +26839,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 179 + 187
    @@ -26269,7 +26849,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 180 + 188
    @@ -26279,7 +26859,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 181 + 189
    @@ -26289,7 +26869,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 182 + 190
    @@ -26299,7 +26879,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 183 + 191
    @@ -26309,7 +26889,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 184 + 192
    @@ -26319,7 +26899,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 185 + 193
    @@ -33082,7 +33662,137 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -0,0 +1,139 @@
    +
    @@ -0,0 +1,152 @@
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    @@ -34575,7 +35285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - "github.com/0xPolygonHermez/zkevm-node/log" + jsontypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    @@ -34585,7 +35295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - "github.com/ethereum/go-ethereum/common" + "github.com/0xPolygonHermez/zkevm-node/log"
    @@ -34595,7 +35305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common"
    @@ -34605,7 +35315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ) + "github.com/ethereum/go-ethereum/crypto"
    @@ -34615,7 +35325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + )
    @@ -34625,7 +35335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - const unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s" +
    @@ -34635,7 +35345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + const (
    @@ -34645,7 +35355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // DataAvailability implements an abstract data availability integration + unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s"
    @@ -34655,7 +35365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - type DataAvailability struct { + failedDataRetrievalTemplate = "failed to retrieve local data for batches %v: %s"
    @@ -34665,7 +35375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - isTrustedSequencer bool + invalidBatchRetrievalArgs = "invalid L2 batch data retrieval arguments, %d != %d"
    @@ -34675,7 +35385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + )
    @@ -34685,7 +35395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - state stateInterface +
    @@ -34695,7 +35405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - zkEVMClient ZKEVMClientTrustedBatchesGetter + // DataAvailability implements an abstract data availability integration
    @@ -34705,7 +35415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - backend DABackender + type DataAvailability struct {
    @@ -34715,7 +35425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + isTrustedSequencer bool
    @@ -34725,7 +35435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ctx context.Context +
    @@ -34735,7 +35445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + state stateInterface
    @@ -34745,7 +35455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + zkEVMClient ZKEVMClientTrustedBatchesGetter
    @@ -34755,7 +35465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // New creates a DataAvailability instance + backend DABackender
    @@ -34765,7 +35475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func New( +
    @@ -34775,7 +35485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - isTrustedSequencer bool, + ctx context.Context
    @@ -34785,7 +35495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - backend DABackender, + }
    @@ -34795,7 +35505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - state stateInterface, +
    @@ -34805,7 +35515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - zkEVMClient ZKEVMClientTrustedBatchesGetter, + // New creates a DataAvailability instance
    @@ -34815,7 +35525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ) (*DataAvailability, error) { + func New(
    @@ -34825,7 +35535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - da := &DataAvailability{ + isTrustedSequencer bool,
    @@ -34835,7 +35545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - isTrustedSequencer: isTrustedSequencer, + backend DABackender,
    @@ -34845,7 +35555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - backend: backend, + state stateInterface,
    @@ -34855,7 +35565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - state: state, + zkEVMClient ZKEVMClientTrustedBatchesGetter,
    @@ -34865,7 +35575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - zkEVMClient: zkEVMClient, + ) (*DataAvailability, error) {
    @@ -34875,7 +35585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ctx: context.Background(), + da := &DataAvailability{
    @@ -34885,7 +35595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + isTrustedSequencer: isTrustedSequencer,
    @@ -34895,7 +35605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - err := da.backend.Init() + backend: backend,
    @@ -34905,7 +35615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return da, err + state: state,
    @@ -34915,7 +35625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + zkEVMClient: zkEVMClient,
    @@ -34925,7 +35635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + ctx: context.Background(),
    @@ -34935,7 +35645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage + }
    @@ -34945,7 +35655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // as expected by the contract + err := da.backend.Init()
    @@ -34955,7 +35665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) { + return da, err
    @@ -34965,7 +35675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batchesData := [][]byte{} + }
    @@ -34975,7 +35685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - for _, batch := range sequences { +
    @@ -34985,7 +35695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // Do not send to the DA backend data that will be stored to L1 + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage
    @@ -34995,7 +35705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if batch.ForcedBatchTimestamp == 0 { + // as expected by the contract
    @@ -35005,7 +35715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batchesData = append(batchesData, batch.BatchL2Data) + func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) {
    @@ -35015,7 +35725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + batchesData := [][]byte{}
    @@ -35025,7 +35735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + for _, batch := range sequences {
    @@ -35035,7 +35745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return d.backend.PostSequence(ctx, batchesData) + // Do not send to the DA backend data that will be stored to L1
    @@ -35045,7 +35755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + if batch.ForcedBatchTimestamp == 0 {
    @@ -35055,7 +35765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + batchesData = append(batchesData, batch.BatchL2Data)
    @@ -35065,7 +35775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // GetBatchL2Data tries to return the data from a batch, in the following priorities + }
    @@ -35075,7 +35785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // 1. From local DB + }
    @@ -35085,7 +35795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // 2. From Sequencer + return d.backend.PostSequence(ctx, batchesData)
    @@ -35095,7 +35805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // 3. From DA backend + }
    @@ -35105,7 +35815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) { +
    @@ -35115,7 +35825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if len(batchNums) != len(batchHashes) { + // GetBatchL2Data tries to return the data from a batch, in the following priorities. batchNums should not include forced batches.
    @@ -35125,7 +35835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, fmt.Errorf("invalid L2 batch data retrieval arguments, %d != %d", len(batchNums), len(batchHashes)) + // 1. From local DB
    @@ -35135,7 +35845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + // 2. From Trusted Sequencer (if not self)
    @@ -35145,7 +35855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + // 3. From DA backend
    @@ -35155,7 +35865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - data, err := d.localData(batchNums, batchHashes) + func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) {
    @@ -35165,7 +35875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if err == nil { + if len(batchNums) != len(batchHashes) {
    @@ -35175,7 +35885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return data, nil + return nil, fmt.Errorf(invalidBatchRetrievalArgs, len(batchNums), len(batchHashes))
    @@ -35195,7 +35905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + localData, err := d.state.GetBatchL2DataByNumbers(d.ctx, batchNums, nil)
    @@ -35205,7 +35915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if !d.isTrustedSequencer { + if err != nil {
    @@ -35215,7 +35925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - data, err = d.trustedSequencerData(batchNums, batchHashes) + return nil, err
    @@ -35225,7 +35935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if err != nil { + }
    @@ -35235,7 +35945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - log.Warnf("trusted sequencer failed to return data for batches %v: %s", batchNums, err.Error()) +
    @@ -35245,7 +35955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } else { + data, err := checkBatches(batchNums, batchHashes, localData)
    @@ -35255,7 +35965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return data, nil + if err != nil {
    @@ -35265,7 +35975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error())
    @@ -35275,7 +35985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + } else {
    @@ -35285,7 +35995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + return data, nil
    @@ -35295,7 +36005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage) + }
    @@ -35305,7 +36015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } +
    @@ -35315,7 +36025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + if !d.isTrustedSequencer {
    @@ -35325,7 +36035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // localData retrieves batches from local database and returns an error unless all are found + data, err = d.rpcData(batchNums, batchHashes, d.zkEVMClient.BatchesByNumbers)
    @@ -35335,7 +36045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func (d *DataAvailability) localData(numbers []uint64, hashes []common.Hash) ([][]byte, error) { + if err != nil {
    @@ -35345,7 +36055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - data, err := d.state.GetBatchL2DataByNumbers(d.ctx, numbers, nil) + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error())
    @@ -35355,7 +36065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if err != nil { + } else {
    @@ -35365,7 +36075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, err + return data, nil
    @@ -35375,7 +36085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + }
    @@ -35385,7 +36095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - var batches [][]byte + }
    @@ -35395,7 +36105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - for i := 0; i < len(numbers); i++ { + return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage)
    @@ -35405,7 +36115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batchNumber := numbers[i] + }
    @@ -35415,7 +36125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - expectedHash := hashes[i] +
    @@ -35425,7 +36135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batchData, ok := data[batchNumber] + func checkBatches(batchNumbers []uint64, expectedHashes []common.Hash, batchData map[uint64][]byte) ([][]byte, error) {
    @@ -35435,7 +36145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if !ok { + if len(batchNumbers) != len(expectedHashes) {
    @@ -35445,7 +36155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, fmt.Errorf("missing batch %v", batchNumber) + return nil, fmt.Errorf("invalid batch parameters")
    @@ -35455,7 +36165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + }
    @@ -35465,7 +36175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - actualHash := crypto.Keccak256Hash(batchData) + result := make([][]byte, len(batchNumbers))
    @@ -35475,7 +36185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if actualHash != expectedHash { + for i := 0; i < len(batchNumbers); i++ {
    @@ -35485,7 +36195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - err = fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash) + batchNumber := batchNumbers[i]
    @@ -35495,7 +36205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - log.Warnf("wrong local data for hash: %s", err.Error()) + expectedHash := expectedHashes[i]
    @@ -35505,7 +36215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, err + bd, ok := batchData[batchNumber]
    @@ -35515,7 +36225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } else { + if !ok {
    @@ -35525,7 +36235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batches = append(batches, batchData) + return nil, fmt.Errorf("missing batch data: [%d] %s", batchNumber, expectedHash.Hex())
    @@ -35545,7 +36255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + actualHash := crypto.Keccak256Hash(bd)
    @@ -35555,7 +36265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return batches, nil + if actualHash != expectedHash {
    @@ -35565,7 +36275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + err := fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash)
    @@ -35575,7 +36285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + -
    + log.Warnf("wrong local data for hash: %s", err.Error())
    @@ -35585,7 +36295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // trustedSequencerData retrieved batch data from the trusted sequencer and returns an error unless all are found + return nil, err
    @@ -35595,7 +36305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func (d *DataAvailability) trustedSequencerData(batchNums []uint64, expectedHashes []common.Hash) ([][]byte, error) { + }
    @@ -35605,7 +36315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if len(batchNums) != len(expectedHashes) { + result[i] = bd
    @@ -35615,7 +36325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d", + }
    @@ -35625,7 +36335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - len(batchNums), len(expectedHashes)) + return result, nil
    @@ -35635,7 +36345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + }
    @@ -35645,7 +36355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - nums := make([]*big.Int, 0, len(batchNums)) +
    @@ -35655,7 +36365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - for _, n := range batchNums { + type rpcBatchDataFunc func(ctx context.Context, numbers []*big.Int) ([]*jsontypes.BatchData, error)
    @@ -35665,7 +36375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - nums = append(nums, new(big.Int).SetUint64(n)) +
    @@ -35675,7 +36385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + // rpcData retrieves batch data from rpcBatchDataFunc, returns an error unless all are found and correct
    @@ -35685,7 +36395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batchData, err := d.zkEVMClient.BatchesByNumbers(d.ctx, nums) + func (d *DataAvailability) rpcData(batchNums []uint64, expectedHashes []common.Hash, rpcFunc rpcBatchDataFunc) ([][]byte, error) {
    @@ -35695,7 +36405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if err != nil { + if len(batchNums) != len(expectedHashes) {
    @@ -35705,7 +36415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, err + return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d",
    @@ -35715,7 +36425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + len(batchNums), len(expectedHashes))
    @@ -35725,7 +36435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if len(batchData) != len(batchNums) { + }
    @@ -35735,7 +36445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData)) + nums := make([]*big.Int, 0, len(batchNums))
    @@ -35745,7 +36455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + for _, n := range batchNums {
    @@ -35755,7 +36465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - result := make([][]byte, 0, len(batchNums)) + nums = append(nums, new(big.Int).SetUint64(n))
    @@ -35765,7 +36475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - for i := 0; i < len(batchNums); i++ { + }
    @@ -35775,7 +36485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - number := batchNums[i] + batchData, err := rpcFunc(d.ctx, nums)
    @@ -35785,7 +36495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - batch := batchData[i] + if err != nil {
    @@ -35795,7 +36505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - expectedTransactionsHash := expectedHashes[i] + return nil, err
    @@ -35805,7 +36515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data) + }
    @@ -35815,7 +36525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - if expectedTransactionsHash != actualTransactionsHash { + if len(batchData) != len(batchNums) {
    @@ -35825,7 +36535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash) + return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData))
    @@ -35835,7 +36545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + }
    @@ -35845,7 +36555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - result = append(result, batch.BatchL2Data) + result := make(map[uint64][]byte)
    @@ -35855,7 +36565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + for i := 0; i < len(batchNums); i++ {
    @@ -35865,7 +36575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - return result, nil + number := batchNums[i]
    @@ -35875,146 +36585,276 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + batch := batchData[i]
    - - - -
    + + + 140 + + +
    + + + expectedTransactionsHash := expectedHashes[i]
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +
    -
    @@ -0,0 +1,309 @@
    - + + 141 -
    -   -
    +
    +
    + + + actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data)
    - + + 142 -
    -   -
    +
    +
    + + + if expectedTransactionsHash != actualTransactionsHash {
    - + + 143 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash)
    - + + 144 -
    -   -
    +
    +
    + + + }
    - + + 145 -
    -   -
    +
    +
    + + + result[number] = batch.BatchL2Data
    - + + 146 -
    -   -
    +
    +
    + + + }
    - + + 147 -
    -   -
    +
    +
    + + + checked, err := checkBatches(batchNums, expectedHashes, result)
    - + + 148 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 149 -
    -   -
    +
    +
    + + + return nil, err
    - + + 150 -
    -   -
    +
    +
    + + + }
    - + + 151 -
    -   -
    +
    +
    + + + return checked, nil +
    +
    + 152 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44791,7 +45631,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + @@ -45794,7 +46654,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45804,7 +46664,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45814,7 +46674,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45824,7 +46684,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45834,7 +46694,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45844,7 +46704,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45854,7 +46714,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45864,7 +46724,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45874,7 +46734,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45884,7 +46744,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45894,7 +46754,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45904,7 +46764,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45914,7 +46774,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45924,7 +46784,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45934,7 +46794,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45944,7 +46804,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -45954,13 +46814,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + - - - - - - - - - - - - - - - - - - - - - @@ -48496,7 +49306,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48506,7 +49316,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48516,7 +49326,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48526,7 +49336,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48536,7 +49346,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48546,7 +49356,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48556,7 +49366,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48566,7 +49376,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48576,7 +49386,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48586,7 +49396,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48596,7 +49406,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48606,7 +49416,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48616,7 +49426,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48626,7 +49436,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48636,7 +49446,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48646,7 +49456,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48656,7 +49466,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48666,7 +49476,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48676,7 +49486,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48696,7 +49506,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -48706,77 +49516,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - @@ -48786,12 +49526,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go RENAMED
    - - -
    +
    @@ -0,0 +1,309 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    -
    @@ -0,0 +1,58 @@
    +
    @@ -0,0 +1,60 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    @@ -45784,7 +46644,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - } + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    + -
    + }
    + - // BatchDataProvider is used to retrieve batch data +
    + - type BatchDataProvider interface { + // BatchDataProvider is used to retrieve batch data
    + - // GetBatchL2Data retrieve the data of a batch from the DA backend. The returned data must be the pre-image of the hash + type BatchDataProvider interface {
    + - GetBatchL2Data(batchNum []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) + // GetBatchL2Data retrieve the data of a batch from the DA backend. The returned data must be the pre-image of the hash
    + - } + GetBatchL2Data(batchNum []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
    + -
    + }
    + - // DataManager is an interface for components that send and retrieve batch data +
    + - type DataManager interface { + // DataManager is an interface for components that send and retrieve batch data
    + - BatchDataProvider + type DataManager interface {
    + - SequenceSender + BatchDataProvider
    + - } + SequenceSender
    + -
    + }
    + - // ZKEVMClientTrustedBatchesGetter contains the methods required to interact with zkEVM-RPC +
    + - type ZKEVMClientTrustedBatchesGetter interface { + // ZKEVMClientTrustedBatchesGetter contains the methods required to interact with zkEVM-RPC
    + - BatchByNumber(ctx context.Context, number *big.Int) (*types.Batch, error) + type ZKEVMClientTrustedBatchesGetter interface {
    + - BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) + BatchByNumber(ctx context.Context, number *big.Int) (*types.Batch, error)
    58 +
    + + + BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) +
    +
    + 59 + +
    + + + ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) +
    +
    + 60 +
    + @@ -48103,12 +48983,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/validium-001.sql + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql RENAMED
    -
    @@ -0,0 +1,32 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    +
    @@ -0,0 +1,25 @@
    @@ -48486,7 +49296,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - CREATE TABLE IF NOT EXISTS state.batch_data_backup + -- the update below fix the wrong receipt TX indexes
    + - ( + WITH map_fix_tx_index AS (
    + - batch_num BIGINT, + SELECT t.l2_block_num AS block_num
    + - data BYTEA, + , t.hash AS tx_hash
    + - created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + , r.tx_index AS current_index
    + - PRIMARY KEY (batch_num, created_at) + , (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index
    + - ); + FROM state.receipt r
    + -
    + INNER JOIN state."transaction" t
    + - -- +migrate StatementBegin + ON t.hash = r.tx_hash
    + - CREATE OR REPLACE FUNCTION backup_batch() RETURNS trigger AS $$ + )
    + - BEGIN + UPDATE state.receipt AS r
    + - INSERT INTO state.batch_data_backup (batch_num, data) + SET tx_index = m.correct_index
    + - VALUES (OLD.batch_num, OLD.raw_txs_data) + FROM map_fix_tx_index m
    + - ON CONFLICT (batch_num, created_at) DO UPDATE SET + WHERE m.block_num = r.block_num
    + - data = EXCLUDED.data; + AND m.tx_hash = r.tx_hash
    + - RETURN OLD; + AND m.current_index = r.tx_index
    + - END; + AND m.current_index != m.correct_index;
    + - $$ +
    + - LANGUAGE plpgsql; +
    + - -- +migrate StatementEnd + -- +migrate Down
    + - CREATE TRIGGER backup_batch + -- no action is needed, the data fixed by the
    + - BEFORE DELETE ON state.batch FOR EACH ROW -
    -
    - 26 - -
    - + - EXECUTE PROCEDURE backup_batch(); -
    -
    - 27 - -
    - + -
    -
    -
    - 28 - -
    - + - -- +migrate Down -
    -
    - 29 - -
    - + -
    -
    -
    - 30 - -
    - + - DROP TRIGGER IF EXISTS backup_batch ON state.batch; -
    -
    - 31 - -
    - + - DROP FUNCTION IF EXISTS backup_batch(); -
    -
    - 32 - -
    - + - DROP TABLE IF EXISTS state.batch_data_backup; + -- migrate up must remain fixed
    -
    @@ -0,0 +1,47 @@
    +
    @@ -0,0 +1,145 @@
    @@ -49278,631 +50018,574 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 + + -
    - + - PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/" +
    +
    +   +
    - 2 + + -
    - + - diff -ruN \ +
    +
    +   +
    - 3 + + -
    - + - -I ".*github.com\/0x.*" \ +
    +
    +   +
    - 4 + + -
    - + - -x "*mock*" -x ".git" \ +
    +
    +   +
    - 5 + + -
    - + - -x ".github" \ +
    +
    +   +
    - 6 + + -
    - + - -x ".gitignore" \ +
    +
    +   +
    - 7 + + -
    - + - -x ".vscode" \ +
    +
    +   +
    - 8 + + -
    - + - -x "ci" \ +
    +
    +   +
    - 9 + + -
    - + - -x "environments" \ +
    +
    +   +
    - 10 + + -
    - + - -x "*.md" \ +
    +
    +   +
    - 11 + + -
    - + - -x "*.html" \ +
    +
    +   +
    - 12 + + -
    - + - -x "*.html" \ +
    +
    +   +
    - 13 + + -
    - + - -x "*.json" \ +
    +
    +   +
    - 14 + + -
    - + - -x "*.toml" \ +
    +
    +   +
    - 15 + + -
    - + - -x "*.abi" \ +
    +
    +   +
    - 16 + + -
    - + - -x "*.bin" \ +
    +
    +   +
    - 17 + + -
    - + - -x "*.pb.go" \ +
    +
    +   +
    - 18 + + -
    - + - -x "smartcontracts" \ +
    +
    +   +
    - 19 + + -
    - + - -x "go.sum" \ +
    +
    +   +
    - 20 + + -
    - + - -x "mock*.go" \ +
    +
    +   +
    - 21 + + -
    - + - -x "*venv*" \ +
    +
    +   +
    - 22 + + -
    - + - -x "/dist/" \ +
    +
    +   +
    - 23 + + -
    - + - -x "/test/e2e/keystore" \ +
    +
    +   +
    - 24 + + -
    - + - -x "/test/vectors/src/**/*md" \ +
    +
    +   +
    - 25 + + -
    - + - -x "/test/vectors/src/**/*js" \ +
    +
    +   +
    - 26 + + -
    - + - -x "/test/vectors/src/**/*sol" \ +
    +
    +   +
    - 27 + + -
    - + - -x "/test/vectors/src/**/*sh" \ +
    +
    +   +
    - 28 + + -
    - + - -x "/test/vectors/src/package.json" \ +
    +
    +   +
    - 29 + + -
    - + - -x "/test/contracts/bin/**/*.bin" \ +
    +
    +   +
    - 30 + + -
    - + - -x "/test/contracts/bin/**/*.abi" \ +
    +
    +   +
    - 31 + + -
    - + - -x "/tools/datastreamer/*.bin" \ +
    +
    +   +
    - 32 + + -
    - + - -x "/test/datastreamer/*.db/*" \ +
    +
    +   +
    - 33 + + -
    - + - -x "/test/*.bin" \ +
    +
    +   +
    - 34 + + -
    - + - -x "/test/*.db/*" \ +
    +
    +   +
    - 35 + + -
    - + - -x "**/.DS_Store" \ +
    +
    +   +
    - 36 + + -
    - + - -x ".vscode" \ +
    +
    +   +
    - 37 + + -
    - + - -x ".idea/" \ +
    +
    +   +
    - 38 + + -
    - + - -x ".env" \ +
    +
    +   +
    - 39 + + -
    - + - -x "out.dat" \ +
    +
    +   +
    - 40 + + -
    - + - -x "cmd/__debug_bin" \ +
    +
    +   +
    - 41 + + -
    - + - -x ".venv" \ +
    +
    +   +
    - 42 + + -
    - + - -x "*metrics.txt" \ +
    +
    +   +
    - 43 + + -
    - + - -x "coverage.out" \ +
    +
    +   +
    - 44 + + -
    - + - -x "*datastream.db*" \ +
    +
    +   +
    - 45 + + -
    - + - ${PATH_TO_ZKEVM_NODE_REPO} . | \ +
    +
    +   +
    - 46 + + -
    - + - diff2html -i stdin -s side -t "zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.6.0<h2/>" \ +
    +
    +   +
    - 47 - -
    - + - -F ./docs/diff/diff.html -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -14,7 +14,6 @@
    - 14 + + -
    +
    +
      - # CONTAINER FOR RUNNING BINARY +
    - 15 + + -
    +
    +
      - FROM alpine:3.18 +
    - 16 + + -
    +
    +
      - COPY --from=build /src/dist/zkevm-node /app/zkevm-node +
    - 17 + + -
    - - - COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml +
    +
    +   +
    - 18 + + -
    +
    +
      - RUN apk update && apk add postgresql15-client +
    - 19 + + -
    +
    +
      - EXPOSE 8123 +
    - 20 + + -
    +
    +
      - CMD ["/bin/sh", "-c", "/app/zkevm-node run"] -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -49916,63 +50599,34 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
     
    - 14 + + -
    +
    +
      - # CONTAINER FOR RUNNING BINARY +
    - 15 + + -
    +
    +
      - FROM alpine:3.18 +
    - 16 + + -
    +
    +
      - COPY --from=build /src/dist/zkevm-node /app/zkevm-node +
    - 17 + + -
    +
    +
      - RUN apk update && apk add postgresql15-client +
    - 18 + + -
    +
    +
      - EXPOSE 8123 +
    - 19 + + -
    +
    +
      - CMD ["/bin/sh", "-c", "/app/zkevm-node run"] -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,15 @@
    @@ -50124,229 +50778,126 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + -
    - + - FROM alpine:3.18 +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - COPY zkevm-node /app/zkevm-node +
    +
    +   +
    - 4 + + -
    - + +
    +
    +  
    - 5 + + -
    - + - EXPOSE 8123 +
    +
    +   +
    - 6 + + -
    - + +
    +
    +  
    - 7 + + -
    - + - RUN addgroup -S zkevm-group \ +
    +
    +   +
    - 8 + + -
    - + - && adduser -S zkevm-user -G zkevm-group +
    +
    +   +
    - 9 + + -
    - + +
    +
    +  
    - 10 + + -
    - + - RUN chown -R zkevm-user:zkevm-group /app +
    +
    +   +
    - 11 + + -
    - + +
    +
    +  
    - 12 - -
    - + - USER zkevm-user -
    -
    - 13 - -
    - + -
    -
    -
    - 14 - -
    - + - CMD ["/app/zkevm-node"] -
    -
    - 15 - -
    - + -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -3,6 +3,7 @@
    -
    - 3 - -
    -   - import ( -
    -
    - 4 - -
    -   - "bytes" -
    -
    - 5 - -
    -   - "context" -
    -
    @@ -50358,66 +50909,41 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 6 - -
    -   - "encoding/json" -
    -
    - 7 - -
    -   - "errors" -
    -
    - 8 + + -
    +
    +
      - "fmt" +
    -
    @@ -106,6 +109,11 @@
    -
    - 106 + + -
    +
    +
      - // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry +
    - 107 + + -
    +
    +
      - methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address) +
    - 108 + + -
    +
    +
     
    @@ -50472,2664 +50998,2610 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 109 - -
    -   - // ErrNotFound is used when the object is not found +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 110 + + 1 +
    -   - ErrNotFound = errors.New("not found") + + + package migrations_test
    - 111 + + 2 +
    -   - // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode. + + +
    -
    @@ -189,6 +197,7 @@
    -
    - 189 + + 3 +
    -   - GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot + + + import (
    - 190 + + 4 +
    -   - OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot + + + "database/sql"
    - 191 + + 5 +
    -   - Pol *pol.Pol + + + "testing"
    - + + 6 -
    -   +
    +
    + +
    - 192 + + 7 +
    -   - SCAddresses []common.Address + + + "github.com/0xPolygonHermez/zkevm-node/hex"
    - 193 + + 8 +
    -   -
    + + + "github.com/ethereum/go-ethereum/common"
    - 194 + + 9 +
    -   - RollupID uint32 + + + "github.com/stretchr/testify/require"
    -
    @@ -198,10 +207,12 @@
    -
    - 198 + + 10 +
    -   - l1Cfg L1Config + + + )
    - 199 + + 11 +
    -   - cfg Config + + +
    - 200 + + 12 +
    -   - auth map[common.Address]bind.TransactOpts // empty in case of read-only client + + + type migrationTest0019TestCase struct {
    - + + 13 -
    -   -
    +
    +
    + + + Name string
    - + + 14 -
    -   -
    +
    +
    + + + Block migrationTest0019TestCaseBlock
    - 201 + + 15 +
    -   + + }
    - 202 + + 16 +
    -   + +
    - 203 + + 17 +
    -   - // NewClient creates a new etherman. + + + type migrationTest0019TestCaseBlock struct {
    - 204 + + 18 +
    - - - func NewClient(cfg Config, l1Config L1Config) (*Client, error) { + + + Transactions []migrationTest0019TestCaseTransaction
    - 205 + + 19 +
    -   - // Connect to ethereum node + + + }
    - 206 + + 20 +
    -   - ethClient, err := ethclient.Dial(cfg.URL) + + +
    - 207 + + 21 +
    -   - if err != nil { + + + type migrationTest0019TestCaseTransaction struct {
    -
    @@ -244,6 +255,14 @@
    -
    - 244 + + 22 +
    -   - log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err) + + + CurrentIndex uint
    - 245 + + 23 +
    -   - return nil, err + + + }
    - 246 + + 24 +
    -   - } -
    -
    - - -
    -   + +
    - + + 25 -
    -   -
    +
    +
    + + + type migrationTest0019 struct {
    - + + 26 -
    -   -
    +
    +
    + + + TestCases []migrationTest0019TestCase
    - + + 27 -
    -   -
    +
    +
    + + + }
    - + + 28 -
    -   +
    +
    + +
    - + + 29 -
    -   -
    +
    +
    + + + func (m migrationTest0019) InsertData(db *sql.DB) error {
    - + + 30 -
    -   -
    +
    +
    + + + const addBlock0 = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES (0, now(), '0x0')"
    - + + 31 -
    -   -
    +
    +
    + + + if _, err := db.Exec(addBlock0); err != nil {
    - 247 + + 32 +
    -   - var scAddresses []common.Address + + + return err
    - 248 + + 33 +
    -   - scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr) + + + }
    - 249 + + 34 +
    -   + +
    -
    @@ -274,6 +293,7 @@
    -
    - 274 + + 35 +
    -   - RollupManager: rollupManager, + + + const addBatch0 = `
    - 275 + + 36 +
    -   - Pol: pol, + + + 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)
    - 276 + + 37 +
    -   - GlobalExitRootManager: globalExitRoot, + + + VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)`
    - + + 38 -
    -   -
    +
    +
    + + + if _, err := db.Exec(addBatch0); err != nil {
    - 277 + + 39 +
    -   - OldGlobalExitRootManager: oldGlobalExitRoot, + + + return err
    - 278 + + 40 +
    -   - SCAddresses: scAddresses, + + + }
    - 279 + + 41 +
    -   - RollupID: rollupID, + + +
    -
    @@ -284,11 +304,13 @@
    -
    - 284 + + 42 +
    -   - l1Cfg: l1Config, + + + const addL2Block = "INSERT INTO state.l2block (block_num, block_hash, header, uncles, parent_hash, state_root, received_at, batch_num, created_at) VALUES ($1, $2, '{}', '{}', '0x0', '0x0', now(), 0, now())"
    - 285 + + 43 +
    -   - cfg: cfg, + + + const addTransaction = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num, effective_percentage, l2_hash) VALUES ($1, 'ABCDEF', '{}', $2, 255, $1)"
    - 286 + + 44 +
    -   - auth: map[common.Address]bind.TransactOpts{}, + + + const addReceipt = "INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address) VALUES ($1, 1, null, 1, 1234, 1234, 1, $2, $3, '')"
    - + + 45 -
    -   +
    +
    + +
    - 287 + + 46 +
    -   - }, nil + + + txUnique := 0
    - 288 + + 47 +
    -   - } + + + for tci, testCase := range m.TestCases {
    - 289 + + 48 +
    -   -
    + + + blockNum := uint64(tci + 1)
    - 290 + + 49 +
    -   - // VerifyGenBlockNumber verifies if the genesis Block Number is valid + + + blockHash := common.HexToHash(hex.EncodeUint64(blockNum)).String()
    - 291 + + 50 +
    -   - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { -
    -
    - - -
    -   -
    + + + if _, err := db.Exec(addL2Block, blockNum, blockHash); err != nil {
    - 292 + + 51 +
    -   - start := time.Now() + + + return err
    - 293 + + 52 +
    -   - log.Info("Verifying genesis blockNumber: ", genBlockNumber) + + + }
    - 294 + + 53 +
    -   - // Filter query + + + for _, tx := range testCase.Block.Transactions {
    -
    @@ -344,6 +366,11 @@
    -
    - 344 + + 54 +
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) + + + txUnique++
    - 345 + + 55 +
    -   - start := time.Now() + + + txHash := common.HexToHash(hex.EncodeUint64(uint64(txUnique))).String()
    - 346 + + 56 +
    -   - var logs []types.Log + + + if _, err := db.Exec(addTransaction, txHash, blockNum); err != nil {
    - + + 57 -
    -   -
    +
    +
    + + + return err
    - + + 58 -
    -   -
    +
    +
    + + + }
    - + + 59 -
    -   -
    +
    +
    + + + if _, err := db.Exec(addReceipt, txHash, blockNum, tx.CurrentIndex); err != nil {
    - + + 60 -
    -   -
    +
    +
    + + + return err
    - + + 61 -
    -   -
    +
    +
    + + + }
    - 347 + + 62 +
    -   - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) + + + }
    - 348 + + 63 +
    -   - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { + + + }
    - 349 + + 64 +
    -   - final := i + etherMan.cfg.ForkIDChunkSize + + +
    -
    @@ -684,61 +711,8 @@
    -
    - 684 + + 65 +
    -   - return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID) + + + return nil
    - 685 + + 66 +
    -   + + }
    - 686 + + 67 +
    -   + +
    - 687 + + 68 +
    - - - func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + + func (m migrationTest0019) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) {
    - 688 + + 69 +
    - - - log.Debug("updateEtrogSequence event detected") + + + const getReceiptsByBlock = "SELECT r.tx_index FROM state.receipt r WHERE r.block_num = $1 ORDER BY r.tx_index"
    - 689 + + 70 +
    - - - updateEtrogSequence, err := etherMan.EtrogZKEVM.ParseUpdateEtrogSequence(vLog) + + +
    - 690 + + 71 +
    - - - if err != nil { + + + for tci := range m.TestCases {
    - 691 + + 72 +
    - - - log.Error("error parsing updateEtrogSequence event. Error: ", err) + + + blockNum := uint64(tci + 1)
    - 692 + + 73 +
    - - - return err + + +
    - 693 + + 74 +
    - - - } + + + rows, err := db.Query(getReceiptsByBlock, blockNum)
    - 694 + + 75 +
    - - -
    + + + require.NoError(t, err)
    - 695 + + 76 +
    - - - // Read the tx for this event. + + +
    - 696 + + 77 +
    - - - tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) + + + var expectedIndex = uint(0)
    - 697 + + 78 +
    - - - if err != nil { + + + var txIndex uint
    - 698 + + 79 +
    - - - return err + + + for rows.Next() {
    - 699 + + 80 +
    - - - } + + + err := rows.Scan(&txIndex)
    - 700 + + 81 +
    - - - if tx.Hash() != vLog.TxHash { + + + require.NoError(t, err)
    - 701 + + 82 +
    - - - return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String()) + + + require.Equal(t, expectedIndex, txIndex)
    - 702 - -
    - - - } -
    -
    - 703 + + 83 +
    - - - msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0)) + + + expectedIndex++
    - 704 + + 84 +
    - - - if err != nil { + + + }
    - 705 + + 85 +
    - - - return err + + + }
    - 706 + + 86 +
    - - - } + + + }
    - 707 + + 87 +
    - - - fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash) + + +
    - 708 + + 88 +
    - - - if err != nil { + + + func (m migrationTest0019) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) {
    - 709 + + 89 +
    - - - return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err) + + + m.RunAssertsAfterMigrationUp(t, db)
    - 710 + + 90 +
    - - - } + + + }
    - 711 + + 91 +
    - - + +
    - 712 + + 92 +
    - - - log.Info("update Etrog transaction sequence...") + + + func TestMigration0019(t *testing.T) {
    - 713 + + 93 +
    - - - sequence := UpdateEtrogSequence{ + + + runMigrationTest(t, 19, migrationTest0019{
    - 714 + + 94 +
    - - - BatchNumber: updateEtrogSequence.NumBatch, + + + TestCases: []migrationTest0019TestCase{
    - 715 + + 95 +
    - - - SequencerAddr: updateEtrogSequence.Sequencer, + + + {
    - 716 + + 96 +
    - - - TxHash: vLog.TxHash, + + + Name: "single tx with correct index",
    - 717 + + 97 +
    - - - Nonce: msg.Nonce, + + + Block: migrationTest0019TestCaseBlock{
    - 718 + + 98 +
    - - - PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + Transactions: []migrationTest0019TestCaseTransaction{
    - 719 + + 99 +
    - - - Transactions: updateEtrogSequence.Transactions, + + + {CurrentIndex: 0},
    - 720 + + 100 +
    - - - ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot, + + + },
    - 721 + + 101 +
    - - - ForcedTimestamp: fullBlock.Time(), + + + },
    - 722 + + 102 +
    - - - ForcedBlockHashL1: fullBlock.ParentHash(), + + + },
    - 723 + + 103 +
    - - - }, + + + {
    - 724 + + 104 +
    - - - } + + + Name: "multiple txs indexes are correct",
    - 725 + + 105 +
    - - -
    + + + Block: migrationTest0019TestCaseBlock{
    - 726 + + 106 +
    - - - if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { + + + Transactions: []migrationTest0019TestCaseTransaction{
    - 727 + + 107 +
    - - - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) + + + {CurrentIndex: 0},
    - 728 + + 108 +
    - - - block.UpdateEtrogSequence = sequence + + + {CurrentIndex: 1},
    - 729 + + 109 +
    - - - *blocks = append(*blocks, block) + + + {CurrentIndex: 2},
    - 730 + + 110 +
    - - - } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { + + + },
    - 731 + + 111 +
    - - - (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence + + + },
    - 732 + + 112 +
    - - - } else { + + + },
    - 733 + + 113 +
    - - - log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber) + + + {
    - 734 + + 114 +
    - - - return fmt.Errorf("error processing UpdateEtrogSequence event") + + + Name: "single tx with wrong tx index",
    - 735 + + 115 +
    - - - } + + + Block: migrationTest0019TestCaseBlock{
    - 736 + + 116 +
    - - - or := Order{ + + + Transactions: []migrationTest0019TestCaseTransaction{
    - 737 + + 117 +
    - - - Name: UpdateEtrogSequenceOrder, + + + {CurrentIndex: 3},
    - 738 + + 118 +
    - - - Pos: 0, + + + },
    - 739 + + 119 +
    - - - } + + + },
    - 740 + + 120 +
    - - - (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or) + + + },
    - 741 + + 121 +
    - - - return nil + + + {
    - 742 + + 122 +
    -   - } + + + Name: "multiple txs missing 0 index",
    - 743 + + 123 +
    -   -
    + + + Block: migrationTest0019TestCaseBlock{
    - 744 + + 124 +
    -   - func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + + Transactions: []migrationTest0019TestCaseTransaction{
    -
    @@ -937,14 +911,14 @@
    -
    - 937 + + 125 +
    -   - } + + + {CurrentIndex: 1},
    - 938 + + 126 +
    -   -
    + + + {CurrentIndex: 2},
    - 939 + + 127 +
    -   - // EstimateGasSequenceBatches estimates gas for sending batches + + + {CurrentIndex: 3},
    - 940 + + 128 +
    - - - func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) { + + + {CurrentIndex: 4},
    - 941 + + 129 +
    -   - opts, err := etherMan.getAuthByAddress(sender) + + + },
    - 942 + + 130 +
    -   - if err == ErrNotFound { + + + },
    - 943 + + 131 +
    -   - return nil, ErrPrivateKeyNotFound + + + },
    - 944 + + 132 +
    -   - } + + + {
    - 945 + + 133 +
    -   - opts.NoSend = true + + + Name: "multiple has index 0 but also txs index gap",
    - 946 + + 134 +
    -   -
    + + + Block: migrationTest0019TestCaseBlock{
    - 947 + + 135 +
    - - - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) + + + Transactions: []migrationTest0019TestCaseTransaction{
    - 948 + + 136 +
    -   - if err != nil { + + + {CurrentIndex: 0},
    - 949 + + 137 +
    -   - return nil, err + + + {CurrentIndex: 2},
    - 950 + + 138 +
    -   - } + + + {CurrentIndex: 4},
    -
    @@ -953,7 +927,7 @@
    -
    - 953 + + 139 +
    -   - } + + + {CurrentIndex: 6},
    - 954 + + 140 +
    -   -
    + + + },
    - 955 + + 141 +
    -   - // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches. + + + },
    - 956 + + 142 +
    - - - func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) { + + + },
    - 957 + + 143 +
    -   - opts, err := etherMan.getAuthByAddress(sender) + + + },
    - 958 + + 144 +
    -   - if err == ErrNotFound { + + + })
    - 959 + + 145 +
    -   - return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound) + + + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020.sql + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -964,7 +938,7 @@
    +
    @@ -0,0 +1,28 @@
    - 964 + + -
    +
    +
      - opts.GasLimit = uint64(1) +
    - 965 + + -
    +
    +
      - opts.GasPrice = big.NewInt(1) +
    - 966 + + -
    +
    +
     
    - 967 - -
    - - - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) -
    -
    - 968 + + -
    +
    +
      - if err != nil { +
    - 969 + + -
    +
    +
      - return nil, nil, err +
    - 970 + + -
    +
    +
      - } +
    -
    @@ -972,15 +946,15 @@
    -
    - 972 + + -
    +
    +
      - return tx.To(), tx.Data(), nil +
    - 973 + + -
    +
    +
      - } +
    - 974 + + -
    +
    +
     
    - 975 + + -
    - - - func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) { +
    +
    +   +
    - 976 + + -
    - - - var batches []polygonzkevm.PolygonRollupBaseEtrogBatchData +
    +
    +   +
    - 977 + + -
    +
    +
      - for _, seq := range sequences { +
    - 978 + + -
    +
    +
      - var ger common.Hash +
    - 979 + + -
    +
    +
      - if seq.ForcedBatchTimestamp > 0 { +
    - 980 + + -
    +
    +
      - ger = seq.GlobalExitRoot +
    - 981 + + -
    +
    +
      - } +
    - 982 + + -
    - - - batch := polygonzkevm.PolygonRollupBaseEtrogBatchData{ +
    +
    +   +
    - 983 + + -
    - - - Transactions: seq.BatchL2Data, +
    +
    +   +
    - 984 + + -
    +
    +
      - ForcedGlobalExitRoot: ger, +
    - 985 + + -
    +
    +
      - ForcedTimestamp: uint64(seq.ForcedBatchTimestamp), +
    - 986 + + -
    +
    +
      - ForcedBlockHashL1: seq.PrevBlockHash, +
    -
    @@ -989,7 +963,7 @@
    -
    - 989 + + -
    +
    +
      - batches = append(batches, batch) +
    - 990 + + -
    +
    +
      - } +
    - 991 + + -
    +
    +
     
    - 992 + + -
    - - - tx, err := etherMan.ZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) +
    +
    +   +
    - 993 + + -
    +
    +
      - if err != nil { +
    - 994 + + -
    +
    +
      - log.Debugf("Batches to send: %+v", batches) +
    - 995 + + -
    +
    +
      - log.Debug("l2CoinBase: ", l2Coinbase) +
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -1185,7 +1159,6 @@
    +
     
    - 1185 + + 1 +
    -   -
    + + + -- +migrate Up
    - 1186 + + 2 +
    -   - func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + +
    - 1187 + + 3 +
    -   - log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:])) + + + -- This migration will delete all empty blocks
    - 1188 + + 4 +
    - - - //tx,isPending, err:=etherMan.EthClient.TransactionByHash(ctx, vLog.TxHash) + + + DELETE FROM state.block
    - 1189 + + 5 +
    -   -
    + + + WHERE NOT EXISTS (SELECT *
    - 1190 + + 6 +
    -   - sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog) + + + FROM state.virtual_batch
    - 1191 + + 7 +
    -   - if err != nil { + + + WHERE state.virtual_batch.block_num = state.block.block_num)
    -
    @@ -1209,13 +1182,15 @@
    -
    - 1209 + + 8 +
    -   - if sb.NumBatch != 1 { + + + AND NOT EXISTS (SELECT *
    - 1210 + + 9 +
    -   - methodId := tx.Data()[:4] + + + FROM state.verified_batch
    - 1211 + + 10 +
    -   - log.Debugf("MethodId: %s", common.Bytes2Hex(methodId)) + + + WHERE state.verified_batch.block_num = state.block.block_num)
    - 1212 + + 11 +
    - - - if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) { + + + AND NOT EXISTS (SELECT *
    - 1213 + + 12 +
    - - - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) -
    -
    - - -
    -   -
    + + + FROM state.forced_batch
    - 1214 + + 13 +
    -   - if err != nil { + + + WHERE state.forced_batch.block_num = state.block.block_num)
    - 1215 + + 14 +
    -   - return fmt.Errorf("error decoding the sequences (etrog): %v", err) + + + AND NOT EXISTS (SELECT *
    - 1216 + + 15 +
    -   - } + + + FROM state.exit_root
    - 1217 + + 16 +
    - - - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) { + + + WHERE state.exit_root.block_num = state.block.block_num)
    - 1218 + + 17 +
    - - - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) + + + AND NOT EXISTS (SELECT *
    - + + 18 -
    -   -
    +
    +
    + + + FROM state.monitored_txs
    - 1219 + + 19 +
    -   - if err != nil { + + + WHERE state.monitored_txs.block_num = state.block.block_num)
    - 1220 + + 20 +
    -   - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) + + + AND NOT EXISTS (SELECT *
    - 1221 + + 21 +
    -   - } + + + FROM state.fork_id
    -
    @@ -1301,7 +1276,7 @@
    -
    - 1301 + + 22 +
    -   - return nil + + + WHERE state.fork_id.block_num = state.block.block_num);
    - 1302 + + 23 +
    -   - } + + +
    - 1303 + + 24 +
    -   + +
    - 1304 + + 25 +
    - - - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { + + +
    - 1305 + + 26 +
    -   - // Extract coded txs. + + + -- +migrate Down
    - 1306 + + 27 +
    -   - // Load contract ABI + + +
    - 1307 + + 28 +
    -   - smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) + + + -- no action is needed, the data must remain deleted as it is useless
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020_test.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -53143,66 +53615,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -1309,54 +1284,11 @@
    +
    @@ -0,0 +1,99 @@
    - 1309 + + -
    +
    +
      - return nil, err +
    - 1310 + + -
    +
    +
      - } +
    - 1311 + + -
    +
    +
     
    - 1312 + + -
    - - - // Recover Method from signature and ABI +
    +
    +   +
    - 1313 + + -
    - - - method, err := smcAbi.MethodById(txData[:4]) +
    +
    +   +
    - 1314 + + -
    - - - if err != nil { +
    +
    +   +
    - 1315 + + -
    - - - return nil, err +
    +
    +   +
    - 1316 + + -
    - - - } +
    +
    +   +
    - 1317 + + -
    - - +
    +
    +  
    - 1318 + + -
    - - - // Unpack method inputs +
    +
    +   +
    - 1319 + + -
    - - - data, err := method.Inputs.Unpack(txData[4:]) +
    +
    +   +
    - 1320 + + -
    - - - if err != nil { +
    +
    +   +
    - 1321 + + -
    - - - return nil, err +
    +
    +   +
    - 1322 + + -
    - - - } +
    +
    +   +
    - 1323 + + -
    - - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData +
    +
    +   +
    - 1324 + + -
    - - - bytedata, err := json.Marshal(data[0]) +
    +
    +   +
    - 1325 + + -
    - - - if err != nil { +
    +
    +   +
    - 1326 + + -
    - - - return nil, err +
    +
    +   +
    - 1327 + + -
    - - - } +
    +
    +   +
    - 1328 + + -
    - - - err = json.Unmarshal(bytedata, &sequences) +
    +
    +   +
    - 1329 + + -
    - - - if err != nil { +
    +
    +   +
    - 1330 + + -
    - - - return nil, err +
    +
    +   +
    - 1331 + + -
    - - - } +
    +
    +   +
    - 1332 + + -
    - - - maxSequenceTimestamp := data[1].(uint64) +
    +
    +   +
    - 1333 + + -
    - - - initSequencedBatchNumber := data[2].(uint64) +
    +
    +   +
    - 1334 + + -
    - - - coinbase := (data[3]).(common.Address) +
    +
    +   +
    - 1335 + + -
    - - - sequencedBatches := make([]SequencedBatch, len(sequences)) +
    +
    +   +
    - 1336 + + -
    - - +
    +
    +  
    - 1337 + + -
    - - - for i, seq := range sequences { +
    +
    +   +
    - 1338 + + -
    - - - elderberry := SequencedBatchElderberryData{ +
    +
    +   +
    - 1339 + + -
    - - - MaxSequenceTimestamp: maxSequenceTimestamp, +
    +
    +   +
    - 1340 + + -
    - - - InitSequencedBatchNumber: initSequencedBatchNumber, +
    +
    +   +
    - 1341 + + -
    - - - } +
    +
    +   +
    - 1342 + + -
    - - - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) +
    +
    +   +
    - 1343 + + -
    - - - s := seq +
    +
    +   +
    - 1344 + + -
    - - - sequencedBatches[i] = SequencedBatch{ +
    +
    +   +
    - 1345 + + -
    - - - BatchNumber: bn, +
    +
    +   +
    - 1346 + + -
    - - - L1InfoRoot: &l1InfoRoot, +
    +
    +   +
    - 1347 + + -
    - - - SequencerAddr: sequencer, +
    +
    +   +
    - 1348 + + -
    - - - TxHash: txHash, +
    +
    +   +
    - 1349 + + -
    - - - Nonce: nonce, +
    +
    +   +
    - 1350 + + -
    - - - Coinbase: coinbase, +
    +
    +   +
    - 1351 + + -
    - - - PolygonRollupBaseEtrogBatchData: &s, +
    +
    +   +
    - 1352 + + -
    - - - SequencedBatchElderberryData: &elderberry, +
    +
    +   +
    - 1353 + + -
    - - - } +
    +
    +   +
    - 1354 + + -
    - - - } +
    +
    +   +
    - 1355 + + -
    - - +
    +
    +  
    - 1356 + + -
    - - - return sequencedBatches, nil +
    +
    +   +
    - 1357 + + -
    +
    +
      - } +
    - 1358 + + -
    +
    +
     
    - 1359 + + -
    - - - func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { +
    +
    +   +
    - 1360 + + -
    +
    +
      - // Extract coded txs. +
    - 1361 + + -
    +
    +
      - // Load contract ABI +
    - 1362 + + -
    +
    +
      - smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) +
    -
    @@ -1364,6 +1296,13 @@
    -
    - 1364 + + -
    +
    +
      - return nil, err +
    - 1365 + + -
    +
    +
      - } +
    - 1366 + + -
    +
    +
     
    @@ -53278,303 +53745,168 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1367 + + -
    +
    +
      - // Recover Method from signature and ABI +
    - 1368 + + -
    +
    +
      - method, err := smcAbi.MethodById(txData[:4]) +
    - 1369 + + -
    +
    +
      - if err != nil { +
    -
    @@ -1375,32 +1314,123 @@
    +
    + + +
    +   +
    +
    - 1375 + + -
    +
    +
      - if err != nil { +
    - 1376 + + -
    +
    +
      - return nil, err +
    - 1377 + + -
    +
    +
      - } +
    - 1378 + + -
    - - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData +
    +
    +   +
    - 1379 + + -
    +
    +
      - bytedata, err := json.Marshal(data[0]) +
    - 1380 + + -
    +
    +
      - if err != nil { +
    - 1381 + + -
    +
    +
      - return nil, err +
    - 1382 + + -
    +
    +
      - } +
    - 1383 + + -
    - - - err = json.Unmarshal(bytedata, &sequences) +
    +
    +   +
    - 1384 + + -
    - - - if err != nil { +
    +
    +   +
    - 1385 + + -
    - - - return nil, err +
    +
    +   +
    - 1386 + + -
    - - - } +
    +
    +   +
    - 1387 - -
    - - - coinbase := (data[1]).(common.Address) -
    -
    - 1388 - -
    - - - sequencedBatches := make([]SequencedBatch, len(sequences)) -
    -
    - 1389 - -
    - - - for i, seq := range sequences { -
    -
    - 1390 - -
    - - - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) -
    -
    - 1391 - -
    - - - s := seq -
    -
    - 1392 - -
    - - - sequencedBatches[i] = SequencedBatch{ -
    -
    - 1393 - -
    - - - BatchNumber: bn, -
    -
    - 1394 - -
    - - - L1InfoRoot: &l1InfoRoot, -
    -
    - 1395 - -
    - - - SequencerAddr: sequencer, -
    -
    - 1396 - -
    - - - TxHash: txHash, -
    -
    - 1397 - -
    - - - Nonce: nonce, -
    -
    - 1398 - -
    - - - Coinbase: coinbase, -
    -
    - 1399 - -
    - - - PolygonRollupBaseEtrogBatchData: &s, -
    -
    - 1400 - -
    -   - } -
    -
    - + +
    @@ -53752,1229 +54084,1107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - + + 1 -
    -   -
    +
    +
    + + + package migrations_test
    - + + 2 -
    -   +
    +
    + +
    - + + 3 -
    -   -
    +
    +
    + + + import (
    - + + 4 -
    -   -
    +
    +
    + + + "database/sql"
    - + + 5 -
    -   -
    +
    +
    + + + "fmt"
    - + + 6 -
    -   -
    +
    +
    + + + "testing"
    - + + 7 -
    -   +
    +
    + +
    - + + 8 -
    -   -
    +
    +
    + + + "github.com/stretchr/testify/assert"
    - + + 9 -
    -   -
    +
    +
    + + + )
    - + + 10 -
    -   +
    +
    + +
    - + + 11 -
    -   -
    +
    +
    + + + // this migration changes length of the token name
    - + + 12 -
    -   -
    +
    +
    + + + type migrationTest0020 struct{}
    - + + 13 -
    -   +
    +
    + +
    - + + 14 -
    -   -
    +
    +
    + + + func (m migrationTest0020) InsertData(db *sql.DB) error {
    - + + 15 -
    -   -
    +
    +
    + + + addBlocks := `
    - + + 16 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 17 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 18 -
    -   -
    +
    +
    + + + VALUES(1, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b20', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fe', '2024-03-11 02:52:23.000', true);
    - + + 19 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 20 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 21 -
    -   -
    +
    +
    + + + VALUES(2, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b21', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f1', '2024-03-11 02:52:24.000', true);
    - + + 22 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 23 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 24 -
    -   -
    +
    +
    + + + VALUES(3, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b22', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f2', '2024-03-11 02:52:25.000', false);
    - + + 25 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 26 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 27 -
    -   -
    +
    +
    + + + VALUES(4, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b23', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f3', '2024-03-11 02:52:26.000', false);
    - + + 28 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 29 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 30 -
    -   -
    +
    +
    + + + VALUES(5, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b24', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f4', '2024-03-11 02:52:27.000', true);
    - + + 31 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 32 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 33 -
    -   -
    +
    +
    + + + VALUES(6, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b25', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f5', '2024-03-11 02:52:28.000', true);
    - + + 34 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 35 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 36 -
    -   -
    +
    +
    + + + VALUES(7, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b26', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f6', '2024-03-11 02:52:29.000', true);
    - + + 37 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 38 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 39 -
    -   -
    +
    +
    + + + VALUES(8, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b27', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f7', '2024-03-11 02:52:30.000', true);
    - + + 40 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 41 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 42 -
    -   -
    +
    +
    + + + VALUES(9, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b28', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f8', '2024-03-11 02:52:31.000', true);
    - + + 43 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 44 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 45 -
    -   -
    +
    +
    + + + VALUES(10, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b29', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f9', '2024-03-11 02:52:32.000', true);
    - + + 46 -
    -   -
    +
    +
    + + + INSERT INTO state.block
    - + + 47 -
    -   -
    +
    +
    + + + (block_num, block_hash, parent_hash, received_at, checked)
    - + + 48 -
    -   -
    +
    +
    + + + VALUES(11, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b2a', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fa', '2024-03-11 02:52:33.000', true);
    - + + 49 -
    -   -
    +
    +
    + + + INSERT INTO state.batch
    - + + 50 -
    -   -
    +
    +
    + + + (batch_num, global_exit_root, local_exit_root, state_root, acc_input_hash, "timestamp", coinbase, raw_txs_data, forced_batch_num, batch_resources, closing_reason, wip, checked)
    - + + 51 -
    -   -
    +
    +
    + + + VALUES(1, '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9', '0xa5bd7311fe00707809dd3aa718be2ea0cb363626b9db44172098515f07acf940', '2023-03-24 16:35:27.000', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', decode('','hex'), NULL, '{"Bytes": 0, "ZKCounters": {"GasUsed": 0, "UsedSteps": 0, "UsedBinaries": 0, "UsedMemAligns": 0, "UsedArithmetics": 0, "UsedKeccakHashes": 0, "UsedPoseidonHashes": 0, "UsedSha256Hashes_V2": 0, "UsedPoseidonPaddings": 0}}'::jsonb, '', false, true);
    - + + 52 -
    -   -
    +
    +
    + + + INSERT INTO state.virtual_batch
    - + + 53 -
    -   -
    +
    +
    + + + (batch_num, tx_hash, coinbase, block_num, sequencer_addr, timestamp_batch_etrog, l1_info_root)
    - + + 54 -
    -   -
    +
    +
    + + + VALUES(1, '0x4314ed5d8ad4812e88895942b2b4642af176d80a97c5489a16a7a5aeb08b51a6', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', 2, '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '2024-04-09 16:26:45.000', '0xcdb4258d7ccd8fd41c4a26fd8d9d1fadbc9c506e64d489170525a65e2ad3580b');
    - + + 55 -
    -   -
    +
    +
    + + + INSERT INTO state.verified_batch
    - + + 56 -
    -   -
    +
    +
    + + + (batch_num, tx_hash, aggregator, state_root, block_num, is_trusted)
    - + + 57 -
    -   -
    +
    +
    + + + VALUES(1, '0x28e82f15ab7bac043598623c65a838c315d00ecb5d6e013c406d6bb889680592', '0x6329Fe417621925C81c16F9F9a18c203C21Af7ab', '0x80bd488b1e150b9b42611d038c7fdfa43a3e95b3a02e5c2d57074e73b583f8fd', 3, true);
    - + + 58 -
    -   -
    +
    +
    + + + INSERT INTO state.fork_id
    - + + 59 -
    -   -
    +
    +
    + + + (fork_id, from_batch_num, to_batch_num, "version", block_num)
    - + + 60 -
    -   -
    +
    +
    + + + VALUES(5, 813267, 1228916, 'v2.0.0-RC1-fork.5', 5);
    - + + 61 -
    -   -
    +
    +
    + + + INSERT INTO state.monitored_txs
    - + + 62 -
    -   -
    +
    +
    + + + ("owner", id, from_addr, to_addr, nonce, value, "data", gas, gas_price, status, history, block_num, created_at, updated_at, gas_offset)
    - + + 63 -
    -   -
    +
    +
    + + + VALUES('sequencer', 'sequence-from-2006249-to-2006252', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '0x519E42c24163192Dca44CD3fBDCEBF6be9130987', 58056, NULL, 'def57e540000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000006614ec3100000000000000000000000000000000000000000000000000000000001e9ce8000000000000000000000000148ee7da0000000300000000ee8306089a84ae0baa0082520894417a7ba2d8d0060ae6c54fd098590db854b9c1d58609184e72a0008082044d80802787e068e6fe23cda64eb868cefb7231a17449d508a77919f6c5408814aaab5f259d43a62eb50df0b2d5740552d3f95176a1f0e31cade590facf70b01c1129151bab0b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000000000000000000000000000000', 1474265, 25212431373, 'done', '{0x44423d538d6fc2f2e882fcd0d1952a735d81c824827b83936e6a5e52268a7d8e}', 7, '2024-04-09 09:26:36.235', '2024-04-09 09:38:24.377', 150000);
    - + + 64 -
    -   -
    +
    +
    + + + INSERT INTO state.exit_root
    - + + 65 -
    -   -
    +
    +
    + + + (id, block_num, "timestamp", mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index)
    - + + 66 -
    -   -
    +
    +
    + + + VALUES(379599, 8, '2024-04-09 09:43:59.000', decode('C90DCBC69719971625800AD619E5EEEFD0378317E26F0DDE9B30B3C7C84DBD78','hex'), decode('514D72BBF7C2AD8E4D15EC1186EBF077E98208479651B1C30C5AC7DA11BAB209','hex'), decode('B20FACBED4A2774CE33A0F68D9B6F9B4D9AD553DACD73705503910B141D2102E','hex'), decode('845E01F723E5C77DBE5A4889F299860FBECD8353BFD423D366851F3A90496334','hex'), decode('EDB0EF9C80E947C411FD9B8B23318708132F8A3BD15CD366499866EF91748FC8','hex'), 8032);
    - + + 67 -
    -   -
    +
    +
    + + + INSERT INTO state.forced_batch
    - + + 68 -
    -   -
    +
    +
    + + + (block_num, forced_batch_num, global_exit_root, timestamp, raw_txs_data, coinbase)
    - + + 69 -
    -   -
    +
    +
    + + + VALUES(10, 1, '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5ca', '2024-04-09 09:26:36.235', '0x3f86b09b', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9');
    - + + 70 -
    -   -
    +
    +
    + + + `
    - + + 71 -
    -   -
    +
    +
    + + + if _, err := db.Exec(addBlocks); err != nil {
    - + + 72 -
    -   -
    +
    +
    + + + return err
    - + + 73 -
    -   -
    +
    +
    + + + }
    - + + 74 -
    -   -
    +
    +
    + + + blockCount := `SELECT count(*) FROM state.block`
    - + + 75 -
    -   -
    +
    +
    + + + var count int
    - + + 76 -
    -   -
    +
    +
    + + + err := db.QueryRow(blockCount).Scan(&count)
    - 1401 + + 77 +
    -   - } + + + if err != nil {
    - 1402 + + 78 +
    -   -
    + + + return err
    - 1403 + + 79 +
    - - - return sequencedBatches, nil -
    -
    - 1404 - -
    -   - } -
    -
    - 1405 - -
    -   -
    -
    -
    - 1406 - -
    -   - func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { + + + }
    -
    @@ -1872,15 +1902,15 @@
    -
    - 1872 + + 80 +
    -   - } + + + if count != 11 {
    - 1873 + + 81 +
    -   -
    + + + return fmt.Errorf("error: initial wrong number of blocks")
    - 1874 + + 82 +
    -   - // LoadAuthFromKeyStore loads an authorization from a key store file + + + }
    - 1875 + + 83 +
    - - - func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) { + + + return nil
    - 1876 + + 84 +
    - - - auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID) + + + }
    - 1877 + + 85 +
    -   - if err != nil { + + +
    - 1878 + + 86 +
    - - - return nil, err + + + func (m migrationTest0020) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) {
    - 1879 + + 87 +
    -   - } + + + blockCount := `SELECT count(*) FROM state.block`
    - 1880 + + 88 +
    -   -
    + + + var count int
    - 1881 + + 89 +
    -   - log.Infof("loaded authorization for address: %v", auth.From.String()) + + + err := db.QueryRow(blockCount).Scan(&count)
    - 1882 + + 90 +
    -   - etherMan.auth[auth.From] = auth + + + assert.NoError(t, err)
    - 1883 + + 91 +
    - - - return &auth, nil + + + assert.Equal(t, 6, count)
    - 1884 + + 92 +
    -   + + }
    - 1885 + + 93 +
    -   + +
    - 1886 + + 94 +
    -   - // newKeyFromKeystore creates an instance of a keystore key from a keystore file + + + func (m migrationTest0020) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) {
    -
    @@ -1901,20 +1931,20 @@
    -
    - 1901 + + 95 +
    -   + + }
    - 1902 + + 96 +
    -   + +
    - 1903 - -
    -   - // newAuthFromKeystore an authorization instance from a keystore file -
    -
    - 1904 - -
    - - - func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) { -
    -
    - 1905 - -
    -   - log.Infof("reading key from: %v", path) -
    -
    - 1906 - -
    -   - key, err := newKeyFromKeystore(path, password) -
    -
    - 1907 - -
    -   - if err != nil { -
    -
    - 1908 - -
    - - - return bind.TransactOpts{}, err -
    -
    - 1909 - -
    -   - } -
    -
    - 1910 - -
    -   - if key == nil { -
    -
    - 1911 - -
    - - - return bind.TransactOpts{}, nil -
    -
    - 1912 + + 97 +
    -   - } + + + func TestMigration0020(t *testing.T) {
    - 1913 + + 98 +
    -   - auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID)) + + + runMigrationTest(t, 20, migrationTest0020{})
    - 1914 + + 99 +
    -   - if err != nil { + + + }
    - 1915 - -
    - - - return bind.TransactOpts{}, err +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/validium-001.sql + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - @@ -55242,33 +55452,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - + + + + + + - - - - - @@ -55278,1217 +55508,1393 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -0,0 +1,32 @@
    - 1916 + + -
    +
    +
      - } -
    -
    - 1917 - -
    - - - return *auth, nil +
    - 1918 + + -
    +
    +
      - } +
    - 1919 + + -
    +
    +
     
    - 1920 + + -
    +
    +
      - // getAuthByAddress tries to get an authorization from the authorizations map +
    -
    @@ -1942,3 +1972,28 @@
    -
    - 1942 + + -
    +
    +
     
    - 1943 + + -
    +
    +
      - return *auth, nil +
    - 1944 + + -
    +
    +
      - } +
    + + 1 + +
    + + + -- +migrate Up +
    +
    + 2 + +
    + + +
    +
    +
    3 +
    -   - import ( + + + CREATE TABLE IF NOT EXISTS state.batch_data_backup
    + 4 +
    -   - "bytes" + + + (
    + 5 +
    -   - "context" + + + batch_num BIGINT,
    + - "crypto/ecdsa" + data BYTEA,
    + 7 +
    -   - "encoding/json" + + + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
    + 8 +
    -   - "errors" + + + PRIMARY KEY (batch_num, created_at)
    + 9 +
    -   - "fmt" + + + );
    -
     
    -
    - 109 + + 10 +
    -   - // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry + + +
    - 110 + + 11 +
    -   - methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address) + + + -- +migrate StatementBegin
    - 111 + + 12 +
    -   -
    + + + CREATE OR REPLACE FUNCTION backup_batch() RETURNS trigger AS $$
    - 112 + 13
    + - // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog + BEGIN
    - 113 + 14
    + - methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes) + INSERT INTO state.batch_data_backup (batch_num, data)
    - 114 + 15
    + - // methodIDSequenceBatchesValidiumElderberry: MethodID for sequenceBatchesValidium in Elderberry + VALUES (OLD.batch_num, OLD.raw_txs_data)
    - 115 + 16
    + - methodIDSequenceBatchesValidiumElderberry = []byte{0xdb, 0x5b, 0x0e, 0xd7} // 0xdb5b0ed7 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes) + ON CONFLICT (batch_num, created_at) DO UPDATE SET
    - 116 + 17
    + -
    + data = EXCLUDED.data;
    - 117 + + 18 +
    -   - // ErrNotFound is used when the object is not found + + + RETURN OLD;
    - 118 + + 19 +
    -   - ErrNotFound = errors.New("not found") + + + END;
    - 119 + + 20 +
    -   - // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode. + + + $$
    -
     
    -
    - 197 + + 21 +
    -   - GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot + + + LANGUAGE plpgsql;
    - 198 + + 22 +
    -   - OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot + + + -- +migrate StatementEnd
    - 199 + + 23 +
    -   - Pol *pol.Pol + + +
    - 200 + 24
    + - DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol + CREATE TRIGGER backup_batch
    - 201 + + 25 +
    -   - SCAddresses []common.Address + + + BEFORE DELETE ON state.batch FOR EACH ROW
    - 202 + + 26 +
    -   -
    + + + EXECUTE PROCEDURE backup_batch();
    - 203 + + 27 +
    -   - RollupID uint32 + + +
    -
     
    -
    - 207 + + 28 +
    -   - l1Cfg L1Config + + + -- +migrate Down
    - 208 + + 29 +
    -   - cfg Config + + +
    - 209 + + 30 +
    -   - auth map[common.Address]bind.TransactOpts // empty in case of read-only client + + + DROP TRIGGER IF EXISTS backup_batch ON state.batch;
    - 210 + 31
    + -
    + DROP FUNCTION IF EXISTS backup_batch();
    - 211 + 32
    + - da dataavailability.BatchDataProvider + DROP TABLE IF EXISTS state.batch_data_backup;
    - 212 - -
    -   - } +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,47 @@
    - 213 + + -
    +
    +
     
    - 214 + + -
    +
    +
      - // NewClient creates a new etherman. +
    - 215 + + -
    - + - func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider) (*Client, error) { +
    +
    +   +
    - 216 + + -
    +
    +
      - // Connect to ethereum node +
    - 217 + + -
    +
    +
      - ethClient, err := ethclient.Dial(cfg.URL) +
    - 218 + + -
    +
    +
      - if err != nil { +
    -
     
    -
    - 255 + + -
    +
    +
      - log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err) +
    - 256 + + -
    +
    +
      - return nil, err +
    - 257 + + -
    +
    +
      - } +
    - 258 + + -
    - + - dapAddr, err := zkevm.DataAvailabilityProtocol(&bind.CallOpts{Pending: false}) +
    +
    +   +
    - 259 + + -
    - + - if err != nil { +
    +
    +   +
    - 260 + + -
    - + - return nil, err +
    +
    +   +
    - 261 + + -
    - + - } +
    +
    +   +
    - 262 + + -
    - + - dap, err := dataavailabilityprotocol.NewDataavailabilityprotocol(dapAddr, ethClient) +
    +
    +   +
    - 263 + + -
    - + - if err != nil { +
    +
    +   +
    - 264 + + -
    - + - return nil, err +
    +
    +   +
    - 265 + + -
    - + - } +
    +
    +   +
    - 266 + + -
    +
    +
      - var scAddresses []common.Address +
    - 267 + + -
    +
    +
      - scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr) +
    - 268 + + -
    +
    +
     
    -
     
    -
    - 293 + + -
    +
    +
      - RollupManager: rollupManager, +
    - 294 + + -
    +
    +
      - Pol: pol, +
    - 295 + + -
    +
    +
      - GlobalExitRootManager: globalExitRoot, +
    - 296 + + -
    - + - DAProtocol: dap, +
    +
    +   +
    - 297 + + -
    +
    +
      - OldGlobalExitRootManager: oldGlobalExitRoot, +
    - 298 + + -
    +
    +
      - SCAddresses: scAddresses, +
    - 299 + + -
    +
    +
      - RollupID: rollupID, +
    -
     
    +
    + + +
    +   +
    +
    - 304 + + -
    +
    +
      - l1Cfg: l1Config, +
    - 305 + + -
    +
    +
      - cfg: cfg, +
    - 306 + + -
    +
    +
      - auth: map[common.Address]bind.TransactOpts{}, +
    - 307 + + -
    - + - da: da, +
    +
    +   +
    - 308 + + -
    +
    +
      - }, nil +
    - 309 + + -
    +
    +
      - } +
    - 310 + + -
    +
    +
     
    - 311 + + -
    +
    +
      - // VerifyGenBlockNumber verifies if the genesis Block Number is valid +
    - 312 + + -
    +
    +
      - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    + + + + + - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - 313 + 1
    + - // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block + PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/"
    - 314 + + 2 +
    -   - start := time.Now() + + + diff -ruN \
    - 315 + + 3 +
    -   - log.Info("Verifying genesis blockNumber: ", genBlockNumber) + + + -I ".*github.com\/0x.*" \
    - 316 + + 4 +
    -   - // Filter query + + + -x "*mock*" -x ".git" \
    -
     
    +
    + 5 + +
    + + + -x ".github" \ +
    - 366 + + 6 +
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) + + + -x ".gitignore" \
    - 367 + + 7 +
    -   - start := time.Now() + + + -x ".vscode" \
    - 368 + + 8 +
    -   - var logs []types.Log + + + -x "ci" \
    - 369 + 9
    + -
    + -x "environments" \
    - 370 + 10
    + - if lastL1BlockSynced < genBlockNumber { + -x "*.md" \
    - 371 + 11
    + - lastL1BlockSynced = genBlockNumber + -x "*.html" \
    - 372 + 12
    + - } + -x "*.html" \
    - 373 + 13
    + -
    + -x "*.json" \
    - 374 + + 14 +
    -   - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) + + + -x "*.toml" \
    - 375 + + 15 +
    -   - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { + + + -x "*.abi" \
    - 376 + + 16 +
    -   - final := i + etherMan.cfg.ForkIDChunkSize + + + -x "*.bin" \
    -
     
    +
    + 17 + +
    + + + -x "*.pb.go" \ +
    - 711 + + 18 +
    -   - return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID) + + + -x "smartcontracts" \
    - 712 + + 19 +
    -   - } + + + -x "go.sum" \
    - 713 + + 20 +
    -   -
    + + + -x "mock*.go" \
    - 714 + + 21 +
    + - func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error { + -x "*venv*" \
    - 715 + + 22 +
    + - return errors.New("upgrading validiums to etrog not supported") + -x "/dist/" \
    - + + 23 -
    -   -
    +
    +
    + + + -x "/test/e2e/keystore" \
    - + + 24 -
    -   -
    +
    +
    + + + -x "/test/vectors/src/**/*md" \
    - + + 25 -
    -   -
    +
    +
    + + + -x "/test/vectors/src/**/*js" \
    - + + 26 -
    -   -
    +
    +
    + + + -x "/test/vectors/src/**/*sol" \
    - + + 27 -
    -   -
    +
    +
    + + + -x "/test/vectors/src/**/*sh" \
    - + + 28 -
    -   -
    +
    +
    + + + -x "/test/vectors/src/package.json" \
    - + + 29 -
    -   -
    +
    +
    + + + -x "/test/contracts/bin/**/*.bin" \
    - + + 30 -
    -   -
    +
    +
    + + + -x "/test/contracts/bin/**/*.abi" \
    - + + 31 -
    -   -
    +
    +
    + + + -x "/tools/datastreamer/*.bin" \
    - + + 32 -
    -   -
    +
    +
    + + + -x "/test/datastreamer/*.db/*" \
    - + + 33 -
    -   -
    +
    +
    + + + -x "/test/*.bin" \
    - + + 34 -
    -   -
    +
    +
    + + + -x "/test/*.db/*" \
    - + + 35 -
    -   -
    +
    +
    + + + -x "**/.DS_Store" \
    - + + 36 -
    -   -
    +
    +
    + + + -x ".vscode" \
    - + + 37 -
    -   -
    +
    +
    + + + -x ".idea/" \
    - + + 38 -
    -   -
    +
    +
    + + + -x ".env" \
    - + + 39 -
    -   -
    +
    +
    + + + -x "out.dat" \
    - + + 40 -
    -   -
    +
    +
    + + + -x "cmd/__debug_bin" \
    - + + 41 -
    -   -
    +
    +
    + + + -x ".venv" \
    - + + 42 -
    -   -
    +
    +
    + + + -x "*metrics.txt" \
    - + + 43 -
    -   -
    +
    +
    + + + -x "coverage.out" \
    - + + 44 -
    -   -
    +
    +
    + + + -x "*datastream.db*" \
    - + + 45 -
    -   -
    +
    +
    + + + ${PATH_TO_ZKEVM_NODE_REPO} . | \
    - + + 46 -
    -   -
    +
    +
    + + + diff2html -i stdin -s side -t "zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.6.0<h2/>" \
    - + + 47 -
    -   -
    +
    +
    + + + -F ./docs/diff/diff.html
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - - - + + +
    +
    @@ -14,7 +14,6 @@
    +
    - + + 14 -
    +
    +
      -
    + # CONTAINER FOR RUNNING BINARY
    - + + 15 -
    +
    +
      -
    + FROM alpine:3.18
    - + + 16 -
    +
    +
      -
    + COPY --from=build /src/dist/zkevm-node /app/zkevm-node
    - + + 17 -
    +
    +
    + - + COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml +
    +
    + 18 + +
      -
    + RUN apk update && apk add postgresql15-client
    - + + 19 -
    +
    +
      -
    + EXPOSE 8123
    - + + 20 -
    +
    +
      -
    + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -56502,34 +56908,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
     
    - + + 14 -
    +
    +
      -
    + # CONTAINER FOR RUNNING BINARY
    - + + 15 -
    +
    +
      -
    + FROM alpine:3.18
    - + + 16 -
    +
    +
      -
    + COPY --from=build /src/dist/zkevm-node /app/zkevm-node
    - + + 17 -
    +
    +
      -
    + RUN apk update && apk add postgresql15-client
    - + + 18 -
    +
    +
      -
    + EXPOSE 8123
    - + + 19 -
    +
    +
      -
    + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release + RENAMED + +
    +
    +
    +
    + + + + + + + +
    +
    @@ -0,0 +1,15 @@
    @@ -56681,594 +57116,627 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + +
    +
     
    +
    - 716 + + 1 +
    -   - } + + + FROM alpine:3.18
    - 717 + + 2 +
    -   + +
    - 718 + + 3 +
    -   - func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + + COPY zkevm-node /app/zkevm-node
    -
     
    -
    - 911 + + 4 +
    -   - } + + +
    - 912 + + 5 +
    -   -
    + + + EXPOSE 8123
    - 913 + + 6 +
    -   - // EstimateGasSequenceBatches estimates gas for sending batches + + +
    - 914 + + 7 +
    + - func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) { + RUN addgroup -S zkevm-group \
    - 915 + + 8 +
    -   - opts, err := etherMan.getAuthByAddress(sender) + + + && adduser -S zkevm-user -G zkevm-group
    - 916 + + 9 +
    -   - if err == ErrNotFound { + + +
    - 917 + + 10 +
    -   - return nil, ErrPrivateKeyNotFound + + + RUN chown -R zkevm-user:zkevm-group /app
    - 918 + + 11 +
    -   - } + + +
    - 919 + + 12 +
    -   - opts.NoSend = true + + + USER zkevm-user
    - 920 + + 13 +
    -   + +
    - 921 + + 14 +
    + - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) + CMD ["/app/zkevm-node"] +
    +
    + 15 + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go + RENAMED + +
    +
    +
    +
    + + + + + - - + - - + - - + - - - - - - - - - - - - - + + + - - - - - - - - - - - - + - - @@ -57282,308 +57750,288 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - @@ -57607,53 +58055,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - @@ -57667,73 +58115,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -57787,1783 +58230,1803 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -3,6 +3,7 @@
    - 922 + 3
      - if err != nil { + import (
    - 923 + 4
      - return nil, err + "bytes"
    - 924 + 5
      - } + "context"
    -
     
    +
    + + +
    +   +
    +
    - 927 + 6
      - } + "encoding/json"
    - 928 + 7
      -
    + "errors"
    - 929 + 8
      - // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches. + "fmt"
    - 930 - -
    - + - func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (to *common.Address, data []byte, err error) { -
    +
    +
    @@ -106,6 +109,11 @@
    - 931 + 106
      - opts, err := etherMan.getAuthByAddress(sender) + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
    - 932 + 107
      - if err == ErrNotFound { + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
    - 933 + 108
      - return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound) +
    -
     
    +
    + + +
    +   +
    +
    - 938 + + -
    +
    +
      - opts.GasLimit = uint64(1) +
    - 939 + + -
    +
    +
      - opts.GasPrice = big.NewInt(1) +
    - 940 + + -
    +
    +
     
    - 941 + + -
    - + - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) +
    +
    +   +
    - 942 + 109
      - if err != nil { + // ErrNotFound is used when the object is not found
    - 943 + 110
      - return nil, nil, err + ErrNotFound = errors.New("not found")
    - 944 + 111
      - } + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    -
     
    +
    @@ -189,6 +197,7 @@
    - 946 + 189
      - return tx.To(), tx.Data(), nil + GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
    - 947 + 190
      - } + OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
    - 948 + 191
      -
    -
    -
    - 949 - -
    - + - func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) { + Pol *pol.Pol
    - 950 + + -
    - + - var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData +
    +
    +   +
    - 951 + 192
      - for _, seq := range sequences { + SCAddresses []common.Address
    - 952 + 193
      - var ger common.Hash +
    - 953 + 194
      - if seq.ForcedBatchTimestamp > 0 { + RollupID uint32
    +
    @@ -198,10 +207,13 @@
    +
    - 954 + 198
      - ger = seq.GlobalExitRoot + l1Cfg L1Config
    - 955 + 199
      - } -
    -
    - 956 - -
    - + - batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ -
    -
    - 957 - -
    - + - TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data), + cfg Config
    - 958 + 200
      - ForcedGlobalExitRoot: ger, + auth map[common.Address]bind.TransactOpts // empty in case of read-only client
    - 959 + + -
    +
    +
      - ForcedTimestamp: uint64(seq.ForcedBatchTimestamp), +
    - 960 + + -
    +
    +
      - ForcedBlockHashL1: seq.PrevBlockHash, +
    -
     
    +
    + + +
    +   +
    +
    - 963 + 201
      - batches = append(batches, batch) + }
    - 964 + 202
      - } +
    - 965 + 203
      -
    + // NewClient creates a new etherman.
    - 966 + + 204 +
    - + - tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) + - + func NewClient(cfg Config, l1Config L1Config) (*Client, error) {
    - 967 + 205
      - if err != nil { + // Connect to ethereum node
    - 968 + 206
      - log.Debugf("Batches to send: %+v", batches) + ethClient, err := ethclient.Dial(cfg.URL)
    - 969 + 207
      - log.Debug("l2CoinBase: ", l2Coinbase) + if err != nil {
    -
     
    +
    @@ -244,6 +256,14 @@
    - 1159 + 244
      -
    + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - 1160 + 245
      - func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + return nil, err
    - 1161 + 246
      - log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:])) + }
    - 1162 + + -
    +
    +
     
    - 1163 + + -
    +
    +
      - sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog) +
    - 1164 + + -
    +
    +
      - if err != nil { +
    -
     
    -
    - 1182 + + -
    +
    +
      - if sb.NumBatch != 1 { +
    - 1183 + + -
    +
    +
      - methodId := tx.Data()[:4] +
    - 1184 + + -
    +
    +
      - log.Debugf("MethodId: %s", common.Bytes2Hex(methodId)) -
    -
    - 1185 - -
    - + - if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) || +
    - 1186 + + -
    - + - bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) { +
    +
    +   +
    - 1187 + + 247 +
    - + - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da) +   + var scAddresses []common.Address
    - 1188 + 248
      - if err != nil { + scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
    - 1189 + 249
      - return fmt.Errorf("error decoding the sequences (etrog): %v", err) +
    +
    @@ -262,7 +282,7 @@
    +
    - 1190 + 262
      - } + rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr)
    - 1191 + + 263 +
    - + - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) || +   + if err != nil {
    - 1192 + + 264 +
    - + - bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) { +   + log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
    - 1193 + + 265 +
    - + - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da) + - + // TODO return error after the upgrade
    - 1194 + 266
      - if err != nil { + }
    - 1195 + 267
      - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) + log.Debug("rollupID: ", rollupID)
    - 1196 + 268
      - } +
    -
     
    +
    @@ -274,6 +294,7 @@
    - 1276 + 274
      - return nil + RollupManager: rollupManager,
    - 1277 + 275
      - } + Pol: pol,
    - 1278 + 276
      -
    + GlobalExitRootManager: globalExitRoot,
    - 1279 + + -
    - + - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, da dataavailability.BatchDataProvider) ([]SequencedBatch, error) { +
    +
    +   +
    - 1280 + 277
      - // Extract coded txs. + OldGlobalExitRootManager: oldGlobalExitRoot,
    - 1281 + 278
      - // Load contract ABI + SCAddresses: scAddresses,
    - 1282 + 279
      - smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) + RollupID: rollupID,
    -
     
    +
    @@ -284,11 +305,14 @@
    - 1284 + 284
      - return nil, err + l1Cfg: l1Config,
    - 1285 + 285
      - } + cfg: cfg,
    - 1286 + 286
      -
    -
    -
    - 1287 - -
    - + - return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da) + auth: map[common.Address]bind.TransactOpts{},
    - + + 287 -
    +
    +
      -
    + }, nil
    - + + 288 -
    +
    +
      -
    + }
    - + + 289 -
    +
    +
     
    - + + 290 -
    +
    +
      -
    + // VerifyGenBlockNumber verifies if the genesis Block Number is valid
    - + + 291 -
    +
    +
      -
    + func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
    - + + 292 -
    +
    +
      -
    + start := time.Now()
    - + + 293 -
    +
    +
      -
    + log.Info("Verifying genesis blockNumber: ", genBlockNumber)
    - + + 294 -
    +
    +
      -
    + // Filter query
    - - -
    -   -
    -
    +
    +
    @@ -344,6 +368,11 @@
    - + + 344 -
    +
    +
      -
    + log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
    - + + 345 -
    +
    +
      -
    + start := time.Now()
    - + + 346 -
    +
    +
      -
    + var logs []types.Log
    - + + 347 -
    +
    +
      -
    + log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
    - + + 348 -
    +
    +
      -
    + for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
    - + + 349 -
    +
    +
      -
    + final := i + etherMan.cfg.ForkIDChunkSize
    - - -
    -   -
    -
    +
    +
    @@ -684,61 +713,8 @@
    - + + 684 -
    +
    +
      -
    + return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
    - + + 685 -
    +
    +
      -
    + }
    - + + 686 -
    +
    +
     
    - + + 687 -
    -   -
    +
    +
    + - + func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 688 -
    -   -
    +
    +
    + - + log.Debug("updateEtrogSequence event detected")
    - + + 689 -
    -   -
    +
    +
    + - + updateEtrogSequence, err := etherMan.EtrogZKEVM.ParseUpdateEtrogSequence(vLog)
    - + + 690 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 691 -
    -   -
    +
    +
    + - + log.Error("error parsing updateEtrogSequence event. Error: ", err)
    - + + 692 -
    -   -
    +
    +
    + - + return err
    - + + 693 -
    -   -
    +
    +
    + - + }
    - + + 694 -
    -   +
    +
    + -
    - + + 695 -
    -   -
    +
    +
    + - + // Read the tx for this event.
    - + + 696 -
    -   -
    +
    +
    + - + tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex)
    - + + 697 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 698 -
    -   -
    +
    +
    + - + return err
    - + + 699 -
    -   -
    +
    +
    + - + }
    - + + 700 -
    -   -
    +
    +
    + - + if tx.Hash() != vLog.TxHash {
    - + + 701 -
    -   -
    +
    +
    + - + return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String())
    - + + 702 -
    -   -
    +
    +
    + - + }
    - + + 703 -
    -   -
    +
    +
    + - + msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0))
    - 1288 + + 704 +
    -   - } + - + if err != nil {
    - 1289 + + 705 +
    -   -
    + - + return err
    - 1290 + + 706 +
    - + - func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, + - + }
    - 1291 + + 707 +
    - + - da dataavailability.BatchDataProvider) ([]SequencedBatch, error) { + - + fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash)
    - 1292 + + 708 +
    -   - // Extract coded txs. + - + if err != nil {
    - 1293 + + 709 +
    -   - // Load contract ABI + - + return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err)
    - 1294 + + 710 +
    -   - smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) + - + }
    -
     
    -
    - 1296 + + 711 +
    -   - return nil, err + - +
    - 1297 + + 712 +
    -   - } + - + log.Info("update Etrog transaction sequence...")
    - 1298 + + 713 +
    -   -
    + - + sequence := UpdateEtrogSequence{
    - 1299 + + 714 +
    - + - return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da) + - + BatchNumber: updateEtrogSequence.NumBatch,
    - 1300 + + 715 +
    - + - } + - + SequencerAddr: updateEtrogSequence.Sequencer,
    - 1301 + + 716 +
    - + -
    + - + TxHash: vLog.TxHash,
    - 1302 + + 717 +
    - + - // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches + - + Nonce: msg.Nonce,
    - 1303 + + 718 +
    - + - func decodeSequencedBatches(smcAbi abi.ABI, txData []byte, forkID uint64, lastBatchNumber uint64, + - + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1304 + + 719 +
    - + - sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, + - + Transactions: updateEtrogSequence.Transactions,
    - 1305 + + 720 +
    - + - da dataavailability.BatchDataProvider) ([]SequencedBatch, error) { + - + ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot,
    - 1306 + + 721 +
    -   - // Recover Method from signature and ABI + - + ForcedTimestamp: fullBlock.Time(),
    - 1307 + + 722 +
    -   - method, err := smcAbi.MethodById(txData[:4]) + - + ForcedBlockHashL1: fullBlock.ParentHash(),
    - 1308 + + 723 +
    -   - if err != nil { + - + },
    -
     
    -
    - 1314 + + 724 +
    -   - if err != nil { + - + }
    - 1315 + + 725 +
    -   - return nil, err + - +
    - 1316 + + 726 +
    -   - } + - + if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) {
    - + + 727 -
    -   -
    +
    +
    + - + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock)
    - 1317 + + 728 +
    -   - bytedata, err := json.Marshal(data[0]) + - + block.UpdateEtrogSequence = sequence
    - 1318 + + 729 +
    -   - if err != nil { + - + *blocks = append(*blocks, block)
    - 1319 + + 730 +
    -   - return nil, err + - + } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber {
    - 1320 + + 731 +
    -   - } + - + (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence
    - 1321 + + 732 +
    - + -
    + - + } else {
    - 1322 + + 733 +
    - + - var ( + - + log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber)
    - 1323 + + 734 +
    - + - maxSequenceTimestamp uint64 + - + return fmt.Errorf("error processing UpdateEtrogSequence event")
    - 1324 + + 735 +
    - + - initSequencedBatchNumber uint64 + - + }
    - 1325 + + 736 +
    - + - coinbase common.Address + - + or := Order{
    - 1326 + + 737 +
    - + - dataAvailabilityMsg []byte + - + Name: UpdateEtrogSequenceOrder,
    - 1327 + + 738 +
    - + - ) + - + Pos: 0,
    - 1328 + + 739 +
    - + -
    + - + }
    - 1329 + + 740 +
    - + - switch method.Name { + - + (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or)
    - 1330 + + 741 +
    - + - case "sequenceBatches": + - + return nil
    - 1331 + + 742 +
    - + - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData +   + }
    - 1332 + + 743 +
    - + - err := json.Unmarshal(bytedata, &sequences) +   +
    - 1333 + + 744 +
    - + - if err != nil { +   + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 1334 + +
    @@ -937,14 +913,14 @@
    +
    + 937 +
    - + - return nil, err +   + }
    - + + 938 -
    +
    +
     
    - + + 939 -
    +
    +
      -
    + // EstimateGasSequenceBatches estimates gas for sending batches
    - + + 940 -
    -   -
    +
    +
    + - + func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
    - 1335 + 941
      - } + opts, err := etherMan.getAuthByAddress(sender)
    - 1336 + + 942 +
    - + -
    +   + if err == ErrNotFound {
    - 1337 + + 943 +
    - + - switch forkID { +   + return nil, ErrPrivateKeyNotFound
    - 1338 + + 944 +
    - + - case state.FORKID_ETROG: +   + }
    - 1339 + + 945 +
    - + - coinbase = data[1].(common.Address) +   + opts.NoSend = true
    - 1340 + + 946 +
    - + +  
    - 1341 + + 947 +
    - + - case state.FORKID_ELDERBERRY: + - + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - 1342 + + 948 +
    - + - maxSequenceTimestamp = data[1].(uint64) +   + if err != nil {
    - 1343 + + 949 +
    - + - initSequencedBatchNumber = data[2].(uint64) +   + return nil, err
    - 1344 + + 950 +
    - + - coinbase = data[3].(common.Address) +   + }
    - 1345 + +
    @@ -953,7 +929,7 @@
    +
    + 953 +
    - + - } +   + }
    - 1346 + + 954 +
    - + +  
    - 1347 + + 955 +
    - + - sequencedBatches := make([]SequencedBatch, len(sequences)) +   + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - 1348 + + 956 +
    - + - for i, seq := range sequences { + - + func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) {
    - 1349 + + 957 +
    - + - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) +   + opts, err := etherMan.getAuthByAddress(sender)
    - 1350 + + 958 +
    - + - s := seq +   + if err == ErrNotFound {
    - 1351 + + 959 +
    - + - batch := SequencedBatch{ +   + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    - 1352 + +
    @@ -964,7 +940,7 @@
    +
    + 964 +
    - + - BatchNumber: bn, +   + opts.GasLimit = uint64(1)
    - 1353 + + 965 +
    - + - L1InfoRoot: &l1InfoRoot, +   + opts.GasPrice = big.NewInt(1)
    - 1354 + + 966 +
    - + - SequencerAddr: sequencer, +   +
    - 1355 + + 967 +
    - + - TxHash: txHash, + - + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - 1356 + + 968 +
    - + - Nonce: nonce, +   + if err != nil {
    - 1357 + + 969 +
    - + - Coinbase: coinbase, +   + return nil, nil, err
    - 1358 + + 970 +
    - + - PolygonRollupBaseEtrogBatchData: &s, +   + }
    - 1359 + +
    @@ -972,15 +948,15 @@
    +
    + 972 +
    - + - } +   + return tx.To(), tx.Data(), nil
    - 1360 + + 973 +
    - + - if forkID >= state.FORKID_ELDERBERRY { +   + }
    - 1361 + + 974 +
    - + - batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{ +   +
    - 1362 + + 975 +
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, + - + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
    - 1363 + + 976 +
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, + - + var batches []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 1364 + + 977 +
    - + - } +   + for _, seq := range sequences {
    - 1365 + + 978 +
    - + - } +   + var ger common.Hash
    - 1366 + + 979 +
    - + - sequencedBatches[i] = batch +   + if seq.ForcedBatchTimestamp > 0 {
    - 1367 + + 980 +
    - + - } +   + ger = seq.GlobalExitRoot
    - 1368 + + 981 +
    - + -
    +   + }
    - 1369 + + 982 +
    - + - return sequencedBatches, nil + - + batch := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1370 + + 983 +
    - + - case "sequenceBatchesValidium": + - + Transactions: seq.BatchL2Data,
    - 1371 + + 984 +
    - + - var sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData +   + ForcedGlobalExitRoot: ger,
    - 1372 + + 985 +
    - + - err := json.Unmarshal(bytedata, &sequencesValidium) +   + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - 1373 + + 986 +
    - + - if err != nil { +   + ForcedBlockHashL1: seq.PrevBlockHash,
    - 1374 + +
    @@ -989,7 +965,7 @@
    +
    + 989 +
    - + - return nil, err +   + batches = append(batches, batch)
    - 1375 + + 990 +
    - + - } +   + }
    - 1376 + + 991 +
    - + +  
    - 1377 + + 992 +
    - + - switch forkID { + - + tx, err := etherMan.ZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - 1378 + + 993 +
    - + - case state.FORKID_ETROG: +   + if err != nil {
    - 1379 + + 994 +
    - + - coinbase = data[1].(common.Address) +   + log.Debugf("Batches to send: %+v", batches)
    - 1380 + + 995 +
    - + - dataAvailabilityMsg = data[2].([]byte) +   + log.Debug("l2CoinBase: ", l2Coinbase)
    - 1381 + +
    @@ -1185,7 +1161,6 @@
    +
    + 1185 +
    - + +  
    - 1382 + + 1186 +
    - + - case state.FORKID_ELDERBERRY: +   + func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 1383 + + 1187 +
    - + - maxSequenceTimestamp = data[1].(uint64) +   + log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:]))
    - 1384 + + 1188 +
    - + - initSequencedBatchNumber = data[2].(uint64) + - + //tx,isPending, err:=etherMan.EthClient.TransactionByHash(ctx, vLog.TxHash)
    - 1385 + + 1189 +
    - + - coinbase = data[3].(common.Address) +   +
    - 1386 + + 1190 +
    - + - dataAvailabilityMsg = data[4].([]byte) +   + sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog)
    - 1387 + + 1191 +
    - + - } +   + if err != nil {
    - 1388 - -
    - + -
    -
    +
    +
    @@ -1209,13 +1184,15 @@
    - 1389 + + 1209 +
    - + - sequencedBatches := make([]SequencedBatch, len(sequencesValidium)) +   + if sb.NumBatch != 1 {
    - 1390 + + 1210 +
    - + -
    +   + methodId := tx.Data()[:4]
    - 1391 + + 1211 +
    - + - var ( +   + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - 1392 + + 1212 +
    - + - batchNums []uint64 + - + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) {
    - 1393 + + 1213 +
    - + - hashes []common.Hash + - + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 1394 + + -
    - + - ) +
    +
    +   +
    - 1395 + + 1214 +
    - + -
    +   + if err != nil {
    - 1396 + + 1215 +
    - + - for i, validiumData := range sequencesValidium { +   + return fmt.Errorf("error decoding the sequences (etrog): %v", err)
    - 1397 + + 1216 +
    - + - bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1)) +   + }
    - 1398 + + 1217 +
    - + - batchNums = append(batchNums, bn) + - + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) {
    - 1399 + + 1218 +
    - + - hashes = append(hashes, validiumData.TransactionsHash) + - + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 1400 + + -
    - + - } +
    +
    +   +
    - 1401 + + 1219 +
    - + - batchL2Data, err := da.GetBatchL2Data(batchNums, hashes, dataAvailabilityMsg) +   + if err != nil {
    - 1402 + + 1220 +
    - + - if err != nil { +   + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 1403 + + 1221 +
    - + - return nil, err +   + }
    - 1404 + +
    @@ -1301,7 +1278,8 @@
    +
    + 1301 +
    - + - } +   + return nil
    - 1405 + + 1302 +
    - + - for i, bn := range batchNums { +   + }
    - 1406 + + 1303 +
    - + - s := polygonzkevm.PolygonRollupBaseEtrogBatchData{ +   +
    - 1407 + + 1304 +
    - + - Transactions: batchL2Data[i], + - + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 1408 + + -
    - + - ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot, +
    +
    +   +
    - 1409 + + 1305 +
    - + - ForcedTimestamp: sequencesValidium[i].ForcedTimestamp, +   + // Extract coded txs.
    - 1410 + + 1306 +
    - + - ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1, +   + // Load contract ABI
    - 1411 + + 1307 +
    - + - } +   + smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    - 1412 + +
    @@ -1309,6 +1287,25 @@
    +
    + 1309 +
    - + - batch := SequencedBatch{ +   + return nil, err
    - 1413 + + 1310 +
    - + - BatchNumber: bn, +   + }
    - 1414 + + 1311 +
    - + - L1InfoRoot: &l1InfoRoot, +   +
    - 1415 + + -
    - + - SequencerAddr: sequencer, +
    +
    +   +
    - 1416 + + -
    - + - TxHash: txHash, +
    +
    +   +
    - 1417 + + -
    - + - Nonce: nonce, +
    +
    +   +
    - 1418 + + -
    - + - Coinbase: coinbase, +
    +
    +   +
    - 1419 + + -
    - + - PolygonRollupBaseEtrogBatchData: &s, +
    +
    +   +
    - 1420 + + -
    - + - } +
    +
    +   +
    - 1421 + + -
    - + - if forkID >= state.FORKID_ELDERBERRY { +
    +
    +   +
    - 1422 + + -
    - + - elderberry := &SequencedBatchElderberryData{ +
    +
    +   +
    - 1423 + + -
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, +
    +
    +   +
    - 1424 + + -
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, +
    +
    +   +
    - 1425 + + -
    - + - } +
    +
    +   +
    - 1426 + + -
    - + - batch.SequencedBatchElderberryData = elderberry +
    +
    +   +
    - 1427 + + -
    - + - } +
    +
    +   +
    - 1428 + + -
    - + - sequencedBatches[i] = batch +
    +
    +   +
    - 1429 + + -
    - + - } +
    +
    +   +
    - 1430 + + -
    - + - return sequencedBatches, nil +
    +
    +   +
    - 1431 + + -
    +
    +
      - } +
    - 1432 + + -
    +
    +
     
    - 1433 + + -
    - + - return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName) +
    +
    +   +
    - 1434 + 1312
      - } + // Recover Method from signature and ABI
    - 1435 + 1313
      -
    + method, err := smcAbi.MethodById(txData[:4])
    - 1436 + 1314
      - func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { + if err != nil {
    -
     
    +
    @@ -1320,87 +1317,212 @@
    - 1902 + 1320
      - } + if err != nil {
    - 1903 + 1321
      -
    + return nil, err
    - 1904 + 1322
      - // LoadAuthFromKeyStore loads an authorization from a key store file + }
    - 1905 + + 1323 +
    - + - func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) { + - + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 1906 + + 1324 +
    - + - auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID) +   + bytedata, err := json.Marshal(data[0])
    - 1907 + 1325
    @@ -59572,18 +60035,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1908 + + 1326 +
    - + - return nil, nil, err +   + return nil, err
    - 1909 + 1327
    @@ -59592,93 +60055,88 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1910 + + 1328 +
    -   -
    + - + err = json.Unmarshal(bytedata, &sequences)
    - 1911 + + 1329 +
    -   - log.Infof("loaded authorization for address: %v", auth.From.String()) + - + if err != nil {
    - 1912 + + 1330 +
    -   - etherMan.auth[auth.From] = auth + - + return nil, err
    - 1913 + + 1331 +
    - + - return &auth, pk, nil + - + }
    - 1914 + + 1332 +
    -   - } + - + maxSequenceTimestamp := data[1].(uint64)
    - 1915 + + 1333 +
    -   -
    + - + initSequencedBatchNumber := data[2].(uint64)
    - 1916 + + 1334 +
    -   - // newKeyFromKeystore creates an instance of a keystore key from a keystore file + - + coinbase := (data[3]).(common.Address)
    -
     
    -
    - 1931 + + 1335 +
    -   - } + - + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 1932 + 1336
    @@ -59687,612 +60145,603 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1933 + + 1337 +
    -   - // newAuthFromKeystore an authorization instance from a keystore file + - + for i, seq := range sequences {
    - 1934 + + 1338 +
    - + - func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) { + - + elderberry := SequencedBatchElderberryData{
    - 1935 + + 1339 +
    -   - log.Infof("reading key from: %v", path) + - + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 1936 + + 1340 +
    + - + InitSequencedBatchNumber: initSequencedBatchNumber, +
    +
    + + +
      - key, err := newKeyFromKeystore(path, password) +
    - 1937 + + -
    +
    +
      - if err != nil { +
    - 1938 + + -
    - + - return bind.TransactOpts{}, nil, err +
    +
    +   +
    - 1939 + + -
    +
    +
      - } +
    - 1940 + + -
    +
    +
      - if key == nil { +
    - 1941 + + -
    - + - return bind.TransactOpts{}, nil, nil +
    +
    +   +
    - 1942 + + -
    +
    +
      - } +
    - 1943 + + -
    +
    +
      - auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID)) +
    - 1944 + 1341
      - if err != nil { + }
    - 1945 + + 1342 +
    - + - return bind.TransactOpts{}, nil, err + - + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 1946 + + 1343 +
    -   - } + - + s := seq
    - 1947 + + 1344 +
    - + - return *auth, key.PrivateKey, nil + - + sequencedBatches[i] = SequencedBatch{
    - 1948 + + 1345 +
    -   - } + - + BatchNumber: bn,
    - 1949 + + 1346 +
    -   -
    + - + L1InfoRoot: &l1InfoRoot,
    - 1950 + + 1347 +
    -   - // getAuthByAddress tries to get an authorization from the authorizations map + - + SequencerAddr: sequencer,
    -
     
    -
    - 1972 + + 1348 +
    -   -
    + - + TxHash: txHash,
    - 1973 + + 1349 +
    -   - return *auth, nil + - + Nonce: nonce,
    - 1974 + + 1350 +
    -   - } + - + Coinbase: coinbase,
    - 1975 + + 1351 +
    - + -
    + - + PolygonRollupBaseEtrogBatchData: &s,
    - 1976 + + 1352 +
    - + - // GetDAProtocolAddr returns the address of the data availability protocol + - + SequencedBatchElderberryData: &elderberry,
    - 1977 + + -
    - + - func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) { +
    +
    +   +
    - 1978 + + -
    - + - return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false}) +
    +
    +   +
    - 1979 + + -
    - + - } +
    +
    +   +
    - 1980 + + -
    - + +
    +
    +  
    - 1981 + + -
    - + - // GetDAProtocolName returns the name of the data availability protocol +
    +
    +   +
    - 1982 + + -
    - + - func (etherMan *Client) GetDAProtocolName() (string, error) { +
    +
    +   +
    - 1983 + + -
    - + - return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false}) +
    +
    +   +
    - 1984 + + -
    - + - } +
    +
    +   +
    - 1985 + + -
    - + +
    +
    +  
    - 1986 + + -
    - + - // SetDataAvailabilityProtocol sets the address for the new data availability protocol +
    +
    +   +
    - 1987 + + -
    - + - func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) { +
    +
    +   +
    - 1988 + + -
    - + - auth, err := etherMan.getAuthByAddress(from) +
    +
    +   +
    - 1989 + + -
    - + - if err != nil { +
    +
    +   +
    - 1990 + + -
    - + - return nil, err +
    +
    +   +
    - 1991 + + -
    - + - } +
    +
    +   +
    - 1992 + + -
    - + +
    +
    +  
    - 1993 + + -
    - + - return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress) +
    +
    +   +
    - 1994 + + -
    - + - } +
    +
    +   +
    - 1995 + + -
    - + +
    +
    +  
    - 1996 + + -
    - + - // GetRollupId returns the rollup id +
    +
    +   +
    - 1997 + + 1353 +
    - + - func (etherMan *Client) GetRollupId() uint32 { +   + }
    - 1998 + + -
    - + - return etherMan.RollupID +
    +
    +   +
    - 1999 + + -
    - + - } +
    +
    +   +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go - RENAMED - -
    -
    -
    -
    - - - - - + + - - - - - - - - - - - - - - - - + - - - - - - - - @@ -60306,578 +60755,613 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - + + + + + + - - - - - - - - - @@ -60921,213 +61405,253 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - + - - - - - - - - - - + - - - - - - - - - - + + + - - + + + @@ -61141,368 +61665,303 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -61516,43 +61975,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - @@ -61566,632 +62005,583 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -38,7 +38,7 @@
    +
    + + +
    +   +
    +
    - 38 + + -
    +
    +
      - } +
    - 39 + + -
    +
    +
     
    - 40 + + -
    +
    +
      - // This function prepare the blockchain, the wallet with funds and deploy the smc +
    - 41 + + -
    - - - func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) { +
    +
    +   +
    - 42 + + -
    +
    +
      - privateKey, err := crypto.GenerateKey() +
    - 43 + + -
    +
    +
      - if err != nil { +
    - 44 + + -
    +
    +
      - log.Fatal(err) +
    -
    @@ -47,7 +47,8 @@
    +
    + + +
    +   +
    +
    - 47 + + -
    +
    +
      - if err != nil { +
    - 48 + + -
    +
    +
      - log.Fatal(err) +
    - 49 + + -
    +
    +
      - } +
    - 50 + + -
    - - - ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth) +
    +
    +   +
    - 51 + + -
    +
    +
      - if err != nil { +
    - 52 + + -
    +
    +
      - log.Fatal(err) +
    - 53 + + -
    +
    +
      - } +
    -
    @@ -55,12 +56,12 @@
    +
    + + +
    +   +
    +
    - 55 + + -
    +
    +
      - if err != nil { +
    - 56 + + -
    +
    +
      - log.Fatal(err) +
    - 57 + + -
    +
    +
      - } +
    - 58 + + -
    - - - return ethman, ethBackend, auth, polAddr, br +
    +
    +   +
    - 59 + + -
    +
    +
      - } +
    - 60 + + -
    +
    +
     
    - 61 + + -
    +
    +
      - func TestGEREvent(t *testing.T) { +
    - 62 + + -
    +
    +
      - // Set up testing environment +
    - 63 + + -
    - - - etherman, ethBackend, auth, _, br := newTestingEnv() +
    +
    +   +
    - 64 + + -
    +
    +
     
    - 65 + + -
    +
    +
      - // Read currentBlock +
    - 66 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -82,14 +83,14 @@
    +
    + + +
    +   +
    +
    - 82 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 83 + + -
    +
    +
      - require.NoError(t, err) +
    - 84 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) +
    - 85 + + -
    - - - assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber) +
    +
    +   +
    - 86 + + -
    +
    +
      - assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot) +
    - 87 + + -
    +
    +
      - assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot) +
    - 88 + + -
    +
    +
      - } +
    - 89 + + -
    +
    +
     
    - 90 + + -
    +
    +
      - func TestForcedBatchEvent(t *testing.T) { +
    - 91 + + -
    +
    +
      - // Set up testing environment +
    - 92 + + -
    - - - etherman, ethBackend, auth, _, _ := newTestingEnv() +
    +
    +   +
    - 93 + + -
    +
    +
     
    - 94 + + -
    +
    +
      - // Read currentBlock +
    - 95 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -114,8 +115,8 @@
    +
    + + +
    +   +
    +
    - 114 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 115 + + -
    +
    +
      - require.NoError(t, err) +
    - 116 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) +
    - 117 + + -
    - - - assert.Equal(t, uint64(8), blocks[0].BlockNumber) +
    +
    +   +
    - 118 + + -
    - - - assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber) +
    +
    +   +
    - 119 + + -
    +
    +
      - assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot) +
    - 120 + + -
    +
    +
      - assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt) +
    - 121 + + -
    +
    +
      - assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber) +
    -
    @@ -125,7 +126,7 @@
    +
    + + +
    +   +
    +
    - 125 + + -
    +
    +
     
    - 126 + + -
    +
    +
      - func TestSequencedBatchesEvent(t *testing.T) { +
    - 127 + + -
    +
    +
      - // Set up testing environment +
    - 128 + + -
    - - - etherman, ethBackend, auth, _, br := newTestingEnv() +
    +
    +   +
    - 129 + + -
    +
    +
     
    - 130 + + -
    +
    +
      - // Read currentBlock +
    - 131 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -156,13 +157,19 @@
    +
    + + +
    +   +
    +
    - 156 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber) +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 157 + 1354
      - require.NoError(t, err) + }
    - 158 + 1355
      - t.Log("Blocks: ", blocks) +
    - 159 + 1356
    - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData + return sequencedBatches, nil
    - 160 + + 1357 +
    - - - sequences = append(sequences, polygonzkevm.PolygonRollupBaseEtrogBatchData{ +   + }
    - 161 + + 1358 +
    - - - Transactions: common.Hex2Bytes(rawTxs), +   +
    - 162 + 1359
    - - }, polygonzkevm.PolygonRollupBaseEtrogBatchData{ + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 163 + 1360
    - - Transactions: common.Hex2Bytes(rawTxs), -
    -
    - - -
    -   -
    + // Extract coded txs.
    - 164 + + 1361 +
    -   - }) + - + // Load contract ABI
    - 165 + 1362
    - - _, err = etherman.ZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From) + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - + + 1363 -
    +
    +
      -
    + if err != nil {
    - 166 + 1364
      - require.NoError(t, err) + return nil, err
    - 167 + 1365
      + } +
    +
    + 1366 + +
    + -
    - 168 + + 1367 +
    -   - // Mine the tx in a block + - + // Recover Method from signature and ABI
    -
    @@ -188,7 +195,7 @@
    +
    + 1368 + +
    + - + method, err := smcAbi.MethodById(txData[:4]) +
    - 188 + 1369
      -
    + if err != nil {
    - 189 + 1370
      - func TestVerifyBatchEvent(t *testing.T) { + return nil, err
    - 190 + 1371
      - // Set up testing environment + }
    - 191 + + -
    - - - etherman, ethBackend, auth, _, _ := newTestingEnv() +
    +
    +   +
    - 192 + + -
    +
    +
     
    - 193 + + -
    +
    +
      - // Read currentBlock +
    - 194 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -197,12 +204,13 @@
    +
    + + +
    +   +
    +
    - 197 + + -
    +
    +
      - require.NoError(t, err) +
    - 198 + + -
    +
    +
     
    - 199 + + -
    +
    +
      - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" +
    - 200 + + -
    - - - tx := polygonzkevm.PolygonRollupBaseEtrogBatchData{ +
    +
    +   +
    - 201 + + -
    - - - Transactions: common.Hex2Bytes(rawTxs), +
    +
    +   +
    +
    +
    + + +
    +   +
    - 202 + 1372
      - } +
    - 203 + 1373
    - - //TODO: Fix params + // Unpack method inputs
    - 204 + 1374
    - - _, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From) + data, err := method.Inputs.Unpack(txData[4:])
    - 205 + + 1375 +
    -   - require.NoError(t, err) + - + if err != nil { +
    +
    + 1376 + +
    + - + return nil, err
    - 206 + + -
    +
    +
     
    - 207 - -
    -   - // Mine the tx in a block -
    -
    - 208 + + -
    +
    +
      - ethBackend.Commit() +
    -
    @@ -220,7 +228,7 @@
    -
    - 220 + + -
    +
    +
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 221 + 1377
      - require.NoError(t, err) + }
    - 222 + + 1378 +
    -   - t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order) + - + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 223 + 1379
    - - assert.Equal(t, uint64(9), blocks[1].BlockNumber) + bytedata, err := json.Marshal(data[0])
    - 224 + + -
    +
    +
      - assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber) +
    - 225 + + -
    +
    +
      - assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator) +
    - 226 + 1380
      - assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash) + if err != nil {
    -
    @@ -232,7 +240,7 @@
    -
    - 232 + 1381
      -
    + return nil, err
    - 233 + 1382
      - func TestSequenceForceBatchesEvent(t *testing.T) { -
    -
    - 234 - -
    -   - // Set up testing environment + }
    - 235 + 1383
    - - etherman, ethBackend, auth, _, _ := newTestingEnv() + err = json.Unmarshal(bytedata, &sequences)
    - 236 + + -
    +
    +
     
    - 237 + + -
    +
    +
      - // Read currentBlock +
    - 238 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -283,7 +291,7 @@
    -
    - 283 + + -
    +
    +
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 284 + + -
    +
    +
      - require.NoError(t, err) +
    - 285 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) -
    -
    - 286 - -
    - - - assert.Equal(t, uint64(12), blocks[1].BlockNumber) +
    - 287 + + -
    +
    +
      - assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber) +
    - 288 + + -
    +
    +
      - assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:])) +
    - 289 + + -
    +
    +
      - assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp) +
    -
    @@ -293,7 +301,7 @@
    -
    - 293 + + -
    +
    +
     
    - 294 + + -
    +
    +
      - func TestSendSequences(t *testing.T) { +
    - 295 + + -
    +
    +
      - // Set up testing environment -
    -
    - 296 - -
    - - - etherman, ethBackend, auth, _, br := newTestingEnv() +
    - 297 + + -
    +
    +
     
    - 298 + + -
    +
    +
      - // Read currentBlock +
    - 299 + + -
    +
    +
      - ctx := context.Background() +
    -
    @@ -315,10 +323,11 @@
    -
    - 315 + + -
    +
    +
      - BatchL2Data: batchL2Data, +
    - 316 + + -
    +
    +
      - LastL2BLockTimestamp: time.Now().Unix(), +
    - 317 + + -
    +
    +
      - } +
    - 318 + + -
    +
    +
      - lastL2BlockTStamp := tx1.Time().Unix() -
    -
    - 319 - -
    - - - // TODO: fix params -
    -
    - 320 - -
    - - - tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From) +
    - 321 + + -
    +
    +
      - require.NoError(t, err) +
    - 322 + + -
    +
    +
      - log.Debug("TX: ", tx.Hash()) +
    - 323 + 1384
      - ethBackend.Commit() + if err != nil {
    - 324 + 1385
      -
    + return nil, err
    -
    @@ -341,7 +350,7 @@
    -
    - 341 + 1386
      -
    + }
    - 342 + + 1387 +
    -   - func TestGasPrice(t *testing.T) { + - + coinbase := (data[1]).(common.Address)
    - 343 + + 1388 +
    -   - // Set up testing environment + - + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 344 + 1389
    - - etherman, _, _, _, _ := newTestingEnv() + for i, seq := range sequences {
    - 345 + + 1390 +
    -   - etherscanM := new(etherscanMock) + - + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 346 + + 1391 +
    -   - ethGasStationM := new(ethGasStationMock) + - + s := seq
    - 347 + + 1392 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + - + sequencedBatches[i] = SequencedBatch{
    -
    @@ -360,14 +369,14 @@
    -
    - 360 + + 1393 +
    -   -
    + - + BatchNumber: bn,
    - 361 + + 1394 +
    -   - func TestErrorEthGasStationPrice(t *testing.T) { + - + L1InfoRoot: &l1InfoRoot,
    - 362 + + 1395 +
    -   - // Set up testing environment + - + SequencerAddr: sequencer,
    - 363 + 1396
    - - etherman, _, _, _, _ := newTestingEnv() + TxHash: txHash,
    - 364 + + 1397 +
    -   - ethGasStationM := new(ethGasStationMock) + - + Nonce: nonce,
    - 365 + + 1398 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM} + - + Coinbase: coinbase,
    - 366 + + 1399 +
    -   - ctx := context.Background() + - + PolygonRollupBaseEtrogBatchData: &s,
    - 367 + 1400
      -
    + }
    - 368 + 1401
      - ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation")) + }
    - 369 + + 1402 +
    -   - gp := etherman.GetL1GasPrice(ctx) + - +
    - 370 + + 1403 +
    - - assert.Equal(t, big.NewInt(1392695906), gp) + return sequencedBatches, nil
    - 371 + 1404
      -
    + }
    - 372 + 1405
      - etherscanM := new(etherscanMock) +
    - 373 + 1406
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
    -
    @@ -379,7 +388,7 @@
    +
    @@ -1513,7 +1635,7 @@
    - 379 + 1513
      -
    + if err != nil {
    - 380 + 1514
      - func TestErrorEtherScanPrice(t *testing.T) { + return err
    - 381 + 1515
      - // Set up testing environment + }
    - 382 + 1516
    - - etherman, _, _, _, _ := newTestingEnv() + // TODO completar los datos de forcedBlockHas, forcedGer y forcedTimestamp
    - 383 + 1517
      - etherscanM := new(etherscanMock) +
    - 384 + 1518
      - ethGasStationM := new(ethGasStationMock) + // Read the tx for this batch.
    - 385 + 1519
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex)
    -
    @@ -393,7 +402,7 @@
    +
    @@ -1818,6 +1940,17 @@
    - 393 + 1818
      -
    + })
    - 394 + 1819
      - func TestGetForks(t *testing.T) { + }
    - 395 + 1820
      - // Set up testing environment +
    - 396 + + -
    - - - etherman, _, _, _, _ := newTestingEnv() +
    +
    +   +
    - 397 + + -
    +
    +
      - ctx := context.Background() +
    - 398 + + -
    +
    +
      - forks, err := etherman.GetForks(ctx, 0, 132) +
    - 399 + + -
    +
    +
      - require.NoError(t, err) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + +
    -
     
    - 38 + + -
    +
    +
      - } +
    - 39 + + -
    +
    +
     
    - 40 + + -
    +
    +
      - // This function prepare the blockchain, the wallet with funds and deploy the smc +
    - 41 + + -
    - + - func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock) { +
    +
    +   +
    - 42 + + -
    +
    +
      - privateKey, err := crypto.GenerateKey() +
    - 43 + + -
    +
    +
      - if err != nil { +
    - 44 + + -
    +
    +
      - log.Fatal(err) +
    -
     
    -
    - 47 + 1821
      - if err != nil { + // CheckTxWasMined check if a tx was already mined
    - 48 + 1822
      - log.Fatal(err) + func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error) {
    - 49 + 1823
      - } -
    -
    - 50 - -
    - + - da = newDaMock(t) + receipt, err := etherMan.EthClient.TransactionReceipt(ctx, txHash)
    - 51 - -
    - + - ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da) -
    +
    +
    @@ -1872,15 +2005,15 @@
    - 52 + 1872
      - if err != nil { + }
    - 53 + 1873
      - log.Fatal(err) +
    - 54 + 1874
      - } + // LoadAuthFromKeyStore loads an authorization from a key store file
    -
     
    -
    - 56 + + 1875 +
    -   - if err != nil { + - + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) {
    - 57 + + 1876 +
    -   - log.Fatal(err) + - + auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 58 + 1877
      - } + if err != nil {
    - 59 + + 1878 +
    - + - return ethman, ethBackend, auth, polAddr, br, da + - + return nil, err
    - 60 + 1879
      - } + }
    - 61 + 1880
    @@ -62201,302 +62591,277 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 62 + 1881
      - func TestGEREvent(t *testing.T) { + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 63 + 1882
      - // Set up testing environment + etherMan.auth[auth.From] = auth
    - 64 + + 1883 +
    - + - etherman, ethBackend, auth, _, br, _ := newTestingEnv(t) + - + return &auth, nil
    - 65 + 1884
      -
    + }
    - 66 + 1885
      - // Read currentBlock +
    - 67 + 1886
      - ctx := context.Background() + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    -
     
    +
    @@ -1901,20 +2034,20 @@
    - 83 + 1901
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + }
    - 84 + 1902
      - require.NoError(t, err) +
    - 85 + 1903
      - t.Logf("Blocks: %+v", blocks) + // newAuthFromKeystore an authorization instance from a keystore file
    - 86 + + 1904 +
    - + - assert.Equal(t, uint64(11), blocks[0].L1InfoTree[0].BlockNumber) + - + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) {
    - 87 + 1905
      - assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot) + log.Infof("reading key from: %v", path)
    - 88 + 1906
      - assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot) + key, err := newKeyFromKeystore(path, password)
    - 89 + 1907
      - } + if err != nil {
    - 90 + + 1908 +
    -   -
    + - + return bind.TransactOpts{}, err
    - 91 + 1909
      - func TestForcedBatchEvent(t *testing.T) { + }
    - 92 + 1910
      - // Set up testing environment -
    -
    - 93 - -
    - + - etherman, ethBackend, auth, _, _, _ := newTestingEnv(t) + if key == nil {
    - 94 + + 1911 +
    -   -
    + - + return bind.TransactOpts{}, nil
    - 95 + 1912
      - // Read currentBlock + }
    - 96 + 1913
      - ctx := context.Background() + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    -
     
    -
    - 115 + 1914
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + if err != nil {
    - 116 + + 1915 +
    -   - require.NoError(t, err) + - + return bind.TransactOpts{}, err
    - 117 + 1916
      - t.Logf("Blocks: %+v", blocks) -
    -
    - 118 - -
    - + - assert.Equal(t, uint64(11), blocks[0].BlockNumber) + }
    - 119 + + 1917 +
    - + - assert.Equal(t, uint64(11), blocks[0].ForcedBatches[0].BlockNumber) + - + return *auth, nil
    - 120 + 1918
      - assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot) + }
    - 121 + 1919
      - assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt) +
    - 122 + 1920
      - assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber) + // getAuthByAddress tries to get an authorization from the authorizations map
    -
     
    +
    @@ -1942,3 +2075,28 @@
    - 126 + 1942
    @@ -62506,332 +62871,356 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 127 + 1943
      - func TestSequencedBatchesEvent(t *testing.T) { + return *auth, nil
    - 128 + 1944
      - // Set up testing environment + }
    - 129 + + -
    - + - etherman, ethBackend, auth, _, br, da := newTestingEnv(t) +
    +
    +   +
    - 130 + + -
    +
    +
     
    - 131 + + -
    +
    +
      - // Read currentBlock +
    - 132 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 157 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber) +
    - 158 + + -
    +
    +
      - require.NoError(t, err) +
    - 159 + + -
    +
    +
      - t.Log("Blocks: ", blocks) +
    - 160 + + -
    - + - var sequences []polygonzkevm.PolygonValidiumEtrogValidiumBatchData +
    +
    +   +
    - 161 + + -
    - + - txsHash := crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)) +
    +
    +   +
    - 162 + + -
    - + - sequences = append(sequences, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    +   +
    - 163 + + -
    - + - TransactionsHash: txsHash, +
    +
    +   +
    - 164 + + -
    - + - }, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    +   +
    - 165 + + -
    - + - TransactionsHash: txsHash, +
    +
    +   +
    - 166 + + -
    +
    +
      - }) +
    - 167 + + -
    - + - batchNums := []uint64{2, 3} +
    +
    +   +
    - 168 + + -
    - + - batchHashes := []common.Hash{txsHash, txsHash} +
    +
    +   +
    - 169 + + -
    - + - batchData := [][]byte{data, data} +
    +
    +   +
    - 170 + + -
    - + - daMessage, _ := hex.DecodeString("0x123456789123456789") +
    +
    +   +
    - 171 + + -
    - + - da.Mock.On("GetBatchL2Data", batchNums, batchHashes, daMessage).Return(batchData, nil) +
    +
    +   +
    - 172 + + -
    - + - _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage) +
    +
    +   +
    - 173 + + -
    +
    +
      - require.NoError(t, err) +
    - 174 + + -
    +
    +
     
    - 175 + + -
    +
    +
      - // Mine the tx in a block +
    +
    +
    + + +
    +   +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + - - @@ -62841,132 +63230,112 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - @@ -62976,72 +63345,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -63051,147 +63420,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - @@ -63201,192 +63555,212 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - + - - - - + + + - - - + - + + - - - - - - @@ -63476,77 +63850,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -63621,72 +63995,112 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + + + + @@ -63696,102 +64110,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
     
    - 195 + 3
      -
    + import (
    - 196 + 4
      - func TestVerifyBatchEvent(t *testing.T) { + "bytes"
    - 197 + 5
      - // Set up testing environment + "context"
    - 198 + + 6 +
    + - etherman, ethBackend, auth, _, _, da := newTestingEnv(t) + "crypto/ecdsa"
    - 199 + 7
      -
    + "encoding/json"
    - 200 + 8
      - // Read currentBlock + "errors"
    - 201 + 9
      - ctx := context.Background() + "fmt"
    - 204 + 109
      - require.NoError(t, err) + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
    - 205 + 110
      -
    + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
    - 206 + 111
      - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" +
    - 207 + + 112 +
    + - tx := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ + // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog
    - 208 + + 113 +
    + - TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)), -
    -
    - 209 - -
    -   - } + methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)
    - 210 + + 114 +
    + - daMessage, _ := hex.DecodeString("0x1234") + // methodIDSequenceBatchesValidiumElderberry: MethodID for sequenceBatchesValidium in Elderberry
    - 211 + + 115 +
    + - _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, []polygonzkevm.PolygonValidiumEtrogValidiumBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage) -
    -
    - 212 - -
    -   - require.NoError(t, err) + methodIDSequenceBatchesValidiumElderberry = []byte{0xdb, 0x5b, 0x0e, 0xd7} // 0xdb5b0ed7 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)
    - 213 + 116
    + - da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))}, daMessage).Return([][]byte{common.Hex2Bytes(rawTxs)}, nil) +
    - 214 + 117
      -
    + // ErrNotFound is used when the object is not found
    - 215 + 118
      - // Mine the tx in a block + ErrNotFound = errors.New("not found")
    - 216 + 119
      - ethBackend.Commit() + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    - 228 + 197
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
    - 229 + 198
      - require.NoError(t, err) + OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
    - 230 + 199
      - t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order) + Pol *pol.Pol
    - 231 + + 200 +
    + - assert.Equal(t, uint64(12), blocks[1].BlockNumber) + DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol
    - 232 + 201
      - assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber) + SCAddresses []common.Address
    - 233 + 202
      - assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator) +
    - 234 + 203
      - assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash) + RollupID uint32
    - 240 + 207
      -
    + l1Cfg L1Config
    - 241 + 208
      - func TestSequenceForceBatchesEvent(t *testing.T) { + cfg Config
    - 242 + 209
      - // Set up testing environment + auth map[common.Address]bind.TransactOpts // empty in case of read-only client
    - 243 + + 210 +
    + - etherman, ethBackend, auth, _, _, _ := newTestingEnv(t) -
    -
    - 244 - -
    -  
    - 245 + + 211 +
    -   - // Read currentBlock + + + da dataavailability.BatchDataProvider
    - 246 + + 212 +
    -   - ctx := context.Background() + + + state stateProvider
    -
     
    -
    - 291 + 213
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + }
    - 292 + 214
      - require.NoError(t, err) +
    - 293 + 215
      - t.Logf("Blocks: %+v", blocks) + // NewClient creates a new etherman.
    - 294 + 216
    + - assert.Equal(t, uint64(15), blocks[1].BlockNumber) + func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider, st stateProvider) (*Client, error) {
    - 295 + 217
      - assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber) + // Connect to ethereum node
    - 296 + 218
      - assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:])) + ethClient, err := ethclient.Dial(cfg.URL)
    - 297 + 219
      - assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp) + if err != nil {
    - 301 + 256
      -
    + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - 302 + 257
      - func TestSendSequences(t *testing.T) { + return nil, err
    - 303 + 258
      - // Set up testing environment + }
    - 304 + + 259 +
    + - etherman, ethBackend, auth, _, br, da := newTestingEnv(t) + dapAddr, err := zkevm.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
    - 305 + + 260 +
    -   -
    + + + if err != nil {
    - 306 + + 261 +
    -   - // Read currentBlock + + + return nil, err
    - 307 + + 262 +
    -   - ctx := context.Background() + + + }
    -
     
    +
    + 263 + +
    + + + dap, err := dataavailabilityprotocol.NewDataavailabilityprotocol(dapAddr, ethClient) +
    - 323 + + 264 +
    -   - BatchL2Data: batchL2Data, + + + if err != nil {
    - 324 + + 265 +
    -   - LastL2BLockTimestamp: time.Now().Unix(), + + + return nil, err +
    +
    + 266 + +
    + + + }
    - 325 + 267
      - } + var scAddresses []common.Address
    - 326 + + 268 +
    - + - daMessage, _ := hex.DecodeString("0x1234") +   + scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
    - 327 + 269
      - lastL2BlockTStamp := tx1.Time().Unix() +
    - 328 + +
     
    +
    + 282 +
    - + - tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From, daMessage) +   + rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr)
    - + + 283 -
    +
    +
      -
    + if err != nil {
    - 329 + 284
      - require.NoError(t, err) + log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
    - 330 + + 285 +
    + - da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(batchL2Data)}, daMessage).Return([][]byte{batchL2Data}, nil) + return nil, err
    - 331 + 286
      - log.Debug("TX: ", tx.Hash()) + }
    - 332 + 287
      - ethBackend.Commit() + log.Debug("rollupID: ", rollupID)
    - 333 + 288
    @@ -63401,72 +63775,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 350 + 294
      -
    + RollupManager: rollupManager,
    - 351 + 295
      - func TestGasPrice(t *testing.T) { + Pol: pol,
    - 352 + 296
      - // Set up testing environment + GlobalExitRootManager: globalExitRoot,
    - 353 + + 297 +
    + - etherman, _, _, _, _, _ := newTestingEnv(t) + DAProtocol: dap,
    - 354 + 298
      - etherscanM := new(etherscanMock) + OldGlobalExitRootManager: oldGlobalExitRoot,
    - 355 + 299
      - ethGasStationM := new(ethGasStationMock) + SCAddresses: scAddresses,
    - 356 + 300
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + RollupID: rollupID,
    - 369 + 305
      -
    + l1Cfg: l1Config,
    - 370 + 306
      - func TestErrorEthGasStationPrice(t *testing.T) { + cfg: cfg,
    - 371 + 307
      - // Set up testing environment + auth: map[common.Address]bind.TransactOpts{},
    - 372 + + 308 +
    + - etherman, _, _, _, _, _ := newTestingEnv(t) + da: da,
    - 373 + + 309 +
    -   - ethGasStationM := new(ethGasStationMock) + + + state: st,
    - 374 + 310
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM} + }, nil
    - 375 + 311
      - ctx := context.Background() + }
    - 376 + 312
    @@ -63556,62 +63930,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 377 + 313
      - ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation")) + // VerifyGenBlockNumber verifies if the genesis Block Number is valid
    - 378 + 314
      - gp := etherman.GetL1GasPrice(ctx) + func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
    - 379 + + 315 +
    + - assert.Equal(t, big.NewInt(1263075579), gp) + // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block
    - 380 + 316
      -
    + start := time.Now()
    - 381 + 317
      - etherscanM := new(etherscanMock) + log.Info("Verifying genesis blockNumber: ", genBlockNumber)
    - 382 + 318
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + // Filter query
    - 388 + 368
      -
    + log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
    - 389 + 369
      - func TestErrorEtherScanPrice(t *testing.T) { + start := time.Now()
    - 390 + 370
      - // Set up testing environment + var logs []types.Log
    - 391 + + 371 + +
    + + +
    +
    +
    + 372 + +
    + + + if lastL1BlockSynced < genBlockNumber { +
    +
    + 373 + +
    + + + lastL1BlockSynced = genBlockNumber +
    +
    + 374 + +
    + + + } +
    +
    + 375 +
    + - etherman, _, _, _, _, _ := newTestingEnv(t) +
    - 392 + 376
      - etherscanM := new(etherscanMock) + log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
    - 393 + 377
      - ethGasStationM := new(ethGasStationMock) + for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
    - 394 + 378
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + final := i + etherMan.cfg.ForkIDChunkSize
    - 402 + 713
      -
    + return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
    - 403 + 714
      - func TestGetForks(t *testing.T) { + }
    - 404 + 715
      - // Set up testing environment +
    - 405 + 716
    + - etherman, _, _, _, _, _ := newTestingEnv(t) + func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error {
    - 406 + + 717 +
    -   - ctx := context.Background() + + + return errors.New("upgrading validiums to etrog not supported")
    - 407 + + -
    +
    +
      - forks, err := etherman.GetForks(ctx, 0, 132) +
    - 408 + + -
    +
    +
      - require.NoError(t, err) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,7 @@
    @@ -63863,222 +64248,174 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 + + -
    - + - package etherman +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import "github.com/ethereum/go-ethereum/common" +
    +
    +   +
    - 4 + + -
    - + +
    +
    +  
    - 5 + + -
    - + - type dataAvailabilityProvider interface { +
    +
    +   +
    - 6 + + -
    - + - GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) +
    +
    +   +
    - 7 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -64092,21 +64429,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - + - - - - + + + - - + + + - - - + + + - - - - - - - - - - - - - - -
    -
    @@ -23,7 +24,7 @@
    - 23 + + -
    +
    +
     
    - 24 + + -
    +
    +
      - // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth +
    - 25 + + -
    +
    +
      - // must be 1337. The address that holds the auth will have an initial balance of 10 ETH +
    - 26 + + -
    - - - func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *polygonzkevmbridge.Polygonzkevmbridge, error) { +
    +
    +   +
    - 27 + + -
    +
    +
      - if auth == nil { +
    - 28 + + -
    +
    +
      - // read only client +
    - 29 + + -
    +
    +
      - return &Client{}, nil, common.Address{}, nil, nil +
    -
    @@ -37,8 +38,26 @@
    -
    - 37 + + -
    +
    +
      - }, +
    - 38 + + -
    +
    +
      - } +
    - 39 + + -
    +
    +
      - blockGasLimit := uint64(999999999999999999) //nolint:gomnd +
    - 40 + + -
    +
    +
      - client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) +
    - 41 + + -
    +
    +
     
    @@ -64282,382 +64619,398 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 42 + + -
    +
    +
      - // Deploy contracts +
    - 43 + + -
    +
    +
      - const polDecimalPlaces = 18 +
    - 44 + + -
    +
    +
      - totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd +
    -
    @@ -102,7 +121,7 @@
    +
    + + +
    +   +
    +
    - 102 + + -
    +
    +
      - log.Error("error: ", err) +
    - 103 + + -
    +
    +
      - return nil, nil, common.Address{}, nil, err +
    +
    +
    + + +
    +   +
    - 104 + 718
      - } + }
    - 105 + + 719 +
    - - - br, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client()) +   +
    - 106 + 720
      - if err != nil { + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    +
     
    +
    - 107 + 913
      - log.Error("error: ", err) + }
    - 108 + 914
      - return nil, nil, common.Address{}, nil, err +
    -
    @@ -182,6 +201,11 @@
    -
    - 182 + 915
      - return nil, nil, common.Address{}, nil, err + // EstimateGasSequenceBatches estimates gas for sending batches +
    +
    + 916 + +
    + + + func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 183 + 917
      - } + opts, err := etherMan.getAuthByAddress(sender)
    - 184 + 918
      -
    + if err == ErrNotFound {
    - + + 919 -
    +
    +
      -
    + return nil, ErrPrivateKeyNotFound
    - + + 920 -
    +
    +
      -
    + }
    - + + 921 -
    +
    +
      -
    + opts.NoSend = true
    - + + 922 -
    +
    +
     
    - + + 923 -
    -   -
    +
    +
    + + + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 185 + 924
      - _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{}) + if err != nil {
    - 186 + 925
      - if err != nil { + return nil, err
    - 187 + 926
      - log.Error("error: ", err) + }
    -
    @@ -199,6 +223,7 @@
    +
     
    - 199 + 929
      - SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr}, + }
    - 200 + 930
      - auth: map[common.Address]bind.TransactOpts{}, +
    - 201 + 931
      - cfg: cfg, + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - + + 932 -
    -   -
    +
    +
    + + + func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (to *common.Address, data []byte, err error) {
    - 202 + 933
      - } + opts, err := etherMan.getAuthByAddress(sender)
    - 203 + 934
      - err = c.AddOrReplaceAuth(*auth) + if err == ErrNotFound {
    - 204 + 935
      - if err != nil { + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    -
    -
    -
    -
    - - - + @@ -64667,262 +65020,227 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - @@ -64932,72 +65250,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -65007,112 +65325,152 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + + + + + + + + + + @@ -65122,514 +65480,462 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + - - -
     
    - 24 + 940
      -
    + opts.GasLimit = uint64(1)
    - 25 + 941
      - // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth + opts.GasPrice = big.NewInt(1)
    - 26 + 942
      - // must be 1337. The address that holds the auth will have an initial balance of 10 ETH +
    - 27 + 943
    + - func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) { + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 28 + 944
      - if auth == nil { + if err != nil {
    - 29 + 945
      - // read only client + return nil, nil, err
    - 30 + 946
      - return &Client{}, nil, common.Address{}, nil, nil + }
    - 38 + 948
      - }, + return tx.To(), tx.Data(), nil
    - 39 + 949
      - } + }
    - 40 + 950
      - blockGasLimit := uint64(999999999999999999) //nolint:gomnd +
    - 41 + + 951 +
    + - // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 42 + + 952 +
    -   - client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) + + + var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - 43 + 953
      -
    -
    -
    - 44 - -
    - + - // DAC Setup -
    -
    - 45 - -
    - + - daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client()) -
    -
    - 46 - -
    - + - if err != nil { + for _, seq := range sequences {
    - 47 + + 954 +
    - + - return nil, nil, common.Address{}, nil, err +   + var ger common.Hash
    - 48 + + 955 +
    - + - } +   + if seq.ForcedBatchTimestamp > 0 {
    - 49 + + 956 +
    - + - client.Commit() +   + ger = seq.GlobalExitRoot
    - 50 + + 957 +
    - + - _, err = da.Initialize(auth) +   + }
    - 51 + + 958 +
    + - if err != nil { + batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - 52 + + 959 +
    + - return nil, nil, common.Address{}, nil, err + TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data),
    - 53 + + 960 +
    - + - } +   + ForcedGlobalExitRoot: ger,
    - 54 + + 961 +
    - + - client.Commit() +   + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - 55 + + 962 +
    - + - _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{}) +   + ForcedBlockHashL1: seq.PrevBlockHash,
    - 56 - -
    - + - if err != nil { -
    +
    +
     
    - 57 + + 965 +
    - + - return nil, nil, common.Address{}, nil, err +   + batches = append(batches, batch)
    - 58 + + 966 +
    - + +   }
    - 59 + + 967 +
    - + - client.Commit() +   +
    - 60 + + 968 +
    + -
    + tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 61 + 969
      - // Deploy contracts + if err != nil {
    - 62 + 970
      - const polDecimalPlaces = 18 + log.Debugf("Batches to send: %+v", batches)
    - 63 + 971
      - totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd + log.Debug("l2CoinBase: ", l2Coinbase)
    - 121 + 1161
      - log.Error("error: ", err) +
    - 122 + 1162
      - return nil, nil, common.Address{}, nil, err + func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 123 + 1163
      - } + log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:]))
    - 124 + + -
    - + - br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client()) +
    +
    +   +
    - 125 + 1164
      - if err != nil { +
    - 126 + 1165
      - log.Error("error: ", err) + sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog)
    - 127 + 1166
      - return nil, nil, common.Address{}, nil, err + if err != nil {
    - 201 + 1184
      - return nil, nil, common.Address{}, nil, err + if sb.NumBatch != 1 {
    - 202 + 1185
      - } + methodId := tx.Data()[:4]
    - 203 + 1186
      -
    + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - 204 + + 1187 +
    + - _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr) + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) ||
    - 205 + + 1188 +
    + - if err != nil { + bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) {
    - 206 + 1189
    + - log.Error("error: ", err) + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 207 + + 1190 + +
    +   + if err != nil { +
    +
    + 1191 + +
    +   + return fmt.Errorf("error decoding the sequences (etrog): %v", err) +
    +
    + 1192 + +
    +   + } +
    +
    + 1193 +
    + - return nil, nil, common.Address{}, nil, err + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) || +
    +
    + 1194 + +
    + + + bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) {
    - 208 + 1195
    + - } + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 209 + 1196
      - _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{}) + if err != nil {
    - 210 + 1197
      - if err != nil { + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 211 + 1198
      - log.Error("error: ", err) + }
    - 223 + 1278
      - SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr}, + return nil
    - 224 + 1279
      - auth: map[common.Address]bind.TransactOpts{}, + }
    - 225 + 1280
      - cfg: cfg, +
    +
    +
    + 1281 + +
    + + + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64,
    - 226 + 1282
    + - da: daBackend, + l1InfoRoot common.Hash, da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - 227 + 1283
      - } + // Extract coded txs.
    - 228 + 1284
      - err = c.AddOrReplaceAuth(*auth) + // Load contract ABI
    - 229 + 1285
      - if err != nil { + smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -42,12 +42,17 @@
    +
     
    - 42 + 1287
      - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" + return nil, err
    - 43 + 1288
      - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts + }
    - 44 + 1289
    -   - EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT" -
    -
    - - -
     
    - + + 1290 -
    -   -
    +
    +
    + + + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st)
    - + + 1291 -
    -   -
    +
    +
    + + + }
    - 45 + + 1292 +
    -   - // EventID_NodeOOC is triggered when an OOC at node level is detected + + +
    - 46 + + 1293 +
    -   - EventID_NodeOOC EventID = "NODE OOC" + + + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
    - 47 + + 1294 +
    -   - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters + + + da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - 48 + + 1295 +
    -   - EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW" + + + // Extract coded txs.
    - 49 + + 1296 +
    -   - // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters + + + // Load contract ABI
    - 50 + + 1297 +
    -   - EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW" + + + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - + + 1298 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 1299 -
    -   -
    +
    +
    + + + return nil, err
    - 51 + + 1300 +
    -   - // Source_Node is the source of the event + + + }
    - 52 + + 1301 +
    -   - Source_Node Source = "node" + + +
    - 53 + + 1302 +
    -   -
    -
    -
    -
    + + + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st)
    -
    -
    - - - - - - - - - - - + + + - - - - - - -
    -
     
    - 42 + + 1303 +
    -   - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" + + + }
    - 43 + + 1304 +
    -   - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts + + +
    - 44 + + 1305 +
    -   - EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT" + + + // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches
    - 45 + 1306
    + - // EventID_UnsupportedPrecompile is triggered when the executor returns an unsupported precompile error + func decodeSequencedBatches(smcAbi abi.ABI, txData []byte, forkID uint64, lastBatchNumber uint64,
    - 46 + 1307
    + - EventID_UnsupportedPrecompile EventID = "UNSUPPORTED PRECOMPILE" + sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
    - 47 + 1308
    + -
    + da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - 48 + 1309
      - // EventID_NodeOOC is triggered when an OOC at node level is detected + // Recover Method from signature and ABI
    - 49 + 1310
      - EventID_NodeOOC EventID = "NODE OOC" + method, err := smcAbi.MethodById(txData[:4])
    - 50 + 1311
      - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters + if err != nil {
    +
     
    +
    - 51 + 1317
      - EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW" + if err != nil {
    - 52 + 1318
      - // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters + return nil, err
    - 53 + 1319
      - EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW" + }
    - 54 + + -
    - + - // EventID_InvalidInfoRoot is triggered when an invalid l1InfoRoot was synced +
    +
    +   +
    - 55 + + 1320 +
    - + - EventID_InvalidInfoRoot EventID = "INVALID INFOROOT" +   + bytedata, err := json.Marshal(data[0])
    - 56 + 1321
      - // Source_Node is the source of the event + if err != nil {
    - 57 + 1322
      - Source_Node Source = "node" + return nil, err
    - 58 + 1323
      -
    + }
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -65662,1390 +65968,1324 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -30,3 +30,6 @@
    - 30 + + -
    +
    +
      - include: +
    - 31 + + -
    +
    +
      - - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments +
    - 32 + + -
    +
    +
      - - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - + + + - - -
    -
     
    - 30 + 1324
      - include: +
    - 31 + + 1325 +
    -   - - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments + + + var (
    - 32 + + 1326 +
    -   - - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments + + + maxSequenceTimestamp uint64
    - 33 + + 1327 +
    + - exclude-rules: + initSequencedBatchNumber uint64 +
    +
    + 1328 + +
    + + + coinbase common.Address
    - 34 + 1329
    + - - path: cmd/policy.go + )
    - 35 + 1330
    + - text: "unused" +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -22,9 +22,9 @@
    -
    - 22 + + 1331 +
    -   - github.com/prometheus/common v0.45.0 + + + switch method.Name {
    - 23 + + 1332 +
    -   - github.com/rubenv/sql-migrate v1.6.1 + + + case "sequenceBatches":
    - 24 + + 1333 +
    -   - github.com/spf13/afero v1.11.0 + + + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 25 + + 1334 +
    - - - github.com/spf13/viper v1.17.0 + + + err := json.Unmarshal(bytedata, &sequences)
    - 26 + + 1335 +
    -   - github.com/stretchr/testify v1.8.4 + + + if err != nil {
    - 27 + + 1336 +
    - - - github.com/umbracle/ethgo v0.1.3 + + + return nil, err
    - 28 + 1337
      - github.com/urfave/cli/v2 v2.26.0 + }
    - 29 + + 1338 +
    -   - go.uber.org/zap v1.26.0 + + +
    - 30 + + 1339 +
    -   - golang.org/x/crypto v0.18.0 + + + switch forkID {
    -
    @@ -45,7 +45,7 @@
    -
    - 45 + + 1340 +
    -   - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + + + case state.FORKID_ETROG:
    - 46 + + 1341 +
    -   - github.com/bahlo/generic-list-go v0.2.0 // indirect + + + coinbase = data[1].(common.Address)
    - 47 + + 1342 +
    -   - github.com/beorn7/perks v1.0.1 // indirect + + +
    - 48 + + 1343 +
    - - - github.com/bits-and-blooms/bitset v1.10.0 // indirect + + + case state.FORKID_ELDERBERRY:
    - 49 + + 1344 +
    -   - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + + + maxSequenceTimestamp = data[1].(uint64)
    - 50 + + 1345 +
    -   - github.com/buger/jsonparser v1.1.1 // indirect + + + initSequencedBatchNumber = data[2].(uint64)
    - 51 + + 1346 +
    -   - github.com/cespare/xxhash/v2 v2.2.0 // indirect + + + coinbase = data[3].(common.Address)
    -
    @@ -63,12 +63,12 @@
    -
    - 63 + + 1347 +
    -   - github.com/cyphar/filepath-securejoin v0.2.4 // indirect + + + }
    - 64 + + 1348 +
    -   - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + + +
    - 65 + + 1349 +
    -   - github.com/deckarep/golang-set/v2 v2.1.0 // indirect + + + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 66 + + 1350 +
    - - - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + + + for i, seq := range sequences {
    - 67 + + 1351 +
    -   - github.com/dlclark/regexp2 v1.7.0 // indirect + + + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 68 + + 1352 +
    -   - github.com/emirpasic/gods v1.18.1 // indirect + + + s := seq
    - 69 + + 1353 +
    -   - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + + + batch := SequencedBatch{
    - 70 + + 1354 +
    -   - github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect + + + BatchNumber: bn,
    - 71 + + 1355 +
    - - - github.com/fsnotify/fsnotify v1.6.0 // indirect + + + L1InfoRoot: &l1InfoRoot,
    - 72 + + 1356 +
    -   - github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect + + + SequencerAddr: sequencer,
    - 73 + + 1357 +
    -   - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + + + TxHash: txHash,
    - 74 + + 1358 +
    -   - github.com/getsentry/sentry-go v0.18.0 // indirect + + + Nonce: nonce,
    -
    @@ -101,6 +101,7 @@
    -
    - 101 + + 1359 +
    -   - github.com/jackc/puddle v1.3.0 // indirect + + + Coinbase: coinbase,
    - 102 + + 1360 +
    -   - github.com/jackpal/go-nat-pmp v1.0.2 // indirect + + + PolygonRollupBaseEtrogBatchData: &s,
    - 103 + + 1361 +
    -   - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + + + }
    - + + 1362 -
    -   -
    +
    +
    + + + if forkID >= state.FORKID_ELDERBERRY {
    - 104 + + 1363 +
    -   - github.com/karrick/godirwalk v1.17.0 // indirect + + + batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{
    - 105 + + 1364 +
    -   - github.com/kevinburke/ssh_config v1.2.0 // indirect + + + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 106 + + 1365 +
    -   - github.com/klauspost/compress v1.17.0 // indirect + + + InitSequencedBatchNumber: initSequencedBatchNumber,
    -
    @@ -116,6 +117,7 @@
    +
    + 1366 + +
    + + + } +
    - 116 + + 1367 +
    -   - github.com/mattn/go-isatty v0.0.20 // indirect + + + }
    - 117 + + 1368 +
    -   - github.com/mattn/go-runewidth v0.0.13 // indirect + + + sequencedBatches[i] = batch
    - 118 + 1369
      - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect + }
    - + + 1370 -
    -   +
    +
    + +
    - 119 + + 1371 +
    -   - github.com/mitchellh/pointerstructure v1.2.0 // indirect + + + return sequencedBatches, nil
    - 120 + + 1372 +
    -   - github.com/mmcloughlin/addchain v0.4.0 // indirect + + + case "sequenceBatchesValidium":
    - 121 + + 1373 +
    -   - github.com/olekukonko/tablewriter v0.0.5 // indirect + + + var (
    -
    @@ -128,14 +130,14 @@
    -
    - 128 + + 1374 +
    -   - github.com/rogpeppe/go-internal v1.11.0 // indirect + + + sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - 129 + + 1375 +
    -   - github.com/rs/cors v1.7.0 // indirect + + + dataAvailabilityMsg []byte
    - 130 + + 1376 +
    -   - github.com/russross/blackfriday/v2 v2.1.0 // indirect + + + )
    - 131 + + 1377 +
    - - - github.com/sagikazarmark/locafero v0.3.0 // indirect + + + err := json.Unmarshal(bytedata, &sequencesValidium)
    - 132 + + 1378 +
    -   - github.com/sagikazarmark/slog-shim v0.1.0 // indirect + + + if err != nil {
    - 133 + + 1379 +
    -   - github.com/sergi/go-diff v1.2.0 // indirect + + + return nil, err
    - 134 + + 1380 +
    -   - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + + + }
    - 135 + + 1381 +
    -   - github.com/sirupsen/logrus v1.9.0 // indirect + + +
    - 136 + + 1382 +
    -   - github.com/skeema/knownhosts v1.2.1 // indirect + + + switch forkID {
    - 137 + + 1383 +
    -   - github.com/sourcegraph/conc v0.3.0 // indirect + + + case state.FORKID_ETROG:
    - 138 + + 1384 +
    - - - github.com/spf13/cast v1.5.1 // indirect + + + coinbase = data[1].(common.Address)
    - 139 + + 1385 +
    -   - github.com/spf13/pflag v1.0.5 // indirect + + + dataAvailabilityMsg = data[2].([]byte)
    - 140 + + 1386 +
    -   - github.com/status-im/keycard-go v0.2.0 // indirect + + +
    - 141 + + 1387 +
    -   - github.com/stretchr/objx v0.5.0 // indirect -
    -
    -
    + + + case state.FORKID_ELDERBERRY:
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - + + + - - - - - - - - -
    -
     
    - 22 + + 1388 +
    -   - github.com/prometheus/common v0.45.0 + + + maxSequenceTimestamp = data[1].(uint64)
    - 23 + + 1389 +
    -   - github.com/rubenv/sql-migrate v1.6.1 + + + initSequencedBatchNumber = data[2].(uint64)
    - 24 + + 1390 +
    -   - github.com/spf13/afero v1.11.0 + + + coinbase = data[3].(common.Address)
    - 25 + + 1391 +
    + - github.com/spf13/viper v1.18.2 + dataAvailabilityMsg = data[4].([]byte)
    - 26 + + 1392 +
    -   - github.com/stretchr/testify v1.8.4 + + + }
    - 27 + + 1393 +
    + - github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0 +
    - 28 + + 1394 +
    -   - github.com/urfave/cli/v2 v2.26.0 + + + // Pair the batch number, hash, and if it is forced. This will allow
    - 29 + + 1395 +
    -   - go.uber.org/zap v1.26.0 + + + // retrieval from different sources, and keep them in original order.
    - 30 + + 1396 +
    -   - golang.org/x/crypto v0.18.0 + + + var batchInfos []batchInfo
    -
     
    -
    - 45 + + 1397 +
    -   - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + + + for i, d := range sequencesValidium {
    - 46 + + 1398 +
    -   - github.com/bahlo/generic-list-go v0.2.0 // indirect + + + bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1))
    - 47 + + 1399 +
    -   - github.com/beorn7/perks v1.0.1 // indirect + + + forced := d.ForcedTimestamp > 0
    - 48 + + 1400 +
    + - github.com/bits-and-blooms/bitset v1.12.0 // indirect + h := d.TransactionsHash
    - 49 + + 1401 +
    -   - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + + + batchInfos = append(batchInfos, batchInfo{num: bn, hash: h, isForced: forced})
    - 50 + + 1402 +
    -   - github.com/buger/jsonparser v1.1.1 // indirect + + + }
    - 51 + + 1403 +
    -   - github.com/cespare/xxhash/v2 v2.2.0 // indirect + + +
    -
     
    -
    - 63 + + 1404 +
    -   - github.com/cyphar/filepath-securejoin v0.2.4 // indirect + + + batchData, err := retrieveBatchData(da, st, batchInfos, dataAvailabilityMsg)
    - 64 + + 1405 +
    -   - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + + + if err != nil {
    - 65 + + 1406 +
    -   - github.com/deckarep/golang-set/v2 v2.1.0 // indirect + + + return nil, err
    - 66 + + 1407 +
    + - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + }
    - 67 + + 1408 +
    -   - github.com/dlclark/regexp2 v1.7.0 // indirect + + +
    - 68 + + 1409 +
    -   - github.com/emirpasic/gods v1.18.1 // indirect + + + sequencedBatches := make([]SequencedBatch, len(sequencesValidium))
    - 69 + + 1410 +
    -   - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + + + for i, info := range batchInfos {
    - 70 + + 1411 +
    -   - github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect + + + bn := info.num
    - 71 + + 1412 +
    + - github.com/fsnotify/fsnotify v1.7.0 // indirect + s := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 72 + + 1413 +
    -   - github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect + + + Transactions: batchData[i],
    - 73 + + 1414 +
    -   - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + + + ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot,
    - 74 + + 1415 +
    -   - github.com/getsentry/sentry-go v0.18.0 // indirect + + + ForcedTimestamp: sequencesValidium[i].ForcedTimestamp,
    -
     
    -
    - 101 + + 1416 +
    -   - github.com/jackc/puddle v1.3.0 // indirect + + + ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1,
    - 102 + + 1417 +
    -   - github.com/jackpal/go-nat-pmp v1.0.2 // indirect + + + }
    - 103 + + 1418 +
    -   - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + + + batch := SequencedBatch{
    - 104 + 1419
    + - github.com/jmoiron/sqlx v1.2.0 // indirect + BatchNumber: bn,
    - 105 + + 1420 +
    -   - github.com/karrick/godirwalk v1.17.0 // indirect + + + L1InfoRoot: &l1InfoRoot,
    - 106 + + 1421 +
    -   - github.com/kevinburke/ssh_config v1.2.0 // indirect + + + SequencerAddr: sequencer,
    - 107 + + 1422 +
    -   - github.com/klauspost/compress v1.17.0 // indirect + + + TxHash: txHash,
    -
     
    +
    + 1423 + +
    + + + Nonce: nonce, +
    - 117 + + 1424 +
    -   - github.com/mattn/go-isatty v0.0.20 // indirect + + + Coinbase: coinbase,
    - 118 + + 1425 +
    -   - github.com/mattn/go-runewidth v0.0.13 // indirect + + + PolygonRollupBaseEtrogBatchData: &s,
    - 119 + + 1426 +
    -   - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect + + + }
    - 120 + 1427
    + - github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect + if forkID >= state.FORKID_ELDERBERRY {
    - 121 + + 1428 +
    -   - github.com/mitchellh/pointerstructure v1.2.0 // indirect + + + elderberry := &SequencedBatchElderberryData{
    - 122 + + 1429 +
    -   - github.com/mmcloughlin/addchain v0.4.0 // indirect + + + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 123 + + 1430 +
    -   - github.com/olekukonko/tablewriter v0.0.5 // indirect + + + InitSequencedBatchNumber: initSequencedBatchNumber,
    -
     
    +
    + 1431 + +
    + + + } +
    - 130 + + 1432 +
    -   - github.com/rogpeppe/go-internal v1.11.0 // indirect + + + batch.SequencedBatchElderberryData = elderberry
    - 131 + + 1433 +
    -   - github.com/rs/cors v1.7.0 // indirect + + + }
    - 132 + + 1434 +
    -   - github.com/russross/blackfriday/v2 v2.1.0 // indirect + + + sequencedBatches[i] = batch
    - 133 + + 1435 +
    + - github.com/sagikazarmark/locafero v0.4.0 // indirect + }
    - 134 + + 1436 +
    -   - github.com/sagikazarmark/slog-shim v0.1.0 // indirect + + +
    - 135 + + 1437 +
    -   - github.com/sergi/go-diff v1.2.0 // indirect + + + return sequencedBatches, nil
    - 136 + 1438
      - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + }
    - 137 + 1439
      - github.com/sirupsen/logrus v1.9.0 // indirect +
    +
    +
    + 1440 + +
    + + + return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName)
    - 138 + 1441
      - github.com/skeema/knownhosts v1.2.1 // indirect + }
    - 139 + 1442
      - github.com/sourcegraph/conc v0.3.0 // indirect +
    - 140 + 1443
    + - github.com/spf13/cast v1.6.0 // indirect + type batchInfo struct {
    - 141 + + 1444 +
    -   - github.com/spf13/pflag v1.0.5 // indirect + + + num uint64
    - 142 + + 1445 +
    -   - github.com/status-im/keycard-go v0.2.0 // indirect + + + hash common.Hash
    - 143 + + 1446 +
    -   - github.com/stretchr/objx v0.5.0 // indirect + + + isForced bool
    -
    + + + 1447 + + +
    + + + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - @@ -67069,673 +67309,683 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -67769,23 +68019,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + @@ -67799,877 +68059,928 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - -
    -
    @@ -0,0 +1,84 @@
    - + + 1448 -
    -   +
    +
    + +
    - + + 1449 -
    -   -
    +
    +
    + + + func retrieveBatchData(da dataavailability.BatchDataProvider, st stateProvider, batchInfos []batchInfo, daMessage []byte) ([][]byte, error) {
    - + + 1450 -
    -   -
    +
    +
    + + + validiumData, err := getBatchL2Data(da, batchInfos, daMessage)
    - + + 1451 -
    +
    +
      -
    + if err != nil {
    - + + 1452 -
    +
    +
      -
    + return nil, err
    - + + 1453 -
    +
    +
      -
    + }
    - + + 1454 -
    -   -
    +
    +
    + + + forcedData, err := getForcedBatchData(st, batchInfos)
    - + + 1455 -
    +
    +
      -
    + if err != nil {
    - + + 1456 -
    +
    +
      -
    + return nil, err
    - + + 1457 -
    +
    +
      -
    + }
    - + + 1458 -
    -   -
    +
    +
    + + + data := make([][]byte, len(batchInfos))
    - + + 1459 -
    -   -
    +
    +
    + + + for i, info := range batchInfos {
    - + + 1460 -
    -   -
    +
    +
    + + + bn := info.num
    - + + 1461 -
    -   -
    +
    +
    + + + if info.isForced {
    - + + 1462 -
    -   -
    +
    +
    + + + data[i] = forcedData[bn]
    - + + 1463 -
    -   -
    +
    +
    + + + } else {
    - + + 1464 -
    -   -
    +
    +
    + + + data[i] = validiumData[bn]
    - + + 1465 -
    -   -
    +
    +
    + + + }
    - + + 1466 -
    -   -
    +
    +
    + + + }
    - + + 1467 -
    -   -
    +
    +
    + + + return data, nil
    - + + 1468 -
    -   -
    +
    +
    + + + }
    - + + 1469 -
    +
    +
     
    - + + 1470 -
    -   -
    +
    +
    + + + func getBatchL2Data(da dataavailability.BatchDataProvider, batchInfos []batchInfo, daMessage []byte) (map[uint64][]byte, error) {
    - + + 1471 -
    -   -
    +
    +
    + + + var batchNums []uint64
    - + + 1472 -
    -   -
    +
    +
    + + + var batchHashes []common.Hash
    - + + 1473 -
    -   -
    +
    +
    + + + for _, info := range batchInfos {
    - + + 1474 -
    -   -
    +
    +
    + + + if !info.isForced {
    - + + 1475 -
    -   -
    +
    +
    + + + batchNums = append(batchNums, info.num)
    - + + 1476 -
    -   -
    +
    +
    + + + batchHashes = append(batchHashes, info.hash)
    - + + 1477 -
    -   -
    +
    +
    + + + }
    - + + 1478 -
    +
    +
      -
    + }
    - + + 1479 -
    -   -
    +
    +
    + + + if len(batchNums) == 0 {
    - + + 1480 -
    -   -
    +
    +
    + + + return nil, nil
    - + + 1481 -
    -   -
    +
    +
    + + + }
    - + + 1482 -
    -   -
    +
    +
    + + + batchL2Data, err := da.GetBatchL2Data(batchNums, batchHashes, daMessage)
    - + + 1483 -
    +
    +
      -
    + if err != nil {
    - + + 1484 -
    +
    +
      -
    + return nil, err
    - + + 1485 -
    +
    +
      -
    + }
    - + + 1486 -
    -   -
    +
    +
    + + + if len(batchL2Data) != len(batchNums) {
    - + + 1487 -
    -   -
    +
    +
    + + + return nil,
    - + + 1488 -
    -   -
    +
    +
    + + + fmt.Errorf("failed to retrieve all batch data. Expected %d, got %d", len(batchNums), len(batchL2Data))
    - + + 1489 -
    -   -
    +
    +
    + + + }
    - + + 1490 -
    -   -
    +
    +
    + + + data := make(map[uint64][]byte)
    - + + 1491 -
    -   -
    +
    +
    + + + for i, bn := range batchNums {
    - + + 1492 -
    -   -
    +
    +
    + + + data[bn] = batchL2Data[i]
    - + + 1493 -
    -   -
    +
    +
    + + + }
    - + + 1494 -
    -   -
    +
    +
    + + + return data, nil
    - + + 1495 -
    -   -
    +
    +
    + + + }
    - + + 1496 -
    -   +
    +
    + +
    - + + 1497 -
    -   -
    +
    +
    + + + func getForcedBatchData(st stateProvider, batchInfos []batchInfo) (map[uint64][]byte, error) {
    - + + 1498 -
    -   -
    +
    +
    + + + var batchNums []uint64
    - + + 1499 -
    -   -
    +
    +
    + + + var batchHashes []common.Hash
    - + + 1500 -
    -   -
    +
    +
    + + + for _, info := range batchInfos {
    - + + 1501 -
    -   -
    +
    +
    + + + if info.isForced {
    - + + 1502 -
    -   -
    +
    +
    + + + batchNums = append(batchNums, info.num)
    - + + 1503 -
    -   -
    +
    +
    + + + batchHashes = append(batchHashes, info.hash)
    - + + 1504 -
    -   -
    +
    +
    + + + }
    - + + 1505 -
    -   -
    +
    +
    + + + }
    - + + 1506 -
    -   -
    +
    +
    + + + if len(batchNums) == 0 {
    - + + 1507 -
    -   -
    +
    +
    + + + return nil, nil
    - + + 1508 -
    -   -
    +
    +
    + + + }
    - + + 1509 -
    -   -
    +
    +
    + + + data, err := st.GetForcedBatchDataByNumbers(context.Background(), batchNums, nil)
    - + + 1510 -
    +
    +
      -
    + if err != nil {
    - + + 1511 -
    +
    +
      -
    + return nil, err
    - + + 1512 -
    +
    +
      -
    + }
    - + + 1513 -
    -   +
    +
    + +
    - + + 1514 -
    -   -
    +
    +
    + + + for i, bn := range batchNums {
    - + + 1515 -
    -   -
    +
    +
    + + + expectedHash := batchHashes[i]
    - + + 1516 -
    -   -
    +
    +
    + + + d, ok := data[bn]
    - + + 1517 -
    -   -
    +
    +
    + + + if !ok {
    - + + 1518 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("missing forced batch data for number %d", bn)
    - + + 1519 -
    -   -
    +
    +
    + + + }
    - + + 1520 -
    -   -
    +
    +
    + + + actualHash := crypto.Keccak256Hash(d)
    - + + 1521 -
    -   -
    +
    +
    + + + if actualHash != expectedHash { +
    +
    + 1522 + +
    + + + return nil, fmt.Errorf("got wrong hash for forced batch data number %d", bn)
    - + + 1523 -
    +
    +
      -
    + }
    - + + 1524 -
    +
    +
      -
    + } +
    +
    + 1525 + +
    + + + return data, nil
    - + + 1526 -
    +
    +
      -
    + }
    - + + 1527 -
    +
    +
     
    -
    + + + 1528 + + +
    +   + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
    -
    -
    - - - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - + - + + - - - - @@ -68679,12 +68990,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go RENAMED
    - - - - - - - - - + - + + - - - - - - @@ -68832,741 +69148,828 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - -
     
    - 1 + + 1635 +
    - + - # .goreleaser-cdk.yaml +   + if err != nil {
    - 2 + + 1636 +
    - + - project_name: cdk-validium-node +   + return err
    - 3 + + 1637 +
    - + -
    +   + }
    - 4 + + 1638 +
    + - release: + // TODO complete data forcedBlockHash, forcedGer y forcedTimestamp
    - 5 + + 1639 +
    - + - disable: false +   +
    - 6 + + 1640 +
    - + - draft: true +   + // Read the tx for this batch.
    - 7 + + 1641 +
    - + - prerelease: auto +   + tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex)
    - 8 + +
     
    +
    + 1940 +
    - + -
    +   + })
    - 9 + + 1941 +
    - + - before: +   + }
    - 10 + + 1942 +
    - + - hooks: +   +
    - 11 + 1943
    + - - go mod download + // DepositCount returns deposits count
    - 12 + 1944
    + - - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 + func (etherman *Client) DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) {
    - 13 + 1945
    + - - packr2 + var opts *bind.CallOpts
    - 14 + 1946
    + -
    + if blockNumber != nil {
    - 15 + 1947
    + - builds: + opts = new(bind.CallOpts)
    - 16 + 1948
    + - - main: ./cmd/ + opts.BlockNumber = new(big.Int).SetUint64(*blockNumber)
    - 17 + 1949
    + - binary: zkevm-node + }
    - 18 + 1950
    + - goos: +
    - 19 + 1951
    + - - linux + return etherman.GlobalExitRootManager.DepositCount(opts)
    - 20 + 1952
    + - - darwin + }
    - 21 + 1953
    + - goarch: +
    - 22 + + 1954 +
    - + - - amd64 +   + // CheckTxWasMined check if a tx was already mined
    - 23 + + 1955 +
    - + - - arm64 +   + func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error) {
    - 24 + + 1956 +
    - + - env: +   + receipt, err := etherMan.EthClient.TransactionReceipt(ctx, txHash)
    - 25 + +
     
    +
    + 2005 +
    - + - - CGO_ENABLED=0 +   + }
    - 26 + + 2006 +
    - + - ldflags: +   +
    - 27 + + 2007 +
    - + - - -s -w +   + // LoadAuthFromKeyStore loads an authorization from a key store file
    - 28 + + 2008 +
    + - - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }} + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 29 + + 2009 +
    + - - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }} + auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 30 + + 2010 +
    - + - - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }} +   + if err != nil {
    - 31 + + 2011 +
    + - - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }} + return nil, nil, err
    - 32 + + 2012 +
    - + +   + } +
    +
    + 2013 + +
    +  
    - 33 + + 2014 +
    - + - archives: +   + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 34 + + 2015 +
    - + - - files: +   + etherMan.auth[auth.From] = auth
    - 35 + + 2016 +
    + - - LICENSE + return &auth, pk, nil
    - 36 + + 2017 +
    - + - - README.md +   + }
    - 37 + + 2018 +
    - + +  
    - 38 + + 2019 +
    - + - dockers: +   + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    - 39 + +
     
    +
    + 2034 +
    - + - - image_templates: +   + }
    - 40 + + 2035 +
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 +   +
    - 41 + + 2036 +
    - + - dockerfile: Dockerfile.release +   + // newAuthFromKeystore an authorization instance from a keystore file
    - 42 + + 2037 +
    + - use: buildx + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 43 + + 2038 +
    - + - goos: linux +   + log.Infof("reading key from: %v", path)
    - 44 + + 2039 +
    - + - goarch: amd64 +   + key, err := newKeyFromKeystore(path, password)
    - 45 + + 2040 +
    - + - build_flag_templates: +   + if err != nil {
    - 46 + + 2041 +
    + - - --platform=linux/amd64 + return bind.TransactOpts{}, nil, err
    - 47 + + 2042 +
    - + - - --label=org.opencontainers.image.title={{ .ProjectName }} +   + }
    - 48 + + 2043 +
    - + - - --label=org.opencontainers.image.description={{ .ProjectName }} +   + if key == nil {
    - 49 + + 2044 +
    + - - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + return bind.TransactOpts{}, nil, nil
    - 50 + + 2045 +
    - + - - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} +   + }
    - 51 + + 2046 +
    - + - - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} +   + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    - 52 + + 2047 +
    - + - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} +   + if err != nil {
    - 53 + + 2048 +
    + - - --label=org.opencontainers.image.revision={{ .FullCommit }} + return bind.TransactOpts{}, nil, err
    - 54 + + 2049 +
    - + - skip_push: false +   + }
    - 55 + + 2050 +
    + + return *auth, key.PrivateKey, nil +
    +
    + 2051 + +
    +   + } +
    +
    + 2052 + +
    +  
    - 56 + + 2053 +
    - + - - image_templates: +   + // getAuthByAddress tries to get an authorization from the authorizations map
    - 57 + +
     
    +
    + 2075 +
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +   +
    - 58 + + 2076 +
    - + - dockerfile: Dockerfile.release +   + return *auth, nil
    - 59 + + 2077 +
    - + - use: buildx +   + }
    - 60 + 2078
    + - goos: linux +
    - 61 + 2079
    + - goarch: arm64 + // GetDAProtocolAddr returns the address of the data availability protocol
    - 62 + 2080
    + - build_flag_templates: + func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) {
    - 63 + 2081
    + - - --platform=linux/arm64 + return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
    - 64 + 2082
    + - - --label=org.opencontainers.image.title={{ .ProjectName }} + }
    - 65 + 2083
    + - - --label=org.opencontainers.image.description={{ .ProjectName }} +
    - 66 + 2084
    + - - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + // GetDAProtocolName returns the name of the data availability protocol
    - 67 + 2085
    + - - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} + func (etherMan *Client) GetDAProtocolName() (string, error) {
    - 68 + 2086
    + - - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} + return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false})
    - 69 + 2087
    + - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + }
    - 70 + 2088
    + - - --label=org.opencontainers.image.revision={{ .FullCommit }} +
    - 71 + 2089
    + - skip_push: false + // SetDataAvailabilityProtocol sets the address for the new data availability protocol
    - 72 + 2090
    + -
    + func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) {
    - 73 + 2091
    + - docker_manifests: + auth, err := etherMan.getAuthByAddress(from)
    - 74 + 2092
    + - - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }} + if err != nil {
    - 75 + 2093
    + - image_templates: + return nil, err
    - 76 + 2094
    + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + }
    - 77 + 2095
    + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +
    - 78 + 2096
    + - skip_push: false + return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress)
    - 79 + 2097
    + -
    + }
    - 80 + 2098
    + - - name_template: 0xpolygon/{{ .ProjectName }}:latest +
    - 81 + 2099
    + - image_templates: + // GetRollupId returns the rollup id
    - 82 + 2100
    + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + func (etherMan *Client) GetRollupId() uint32 {
    - 83 + 2101
    + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 + return etherMan.RollupID
    - 84 + 2102
    + - skip_push: false + }
    -
    @@ -58,6 +58,35 @@
    +
    @@ -38,7 +38,7 @@
    - 58 + 38
      - return result, nil + }
    - 59 + 39
      - } +
    - 60 + 40
      -
    + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - + + 41 -
    -   -
    +
    +
    + - + func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) {
    - + + 42 -
    +
    +
      -
    + privateKey, err := crypto.GenerateKey()
    - + + 43 -
    +
    +
      -
    + if err != nil {
    - + + 44 -
    +
    +
      -
    + log.Fatal(err)
    - + +
    @@ -47,7 +47,9 @@
    -
    +
    + 47 + +
      -
    + if err != nil {
    - + + 48 -
    +
    +
      -
    + log.Fatal(err)
    - + + 49 -
    +
    +
      -
    + }
    - + + 50 -
    -   -
    +
    +
    + - + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth)
    - + + 51 -
    +
    +
      -
    + if err != nil {
    - + + 52 -
    +
    +
      -
    + log.Fatal(err)
    - + + 53 -
    +
    +
      -
    + }
    - + +
    @@ -55,12 +57,12 @@
    -
    +
    + 55 + +
      -
    + if err != nil {
    - + + 56 -
    +
    +
      -
    + log.Fatal(err)
    - + + 57 -
    +
    +
      -
    + }
    - + + 58 -
    -   -
    +
    +
    + - + return ethman, ethBackend, auth, polAddr, br
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    +
    +
     
    - + + 61 -
    +
    +
      -
    + func TestGEREvent(t *testing.T) {
    - + + 62 -
    +
    +
      -
    + // Set up testing environment
    - + + 63 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, br := newTestingEnv()
    - + + 64 -
    +
    +
     
    - + + 65 -
    +
    +
      -
    + // Read currentBlock
    - + + 66 -
    +
    +
      -
    + ctx := context.Background()
    - + +
    @@ -82,14 +84,14 @@
    -
    +
    + 82 + +
      -
    + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 83 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 84 -
    +
    +
      -
    + t.Logf("Blocks: %+v", blocks)
    - + + 85 -
    -   -
    +
    +
    + - + assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber)
    - 61 + 86
      - // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root + assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
    - 62 + 87
      - func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) { + assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
    - 63 + 88
      - response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) -
    -
    -
    + }
    -
    -
    - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + + + + + - - -
    -
     
    - 58 + 89
      - return result, nil +
    - 59 + 90
      - } + func TestForcedBatchEvent(t *testing.T) {
    - 60 + 91
      -
    + // Set up testing environment
    - 61 + + 92 +
    - + - // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last + - + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 62 + + 93 +
    - + - // known batch is returned as a list. +   +
    - 63 + + 94 +
    - + - func (c *Client) BatchesByNumbers(_ context.Context, numbers []*big.Int) ([]*types.BatchData, error) { +   + // Read currentBlock
    - 64 + + 95 +
    - + - batchNumbers := make([]types.BatchNumber, 0, len(numbers)) +   + ctx := context.Background()
    - 65 + +
    @@ -114,8 +116,8 @@
    +
    + 114 +
    - + - for _, n := range numbers { +   + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 66 + + 115 +
    - + - batchNumbers = append(batchNumbers, types.BatchNumber(n.Int64())) +   + require.NoError(t, err)
    - 67 + + 116 +
    - + - } +   + t.Logf("Blocks: %+v", blocks)
    - 68 + + 117 +
    - + - if len(batchNumbers) == 0 { + - + assert.Equal(t, uint64(8), blocks[0].BlockNumber)
    - 69 + + 118 +
    - + - batchNumbers = append(batchNumbers, types.LatestBatchNumber) + - + assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber)
    - 70 + + 119 +
    - + - } +   + assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
    - 71 + + 120 +
    - + -
    +   + assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
    - 72 + + 121 +
    - + - response, err := JSONRPCCall(c.url, "zkevm_getBatchDataByNumbers", &types.BatchFilter{Numbers: batchNumbers}) +   + assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
    - 73 + +
    @@ -125,7 +127,7 @@
    +
    + 125 +
    - + - if err != nil { +   +
    - 74 + + 126 +
    - + - return nil, err +   + func TestSequencedBatchesEvent(t *testing.T) {
    - 75 + + 127 +
    - + - } +   + // Set up testing environment
    - 76 + + 128 +
    - + + - + etherman, ethBackend, auth, _, br := newTestingEnv() +
    +
    + 129 + +
    +  
    - 77 + + 130 +
    - + - if response.Error != nil { +   + // Read currentBlock
    - 78 + + 131 +
    - + - return nil, response.Error.RPCError() +   + ctx := context.Background()
    - 79 + +
    @@ -156,13 +158,19 @@
    +
    + 156 +
    - + - } +   + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
    - 80 + + 157 +
    - + -
    +   + require.NoError(t, err)
    - 81 + + 158 +
    - + - var result *types.BatchDataResult +   + t.Log("Blocks: ", blocks)
    - 82 + + 159 +
    - + - err = json.Unmarshal(response.Result, &result) + - + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 83 + + 160 +
    - + - if err != nil { + - + sequences = append(sequences, polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 84 + + 161 +
    - + - return nil, err + - + Transactions: common.Hex2Bytes(rawTxs),
    - 85 + + 162 +
    - + - } + - + }, polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 86 + + 163 +
    - + + - + Transactions: common.Hex2Bytes(rawTxs), +
    +
    + + +
    +  
    - 87 + + 164 +
    - + - return result.Data, nil +   + })
    - 88 + + 165 +
    - + - } + - + _, err = etherman.ZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From)
    - 89 + + -
    - + +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +  
    - 90 + 166
      - // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root + require.NoError(t, err)
    - 91 + 167
      - func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) { +
    - 92 + 168
      - response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) + // Mine the tx in a block
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go - RENAMED - -
    -
    -
    -
    - - - + - - + + + + + + - - + + + + + + @@ -69581,425 +69984,367 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -106,7 +106,7 @@
    +
    @@ -188,7 +196,7 @@
    - 106 + 188
      - result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) +
    - 107 + 189
      - if err != nil { + func TestVerifyBatchEvent(t *testing.T) {
    - 108 + 190
      - errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) + // Set up testing environment
    - 109 + 191
    - - logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas) + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 110 + 192
      - return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) +
    - 111 + 193
      - } + // Read currentBlock
    - 112 + 194
      -
    + ctx := context.Background()
    -
    @@ -941,6 +941,9 @@
    +
    @@ -197,12 +205,13 @@
    - 941 + 197
      - if e.cfg.SequencerNodeURI != "" { + require.NoError(t, err)
    - 942 + 198
      - return e.relayTxToSequencerNode(input) +
    - 943 + 199
      - } else { + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - + + 200 -
    +
    +
    + - + tx := polygonzkevm.PolygonRollupBaseEtrogBatchData{ +
    +
    + 201 + +
    + - + Transactions: common.Hex2Bytes(rawTxs), +
    +
    + 202 + +
      -
    + }
    - + + 203 -
    +
    +
    + - + //TODO: Fix params +
    +
    + 204 + +
    + - + _, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From) +
    +
    + 205 + +
      -
    + require.NoError(t, err)
    - 944 + 206
      - ip := "" +
    - 945 + 207
      - ips := httpRequest.Header.Get("X-Forwarded-For") + // Mine the tx in a block
    - 946 + 208
      -
    + ethBackend.Commit()
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - -
    -
     
    +
    @@ -220,7 +229,7 @@
    - 106 + 220
      - result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 107 + 221
      - if err != nil { + require.NoError(t, err)
    - 108 + 222
      - errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) + t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
    - 109 + + 223 +
    - + - logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas)) + - + assert.Equal(t, uint64(9), blocks[1].BlockNumber)
    - 110 + 224
      - return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) + assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
    - 111 + 225
      - } + assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
    - 112 + 226
      -
    + assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
    -
     
    +
    @@ -232,7 +241,7 @@
    - 941 + 232
      - if e.cfg.SequencerNodeURI != "" { +
    - 942 + 233
      - return e.relayTxToSequencerNode(input) + func TestSequenceForceBatchesEvent(t *testing.T) {
    - 943 + 234
      - } else { -
    -
    - 944 - -
    - + - if err := checkPolicy(context.Background(), e.pool, input); err != nil { -
    -
    - 945 - -
    - + - return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false) + // Set up testing environment
    - 946 + + 235 +
    - + - } + - + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 947 + 236
      - ip := "" +
    - 948 + 237
      - ips := httpRequest.Header.Get("X-Forwarded-For") + // Read currentBlock
    - 949 + 238
      -
    + ctx := context.Background()
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - + - - - - - - @@ -70013,43 +70358,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -70073,1683 +70418,1782 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    -
    @@ -6,6 +6,7 @@
    +
    @@ -283,7 +292,7 @@
    - 6 + 283
      - "errors" + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 7 + 284
      - "fmt" + require.NoError(t, err)
    - 8 + 285
      - "math/big" + t.Logf("Blocks: %+v", blocks)
    - + + 286 -
    -   -
    +
    +
    + - + assert.Equal(t, uint64(12), blocks[1].BlockNumber)
    - 9 + 287
      - "sync" + assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
    - 10 + 288
      - "testing" + assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
    - 11 + 289
      - "time" + assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
    -
    @@ -5416,3 +5417,237 @@
    +
    @@ -293,7 +302,7 @@
    - 5416 + 293
      - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) +
    - 5417 + 294
      - assert.ElementsMatch(t, []int{16}, results[5]) + func TestSendSequences(t *testing.T) {
    - 5418 + 295
      - } + // Set up testing environment
    - + + 296 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, br := newTestingEnv()
    - + + 297 -
    +
    +
     
    - + + 298 -
    +
    +
      -
    + // Read currentBlock
    - + + 299 -
    +
    +
      -
    + ctx := context.Background()
    - - -
    -   -
    -
    +
    +
    @@ -315,10 +324,12 @@
    - + + 315 -
    +
    +
      -
    + BatchL2Data: batchL2Data,
    - + + 316 -
    +
    +
      -
    + LastL2BLockTimestamp: time.Now().Unix(),
    - + + 317 -
    +
    +
      -
    + }
    - + + 318 -
    +
    +
      -
    + lastL2BlockTStamp := tx1.Time().Unix()
    - + + 319 -
    -   -
    +
    +
    + - + // TODO: fix params
    - + + 320 -
    -   -
    +
    +
    + - + tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From)
    - + + 321 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 322 -
    +
    +
      -
    + log.Debug("TX: ", tx.Hash())
    - + + 323 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 324 -
    +
    +
     
    - + +
    @@ -341,7 +352,7 @@
    -
    +
    + 341 + +
     
    - + + 342 -
    +
    +
      -
    + func TestGasPrice(t *testing.T) {
    - + + 343 -
    +
    +
      -
    + // Set up testing environment
    - + + 344 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 345 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 346 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 347 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
    @@ -360,14 +371,14 @@
    -
    +
    + 360 + +
     
    - + + 361 -
    +
    +
      -
    + func TestErrorEthGasStationPrice(t *testing.T) {
    - + + 362 -
    +
    +
      -
    + // Set up testing environment
    - + + 363 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 364 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 365 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
    - + + 366 -
    +
    +
      -
    + ctx := context.Background()
    - + + 367 -
    +
    +
     
    - + + 368 -
    +
    +
      -
    + ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
    - + + 369 -
    +
    +
      -
    + gp := etherman.GetL1GasPrice(ctx)
    - + + 370 -
    -   -
    +
    +
    + - + assert.Equal(t, big.NewInt(1392695906), gp)
    - + + 371 -
    +
    +
     
    - + + 372 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 373 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
    @@ -379,7 +390,7 @@
    -
    +
    + 379 + +
     
    - + + 380 -
    +
    +
      -
    + func TestErrorEtherScanPrice(t *testing.T) {
    - + + 381 -
    +
    +
      -
    + // Set up testing environment
    - + + 382 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 383 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 384 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 385 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - - -
    -   -
    -
    +
    +
    @@ -393,7 +404,7 @@
    - + + 393 -
    +
    +
     
    - + + 394 -
    +
    +
      -
    + func TestGetForks(t *testing.T) {
    - + + 395 -
    +
    +
      -
    + // Set up testing environment
    - + + 396 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 397 -
    +
    +
      -
    + ctx := context.Background()
    - + + 398 -
    +
    +
      -
    + forks, err := etherman.GetForks(ctx, 0, 132)
    - + + 399 -
    +
    +
      -
    + require.NoError(t, err)
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + + + + @@ -71763,344 +72207,463 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - - - - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - + + +
    +
     
    - + + 38 -
    +
    +
      -
    + }
    - + + 39 -
    +
    +
     
    - + + 40 -
    +
    +
      -
    + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - + + 41 -
    -   -
    +
    +
    + + + func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock, st *stateMock) {
    - + + 42 -
    +
    +
      -
    + privateKey, err := crypto.GenerateKey()
    - + + 43 -
    +
    +
      -
    + if err != nil {
    - + + 44 -
    +
    +
      -
    + log.Fatal(err)
    - - -
    -   -
    -
    +
    +
     
    - + + 47 -
    +
    +
      -
    + if err != nil {
    - + + 48 -
    +
    +
      -
    + log.Fatal(err)
    - + + 49 -
    +
    +
      -
    + }
    - + + 50 -
    -   -
    +
    +
    + + + da = newDaMock(t)
    - + + 51 -
    -   -
    +
    +
    + + + st = newStateMock(t)
    - + + 52 -
    -   -
    +
    +
    + + + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da, st)
    - + + 53 -
    +
    +
      -
    + if err != nil {
    - + + 54 -
    +
    +
      -
    + log.Fatal(err)
    - + + 55 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 57 + +
      -
    + if err != nil {
    - + + 58 -
    +
    +
      -
    + log.Fatal(err)
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    -   -
    +
    +
    + + + return ethman, ethBackend, auth, polAddr, br, da, st
    - + + 61 -
    +
    +
      -
    + }
    - + + 62 -
    +
    +
     
    - + + 63 -
    +
    +
      -
    + func TestGEREvent(t *testing.T) {
    - + + 64 -
    +
    +
      -
    + // Set up testing environment
    - + + 65 -
    -   -
    +
    +
    + + + etherman, ethBackend, auth, _, br, _, _ := newTestingEnv(t)
    - + + 66 -
    +
    +
     
    - + + 67 -
    +
    +
      -
    + // Read currentBlock
    - + + 68 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 84 + +
      -
    + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 85 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 86 -
    +
    +
      -
    + t.Logf("Blocks: %+v", blocks)
    - + + 87 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(11), blocks[0].L1InfoTree[0].BlockNumber)
    - + + 88 -
    +
    +
      -
    + assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
    - + + 89 -
    +
    +
      -
    + assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
    - + + 90 -
    +
    +
      -
    + }
    - + + 91 -
    +
    +
     
    - + + 92 -
    +
    +
      -
    + func TestForcedBatchEvent(t *testing.T) {
    - + + 93 -
    +
    +
      -
    + // Set up testing environment
    - + + 94 -
    -   -
    +
    +
    + + + etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t)
    - + + 95 -
    +
    +
     
    - + + 96 -
    +
    +
      -
    + // Read currentBlock
    - + + 97 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 116 + +
      -
    + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 117 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 118 -
    +
    +
      -
    + t.Logf("Blocks: %+v", blocks)
    - + + 119 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(11), blocks[0].BlockNumber)
    - + + 120 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(11), blocks[0].ForcedBatches[0].BlockNumber)
    - + + 121 -
    +
    +
      -
    + assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
    - + + 122 -
    +
    +
      -
    + assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
    - + + 123 -
    +
    +
      -
    + assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
    - + +
     
    -
    +
    + 127 + +
     
    - + + 128 -
    +
    +
      -
    + func TestSequencedBatchesEvent(t *testing.T) {
    - + + 129 -
    +
    +
      -
    + // Set up testing environment
    - + + 130 -
    -   -
    +
    +
    + + + etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t)
    - + + 131 -
    +
    +
     
    - + + 132 -
    +
    +
      -
    + // Read currentBlock
    - + + 133 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 158 + +
      -
    + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
    - + + 159 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 160 -
    +
    +
      -
    + t.Log("Blocks: ", blocks)
    - + + 161 -
    -   -
    +
    +
    + + + var sequences []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - + + 162 -
    -   -
    +
    +
    + + + txsHash := crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))
    - + + 163 -
    -   -
    +
    +
    + + + sequences = append(sequences, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - + + 164 -
    -   -
    +
    +
    + + + TransactionsHash: txsHash,
    - + + 165 -
    -   -
    +
    +
    + + + }, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - + + 166 -
    -   -
    +
    +
    + + + TransactionsHash: txsHash,
    - + + 167 -
    +
    +
      -
    + })
    - + + 168 -
    -   -
    +
    +
    + + + batchNums := []uint64{2, 3}
    - + + 169 -
    -   -
    +
    +
    + + + batchHashes := []common.Hash{txsHash, txsHash}
    - + + 170 -
    -   -
    +
    +
    + + + batchData := [][]byte{data, data}
    - + + 171 -
    -   -
    +
    +
    + + + daMessage, _ := hex.DecodeString("0x123456789123456789")
    - + + 172 -
    -   -
    +
    +
    + + + da.Mock.On("GetBatchL2Data", batchNums, batchHashes, daMessage).Return(batchData, nil)
    - + + 173 -
    -   -
    +
    +
    + + + _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
    - + + 174 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 175 -
    +
    +
     
    - + + 176 -
    +
    +
      -
    + // Mine the tx in a block
    - + +
     
    -
    +
    + 196 + +
     
    - + + 197 -
    +
    +
      -
    + func TestVerifyBatchEvent(t *testing.T) {
    - + + 198 -
    +
    +
      -
    + // Set up testing environment
    - + + 199 -
    -   -
    +
    +
    + + + etherman, ethBackend, auth, _, _, da, _ := newTestingEnv(t)
    - + + 200 -
    +
    +
     
    - + + 201 -
    +
    +
      -
    + // Read currentBlock
    - + + 202 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 205 + +
      -
    + require.NoError(t, err)
    - + + 206 -
    +
    +
     
    - + + 207 -
    +
    +
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - - -
    -   -
    +
    + 208 + +
    + + + tx := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - + + 209 -
    -   -
    +
    +
    + + + TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
    - + + 210 -
    +
    +
      -
    + }
    - + + 211 -
    -   -
    +
    +
    + + + daMessage, _ := hex.DecodeString("0x1234")
    - + + 212 -
    -   -
    +
    +
    + + + _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, []polygonzkevm.PolygonValidiumEtrogValidiumBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
    - + + 213 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 214 -
    -   -
    +
    +
    + + + da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))}, daMessage).Return([][]byte{common.Hex2Bytes(rawTxs)}, nil)
    - + + 215 -
    +
    +
     
    - + + 216 -
    +
    +
      -
    + // Mine the tx in a block
    - + + 217 -
    +
    +
      -
    + ethBackend.Commit()
    - + +
     
    -
    +
    + 229 + +
      -
    + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 230 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 231 -
    +
    +
      -
    + t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
    - + + 232 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(12), blocks[1].BlockNumber)
    - + + 233 -
    +
    +
      -
    + assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
    - + + 234 -
    +
    +
      -
    + assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
    - + + 235 -
    +
    +
      -
    + assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
    - + +
     
    -
    +
    + 241 + +
     
    - + + 242 -
    +
    +
      -
    + func TestSequenceForceBatchesEvent(t *testing.T) {
    - + + 243 -
    +
    +
      -
    + // Set up testing environment
    - + + 244 -
    -   -
    +
    +
    + + + etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t)
    - + + 245 -
    +
    +
     
    - + + 246 -
    +
    +
      -
    + // Read currentBlock
    - + + 247 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 292 + +
      -
    + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 293 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 294 -
    +
    +
      -
    + t.Logf("Blocks: %+v", blocks)
    - + + 295 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(15), blocks[1].BlockNumber)
    - + + 296 -
    +
    +
      -
    + assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
    - + + 297 -
    +
    +
      -
    + assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
    - + + 298 -
    +
    +
      -
    + assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
    - + +
     
    -
    +
    + 302 + +
     
    - + + 303 -
    +
    +
      -
    + func TestSendSequences(t *testing.T) {
    - + + 304 -
    +
    +
      -
    + // Set up testing environment
    - + + 305 -
    +
    +
    + + + etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t) +
    +
    + 306 + +
     
    - + + 307 -
    +
    +
      -
    + // Read currentBlock
    - + + 308 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 324 + +
      -
    + BatchL2Data: batchL2Data,
    - + + 325 -
    +
    +
      -
    + LastL2BLockTimestamp: time.Now().Unix(),
    - + + 326 -
    +
    +
      -
    + }
    - + + 327 -
    +
    +
    + + + daMessage, _ := hex.DecodeString("0x1234") +
    +
    + 328 + +
      -
    + lastL2BlockTStamp := tx1.Time().Unix() +
    +
    + 329 + +
    + + + tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From, daMessage)
    - + + 330 -
    +
    +
      + require.NoError(t, err) +
    +
    + 331 + +
    + + + da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(batchL2Data)}, daMessage).Return([][]byte{batchL2Data}, nil) +
    +
    + 332 + +
    + +
    - + + 333 -
    +
    +
      -
    + log.Debug("TX: ", tx.Hash())
    - + + 334 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 335 -
    +
    +
     
    - + +
     
    -
    +
    + 352 + +
     
    - + + 353 -
    +
    +
      -
    + func TestGasPrice(t *testing.T) {
    - + + 354 -
    +
    +
      -
    + // Set up testing environment
    - + + 355 -
    +
    +
    + + + etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    + 356 + +
      -
    + etherscanM := new(etherscanMock)
    - + + 357 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 358 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
     
    -
    +
    + 371 + +
     
    - + + 372 -
    +
    +
      -
    + func TestErrorEthGasStationPrice(t *testing.T) {
    - + + 373 -
    +
    +
      -
    + // Set up testing environment
    - + + 374 -
    +
    +
    + + + etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    + 375 + +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 376 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
    - + + 377 -
    +
    +
      -
    + ctx := context.Background()
    - + + 378 -
    +
    +
     
    - + + 379 -
    +
    +
      -
    + ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
    - + + 380 -
    +
    +
      -
    + gp := etherman.GetL1GasPrice(ctx)
    - + + 381 -
    +
    +
    + + + assert.Equal(t, big.NewInt(1263075579), gp) +
    +
    + 382 + +
     
    - + + 383 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 384 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
     
    -
    +
    + 390 + +
     
    - + + 391 -
    +
    +
      -
    + func TestErrorEtherScanPrice(t *testing.T) {
    - + + 392 -
    +
    +
      -
    + // Set up testing environment
    - + + 393 -
    +
    +
    + + + etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    + 394 + +
      -
    + etherscanM := new(etherscanMock)
    - + + 395 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 396 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
     
    -
    +
    + 404 + +
     
    - + + 405 -
    +
    +
      -
    + func TestGetForks(t *testing.T) {
    - + + 406 -
    +
    +
      -
    + // Set up testing environment
    - + + 407 -
    +
    +
    + + + etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    + 408 + +
      -
    + ctx := context.Background()
    - + + 409 -
    +
    +
      -
    + forks, err := etherman.GetForks(ctx, 0, 132)
    - + + 410 -
    +
    +
      -
    + require.NoError(t, err) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,16 @@
    @@ -72277,2448 +72840,3395 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - 6 + + 1 +
    -   - "errors" + + + package etherman
    - 7 + + 2 +
    -   - "fmt" + + +
    - 8 + + 3 +
    -   - "math/big" + + + import (
    - 9 + 4
    + - "strings" + "context"
    - 10 + + 5 +
    -   - "sync" + + +
    - 11 + + 6 +
    -   - "testing" + + + "github.com/ethereum/go-ethereum/common"
    - 12 + + 7 +
    -   - "time" + + + "github.com/jackc/pgx/v4"
    -
     
    -
    - 5417 + + 8 +
    -   - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) + + + )
    - 5418 + + 9 +
    -   - assert.ElementsMatch(t, []int{16}, results[5]) + + +
    - 5419 + + 10 +
    -   - } + + + type dataAvailabilityProvider interface {
    - 5420 + 11
    + -
    + GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
    - 5421 + 12
    + - func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) { + }
    - 5422 + 13
    + - // Set up the sender +
    - 5423 + 14
    + - allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x")) + type stateProvider interface {
    - 5424 + 15
    + - require.NoError(t, err) + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 5425 + 16
    + - allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1)) + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + + + + + - - - - - + - + + - - - - - - + + + + + + - - - - + + +
    +
    @@ -23,7 +24,7 @@
    - 5426 + + 23 +
    - + - require.NoError(t, err) +   +
    - 5427 + + 24 +
    - + -
    +   + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - 5428 + + 25 +
    - + - disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x")) +   + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - 5429 + + 26 +
    - + - require.NoError(t, err) + - + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *polygonzkevmbridge.Polygonzkevmbridge, error) {
    - 5430 + + 27 +
    - + - disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1)) +   + if auth == nil {
    - 5431 + + 28 +
    - + - require.NoError(t, err) +   + // read only client
    - 5432 + + 29 +
    - + - require.NotNil(t, disallowed) +   + return &Client{}, nil, common.Address{}, nil, nil
    - 5433 + +
    @@ -37,8 +38,26 @@
    +
    + 37 +
    - + -
    +   + },
    - 5434 + + 38 +
    - + - allowedContract := common.HexToAddress("0x1") +   + }
    - 5435 + + 39 +
    - + - disallowedContract := common.HexToAddress("0x2") +   + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - 5436 + + -
    - + +
    +
    +  
    - 5437 + + 40 +
    - + - senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy") +   + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 5438 + + 41 +
    - + - contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy") +   +
    - 5439 + + -
    - + - deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy") +
    +
    +   +
    - 5440 + + -
    - + +
    +
    +  
    - 5441 + + -
    - + - cfg := getSequencerDefaultConfig() +
    +
    +   +
    - 5442 + + -
    - + - s, m, _ := newMockedServerWithCustomConfig(t, cfg) +
    +
    +   +
    - 5443 + + -
    - + - defer s.Stop() +
    +
    +   +
    - 5444 + + -
    - + +
    +
    +  
    - 5445 + + -
    - + - type testCase struct { +
    +
    +   +
    - 5446 + + -
    - + - Name string +
    +
    +   +
    - 5447 + + -
    - + - Input string +
    +
    +   +
    - 5448 + + -
    - + - ExpectedResult *common.Hash +
    +
    +   +
    - 5449 + + -
    - + - ExpectedError types.Error +
    +
    +   +
    - 5450 + + -
    - + - Prepare func(t *testing.T, tc *testCase) +
    +
    +   +
    - 5451 + + -
    - + - SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase) +
    +
    +   +
    - 5452 + + -
    - + - } +
    +
    +   +
    - 5453 + + -
    - + +
    +
    +  
    - 5454 + + -
    - + - testCases := []testCase{ +
    +
    +   +
    - 5455 + + -
    - + - { +
    +
    +   +
    - 5456 + + 42 +
    - + - Name: "Sender & contract on allow list, accepted", +   + // Deploy contracts
    - 5457 + + 43 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + const polDecimalPlaces = 18
    - 5458 + + 44 +
    - + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - 5459 + +
    @@ -102,7 +121,7 @@
    +
    + 102 +
    - + -
    +   + log.Error("error: ", err)
    - 5460 + + 103 +
    - + - signedTx, err := allowed.Signer(allowed.From, tx) +   + return nil, nil, common.Address{}, nil, err
    - 5461 + + 104 +
    - + - require.NoError(t, err) +   + }
    - 5462 + + 105 +
    - + -
    + - + br, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
    - 5463 + + 106 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + if err != nil {
    - 5464 + + 107 +
    - + - require.NoError(t, err) +   + log.Error("error: ", err)
    - 5465 + + 108 +
    - + -
    +   + return nil, nil, common.Address{}, nil, err
    - 5466 + +
    @@ -182,6 +201,11 @@
    +
    + 182 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + return nil, nil, common.Address{}, nil, err
    - 5467 + + 183 +
    - + - require.NoError(t, err) +   + }
    - 5468 + + 184 +
    - + +  
    - 5469 + + -
    - + - tc.Input = rawTx +
    +
    +   +
    - 5470 + + -
    - + - expectedHash := signedTx.Hash() +
    +
    +   +
    - 5471 + + -
    - + - tc.ExpectedResult = &expectedHash +
    +
    +   +
    - 5472 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 185 +
    - + - tc.ExpectedError = nil +   + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - 5473 + + 186 +
    - + - }, +   + if err != nil {
    - 5474 + + 187 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + log.Error("error: ", err)
    - 5475 + +
    @@ -199,6 +223,8 @@
    +
    + 199 +
    - + - m.Pool. +   + SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
    - 5476 + + 200 +
    - + - On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), ""). +   + auth: map[common.Address]bind.TransactOpts{},
    - 5477 + + 201 +
    - + - Return(nil). +   + cfg: cfg,
    - 5478 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 202 +
    - + - Once() +   + }
    - 5479 + + 203 +
    - + - m.Pool. +   + err = c.AddOrReplaceAuth(*auth)
    - 5480 + + 204 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, allowedContract). +   + if err != nil { +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + - - - - - - - - - - - - + + +
    +
     
    - 5481 + + 24 +
    - + - Return(true, nil). +   +
    - 5482 + + 25 +
    - + - Once() +   + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - 5483 + + 26 +
    - + - m.Pool. +   + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - 5484 + + 27 +
    + - On("CheckPolicy", context.Background(), pool.SendTx, allowed.From). + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider, st stateProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) {
    - 5485 + + 28 +
    - + - Return(true, nil). +   + if auth == nil {
    - 5486 + + 29 +
    - + - Once() +   + // read only client
    - 5487 + + 30 +
    - + - }, +   + return &Client{}, nil, common.Address{}, nil, nil
    - 5488 + +
     
    +
    + 38 +
    - + +   },
    - 5489 + + 39 +
    - + - { +   + }
    - 5490 + + 40 +
    - + - Name: "Contract not on allow list, rejected", +   + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - 5491 + 41
    + - Prepare: func(t *testing.T, tc *testCase) { + // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 5492 + + 42 +
    - + - tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - 5493 + + 43 +
    - + +  
    - 5494 + 44
    + - signedTx, err := allowed.Signer(allowed.From, tx) + // DAC Setup
    - 5495 + 45
    + - require.NoError(t, err) + daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
    - 5496 + 46
    + -
    + if err != nil {
    - 5497 + 47
    + - txBinary, err := signedTx.MarshalBinary() + return nil, nil, common.Address{}, nil, err
    - 5498 + 48
    + - require.NoError(t, err) + }
    - 5499 + 49
    + -
    + client.Commit()
    - 5500 + 50
    + - rawTx := hex.EncodeToHex(txBinary) + _, err = da.Initialize(auth)
    - 5501 + 51
    + - require.NoError(t, err) + if err != nil {
    - 5502 + 52
    + -
    + return nil, nil, common.Address{}, nil, err
    - 5503 + 53
    + - tc.Input = rawTx + }
    - 5504 + 54
    + - tc.ExpectedResult = nil + client.Commit()
    - 5505 + 55
    + - tc.ExpectedError = contractDenied + _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
    - 5506 + 56
    + - }, + if err != nil {
    - 5507 + 57
    + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { + return nil, nil, common.Address{}, nil, err
    - 5508 + 58
    + - m.Pool. + }
    - 5509 + 59
    + - On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract). + client.Commit()
    - 5510 + 60
    + - Return(false, contractDenied). +
    - 5511 + + 61 +
    - + - Once() +   + // Deploy contracts
    - 5512 + + 62 +
    - + - }, +   + const polDecimalPlaces = 18
    - 5513 + + 63 +
    - + - }, +   + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - 5514 + +
     
    +
    + 121 +
    - + - { +   + log.Error("error: ", err)
    - 5515 + + 122 +
    - + - Name: "Sender not on allow list, rejected", +   + return nil, nil, common.Address{}, nil, err
    - 5516 + + 123 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + }
    - 5517 + + 124 +
    + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) + br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
    - 5518 + + 125 +
    - + -
    +   + if err != nil {
    - 5519 + + 126 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + log.Error("error: ", err)
    - 5520 + + 127 +
    - + - require.NoError(t, err) +   + return nil, nil, common.Address{}, nil, err
    - 5521 + +
     
    +
    + 201 +
    - + -
    +   + return nil, nil, common.Address{}, nil, err
    - 5522 + + 202 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + }
    - 5523 + + 203 +
    - + - require.NoError(t, err) +   +
    - 5524 + 204
    + -
    + _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr)
    - 5525 + 205
    + - rawTx := hex.EncodeToHex(txBinary) + if err != nil {
    - 5526 + 206
    + - require.NoError(t, err) + log.Error("error: ", err)
    - 5527 + 207
    + -
    + return nil, nil, common.Address{}, nil, err
    - 5528 + 208
    + - tc.Input = rawTx + }
    - 5529 + + 209 +
    - + - tc.ExpectedResult = nil +   + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - 5530 + + 210 +
    - + - tc.ExpectedError = senderDenied +   + if err != nil {
    - 5531 + + 211 +
    - + - }, +   + log.Error("error: ", err)
    - 5532 - -
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { -
    +
    +
     
    - 5533 + + 223 +
    - + - m.Pool. +   + SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
    - 5534 + + 224 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, allowedContract). +   + auth: map[common.Address]bind.TransactOpts{},
    - 5535 + + 225 +
    - + - Return(true, nil). +   + cfg: cfg,
    - 5536 + 226
    + - Once() + da: daBackend,
    - 5537 + 227
    + - m.Pool. + state: st,
    - 5538 + + 228 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From). +   + }
    - 5539 + + 229 +
    - + - Return(false, senderDenied). +   + err = c.AddOrReplaceAuth(*auth)
    - 5540 + + 230 +
    - + - Once() +   + if err != nil { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -42,12 +42,17 @@
    - 5541 + + 42 +
    - + - }, +   + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - 5542 + + 43 +
    - + - }, +   + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - 5543 + + 44 +
    - + - { +   + EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
    - 5544 + + -
    - + - Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility +
    +
    +   +
    - 5545 + + -
    - + - Prepare: func(t *testing.T, tc *testCase) { +
    +
    +   +
    - 5546 + + -
    - + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +
    +
    +   +
    - 5547 + + 45 +
    - + -
    +   + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - 5548 + + 46 +
    - + - txBinary, err := tx.MarshalBinary() +   + EventID_NodeOOC EventID = "NODE OOC"
    - 5549 + + 47 +
    - + - require.NoError(t, err) +   + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
    - 5550 + + 48 +
    - + -
    +   + EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW"
    - 5551 + + 49 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters
    - 5552 + + 50 +
    - + - require.NoError(t, err) +   + EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW"
    - 5553 + + -
    - + +
    +
    +  
    - 5554 + + -
    - + - tc.Input = rawTx +
    +
    +   +
    - 5555 + + 51 +
    - + - expectedHash := tx.Hash() +   + // Source_Node is the source of the event
    - 5556 + + 52 +
    - + - tc.ExpectedResult = &expectedHash +   + Source_Node Source = "node"
    - 5557 + + 53 +
    - + - tc.ExpectedError = nil +   +
    +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 5558 + + 42 +
    - + - }, +   + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - 5559 + + 43 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - 5560 + + 44 +
    - + - m.Pool. +   + EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
    - 5561 + 45
    + - On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), ""). + // EventID_UnsupportedPrecompile is triggered when the executor returns an unsupported precompile error
    - 5562 + 46
    + - Return(nil). + EventID_UnsupportedPrecompile EventID = "UNSUPPORTED PRECOMPILE"
    - 5563 + 47
    + - Once() +
    - 5564 + + 48 +
    - + - // policy does not reject this case for backward compat +   + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - 5565 + + 49 +
    - + - }, +   + EventID_NodeOOC EventID = "NODE OOC"
    - 5566 + + 50 +
    - + - }, +   + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
    - 5567 + + 51 +
    - + - { +   + EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW"
    - 5568 + + 52 +
    - + - Name: "Unsigned tx with disallowed contract, rejected", +   + // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters
    - 5569 + + 53 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW"
    - 5570 + 54
    + - tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) + // EventID_InvalidInfoRoot is triggered when an invalid l1InfoRoot was synced
    - 5571 + 55
    + -
    + EventID_InvalidInfoRoot EventID = "INVALID INFOROOT"
    - 5572 + + 56 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + // Source_Node is the source of the event
    - 5573 + + 57 +
    - + - require.NoError(t, err) +   + Source_Node Source = "node"
    - 5574 + + 58 +
    - + +  
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + +
    +
    @@ -30,3 +30,6 @@
    +
    - 5575 + + 30 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + include:
    - 5576 + + 31 +
    - + - require.NoError(t, err) +   + - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - 5577 + + 32 +
    - + -
    +   + - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - 5578 + + -
    - + - rawTx := hex.EncodeToHex(txBinary) +
    +
    +   +
    - 5579 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 5580 + + -
    - + +
    +
    +  
    +
    +
    +
    +
    + + + + + - - - - - - + + +
    +
     
    +
    - 5581 + + 30 +
    - + - tc.Input = rawTx +   + include:
    - 5582 + + 31 +
    - + - tc.ExpectedResult = nil +   + - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - 5583 + + 32 +
    - + - tc.ExpectedError = contractDenied +   + - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - 5584 + 33
    + - }, + exclude-rules:
    - 5585 + 34
    + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { + - path: cmd/policy.go
    - 5586 + 35
    + - m.Pool. + text: "unused" +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + + + - - + + + + + + + + + + + +
    +
    @@ -22,9 +22,9 @@
    - 5587 + + 22 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract). +   + github.com/prometheus/common v0.45.0
    - 5588 + + 23 +
    - + - Return(false, contractDenied). +   + github.com/rubenv/sql-migrate v1.6.1
    - 5589 + + 24 +
    - + - Once() +   + github.com/spf13/afero v1.11.0
    - 5590 + + 25 +
    - + - }, + - + github.com/spf13/viper v1.17.0
    - 5591 + + 26 +
    - + - }, +   + github.com/stretchr/testify v1.8.4
    - 5592 + + 27 +
    - + - { + - + github.com/umbracle/ethgo v0.1.3
    - 5593 + + 28 +
    - + - Name: "Send invalid tx input", // for backward compatibility +   + github.com/urfave/cli/v2 v2.26.0
    - 5594 + + 29 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + go.uber.org/zap v1.26.0
    - 5595 + + 30 +
    - + - tc.Input = "0x1234" +   + golang.org/x/crypto v0.18.0
    - 5596 + +
    @@ -45,7 +45,7 @@
    +
    + 45 +
    - + - tc.ExpectedResult = nil +   + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
    - 5597 + + 46 +
    - + - tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input") +   + github.com/bahlo/generic-list-go v0.2.0 // indirect
    - 5598 + + 47 +
    - + - }, +   + github.com/beorn7/perks v1.0.1 // indirect
    - 5599 + + 48 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {}, + - + github.com/bits-and-blooms/bitset v1.10.0 // indirect
    - 5600 + + 49 +
    - + - }, +   + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
    - 5601 + + 50 +
    - + - { +   + github.com/buger/jsonparser v1.1.1 // indirect
    - 5602 + + 51 +
    - + - Name: "Sender not on deploy allow list, rejected", +   + github.com/cespare/xxhash/v2 v2.2.0 // indirect
    - 5603 + +
    @@ -63,12 +63,12 @@
    +
    + 63 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + github.com/cyphar/filepath-securejoin v0.2.4 // indirect
    - 5604 + + 64 +
    - + - deployAddr := common.HexToAddress("0x0") +   + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
    - 5605 + + 65 +
    - + - tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + github.com/deckarep/golang-set/v2 v2.1.0 // indirect
    - 5606 + + 66 +
    - + -
    + - + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
    - 5607 + + 67 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + github.com/dlclark/regexp2 v1.7.0 // indirect
    - 5608 + + 68 +
    - + - require.NoError(t, err) +   + github.com/emirpasic/gods v1.18.1 // indirect
    - 5609 + + 69 +
    - + -
    +   + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
    - 5610 + + 70 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
    - 5611 + + 71 +
    - + - require.NoError(t, err) + - + github.com/fsnotify/fsnotify v1.6.0 // indirect
    - 5612 + + 72 +
    - + -
    +   + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
    - 5613 + + 73 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
    - 5614 + + 74 +
    - + - require.NoError(t, err) +   + github.com/getsentry/sentry-go v0.18.0 // indirect
    - 5615 + +
    @@ -101,6 +101,7 @@
    +
    + 101 +
    - + -
    +   + github.com/jackc/puddle v1.3.0 // indirect
    - 5616 + + 102 +
    - + - tc.Input = rawTx +   + github.com/jackpal/go-nat-pmp v1.0.2 // indirect
    - 5617 + + 103 +
    - + - tc.ExpectedResult = nil +   + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    - 5618 + + -
    - + - tc.ExpectedError = deployDenied +
    +
    +   +
    - 5619 + + 104 +
    - + - }, +   + github.com/karrick/godirwalk v1.17.0 // indirect
    - 5620 + + 105 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + github.com/kevinburke/ssh_config v1.2.0 // indirect
    - 5621 + + 106 +
    - + - m.Pool. +   + github.com/klauspost/compress v1.17.0 // indirect
    - 5622 + +
    @@ -116,6 +117,7 @@
    +
    + 116 +
    - + - On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From). +   + github.com/mattn/go-isatty v0.0.20 // indirect
    - 5623 + + 117 +
    - + - Return(false, nil). +   + github.com/mattn/go-runewidth v0.0.13 // indirect
    - 5624 + + 118 +
    - + - Once() +   + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
    - 5625 + + + +
    +   +
    +
    +
    + 119 +
    - + - }, +   + github.com/mitchellh/pointerstructure v1.2.0 // indirect
    - 5626 + + 120 +
    - + - }, +   + github.com/mmcloughlin/addchain v0.4.0 // indirect
    - 5627 + + 121 +
    - + - } +   + github.com/olekukonko/tablewriter v0.0.5 // indirect
    - 5628 + +
    @@ -128,14 +130,14 @@
    +
    + 128 +
    - + -
    +   + github.com/rogpeppe/go-internal v1.11.0 // indirect
    - 5629 + + 129 +
    - + - for _, testCase := range testCases { +   + github.com/rs/cors v1.7.0 // indirect
    - 5630 + + 130 +
    - + - t.Run(testCase.Name, func(t *testing.T) { +   + github.com/russross/blackfriday/v2 v2.1.0 // indirect
    - 5631 + + 131 +
    - + - tc := testCase + - + github.com/sagikazarmark/locafero v0.3.0 // indirect
    - 5632 + + 132 +
    - + - tc.Prepare(t, &tc) +   + github.com/sagikazarmark/slog-shim v0.1.0 // indirect
    - 5633 + + 133 +
    - + - tc.SetupMocks(t, m, tc) +   + github.com/sergi/go-diff v1.2.0 // indirect
    - 5634 + + 134 +
    - + -
    +   + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
    - 5635 + + 135 +
    - + - res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input) +   + github.com/sirupsen/logrus v1.9.0 // indirect
    - 5636 + + 136 +
    - + - require.NoError(t, err) +   + github.com/skeema/knownhosts v1.2.1 // indirect
    - 5637 + + 137 +
    - + -
    +   + github.com/sourcegraph/conc v0.3.0 // indirect
    - 5638 + + 138 +
    - + - assert.Equal(t, float64(1), res.ID) + - + github.com/spf13/cast v1.5.1 // indirect
    - 5639 + + 139 +
    - + - assert.Equal(t, "2.0", res.JSONRPC) +   + github.com/spf13/pflag v1.0.5 // indirect
    - 5640 + + 140 +
    - + +   + github.com/status-im/keycard-go v0.2.0 // indirect +
    +
    + 141 + +
    +   + github.com/stretchr/objx v0.5.0 // indirect +
    +
    +
    @@ -170,8 +172,9 @@
    +
    + 170 + +
    +   + ) +
    +
    + 171 + +
    +  
    - 5641 + + 172 +
    - + - if res.Result != nil || tc.ExpectedResult != nil { +   + require (
    - 5642 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 173 +
    - + - var result common.Hash +   + github.com/fatih/color v1.16.0
    - 5643 + + 174 + +
    + - + github.com/joho/godotenv v1.5.1 +
    +
    + 175 + +
    +   + github.com/prometheus/client_golang v1.18.0 +
    +
    + 176 + +
    +   + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa +
    +
    + 177 + +
    +   + ) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + - - + + + - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -74728,12 +76238,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    +
    + 22 + +
    +   + github.com/prometheus/common v0.45.0 +
    +
    + 23 + +
    +   + github.com/rubenv/sql-migrate v1.6.1 +
    +
    + 24 + +
    +   + github.com/spf13/afero v1.11.0 +
    +
    + 25 +
    + - err = json.Unmarshal(res.Result, &result) + github.com/spf13/viper v1.18.2
    - 5644 + + 26 + +
    +   + github.com/stretchr/testify v1.8.4 +
    +
    + 27 +
    + - require.NoError(t, err) + github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0
    - 5645 + + 28 + +
    +   + github.com/urfave/cli/v2 v2.26.0 +
    +
    + 29 + +
    +   + go.uber.org/zap v1.26.0 +
    +
    + 30 + +
    +   + golang.org/x/crypto v0.18.0 +
    +
    +
     
    +
    + 45 + +
    +   + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect +
    +
    + 46 + +
    +   + github.com/bahlo/generic-list-go v0.2.0 // indirect +
    +
    + 47 + +
    +   + github.com/beorn7/perks v1.0.1 // indirect +
    +
    + 48 +
    + - assert.Equal(t, *tc.ExpectedResult, result) + github.com/bits-and-blooms/bitset v1.12.0 // indirect
    - 5646 + + 49 + +
    +   + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect +
    +
    + 50 + +
    +   + github.com/buger/jsonparser v1.1.1 // indirect +
    +
    + 51 + +
    +   + github.com/cespare/xxhash/v2 v2.2.0 // indirect +
    +
    +
     
    +
    + 63 + +
    +   + github.com/cyphar/filepath-securejoin v0.2.4 // indirect +
    +
    + 64 + +
    +   + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect +
    +
    + 65 + +
    +   + github.com/deckarep/golang-set/v2 v2.1.0 // indirect +
    +
    + 66 +
    + - } + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
    - 5647 + + 67 + +
    +   + github.com/dlclark/regexp2 v1.7.0 // indirect +
    +
    + 68 + +
    +   + github.com/emirpasic/gods v1.18.1 // indirect +
    +
    + 69 + +
    +   + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect +
    +
    + 70 + +
    +   + github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect +
    +
    + 71 +
    + - if res.Error != nil || tc.ExpectedError != nil { + github.com/fsnotify/fsnotify v1.7.0 // indirect +
    +
    + 72 + +
    +   + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect +
    +
    + 73 + +
    +   + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect +
    +
    + 74 + +
    +   + github.com/getsentry/sentry-go v0.18.0 // indirect +
    +
    +
     
    +
    + 101 + +
    +   + github.com/jackc/puddle v1.3.0 // indirect +
    +
    + 102 + +
    +   + github.com/jackpal/go-nat-pmp v1.0.2 // indirect +
    +
    + 103 + +
    +   + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    - 5648 + 104
    + - assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code) + github.com/jmoiron/sqlx v1.2.0 // indirect +
    +
    + 105 + +
    +   + github.com/karrick/godirwalk v1.17.0 // indirect +
    +
    + 106 + +
    +   + github.com/kevinburke/ssh_config v1.2.0 // indirect +
    +
    + 107 + +
    +   + github.com/klauspost/compress v1.17.0 // indirect +
    +
    +
     
    +
    + 117 + +
    +   + github.com/mattn/go-isatty v0.0.20 // indirect +
    +
    + 118 + +
    +   + github.com/mattn/go-runewidth v0.0.13 // indirect +
    +
    + 119 + +
    +   + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
    - 5649 + 120
    + - assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message) + github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect
    - 5650 + + 121 + +
    +   + github.com/mitchellh/pointerstructure v1.2.0 // indirect +
    +
    + 122 + +
    +   + github.com/mmcloughlin/addchain v0.4.0 // indirect +
    +
    + 123 + +
    +   + github.com/olekukonko/tablewriter v0.0.5 // indirect +
    +
    +
     
    +
    + 130 + +
    +   + github.com/rogpeppe/go-internal v1.11.0 // indirect +
    +
    + 131 + +
    +   + github.com/rs/cors v1.7.0 // indirect +
    +
    + 132 + +
    +   + github.com/russross/blackfriday/v2 v2.1.0 // indirect +
    +
    + 133 +
    + - } + github.com/sagikazarmark/locafero v0.4.0 // indirect
    - 5651 + + 134 + +
    +   + github.com/sagikazarmark/slog-shim v0.1.0 // indirect +
    +
    + 135 + +
    +   + github.com/sergi/go-diff v1.2.0 // indirect +
    +
    + 136 + +
    +   + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect +
    +
    + 137 + +
    +   + github.com/sirupsen/logrus v1.9.0 // indirect +
    +
    + 138 + +
    +   + github.com/skeema/knownhosts v1.2.1 // indirect +
    +
    + 139 + +
    +   + github.com/sourcegraph/conc v0.3.0 // indirect +
    +
    + 140 +
    + - }) + github.com/spf13/cast v1.6.0 // indirect +
    +
    + 141 + +
    +   + github.com/spf13/pflag v1.0.5 // indirect +
    +
    + 142 + +
    +   + github.com/status-im/keycard-go v0.2.0 // indirect +
    +
    + 143 + +
    +   + github.com/stretchr/objx v0.5.0 // indirect +
    +
    +
     
    +
    + 172 + +
    +   + ) +
    +
    + 173 + +
    +   +
    +
    +
    + 174 + +
    +   + require (
    - 5652 + 175
    + - } + github.com/0xPolygon/agglayer v0.0.1
    - 5653 + 176
    + - } + github.com/0xPolygon/cdk-data-availability v0.0.5 +
    +
    + 177 + +
    +   + github.com/fatih/color v1.16.0 +
    +
    + + +
    +   +
    +
    +
    + 178 + +
    +   + github.com/prometheus/client_golang v1.18.0 +
    +
    + 179 + +
    +   + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa +
    +
    + 180 + +
    +   + )
    -
    @@ -204,6 +204,42 @@
    +
    @@ -0,0 +1,84 @@
    - 204 + + -
    +
    +
      - }) +
    - 205 + + -
    +
    +
      - } +
    - 206 + + -
    +
    +
     
    @@ -75141,676 +76651,163 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 207 + + -
    +
    +
      - // GetFullBlockByNumber returns information about a block by block number +
    - 208 + + -
    -   - func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { -
    -
    - 209 - -
    -   - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { -
    -
    -
    @@ -516,7 +552,7 @@
    -
    - 516 - -
    +
    +
     
    - 517 - -
    -   - if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice -
    -
    - 518 - -
    -   - // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice -
    -
    - 519 - -
    - - - txEGPPct, err = z.pool.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP) -
    -
    - 520 - -
    -   - if err != nil { -
    -
    - 521 - -
    -   - return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false) -
    -
    - 522 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 204 - -
    -   - }) -
    -
    - 205 - -
    -   - } -
    -
    - 206 + + -
    +
    +
     
    - 207 - -
    - + - // GetBatchDataByNumbers returns the batch data for batches by numbers -
    -
    - 208 - -
    - + - func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) { -
    -
    - 209 - -
    - + - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { -
    -
    - 210 - -
    - + - batchNumbers := make([]uint64, 0, len(filter.Numbers)) -
    -
    - 211 - -
    - + - for _, bn := range filter.Numbers { -
    -
    - 212 - -
    - + - n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx) -
    -
    - 213 - -
    - + - if rpcErr != nil { -
    -
    - 214 - -
    - + - return nil, rpcErr -
    -
    - 215 - -
    - + - } -
    -
    - 216 - -
    - + - batchNumbers = append(batchNumbers, n) -
    -
    - 217 - -
    - + - } -
    -
    - 218 - -
    - + -
    -
    -
    - 219 - -
    - + - batchesData, err := z.state.GetBatchL2DataByNumbers(ctx, batchNumbers, dbTx) -
    -
    - 220 - -
    - + - if errors.Is(err, state.ErrNotFound) { -
    -
    - 221 - -
    - + - return nil, nil -
    -
    - 222 - -
    - + - } else if err != nil { -
    -
    - 223 - -
    - + - return RPCErrorResponse(types.DefaultErrorCode, -
    -
    - 224 - -
    - + - fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true) -
    -
    - 225 - -
    - + - } -
    -
    - 226 - -
    - + -
    -
    -
    - 227 - -
    - + - ret := make([]*types.BatchData, 0, len(batchNumbers)) -
    -
    - 228 - -
    - + - for _, n := range batchNumbers { -
    -
    - 229 - -
    - + - data := &types.BatchData{Number: types.ArgUint64(n)} -
    -
    - 230 - -
    - + - if b, ok := batchesData[n]; ok { -
    -
    - 231 - -
    - + - data.BatchL2Data = b -
    -
    - 232 - -
    - + - data.Empty = false -
    -
    - 233 - -
    - + - } else { -
    -
    - 234 - -
    - + - data.Empty = true -
    -
    - 235 - -
    - + - } -
    -
    - 236 - -
    - + - ret = append(ret, data) -
    -
    - 237 - -
    - + - } -
    -
    - 238 - -
    - + -
    -
    -
    - 239 - -
    - + - return types.BatchDataResult{Data: ret}, nil -
    -
    - 240 - -
    - + - }) -
    -
    - 241 - -
    - + - } -
    -
    - 242 + + -
    - + +
    +
    +  
    - 243 + + -
    +
    +
      - // GetFullBlockByNumber returns information about a block by block number +
    - 244 + + -
    +
    +
      - func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { +
    - 245 + + -
    +
    +
      - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { +
    -
     
    -
    - 552 + + -
    +
    +
     
    - 553 + + -
    +
    +
      - if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice +
    - 554 + + -
    +
    +
      - // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice -
    -
    - 555 - -
    - + - txEGPPct, err = state.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP) +
    - 556 + + -
    +
    +
      - if err != nil { +
    - 557 + + -
    +
    +
      - return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false) +
    - 558 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -76118,38 +77115,28 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - -
    -
    @@ -2705,3 +2705,32 @@
    - 2705 + + -
    +
    +
      - }) +
    - 2706 + + -
    +
    +
      - } +
    - 2707 + + -
    +
    +
      - } +
    - 2705 - -
    -   - }) -
    -
    - 2706 + + 1 +
    -   - } + + + # .goreleaser-cdk.yaml
    - 2707 + + 2 +
    -   - } + + + project_name: cdk-validium-node
    - 2708 + 3
    @@ -76159,107 +77146,107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2709 + 4
    + - func TestClient_BatchesByNumbers(t *testing.T) { + release:
    - 2710 + 5
    + - const batchesCount = 6 + disable: false
    - 2711 + 6
    + -
    + draft: true
    - 2712 + 7
    + - s, m, _ := newSequencerMockedServer(t) + prerelease: auto
    - 2713 + 8
    + - defer s.Stop() +
    - 2714 + 9
    + -
    + before:
    - 2715 + 10
    + - batchesDataMap := make(map[uint64][]byte, batchesCount) + hooks:
    - 2716 + 11
    + - for i := 0; i < batchesCount; i++ { + - go mod download
    - 2717 + 12
    + - batchesDataMap[uint64(i+1)] = []byte(fmt.Sprintf("batch %d data", i+1)) + - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
    - 2718 + 13
    + - } + - packr2
    - 2719 + 14
    @@ -76269,429 +77256,759 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2720 + 15
    + - m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything). + builds:
    - 2721 + 16
    + - Return(batchesDataMap, nil).Once() + - main: ./cmd/
    - 2722 + 17
    + -
    + binary: zkevm-node
    - 2723 + 18
    + - m.State.On("BeginStateTransaction", context.Background()). + goos:
    - 2724 + 19
    + - Return(m.DbTx, nil).Once() + - linux
    - 2725 + 20
    + -
    + - darwin
    - 2726 + 21
    + - m.DbTx.On("Commit", context.Background()).Return(nil).Once() + goarch:
    - 2727 + 22
    + -
    + - amd64
    - 2728 + 23
    + - zkEVMClient := client.NewClient(s.ServerURL) + - arm64
    - 2729 + 24
    + - reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)} + env:
    - 2730 + 25
    + - result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum) + - CGO_ENABLED=0
    - 2731 + 26
    + - require.NoError(t, err) + ldflags:
    - 2732 + 27
    + - require.Len(t, result, len(reqBatchesNum)) + - -s -w
    - 2733 + 28
    + - for i, batchNum := range reqBatchesNum { + - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }}
    - 2734 + 29
    + - require.Equal(t, hex.EncodeToHex(batchesDataMap[batchNum.Uint64()]), result[i].BatchL2Data.Hex()) + - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }}
    - 2735 + 30
    + - } + - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }}
    - 2736 + 31
    + - } -
    -
    -
    + - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }}
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + +
    -
    @@ -0,0 +1,61 @@
    - + + 32 -
    -   +
    +
    + +
    - + + 33 -
    -   -
    +
    +
    + + + archives:
    - + + 34 -
    -   -
    +
    +
    + + + - files:
    - + + 35 -
    -   -
    +
    +
    + + + - LICENSE
    - + + 36 -
    -   -
    +
    +
    + + + - README.md
    - + + 37 -
    -   +
    +
    + +
    - + + 38 -
    -   -
    +
    +
    + + + dockers:
    - + + 39 -
    -   -
    +
    +
    + + + - image_templates:
    - + + 40 -
    -   -
    +
    +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
    - + + 41 -
    -   -
    +
    +
    + + + dockerfile: Dockerfile.release
    - + + 42 -
    -   -
    +
    +
    + + + use: buildx
    - + + 43 -
    -   -
    +
    +
    + + + goos: linux
    - + + 44 -
    -   -
    +
    +
    + + + goarch: amd64
    - + + 45 -
    -   -
    +
    +
    + + + build_flag_templates:
    - + + 46 -
    -   -
    +
    +
    + + + - --platform=linux/amd64
    - + + 47 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.title={{ .ProjectName }}
    - + + 48 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.description={{ .ProjectName }}
    - + + 49 -
    -   +
    +
    + + + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} +
    +
    + 50 + +
    + + + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} +
    +
    + 51 + +
    + + + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} +
    +
    + 52 + +
    + + + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} +
    +
    + 53 + +
    + + + - --label=org.opencontainers.image.revision={{ .FullCommit }} +
    +
    + 54 + +
    + + + skip_push: false +
    +
    + 55 + +
    + +
    - + + 56 -
    -   +
    +
    + + + - image_templates: +
    +
    + 57 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +
    +
    + 58 + +
    + + + dockerfile: Dockerfile.release +
    +
    + 59 + +
    + + + use: buildx +
    +
    + 60 + +
    + + + goos: linux +
    +
    + 61 + +
    + + + goarch: arm64 +
    +
    + 62 + +
    + + + build_flag_templates: +
    +
    + 63 + +
    + + + - --platform=linux/arm64 +
    +
    + 64 + +
    + + + - --label=org.opencontainers.image.title={{ .ProjectName }} +
    +
    + 65 + +
    + + + - --label=org.opencontainers.image.description={{ .ProjectName }} +
    +
    + 66 + +
    + + + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} +
    +
    + 67 + +
    + + + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} +
    +
    + 68 + +
    + + + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} +
    +
    + 69 + +
    + + + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} +
    +
    + 70 + +
    + + + - --label=org.opencontainers.image.revision={{ .FullCommit }} +
    +
    + 71 + +
    + + + skip_push: false +
    +
    + 72 + +
    + +
    - + + 73 -
    -   +
    +
    + + + docker_manifests: +
    +
    + 74 + +
    + + + - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }} +
    +
    + 75 + +
    + + + image_templates: +
    +
    + 76 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 +
    +
    + 77 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +
    +
    + 78 + +
    + + + skip_push: false +
    +
    + 79 + +
    + +
    - + + 80 -
    +
    +
    + + + - name_template: 0xpolygon/{{ .ProjectName }}:latest +
    +
    + 81 + +
    + + + image_templates: +
    +
    + 82 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 +
    +
    + 83 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +
    +
    + 84 + +
    + + + skip_push: false +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - - - - -
    +
    @@ -58,6 +58,46 @@
    +
    + 58 + +
      -
    + return result, nil
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    +
    +
     
    @@ -77076,203 +78393,153 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    -
    - 1 - -
    - + - package jsonrpc -
    -
    - 2 + + -
    - + +
    +
    +  
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 + + -
    - + +
    +
    +  
    - 6 + + 61 +
    - + - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +   + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    - 7 + + 62 +
    - + - "github.com/0xPolygonHermez/zkevm-node/pool" +   + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    - 8 + + 63 +
    - + - "github.com/0xPolygonHermez/zkevm-node/state" +   + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String())
    - 9 - -
    - + - "github.com/ethereum/go-ethereum/common" +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -77707,12 +78924,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go RENAMED
    - - - - - - -
    +
     
    - 10 + + 58 +
    - + - ethTypes "github.com/ethereum/go-ethereum/core/types" +   + return result, nil
    - 11 + + 59 +
    - + - ) +   + }
    - 12 + + 60 +
    - + +  
    - 13 - -
    - + - func checkPolicy(ctx context.Context, p types.PoolInterface, input string) error { -
    -
    - 14 + 61
    + - tx, err := hexToTx(input) + // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
    - 15 + 62
    + - if err != nil { + // known batch is returned as a list.
    - 16 + 63
    + - // ignore it, let the later processing reject + func (c *Client) BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    - 17 + 64
    + - return nil + return c.batchesByNumbers(ctx, numbers, "zkevm_getBatchDataByNumbers")
    - 18 + 65
    + - } + }
    - 19 + 66
    @@ -77282,77 +78549,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 20 - -
    - + - // if the tx is signed, check the from address. If there is no from address, the tx is not rejected as it -
    -
    - 21 - -
    - + - // will get rejected later. This maintains backward compatibility with RPC expectations. TODO: verify this is ok behavior -
    -
    - 22 - -
    - + - var from common.Address -
    -
    - 23 + 67
    + - if from, err = state.GetSender(*tx); err != nil { + // ForcedBatchesByNumbers returns forced batches data.
    - 24 + 68
    + - // if not signed, then skip check, it fails later on its own + func (c *Client) ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    - 25 + 69
    + - return nil + return c.batchesByNumbers(ctx, numbers, "zkevm_getForcedBatchDataByNumbers")
    - 26 + 70
    + - } + }
    - 27 + 71
    @@ -77362,247 +78599,247 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 28 + 72
    + - switch resolvePolicy(tx) { + // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
    - 29 + 73
    + - case pool.SendTx: + // known batch is returned as a list.
    - 30 + 74
    + - var allow bool + func (c *Client) batchesByNumbers(_ context.Context, numbers []*big.Int, method string) ([]*types.BatchData, error) {
    - 31 + 75
    + - if allow, err = p.CheckPolicy(ctx, pool.SendTx, *tx.To()); err != nil { + batchNumbers := make([]types.BatchNumber, 0, len(numbers))
    - 32 + 76
    + - return err + for _, n := range numbers {
    - 33 + 77
    + - } + batchNumbers = append(batchNumbers, types.BatchNumber(n.Int64()))
    - 34 + 78
    + - if !allow { + }
    - 35 + 79
    + - return pool.ErrContractDisallowedSendTx + if len(batchNumbers) == 0 {
    - 36 + 80
    + - } + batchNumbers = append(batchNumbers, types.LatestBatchNumber)
    - 37 + 81
    + - if allow, err = p.CheckPolicy(ctx, pool.SendTx, from); err != nil { + }
    - 38 + 82
    + - return err +
    - 39 + 83
    + - } + response, err := JSONRPCCall(c.url, method, &types.BatchFilter{Numbers: batchNumbers})
    - 40 + 84
    + - if !allow { + if err != nil {
    - 41 + 85
    + - return pool.ErrSenderDisallowedSendTx + return nil, err
    - 42 + 86
    + - } + }
    - 43 + 87
    + - case pool.Deploy: +
    - 44 + 88
    + - var allow bool + if response.Error != nil {
    - 45 + 89
    + - // check that sender may deploy contracts + return nil, response.Error.RPCError()
    - 46 + 90
    + - if allow, err = p.CheckPolicy(ctx, pool.Deploy, from); err != nil { + }
    - 47 + 91
    + - return err +
    - 48 + 92
    + - } + var result *types.BatchDataResult
    - 49 + 93
    + - if !allow { + err = json.Unmarshal(response.Result, &result)
    - 50 + 94
    + - return pool.ErrSenderDisallowedDeploy + if err != nil {
    - 51 + 95
    + - } + return nil, err
    - 52 + 96
    @@ -77612,27 +78849,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 53 - -
    - + - return nil -
    -
    - 54 - -
    - + - } -
    -
    - 55 + 97
    @@ -77642,62 +78859,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 56 + 98
    + - func resolvePolicy(tx *ethTypes.Transaction) pool.PolicyName { + return result.Data, nil
    - 57 + 99
    + - if tx.To() == nil || tx.To().Hex() == common.HexToAddress("0x0").Hex() { + }
    - 58 + 100
    + - return pool.Deploy +
    - 59 + + 101 +
    - + - } +   + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    - 60 + + 102 +
    - + - return pool.SendTx +   + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    - 61 + + 103 +
    - + - } +   + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String())
    -
    @@ -15,6 +15,8 @@
    +
    @@ -68,8 +68,6 @@
    - 15 + 68
      - InvalidParamsErrorCode = -32602 + return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 16 + 69
      - // ParserErrorCode error code for parsing errors + if arg == nil {
    - 17 + 70
      - ParserErrorCode = -32700 + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false)
    - + + 71 -
    -   -
    +
    +
    + - + } else if blockArg == nil {
    - + + 72 -
    -   -
    +
    +
    + - + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 1", nil, false)
    - 18 + 73
      - ) + }
    - 19 + 74
      -
    + block, respErr := e.getBlockByArg(ctx, blockArg, dbTx)
    - 20 + 75
      - var ( + if respErr != nil {
    -
    -
    -
    -
    - - - + - - - - - - - -
    -
     
    +
    @@ -106,13 +104,16 @@
    - 15 + 106
      - InvalidParamsErrorCode = -32602 + result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx)
    - 16 + 107
      - // ParserErrorCode error code for parsing errors + if err != nil {
    - 17 + 108
      - ParserErrorCode = -32700 -
    -
    - 18 - -
    - + - // AccessDeniedCode error code when requests are denied + errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
    - 19 + + 109 +
    - + - AccessDeniedCode = -32800 + - + logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas)
    - 20 + 110
      - ) + return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
    - 21 + 111
      -
    + }
    - 22 + 112
      - var ( -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - @@ -77973,88 +79142,108 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + + + + @@ -78069,96 +79258,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -23,8 +23,8 @@
    - 23 + 113
      - CountPendingTransactions(ctx context.Context) (uint64, error) + if result.Reverted() {
    - 24 + 114
      - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) + data := make([]byte, len(result.ReturnValue))
    - 25 + 115
      - GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) + copy(data, result.ReturnValue)
    - 26 + + -
    +
    +
      - CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error) +
    - 27 + + -
    - - - CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) +
    +
    +   +
    - 28 + 116
      - EffectiveGasPriceEnabled() bool + return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, result.Err.Error(), data)
    - 29 + 117
      - } + } else if result.Failed() {
    - 30 + 118
      -
    + return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error())
    -
    @@ -64,6 +64,7 @@
    +
    @@ -191,6 +192,9 @@
    - 64 + 191
      - GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) + if errors.Is(err, runtime.ErrExecutionReverted) {
    - 65 + 192
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + data := make([]byte, len(returnValue))
    - 66 + 193
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + copy(data, returnValue) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 67 + 194
      - GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error) + return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data)
    - 68 + 195
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) + } else if err != nil {
    - 69 + 196
      - GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) + return nil, types.NewRPCError(types.DefaultErrorCode, err.Error())
    -
    -
    -
    -
    - - - + - - - - - - @@ -78172,108 +79332,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - @@ -78281,21 +79386,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    @@ -941,6 +945,9 @@
    - 23 + 941
      - CountPendingTransactions(ctx context.Context) (uint64, error) + if e.cfg.SequencerNodeURI != "" {
    - 24 + 942
      - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) + return e.relayTxToSequencerNode(input)
    - 25 + 943
      - GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) -
    -
    - 26 - -
    - + - CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) -
    -
    - 27 - -
    -   - CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error) + } else {
    - 28 - -
    -   - EffectiveGasPriceEnabled() bool -
    -
    - 29 - -
    -   - } -
    -
    - 30 + + -
    +
    +
     
    -
     
    -
    - 64 - -
    -   - GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) -
    -
    - 65 - -
    -   - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) -
    -
    - 66 + + -
    +
    +
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) -
    -
    - 67 - -
    - + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    - 68 + 944
      - GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error) + ip := ""
    - 69 + 945
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) + ips := httpRequest.Header.Get("X-Forwarded-For")
    - 70 + 946
      - GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go - RENAMED - -
    -
    @@ -78303,36 +79393,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -78356,561 +79446,597 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - + + + - - -
    -
    @@ -446,6 +446,23 @@
    +
     
    - 446 + 68
      - return res, nil + return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 447 + 69
      - } + if arg == nil {
    - 448 + 70
      -
    + return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false)
    - + + 71 -
    +
    +
      -
    + }
    - + + 72 -
    +
    +
      -
    + block, respErr := e.getBlockByArg(ctx, blockArg, dbTx)
    - + + 73 -
    +
    +
      -
    + if respErr != nil {
    - + +
     
    -
    +
    + 104 + +
      -
    + result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx)
    - + + 105 -
    +
    +
      -
    + if err != nil {
    - + + 106 -
    +
    +
      -
    + errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
    - + + 107 -
    -   -
    +
    +
    + + + logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas))
    - + + 108 -
    +
    +
      -
    + return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
    - + + 109 -
    +
    +
      -
    + }
    - + + 110 -
    +
    +
     
    - + + 111 -
    +
    +
      -
    + if result.Reverted() {
    - + + 112 -
    +
    +
      -
    + data := make([]byte, len(result.ReturnValue))
    - + + 113 -
    +
    +
      -
    + copy(data, result.ReturnValue)
    - + + 114 -
    -   -
    +
    +
    + + + if len(data) == 0 {
    - + + 115 -
    -   -
    +
    +
    + + + return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) +
    +
    + 116 + +
    + + + }
    - 449 + 117
      - // TransactionOrHash for union type of transaction and types.Hash + return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, result.Err.Error(), data)
    - 450 + 118
      - type TransactionOrHash struct { + } else if result.Failed() {
    - 451 + 119
      - Hash *common.Hash + return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error())
    -
    -
    -
    -
    - - - + - - - - - - - + - + + - - - - - - - - - - + + +
     
    - 446 + 192
      - return res, nil + if errors.Is(err, runtime.ErrExecutionReverted) {
    - 447 + 193
      - } + data := make([]byte, len(returnValue))
    - 448 + 194
      -
    + copy(data, returnValue)
    - 449 + 195
    + - // BatchFilter is a list of batch numbers to retrieve + if len(data) == 0 {
    - 450 + 196
    + - type BatchFilter struct { + return nil, types.NewRPCError(types.DefaultErrorCode, err.Error())
    - 451 + 197
    + - Numbers []BatchNumber `json:"numbers"` + }
    - 452 + + 198 +
    - + - } +   + return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data)
    - 453 + + 199 +
    - + -
    +   + } else if err != nil {
    - 454 + + 200 +
    - + - // BatchData is an abbreviated structure that only contains the number and L2 batch data +   + return nil, types.NewRPCError(types.DefaultErrorCode, err.Error())
    - 455 + +
     
    +
    + 945 +
    - + - type BatchData struct { +   + if e.cfg.SequencerNodeURI != "" {
    - 456 + + 946 +
    - + - Number ArgUint64 `json:"number"` +   + return e.relayTxToSequencerNode(input)
    - 457 + + 947 +
    - + - BatchL2Data ArgBytes `json:"batchL2Data,omitempty"` +   + } else {
    - 458 + 948
    + - Empty bool `json:"empty"` + if err := checkPolicy(context.Background(), e.pool, input); err != nil {
    - 459 + 949
    + - } + return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false)
    - 460 + 950
    + -
    + }
    - 461 + + 951 +
    - + - // BatchDataResult is a list of BatchData for a BatchFilter +   + ip := ""
    - 462 + + 952 +
    - + - type BatchDataResult struct { +   + ips := httpRequest.Header.Get("X-Forwarded-For")
    - 463 + + 953 +
    - + - Data []*BatchData `json:"data"` +   +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - + + + - - -
    +
    @@ -6,6 +6,7 @@
    - 464 + + 6 +
    - + - } +   + "errors"
    - 465 + + 7 +
    - + -
    +   + "fmt"
    - 466 + 8
      - // TransactionOrHash for union type of transaction and types.Hash + "math/big" +
    +
    + + +
    +   +
    - 467 + 9
      - type TransactionOrHash struct { + "sync"
    - 468 + 10
      - Hash *common.Hash + "testing"
    -
    + + + 11 + + +
    +   + "time"
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go - RENAMED - -
    -
    -
    -
    - - - + + @@ -79104,990 +80230,923 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -26,7 +26,7 @@
    +
    @@ -503,7 +504,7 @@
    - 26 + 503
      - var err error + latest,
    - 27 + 504
      - mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves) + },
    - 28 + 505
      - if err != nil { + expectedResult: nil,
    - 29 + 506
    - - log.Error("error initializing si siblings. Error: ", err) + expectedError: types.NewRPCError(types.RevertedErrorCode, "execution reverted"),
    - 30 + 507
      - return nil, err + setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) {
    - 31 + 508
      - } + nonce := uint64(7)
    - 32 + 509
      - log.Debug("Initial count: ", mt.count) + m.DbTx.On("Rollback", context.Background()).Return(nil).Once()
    -
    @@ -34,6 +34,25 @@
    +
    @@ -5416,3 +5417,237 @@
    - 34 + 5416
      - return mt, nil + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 35 + 5417
      - } + assert.ElementsMatch(t, []int{16}, results[5])
    - 36 + 5418
      -
    + }
    - 37 + + -
    +
    +
      - func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) { +
    - 38 + + -
    +
    +
      - var ( +
    - 39 + + -
    +
    +
      - nodes [][][]byte -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 26 + + -
    +
    +
      - var err error +
    - 27 + + -
    +
    +
      - mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves) +
    - 28 + + -
    +
    +
      - if err != nil { +
    - 29 + + -
    - + - log.Error("error initializing siblings. Error: ", err) +
    +
    +   +
    - 30 + + -
    +
    +
      - return nil, err +
    - 31 + + -
    +
    +
      - } +
    - 32 + + -
    +
    +
      - log.Debug("Initial count: ", mt.count) +
    -
     
    -
    - 34 + + -
    +
    +
      - return mt, nil +
    - 35 + + -
    +
    +
      - } +
    - 36 + + -
    +
    +
     
    - 37 + + -
    - + - // ResetL1InfoTree resets the L1InfoTree. +
    +
    +   +
    - 38 + + -
    - + - func (mt *L1InfoTree) ResetL1InfoTree(initialLeaves [][32]byte) (*L1InfoTree, error) { +
    +
    +   +
    - 39 + + -
    - + - log.Info("Resetting L1InfoTree...") +
    +
    +   +
    - 40 + + -
    - + - newMT := &L1InfoTree{ +
    +
    +   +
    - 41 + + -
    - + - zeroHashes: generateZeroHashes(32), // nolint:gomnd +
    +
    +   +
    - 42 + + -
    - + - height: 32, // nolint:gomnd +
    +
    +   +
    - 43 + + -
    - + - count: uint32(len(initialLeaves)), +
    +
    +   +
    - 44 + + -
    - + - } +
    +
    +   +
    - 45 + + -
    - + - var err error +
    +
    +   +
    - 46 + + -
    - + - newMT.siblings, newMT.currentRoot, err = newMT.initSiblings(initialLeaves) +
    +
    +   +
    - 47 + + -
    - + - if err != nil { +
    +
    +   +
    - 48 + + -
    - + - log.Error("error initializing siblings. Error: ", err) +
    +
    +   +
    - 49 + + -
    - + - return nil, err +
    +
    +   +
    - 50 + + -
    - + - } +
    +
    +   +
    - 51 + + -
    - + - log.Debug("Reset initial count: ", newMT.count) +
    +
    +   +
    - 52 + + -
    - + - log.Debug("Reset initial root: ", newMT.currentRoot) +
    +
    +   +
    - 53 + + -
    - + - return newMT, nil +
    +
    +   +
    - 54 + + -
    - + - } +
    +
    +   +
    - 55 + + -
    - + +
    +
    +  
    - 56 + + -
    +
    +
      - func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) { +
    - 57 + + -
    +
    +
      - var ( +
    - 58 + + -
    +
    +
      - nodes [][][]byte -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -2,21 +2,12 @@
    - 2 + + -
    +
    +
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "bytes" +
    - 5 + + -
    - - - "errors" +
    +
    +   +
    - 6 + + -
    +
    +
      - "math/big" +
    - 7 + + -
    +
    +
     
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    - 9 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/state" +
    - 10 + + -
    +
    +
      - ) +
    - 11 + + -
    +
    +
     
    - 12 + + -
    - - - var ( +
    +
    +   +
    - 13 + + -
    - - - // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero +
    +
    +   +
    - 14 + + -
    - - - ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") +
    +
    +   +
    - 15 + + -
    - - +
    +
    +  
    - 16 + + -
    - - - // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero +
    +
    +   +
    - 17 + + -
    - - - ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") +
    +
    +   +
    - 18 + + -
    - - - ) +
    +
    +   +
    - 19 + + -
    - - +
    +
    +  
    - 20 + + -
    +
    +
      - // EffectiveGasPrice implements the effective gas prices calculations and checks +
    - 21 + + -
    +
    +
      - type EffectiveGasPrice struct { +
    - 22 + + -
    +
    +
      - cfg EffectiveGasPriceCfg +
    -
    @@ -122,33 +113,8 @@
    -
    - 122 + + -
    +
    +
      - bfEffectiveGasPrice.Int(effectiveGasPrice) +
    - 123 + + -
    +
    +
     
    - 124 + + -
    +
    +
      - if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { +
    - 125 + + -
    - - - return nil, ErrEffectiveGasPriceIsZero +
    +
    +   +
    - 126 + + -
    +
    +
      - } +
    - 127 + + -
    +
    +
     
    - 128 + + -
    +
    +
      - return effectiveGasPrice, nil +
    - 129 + + -
    +
    +
      - } +
    - 130 + + -
    - - +
    +
    +  
    - 131 + + -
    - - - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage +
    +
    +   +
    - 132 + + -
    - - - func (e *EffectiveGasPrice) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { +
    +
    +   +
    - 133 + + -
    - - - const bits = 256 +
    +
    +   +
    - 134 + + -
    - - - var bitsBigInt = big.NewInt(bits) +
    +
    +   +
    - 135 + + -
    - - +
    +
    +  
    - 136 + + -
    - - - if effectiveGasPrice == nil || gasPrice == nil || +
    +
    +   +
    - 137 + + -
    - - - gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 { +
    +
    +   +
    - 138 + + -
    - - - return 0, ErrEffectiveGasPriceEmpty +
    +
    +   +
    - 139 + + -
    - - - } +
    +
    +   +
    - 140 + + -
    - - +
    +
    +  
    - 141 + + -
    - - - if gasPrice.Cmp(effectiveGasPrice) <= 0 { +
    +
    +   +
    - 142 + + -
    - - - return state.MaxEffectivePercentage, nil +
    +
    +   +
    - 143 + + -
    - - - } +
    +
    +   +
    - 144 + + -
    - - +
    +
    +  
    - 145 + + -
    - - - // Simulate Ceil with integer division +
    +
    +   +
    - 146 + + -
    - - - b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt) +
    +
    +   +
    - 147 + + -
    - - - b = b.Add(b, gasPrice) +
    +
    +   +
    - 148 + + -
    - - - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    +   +
    - 149 + + -
    - - - b = b.Div(b, gasPrice) +
    +
    +   +
    - 150 + + -
    - - - // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) +
    +
    +   +
    - 151 + + -
    - - - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    +   +
    - 152 + + -
    - - +
    +
    +  
    - 153 + + -
    - - - return uint8(b.Uint64()), nil +
    +
    +   +
    - 154 - -
    - - - } -
    +
    +
    -
    + +
    +   +
    -
    -
    - - - - - - - - - - - @@ -80101,61 +81160,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -80605,377 +81659,334 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
     
    - 2 + + -
    +
    +
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "bytes" +
    - 5 + + -
    +
    +
      - "math/big" +
    - 6 + + -
    +
    +
     
    - 7 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/state" +
    - 9 + + -
    +
    +
      - ) +
    - 10 + + -
    +
    +
     
    @@ -80241,118 +81300,113 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 11 + + -
    +
    +
      - // EffectiveGasPrice implements the effective gas prices calculations and checks +
    - 12 + + -
    +
    +
      - type EffectiveGasPrice struct { +
    - 13 + + -
    +
    +
      - cfg EffectiveGasPriceCfg +
    -
     
    -
    - 113 + + -
    +
    +
      - bfEffectiveGasPrice.Int(effectiveGasPrice) +
    - 114 + + -
    +
    +
     
    - 115 + + -
    +
    +
      - if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { +
    - 116 + + -
    - + - return nil, state.ErrEffectiveGasPriceIsZero +
    +
    +   +
    - 117 + + -
    +
    +
      - } +
    - 118 + + -
    +
    +
     
    - 119 + + -
    +
    +
      - return effectiveGasPrice, nil +
    - 120 + + -
    +
    +
      - } +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -23,8 +24,6 @@
    -
    - 23 + + -
    +
    +
      - ) +
    - 24 + + -
    +
    +
     
    - 25 + + -
    +
    +
      - func TestCalculateEffectiveGasPricePercentage(t *testing.T) { +
    - 26 + + -
    - - - egp := NewEffectiveGasPrice(egpCfg) +
    +
    +   +
    - 27 + + -
    - - +
    +
    +  
    - 28 + + -
    +
    +
      - testCases := []struct { +
    - 29 + + -
    +
    +
      - name string +
    - 30 + + -
    +
    +
      - breakEven *big.Int +
    -
    @@ -37,14 +36,14 @@
    +
    + + +
    +   +
    +
    - 37 + + -
    +
    +
      - name: "Nil breakEven or gasPrice", +
    - 38 + + -
    +
    +
      - gasPrice: big.NewInt(1), +
    - 39 + + -
    +
    +
      - expectedValue: uint8(0), +
    - 40 + + -
    - - - err: ErrEffectiveGasPriceEmpty, +
    +
    +   +
    - 41 + + -
    +
    +
      - }, +
    - 42 + + -
    +
    +
      - { +
    - 43 + + -
    +
    +
      - name: "Zero breakEven or gasPrice", +
    - 44 + + -
    +
    +
      - breakEven: big.NewInt(1), +
    - 45 + + -
    +
    +
      - gasPrice: big.NewInt(0), +
    - 46 + + -
    +
    +
      - expectedValue: uint8(0), +
    - 47 + + -
    - - - err: ErrEffectiveGasPriceEmpty, +
    +
    +   +
    - 48 + + -
    +
    +
      - }, +
    - 49 + + -
    +
    +
      - { +
    - 50 + + -
    +
    +
      - name: "Both positive, gasPrice less than breakEven", +
    -
    @@ -104,7 +103,7 @@
    -
    - 104 + + -
    +
    +
     
    - 105 + + -
    +
    +
      - for _, tc := range testCases { +
    - 106 + + -
    +
    +
      - t.Run(tc.name, func(t *testing.T) { +
    - 107 + + -
    - - - actual, err := egp.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven) +
    +
    +   +
    - 108 + + -
    +
    +
      - assert.Equal(t, tc.err, err) +
    - 109 + + -
    +
    +
      - if actual != 0 { +
    - 110 + + -
    +
    +
      - assert.Equal(t, tc.expectedValue, actual) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -80999,312 +82010,273 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 24 + + -
    +
    +
      - ) +
    - 25 + + -
    +
    +
     
    - 26 + + -
    +
    +
      - func TestCalculateEffectiveGasPricePercentage(t *testing.T) { +
    - 27 + + -
    +
    +
      - testCases := []struct { +
    - 28 + + -
    +
    +
      - name string +
    - 29 + + -
    +
    +
      - breakEven *big.Int +
    -
     
    -
    - 36 + + -
    +
    +
      - name: "Nil breakEven or gasPrice", +
    - 37 + + -
    +
    +
      - gasPrice: big.NewInt(1), +
    - 38 + + -
    +
    +
      - expectedValue: uint8(0), +
    - 39 + + -
    - + - err: state.ErrEffectiveGasPriceEmpty, +
    +
    +   +
    - 40 + + -
    +
    +
      - }, +
    - 41 + + -
    +
    +
      - { +
    - 42 + + -
    +
    +
      - name: "Zero breakEven or gasPrice", +
    - 43 + + -
    +
    +
      - breakEven: big.NewInt(1), +
    - 44 + + -
    +
    +
      - gasPrice: big.NewInt(0), +
    - 45 + + -
    +
    +
      - expectedValue: uint8(0), +
    - 46 + + -
    - + - err: state.ErrEffectiveGasPriceEmpty, +
    +
    +   +
    - 47 + + -
    +
    +
      - }, +
    - 48 + + -
    +
    +
      - { +
    - 49 + + -
    +
    +
      - name: "Both positive, gasPrice less than breakEven", +
    -
     
    -
    - 103 + + -
    +
    +
     
    - 104 + + -
    +
    +
      - for _, tc := range testCases { +
    - 105 + + -
    +
    +
      - t.Run(tc.name, func(t *testing.T) { +
    - 106 + + -
    - + - actual, err := state.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven) +
    +
    +   +
    - 107 + + -
    +
    +
      - assert.Equal(t, tc.err, err) +
    - 108 + + -
    +
    +
      - if actual != 0 { +
    - 109 + + -
    +
    +
      - assert.Equal(t, tc.expectedValue, actual) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -81398,13 +82370,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -81423,261 +82395,177 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -76,4 +76,13 @@
    - 76 + + -
    +
    +
     
    - 77 + + -
    +
    +
      - // ErrZeroL1GasPrice is returned if the L1 gas price is 0. +
    - 78 + + -
    +
    +
      - ErrZeroL1GasPrice = errors.New("L1 gas price 0") +
    - 79 + + -
    +
    +
      - ) +
    - 76 + 6
      -
    + "errors"
    - 77 + 7
      - // ErrZeroL1GasPrice is returned if the L1 gas price is 0. + "fmt"
    - 78 + 8
      - ErrZeroL1GasPrice = errors.New("L1 gas price 0") -
    -
    - 79 - -
    - + -
    -
    -
    - 80 - -
    - + - // ErrSenderDisallowedSendTx is returned when transactions by sender are is disallowed by policy -
    -
    - 81 - -
    - + - ErrSenderDisallowedSendTx = errors.New("sender disallowed send_tx by policy") -
    -
    - 82 - -
    - + -
    -
    -
    - 83 - -
    - + - // ErrContractDisallowedSendTx is returned when transactions to contract are is disallowed by policy -
    -
    - 84 - -
    - + - ErrContractDisallowedSendTx = errors.New("contract disallowed send_tx by policy") + "math/big"
    - 85 + 9
    + -
    + "strings"
    - 86 + + 10 +
    - + - // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy +   + "sync"
    - 87 + + 11 +
    - + - ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy") +   + "testing"
    - 88 + 12
      - ) + "time"
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -38,6 +38,7 @@
    +
     
    - 38 + 504
      - MarkWIPTxsAsPending(ctx context.Context) error + latest,
    - 39 + 505
      - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) + },
    - 40 + 506
      - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) + expectedResult: nil,
    - + + 507 -
    -   -
    +
    +
    + + + expectedError: types.NewRPCError(types.DefaultErrorCode, "execution reverted"),
    - 41 + 508
      - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) + setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) {
    - 42 + 509
      - } + nonce := uint64(7)
    - 43 + 510
      -
    + m.DbTx.On("Rollback", context.Background()).Return(nil).Once()
    -
    @@ -48,3 +49,12 @@
    +
     
    - 48 + 5417
      - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 49 + 5418
      - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) + assert.ElementsMatch(t, []int{16}, results[5])
    - 50 + 5419
    @@ -81686,2161 +82574,2402 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 5420 -
    -   +
    +
    + +
    - + + 5421 -
    -   -
    +
    +
    + + + func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) {
    - + + 5422 -
    -   -
    +
    +
    + + + // Set up the sender
    - + + 5423 -
    -   -
    +
    +
    + + + allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    - + + 5424 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5425 -
    -   -
    +
    +
    + + + allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1))
    - + + 5426 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5427 -
    -   +
    +
    + +
    - + + 5428 -
    -   -
    +
    +
    + + + disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    -
    + + + 5429 + + +
    + + + require.NoError(t, err)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 38 + + 5430 +
    -   - MarkWIPTxsAsPending(ctx context.Context) error + + + disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1))
    - 39 + + 5431 +
    -   - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) + + + require.NoError(t, err)
    - 40 + + 5432 +
    -   - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) + + + require.NotNil(t, disallowed)
    - 41 + 5433
    + - policy +
    - 42 + + 5434 +
    -   - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) + + + allowedContract := common.HexToAddress("0x1")
    - 43 + + 5435 +
    -   - } + + + disallowedContract := common.HexToAddress("0x2")
    - 44 + + 5436 +
    -   + +
    -
     
    -
    - 49 + + 5437 +
    -   - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) + + + senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy")
    - 50 + + 5438 +
    -   - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) + + + contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy")
    - 51 + + 5439 +
    -   - } + + + deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy")
    - 52 + 5440
    + - type policy interface { +
    - 53 + 5441
    + - CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) + cfg := getSequencerDefaultConfig()
    - 54 + 5442
    + - AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error + s, m, _ := newMockedServerWithCustomConfig(t, cfg)
    - 55 + 5443
    + - RemoveAddressesFromPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error + defer s.Stop()
    - 56 + 5444
    + - ClearPolicy(ctx context.Context, policy PolicyName) error +
    - 57 + 5445
    + - DescribePolicies(ctx context.Context) ([]Policy, error) + type testCase struct {
    - 58 + 5446
    + - DescribePolicy(ctx context.Context, name PolicyName) (Policy, error) + Name string
    - 59 + 5447
    + - ListAcl(ctx context.Context, policy PolicyName, query []common.Address) ([]common.Address, error) + Input string
    - 60 + 5448
    + - } + ExpectedResult *common.Hash
    -
    + + + 5449 + + +
    + + + ExpectedError types.Error
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
    @@ -0,0 +1,202 @@
    - + + 5450 -
    -   -
    +
    +
    + + + Prepare func(t *testing.T, tc *testCase)
    - + + 5451 -
    -   -
    +
    +
    + + + SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase)
    - + + 5452 -
    -   -
    +
    +
    + + + }
    - + + 5453 -
    -   +
    +
    + +
    - + + 5454 -
    -   -
    +
    +
    + + + testCases := []testCase{
    - + + 5455 -
    -   -
    +
    +
    + + + {
    - + + 5456 -
    -   -
    +
    +
    + + + Name: "Sender & contract on allow list, accepted",
    - + + 5457 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5458 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5459 -
    -   +
    +
    + +
    - + + 5460 -
    -   -
    +
    +
    + + + signedTx, err := allowed.Signer(allowed.From, tx)
    - + + 5461 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5462 -
    -   +
    +
    + +
    - + + 5463 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5464 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5465 -
    -   +
    +
    + +
    - + + 5466 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5467 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5468 -
    -   +
    +
    + +
    - + + 5469 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5470 -
    -   -
    +
    +
    + + + expectedHash := signedTx.Hash()
    - + + 5471 -
    -   -
    +
    +
    + + + tc.ExpectedResult = &expectedHash
    - + + 5472 -
    -   -
    +
    +
    + + + tc.ExpectedError = nil
    - + + 5473 -
    -   -
    +
    +
    + + + },
    - + + 5474 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5475 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5476 -
    -   -
    +
    +
    + + + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - + + 5477 -
    -   -
    +
    +
    + + + Return(nil).
    - + + 5478 -
    -   -
    +
    +
    + + + Once()
    - + + 5479 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5480 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - + + 5481 -
    -   -
    +
    +
    + + + Return(true, nil).
    - + + 5482 -
    -   -
    +
    +
    + + + Once()
    - + + 5483 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5484 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, allowed.From).
    - + + 5485 -
    -   -
    +
    +
    + + + Return(true, nil).
    - + + 5486 -
    -   -
    +
    +
    + + + Once()
    - + + 5487 -
    -   -
    +
    +
    + + + },
    - + + 5488 -
    -   -
    +
    +
    + + + },
    - + + 5489 -
    -   -
    +
    +
    + + + {
    - + + 5490 -
    -   -
    +
    +
    + + + Name: "Contract not on allow list, rejected",
    - + + 5491 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5492 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5493 -
    -   +
    +
    + +
    - + + 5494 -
    -   -
    +
    +
    + + + signedTx, err := allowed.Signer(allowed.From, tx)
    - + + 5495 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5496 -
    -   +
    +
    + +
    - + + 5497 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5498 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5499 -
    -   +
    +
    + +
    - + + 5500 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5501 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5502 -
    -   +
    +
    + +
    - + + 5503 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5504 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5505 -
    -   -
    +
    +
    + + + tc.ExpectedError = contractDenied
    - + + 5506 -
    -   -
    +
    +
    + + + },
    - + + 5507 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5508 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5509 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    - + + 5510 -
    -   -
    +
    +
    + + + Return(false, contractDenied).
    - + + 5511 -
    -   -
    +
    +
    + + + Once()
    - + + 5512 -
    -   -
    +
    +
    + + + },
    - + + 5513 -
    -   -
    +
    +
    + + + },
    - + + 5514 -
    -   -
    +
    +
    + + + {
    - + + 5515 -
    -   -
    +
    +
    + + + Name: "Sender not on allow list, rejected",
    - + + 5516 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5517 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5518 -
    -   +
    +
    + +
    - + + 5519 -
    -   -
    +
    +
    + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - + + 5520 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5521 -
    -   +
    +
    + +
    - + + 5522 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5523 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5524 -
    -   +
    +
    + +
    - + + 5525 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5526 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5527 -
    -   +
    +
    + +
    - + + 5528 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5529 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5530 -
    -   -
    +
    +
    + + + tc.ExpectedError = senderDenied
    - + + 5531 -
    -   -
    +
    +
    + + + },
    - + + 5532 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5533 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5534 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - + + 5535 -
    -   -
    +
    +
    + + + Return(true, nil).
    - + + 5536 -
    -   -
    +
    +
    + + + Once()
    - + + 5537 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5538 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From).
    - + + 5539 -
    -   -
    +
    +
    + + + Return(false, senderDenied).
    - + + 5540 -
    -   -
    +
    +
    + + + Once()
    - + + 5541 -
    -   -
    +
    +
    + + + },
    - + + 5542 -
    -   -
    +
    +
    + + + },
    - + + 5543 -
    -   -
    +
    +
    + + + {
    - + + 5544 -
    -   -
    +
    +
    + + + Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility
    - + + 5545 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5546 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5547 -
    -   +
    +
    + +
    - + + 5548 -
    -   -
    +
    +
    + + + txBinary, err := tx.MarshalBinary()
    - + + 5549 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5550 -
    -   +
    +
    + +
    - + + 5551 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5552 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5553 -
    -   +
    +
    + +
    - + + 5554 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5555 -
    -   -
    +
    +
    + + + expectedHash := tx.Hash()
    - + + 5556 -
    -   -
    +
    +
    + + + tc.ExpectedResult = &expectedHash
    - + + 5557 -
    -   -
    +
    +
    + + + tc.ExpectedError = nil
    - + + 5558 -
    -   -
    +
    +
    + + + },
    - + + 5559 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5560 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5561 -
    -   -
    +
    +
    + + + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - + + 5562 -
    -   -
    +
    +
    + + + Return(nil).
    - + + 5563 -
    -   -
    +
    +
    + + + Once()
    - + + 5564 -
    -   -
    +
    +
    + + + // policy does not reject this case for backward compat
    - + + 5565 -
    -   -
    +
    +
    + + + },
    - + + 5566 -
    -   -
    +
    +
    + + + },
    - + + 5567 -
    -   -
    +
    +
    + + + {
    - + + 5568 -
    -   -
    +
    +
    + + + Name: "Unsigned tx with disallowed contract, rejected",
    - + + 5569 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5570 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5571 -
    -   +
    +
    + +
    - + + 5572 -
    -   -
    +
    +
    + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - + + 5573 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5574 -
    -   +
    +
    + +
    - + + 5575 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5576 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5577 -
    -   +
    +
    + +
    - + + 5578 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5579 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5580 -
    -   +
    +
    + +
    - + + 5581 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5582 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5583 -
    -   -
    +
    +
    + + + tc.ExpectedError = contractDenied
    - + + 5584 -
    -   -
    +
    +
    + + + },
    - + + 5585 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5586 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5587 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    - + + 5588 -
    -   -
    +
    +
    + + + Return(false, contractDenied).
    - + + 5589 -
    -   -
    +
    +
    + + + Once()
    - + + 5590 -
    -   -
    +
    +
    + + + },
    - + + 5591 -
    -   -
    +
    +
    + + + },
    - + + 5592 -
    -   -
    +
    +
    + + + {
    - + + 5593 -
    -   -
    +
    +
    + + + Name: "Send invalid tx input", // for backward compatibility
    - + + 5594 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5595 -
    -   -
    +
    +
    + + + tc.Input = "0x1234"
    - + + 5596 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5597 -
    -   -
    +
    +
    + + + tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input")
    - + + 5598 -
    -   -
    +
    +
    + + + },
    - + + 5599 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {},
    - + + 5600 -
    -   -
    +
    +
    + + + },
    - + + 5601 -
    -   -
    +
    +
    + + + {
    - + + 5602 -
    -   -
    +
    +
    + + + Name: "Sender not on deploy allow list, rejected",
    - + + 5603 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5604 -
    -   -
    +
    +
    + + + deployAddr := common.HexToAddress("0x0")
    - + + 5605 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5606 -
    -   +
    +
    + +
    - + + 5607 -
    -   -
    +
    +
    + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - + + 5608 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5609 -
    -   +
    +
    + +
    - + + 5610 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5611 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5612 -
    -   +
    +
    + +
    - + + 5613 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5614 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5615 -
    -   +
    +
    + +
    - + + 5616 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5617 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5618 -
    -   -
    +
    +
    + + + tc.ExpectedError = deployDenied
    - + + 5619 -
    -   -
    +
    +
    + + + },
    - + + 5620 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5621 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5622 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From).
    - + + 5623 -
    -   -
    +
    +
    + + + Return(false, nil).
    - + + 5624 -
    -   -
    +
    +
    + + + Once()
    - + + 5625 -
    -   -
    +
    +
    + + + },
    - + + 5626 -
    -   -
    +
    +
    + + + },
    - + + 5627 -
    -   -
    +
    +
    + + + }
    - + + 5628 -
    -   +
    +
    + +
    - + + 5629 -
    -   -
    +
    +
    + + + for _, testCase := range testCases {
    - + + 5630 -
    -   -
    +
    +
    + + + t.Run(testCase.Name, func(t *testing.T) {
    - + + 5631 -
    -   -
    +
    +
    + + + tc := testCase
    - + + 5632 -
    -   -
    +
    +
    + + + tc.Prepare(t, &tc) +
    +
    + 5633 + +
    + + + tc.SetupMocks(t, m, tc) +
    +
    + 5634 + +
    + + +
    +
    +
    + 5635 + +
    + + + res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input) +
    +
    + 5636 + +
    + + + require.NoError(t, err) +
    +
    + 5637 + +
    + + +
    +
    +
    + 5638 + +
    + + + assert.Equal(t, float64(1), res.ID) +
    +
    + 5639 + +
    + + + assert.Equal(t, "2.0", res.JSONRPC) +
    +
    + 5640 + +
    + + +
    +
    +
    + 5641 + +
    + + + if res.Result != nil || tc.ExpectedResult != nil { +
    +
    + 5642 + +
    + + + var result common.Hash +
    +
    + 5643 + +
    + + + err = json.Unmarshal(res.Result, &result) +
    +
    + 5644 + +
    + + + require.NoError(t, err) +
    +
    + 5645 + +
    + + + assert.Equal(t, *tc.ExpectedResult, result) +
    +
    + 5646 + +
    + + + } +
    +
    + 5647 + +
    + + + if res.Error != nil || tc.ExpectedError != nil { +
    +
    + 5648 + +
    + + + assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code) +
    +
    + 5649 + +
    + + + assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message) +
    +
    + 5650 + +
    + + + } +
    +
    + 5651 + +
    + + + }) +
    +
    + 5652 + +
    + + + } +
    +
    + 5653 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + @@ -84033,433 +85162,448 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    +
    @@ -204,6 +204,53 @@
    +
    + 204 + +
    +   + }) +
    +
    + 205 + +
    +   + } +
    +
    + 206 + +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
     
    - 1 + + -
    - + - package pgpoolstorage +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import ( +
    +
    +   +
    - 4 + + -
    - + - "context" +
    +
    +   +
    - 5 + + -
    - + - "errors" +
    +
    +   +
    - 6 + + -
    - + - "fmt" +
    +
    +   +
    - 7 + + -
    - + - "strings" +
    +
    +   +
    - 8 + + -
    - + +
    +
    +  
    - 9 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/pool" +
    +
    +   +
    - 10 + + -
    - + - "github.com/ethereum/go-ethereum/common" +
    +
    +   +
    - 11 + + -
    - + - "github.com/jackc/pgx/v4" +
    +
    +   +
    - 12 + + -
    - + - ) +
    +
    +   +
    - 13 + + -
    - + +
    +
    +  
    - 14 + + -
    - + - // CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule +
    +
    +   +
    - 15 + + -
    - + - // will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of +
    +
    +   +
    - 16 + + -
    - + - // the policy setting. +
    +
    +   +
    - 17 + + -
    - + - func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) { +
    +
    +   +
    - 18 + + -
    - + - sql := `SELECT +
    +
    +   +
    - 19 + + -
    - + - CASE WHEN a.address is null THEN +
    +
    +   +
    - 20 + + -
    - + - NOT p.allow +
    +
    +   +
    - 21 + + -
    - + - ELSE +
    +
    +   +
    - 22 + + -
    - + - p.allow +
    +
    +   +
    - 23 + + -
    - + - END +
    +
    +   +
    - 24 + + -
    - + - FROM pool.policy p +
    +
    +   +
    - 25 + + -
    - + - LEFT JOIN pool.acl a +
    +
    +   +
    - 26 + + -
    - + - ON p.name = a.policy +
    +
    +   +
    - 27 + + -
    - + - AND a.address = $1 +
    +
    +   +
    - 28 + + 207 +
    - + - WHERE p.name = $2` +   + // GetFullBlockByNumber returns information about a block by block number
    - 29 + + 208 +
    - + -
    +   + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
    - 30 + + 209 +
    - + - rows, err := p.db.Query(ctx, sql, address.Hex(), policy) +   + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 31 + +
    @@ -516,7 +563,7 @@
    +
    + 516 +
    - + +  
    - 32 + + 517 +
    - + - if errors.Is(err, pgx.ErrNoRows) { +   + if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice
    - 33 + + 518 +
    - + - return false, pool.ErrNotFound +   + // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice
    - 34 + + 519 +
    - + - } else if err != nil { + - + txEGPPct, err = z.pool.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP)
    - 35 + + 520 +
    - + - return false, err +   + if err != nil {
    - 36 + + 521 +
    - + - } +   + return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false)
    - 37 + + 522 +
    - + -
    +   + }
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    - 38 + + 204 +
    - + - defer rows.Close() +   + })
    - 39 + + 205 +
    - + - if !rows.Next() { // should always be a row if the policy exists +   + }
    - 40 + + 206 +
    - + - return false, nil +   +
    - 41 + 207
    + - } + type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 42 + 208
    @@ -84469,287 +85613,287 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 43 + 209
    + - var allow bool + // GetBatchDataByNumbers returns L2 batch data by batch numbers.
    - 44 + 210
    + - err = rows.Scan(&allow) + func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    - 45 + 211
    + - if err != nil { + return z.getBatchData(filter, z.state.GetBatchL2DataByNumbers)
    - 46 + 212
    + - return false, err + }
    - 47 + 213
    + - } +
    - 48 + 214
    + - return allow, nil + // GetForcedBatchDataByNumbers returns forced batch data by batch numbers.
    - 49 + 215
    + - } + func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    - 50 + 216
    + -
    + return z.getBatchData(filter, z.state.GetForcedBatchDataByNumbers)
    - 51 + 217
    + - // UpdatePolicy sets the allow/deny rule for the named policy + }
    - 52 + 218
    + - func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error { +
    - 53 + 219
    + - sql := "UPDATE pool.policy SET allow = $1 WHERE name = $2" + func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) (interface{}, types.Error) {
    - 54 + 220
    + - _, err := p.db.Exec(ctx, sql, allow, string(policy)) + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 55 + 221
    + - if err != nil { + batchNumbers := make([]uint64, 0, len(filter.Numbers))
    - 56 + 222
    + - return err + for _, bn := range filter.Numbers {
    - 57 + 223
    + - } + n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx)
    - 58 + 224
    + - return nil + if rpcErr != nil {
    - 59 + 225
    + - } + return nil, rpcErr
    - 60 + 226
    + -
    + }
    - 61 + 227
    + - // AddAddressesToPolicy adds addresses to the named policy + batchNumbers = append(batchNumbers, n)
    - 62 + 228
    + - func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { + }
    - 63 + 229
    + - sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING" +
    - 64 + 230
    + - tx, err := p.db.Begin(ctx) + batchesData, err := f(ctx, batchNumbers, dbTx)
    - 65 + 231
    + - if err != nil { + if errors.Is(err, state.ErrNotFound) {
    - 66 + 232
    + - return err + return nil, nil
    - 67 + 233
    + - } + } else if err != nil {
    - 68 + 234
    + - defer func(tx pgx.Tx, ctx context.Context) { + return RPCErrorResponse(types.DefaultErrorCode,
    - 69 + 235
    + - _ = tx.Rollback(ctx) + fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true)
    - 70 + 236
    + - }(tx, ctx) + }
    - 71 + 237
    @@ -84759,967 +85903,665 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 72 + 238
    + - for _, a := range addresses { + ret := make([]*types.BatchData, 0, len(batchNumbers))
    - 73 + 239
    + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) + for _, n := range batchNumbers {
    - 74 + 240
    + - if err != nil { + data := &types.BatchData{Number: types.ArgUint64(n)}
    - 75 + 241
    + - return err + if b, ok := batchesData[n]; ok {
    - 76 + 242
    + - } + data.BatchL2Data = b
    - 77 + 243
    + - } + data.Empty = false
    - 78 + 244
    + - err = tx.Commit(ctx) + } else {
    - 79 + 245
    + - if err != nil { + data.Empty = true
    - 80 + 246
    + - return nil + }
    - 81 + 247
    + - } + ret = append(ret, data)
    - 82 + 248
    + - return nil + }
    - 83 + 249
    + - } +
    - 84 + 250
    + -
    + return types.BatchDataResult{Data: ret}, nil
    - 85 + 251
    + - // RemoveAddressesFromPolicy removes addresses from the named policy + })
    - 86 + 252
    + - func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { + }
    - 87 + 253
    + - sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2" +
    - 88 + + 254 +
    - + - tx, err := p.db.Begin(ctx) +   + // GetFullBlockByNumber returns information about a block by block number
    - 89 + + 255 +
    - + - if err != nil { +   + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
    - 90 + + 256 +
    - + - return err +   + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 91 - -
    - + - } -
    +
    +
     
    - 92 + + 563 +
    - + - defer func(tx pgx.Tx, ctx context.Context) { +   +
    - 93 + + 564 +
    - + - _ = tx.Rollback(ctx) +   + if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice
    - 94 + + 565 +
    - + - }(tx, ctx) +   + // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice
    - 95 + + 566 +
    + -
    + txEGPPct, err = state.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP)
    - 96 + + 567 +
    - + - for _, a := range addresses { +   + if err != nil {
    - 97 - -
    - + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) -
    -
    - 98 - -
    - + - if err != nil { -
    -
    - 99 - -
    - + - return err -
    -
    - 100 - -
    - + - } -
    -
    - 101 + + 568 +
    - + - } +   + return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false)
    - 102 + + 569 +
    - + - err = tx.Commit(ctx) +   + }
    - 103 - -
    - + - if err != nil { +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -2705,3 +2705,32 @@
    - 104 + + 2705 +
    - + - return err +   + })
    - 105 + + 2706 +
    - + +   }
    - 106 - -
    - + - return nil -
    -
    - 107 + + 2707 +
    - + +   }
    - 108 + + -
    - + +
    +
    +  
    - 109 - -
    - + - // ClearPolicy removes _all_ addresses from the named policy -
    -
    - 110 - -
    - + - func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error { -
    -
    - 111 - -
    - + - sql := "DELETE FROM pool.acl WHERE policy = $1" -
    -
    - 112 - -
    - + - _, err := p.db.Exec(ctx, sql, policy) -
    -
    - 113 - -
    - + - if err != nil { -
    -
    - 114 - -
    - + - return err -
    -
    - 115 - -
    - + - } -
    -
    - 116 - -
    - + - return nil -
    -
    - 117 - -
    - + - } -
    -
    - 118 + + -
    - + +
    +
    +  
    - 119 - -
    - + - // DescribePolicies return all the policies -
    -
    - 120 - -
    - + - func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error) { -
    -
    - 121 - -
    - + - sql := "SELECT name, allow FROM pool.policy" -
    -
    - 122 - -
    - + - rows, err := p.db.Query(ctx, sql) -
    -
    - 123 - -
    - + - if err != nil { -
    -
    - 124 - -
    - + - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 125 - -
    - + - return nil, nil -
    -
    - 126 - -
    - + - } else { -
    -
    - 127 - -
    - + - return nil, err -
    -
    - 128 - -
    - + - } -
    -
    - 129 - -
    - + - } -
    -
    - 130 - -
    - + - defer rows.Close() -
    -
    - 131 + + -
    - + +
    +
    +  
    - 132 - -
    - + - var list []pool.Policy -
    -
    - 133 - -
    - + - for rows.Next() { -
    -
    - 134 + + -
    - + - var name string +
    +
    +   +
    - 135 + + -
    - + - var allow bool +
    +
    +   +
    - 136 + + -
    - + - err = rows.Scan(&name, &allow) +
    +
    +   +
    - 137 + + -
    - + - if err != nil { +
    +
    +   +
    - 138 + + -
    - + - return nil, err +
    +
    +   +
    - 139 + + -
    - + - } +
    +
    +   +
    - 140 + + -
    - + - if pool.IsPolicy(name) { // skip unknown +
    +
    +   +
    - 141 + + -
    - + - p := pool.Policy{ +
    +
    +   +
    - 142 + + -
    - + - Name: pool.PolicyName(name), +
    +
    +   +
    - 143 + + -
    - + - Allow: allow, +
    +
    +   +
    - 144 + + -
    - + - } +
    +
    +   +
    - 145 + + -
    - + - list = append(list, p) +
    +
    +   +
    - 146 + + -
    - + - } +
    +
    +   +
    - 147 + + -
    - + - } +
    +
    +   +
    - 148 + + -
    - + - return list, nil +
    +
    +   +
    - 149 + + -
    - + - } +
    +
    +   +
    - 150 + + -
    - + +
    +
    +  
    - 151 + + -
    - + - // DescribePolicy returns the named policy +
    +
    +   +
    - 152 + + -
    - + - func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error) { +
    +
    +   +
    - 153 + + -
    - + - sql := "SELECT name, allow FROM pool.policy WHERE name = $1 LIMIT 1" +
    +
    +   +
    - 154 + + -
    - + - row := p.db.QueryRow(ctx, sql, name) +
    +
    +   +
    - 155 + + -
    - + - var ( +
    +
    +   +
    - 156 + + -
    - + - pName string +
    +
    +   +
    - 157 + + -
    - + - allow bool +
    +
    +   +
    - 158 + + -
    - + - ) +
    +
    +   +
    - 159 + + -
    - + - err := row.Scan(&pName, &allow) +
    +
    +   +
    - 160 - -
    - + - if err != nil { +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 161 + + 2705 +
    - + - return pool.Policy{}, err +   + })
    - 162 + + 2706 +
    - + +   }
    - 163 - -
    - + - return pool.Policy{ -
    -
    - 164 - -
    - + - Name: pool.PolicyName(pName), -
    -
    - 165 - -
    - + - Allow: allow, -
    -
    - 166 - -
    - + - }, nil -
    -
    - 167 + + 2707 +
    - + +   }
    - 168 + 2708
    @@ -85729,47 +86571,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 169 - -
    - + - // ListAcl returns a list of the addresses associated with the policy -
    -
    - 170 - -
    - + - func (p *PostgresPoolStorage) ListAcl( -
    -
    - 171 + 2709
    + - ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error) { + func TestClient_BatchesByNumbers(t *testing.T) {
    - 172 + 2710
    + - sql := "SELECT address FROM pool.acl WHERE policy = $1" + const batchesCount = 6
    - 173 + 2711
    @@ -85779,67 +86601,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 174 + 2712
    + - if len(query) > 0 { + s, m, _ := newSequencerMockedServer(t)
    - 175 + 2713
    + - var addrs []string + defer s.Stop()
    - 176 + 2714
    + - for _, a := range query { +
    - 177 + 2715
    + - addrs = append(addrs, a.Hex()) + batchesDataMap := make(map[uint64][]byte, batchesCount)
    - 178 + 2716
    + - } + for i := 0; i < batchesCount; i++ {
    - 179 + 2717
    + - sql = sql + fmt.Sprintf(" IN (%v)", strings.Join(addrs, ",")) + batchesDataMap[uint64(i+1)] = []byte(fmt.Sprintf("batch %d data", i+1))
    - 180 + 2718
    @@ -85849,7 +86671,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 181 + 2719
    @@ -85859,97 +86681,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 182 - -
    - + - rows, err := p.db.Query(ctx, sql, string(policy)) -
    -
    - 183 - -
    - + - if err != nil { -
    -
    - 184 + 2720
    + - if errors.Is(err, pgx.ErrNoRows) { + m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything).
    - 185 + 2721
    + - return nil, nil + Return(batchesDataMap, nil).Once()
    - 186 + 2722
    + - } else { +
    - 187 + 2723
    + - return nil, err + m.State.On("BeginStateTransaction", context.Background()).
    - 188 + 2724
    + - } + Return(m.DbTx, nil).Once()
    - 189 + 2725
    + - } +
    - 190 + 2726
    + - defer rows.Close() + m.DbTx.On("Commit", context.Background()).Return(nil).Once()
    - 191 + 2727
    @@ -85959,87 +86761,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 192 - -
    - + - var addresses []common.Address -
    -
    - 193 + 2728
    + - for rows.Next() { + zkEVMClient := client.NewClient(s.ServerURL)
    - 194 + 2729
    + - var addr string + reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)}
    - 195 + 2730
    + - err = rows.Scan(&addr) + result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum)
    - 196 + 2731
    + - if err != nil { + require.NoError(t, err)
    - 197 + 2732
    + - return nil, err + require.Len(t, result, len(reqBatchesNum))
    - 198 + 2733
    + - } + for i, batchNum := range reqBatchesNum {
    - 199 + 2734
    + - addresses = append(addresses, common.HexToAddress(addr)) + require.Equal(t, hex.EncodeToHex(batchesDataMap[batchNum.Uint64()]), result[i].BatchL2Data.Hex())
    - 200 + 2735
    @@ -86049,17 +86841,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 201 - -
    - + - return addresses, nil -
    -
    - 202 + 2736
    @@ -86074,12 +86856,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go RENAMED
    -
    @@ -0,0 +1,43 @@
    +
    @@ -0,0 +1,61 @@
    @@ -86526,83 +87308,243 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    -
    - 1 + + -
    - + - package pool +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import "github.com/ethereum/go-ethereum/common" +
    +
    +   +
    - 4 + + -
    - + +
    +
    +  
    - 5 + + -
    - + - // PolicyName is a named policy +
    +
    +   +
    - 6 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + @@ -86627,7 +87589,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86637,7 +87599,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86647,7 +87609,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86657,7 +87619,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86667,7 +87629,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86677,7 +87639,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86687,7 +87649,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86697,7 +87659,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86707,7 +87669,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86717,7 +87679,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86727,7 +87689,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86737,7 +87699,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86747,7 +87709,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86757,7 +87719,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86767,7 +87729,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86777,7 +87739,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86787,7 +87749,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86797,7 +87759,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86807,7 +87769,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86817,7 +87779,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86827,7 +87789,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86837,7 +87799,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86847,7 +87809,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86857,7 +87819,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86867,7 +87829,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86877,7 +87839,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86887,7 +87849,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86897,7 +87859,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86907,7 +87869,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86917,7 +87879,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86927,7 +87889,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86937,7 +87899,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86947,7 +87909,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -86957,13 +87919,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - @@ -87101,92 +88193,111 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + +
    +
     
    +
    + 1
    + - type PolicyName string + package jsonrpc
    - 7 + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5
    @@ -86610,6 +87552,26 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 6 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    + 7 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/pool" +
    +
    8 @@ -86617,7 +87579,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - const ( + "github.com/0xPolygonHermez/zkevm-node/state"
    + - // SendTx is the name of the policy that governs that an address may send transactions to pool + "github.com/ethereum/go-ethereum/common"
    + - SendTx PolicyName = "send_tx" + ethTypes "github.com/ethereum/go-ethereum/core/types"
    + - // Deploy is the name of the policy that governs that an address may deploy a contract + )
    + - Deploy PolicyName = "deploy" +
    + - ) + func checkPolicy(ctx context.Context, p types.PoolInterface, input string) error {
    + -
    + tx, err := hexToTx(input)
    + - // Policy describes state of a named policy + if err != nil {
    + - type Policy struct { + // ignore it, let the later processing reject
    + - Name PolicyName + return nil
    + - Allow bool + }
    + - } +
    + -
    + // if the tx is signed, check the from address. If there is no from address, the tx is not rejected as it
    + - // Desc returns the string representation of a policy rule + // will get rejected later. This maintains backward compatibility with RPC expectations. TODO: verify this is ok behavior
    + - func (p *Policy) Desc() string { + var from common.Address
    + - if p.Allow { + if from, err = state.GetSender(*tx); err != nil {
    + - return "allow" + // if not signed, then skip check, it fails later on its own
    + - } + return nil
    + - return "deny" + }
    + - } +
    + -
    + switch resolvePolicy(tx) {
    + - // Acl describes exception to a named Policy by address + case pool.SendTx:
    + - type Acl struct { + var allow bool
    + - PolicyName PolicyName + if allow, err = p.CheckPolicy(ctx, pool.SendTx, *tx.To()); err != nil {
    + - Address common.Address + return err
    + - } + }
    + -
    + if !allow {
    + - // IsPolicy tests if a string represents a known named Policy + return pool.ErrContractDisallowedSendTx
    + - func IsPolicy(name string) bool { + }
    + - for _, p := range []PolicyName{SendTx, Deploy} { + if allow, err = p.CheckPolicy(ctx, pool.SendTx, from); err != nil {
    + - if name == string(p) { + return err
    + - return true + }
    + - } + if !allow {
    + - } + return pool.ErrSenderDisallowedSendTx
    + - return false + }
    43 +
    + + + case pool.Deploy: +
    +
    + 44 + +
    + + + var allow bool +
    +
    + 45 + +
    + + + // check that sender may deploy contracts +
    +
    + 46 + +
    + + + if allow, err = p.CheckPolicy(ctx, pool.Deploy, from); err != nil { +
    +
    + 47 + +
    + + + return err +
    +
    + 48 + +
    + + + } +
    +
    + 49 + +
    + + + if !allow { +
    +
    + 50 + +
    + + + return pool.ErrSenderDisallowedDeploy +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + + return nil +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + func resolvePolicy(tx *ethTypes.Transaction) pool.PolicyName { +
    +
    + 57 + +
    + + + if tx.To() == nil || tx.To().Hex() == common.HexToAddress("0x0").Hex() { +
    +
    + 58 + +
    + + + return pool.Deploy +
    +
    + 59 + +
    + + + } +
    +
    + 60 + +
    + + + return pool.SendTx +
    +
    + 61 +
    + @@ -86977,12 +88119,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go RENAMED
    -
    @@ -93,6 +93,13 @@
    +
    @@ -15,6 +15,8 @@
    - 93 + 15
      - time.Sleep(cfg.IntervalToRefreshGasPrices.Duration) + InvalidParamsErrorCode = -32602
    - 94 + 16
      - } + // ParserErrorCode error code for parsing errors
    - 95 + 17
      - }(&cfg, p) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + ParserErrorCode = -32700
    - 96 + 18
      -
    + )
    - 97 + 19
      - return p +
    - 98 + 20
      - } + var (
    +
    +
    +
    +
    + + + - - + + + - + + +
    -
    @@ -686,7 +693,7 @@
    +
     
    - 686 + 15
      -
    + InvalidParamsErrorCode = -32602
    - 687 + 16
      - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage + // ParserErrorCode error code for parsing errors
    - 688 + 17
      - func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { + ParserErrorCode = -32700
    - 689 + + 18 +
    - - - return p.effectiveGasPrice.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice) + + + // AccessDeniedCode error code when requests are denied +
    +
    + 19 + +
    + + + AccessDeniedCode = -32800
    - 690 + 20
      - } + )
    - 691 + 21
    @@ -87196,67 +88307,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 692 + 22
      - // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not + var (
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - @@ -87270,242 +88385,242 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - -
    -
    @@ -728,3 +735,8 @@
    +
    @@ -23,8 +23,8 @@
    - 728 + 23
      - } + CountPendingTransactions(ctx context.Context) (uint64, error)
    - 729 + 24
      - return gas, nil + GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 730 + 25
      - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - + + 26 -
    +
    +
      -
    + CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
    - - -
    -   -
    -
    +
    + 27
    -
    + +
    + - + CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
    -
    -
    - - - - - - - - - - + - - - - - - - - - - - + + +
    -
     
    - 93 + 28
      - time.Sleep(cfg.IntervalToRefreshGasPrices.Duration) + EffectiveGasPriceEnabled() bool
    - 94 + 29
      - } + }
    - 95 + 30
      - }(&cfg, p) -
    -
    - 96 - -
    - + - p.refreshBlockedAddresses() +
    - 97 - -
    - + - go func(cfg *Config, p *Pool) { -
    +
    +
    @@ -64,6 +64,8 @@
    - 98 + + 64 +
    - + - for { +   + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    - 99 + + 65 +
    - + - time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration) +   + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 100 + + 66 +
    - + - p.refreshBlockedAddresses() +   + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - 101 + + -
    - + - } +
    +
    +   +
    - 102 + + -
    - + - }(&cfg, p) +
    +
    +   +
    - 103 + 67
      -
    + GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
    - 104 + 68
      - return p + GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
    - 105 + 69
      - } + GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    +
    +
    +
    +
    + + + - - + + + + + + @@ -87515,82 +88630,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -87600,12 +88715,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go RENAMED
    @@ -87823,271 +88938,409 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + +
     
    - 693 + 23
      -
    + CountPendingTransactions(ctx context.Context) (uint64, error)
    - 694 + 24
      - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage + GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 695 + 25
      - func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { + GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 696 + + 26 +
    + - return state.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice) + CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error)
    - 697 + 27
      - } + CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error) +
    +
    + + +
    +   +
    - 698 + 28
      -
    + EffectiveGasPriceEnabled() bool
    - 699 + 29
      - // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not + } +
    +
    + 30 + +
    +   +
    - 735 + 64
      - } + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    - 736 + 65
      - return gas, nil + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 737 + 66
      - } + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - 738 + 67
    + -
    + GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 739 + 68
    + - // CheckPolicy checks if an address is allowed by policy name + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 740 + + 69 +
    - + - func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) { +   + GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
    - 741 + + 70 +
    - + - return p.storage.CheckPolicy(ctx, policy, address) +   + GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
    - 742 + + 71 +
    - + - } +   + GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    -
    @@ -2032,3 +2032,69 @@
    +
    @@ -446,6 +446,23 @@
    - 2032 + 446
      - require.NoError(t, err) + return res, nil
    - 2033 + 447
      - return signedTx + }
    - 2034 + 448
      - } +
    - + + 449 -
    +
    +
      -
    + // TransactionOrHash for union type of transaction and types.Hash
    - + + 450 -
    +
    +
      -
    + type TransactionOrHash struct {
    - + + 451 -
    +
    +
      -
    + Hash *common.Hash
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - - - - - - + + +
    +
     
    - + + 446 -
    +
    +
      -
    + return res, nil
    - + + 447 -
    +
    +
      -
    + }
    - + + 448 -
    +
    +
     
    - + + 449 -
    -   -
    +
    +
    + + + // BatchFilter is a list of batch numbers to retrieve
    - + + 450 -
    -   -
    +
    +
    + + + type BatchFilter struct {
    - + + 451 -
    -   -
    +
    +
    + + + Numbers []BatchNumber `json:"numbers"`
    - + + 452 -
    -   -
    +
    +
    + + + }
    - + + 453 -
    -   +
    +
    + +
    - + + 454 -
    -   -
    +
    +
    + + + // BatchData is an abbreviated structure that only contains the number and L2 batch data
    - + + 455 -
    -   +
    +
    + + + type BatchData struct { +
    +
    + 456 + +
    + + + Number ArgUint64 `json:"number"` +
    +
    + 457 + +
    + + + BatchL2Data ArgBytes `json:"batchL2Data,omitempty"` +
    +
    + 458 + +
    + + + Empty bool `json:"empty"` +
    +
    + 459 + +
    + + + } +
    +
    + 460 + +
    + +
    - + + 461 -
    -   +
    +
    + + + // BatchDataResult is a list of BatchData for a BatchFilter +
    +
    + 462 + +
    + + + type BatchDataResult struct { +
    +
    + 463 + +
    + + + Data []*BatchData `json:"data"` +
    +
    + 464 + +
    + + + } +
    +
    + 465 + +
    + +
    - + + 466 -
    +
    +
      -
    + // TransactionOrHash for union type of transaction and types.Hash
    - + + 467 -
    +
    +
      -
    + type TransactionOrHash struct {
    - + + 468 -
    +
    +
      -
    + Hash *common.Hash +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - @@ -88328,875 +89581,901 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - + - - - - - - - - - - - - + + +
    +
    @@ -26,7 +26,7 @@
    - + + 26 -
    +
    +
      -
    + var err error
    - + + 27 -
    +
    +
      -
    + mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves)
    - + + 28 -
    +
    +
      -
    + if err != nil {
    - + + 29 -
    +
    +
    + - + log.Error("error initializing si siblings. Error: ", err) +
    +
    + 30 + +
      -
    + return nil, err
    - + + 31 -
    +
    +
      -
    + }
    - + + 32 -
    +
    +
      -
    + log.Debug("Initial count: ", mt.count)
    - + +
    @@ -34,6 +34,25 @@
    -
    +
    + 34 + +
      -
    + return mt, nil
    - + + 35 -
    +
    +
      -
    + }
    - + + 36 -
    +
    +
     
    @@ -88283,33 +89536,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 37 -
    +
    +
      -
    + func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) {
    - + + 38 -
    +
    +
      -
    + var (
    - + + 39 -
    +
    +
      -
    + nodes [][][]byte
    - 2032 + 26
      - require.NoError(t, err) + var err error
    - 2033 + 27
      - return signedTx + mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves)
    - 2034 + 28
      - } + if err != nil {
    - 2035 + + 29 +
    + -
    + log.Error("error initializing siblings. Error: ", err)
    - 2036 + + 30 +
    - + - func Test_PolicyAcl(t *testing.T) { +   + return nil, err
    - 2037 + + 31 +
    - + - initOrResetDB(t) +   + }
    - 2038 + + 32 +
    - + -
    +   + log.Debug("Initial count: ", mt.count)
    - 2039 - -
    - + - poolSqlDB, err := db.NewSQLDB(poolDBCfg) -
    +
    +
     
    - 2040 + + 34 +
    - + - require.NoError(t, err) +   + return mt, nil
    - 2041 + + 35 +
    - + - defer poolSqlDB.Close() //nolint:gosec,errcheck +   + }
    - 2042 + + 36 +
    - + +  
    - 2043 + 37
    + - ctx := context.Background() + // ResetL1InfoTree resets the L1InfoTree.
    - 2044 + 38
    + - s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) + func (mt *L1InfoTree) ResetL1InfoTree(initialLeaves [][32]byte) (*L1InfoTree, error) {
    - 2045 + 39
    + - require.NoError(t, err) + log.Info("Resetting L1InfoTree...")
    - 2046 + 40
    + -
    + newMT := &L1InfoTree{
    - 2047 + 41
    + - p := pool.NewPool(cfg, bc, s, nil, uint64(1), nil) + zeroHashes: generateZeroHashes(32), // nolint:gomnd
    - 2048 + 42
    + -
    + height: 32, // nolint:gomnd
    - 2049 + 43
    + - randAddr := func() common.Address { + count: uint32(len(initialLeaves)),
    - 2050 + 44
    + - buf := make([]byte, 20) + }
    - 2051 + 45
    + - _, err = rand.Read(buf) + var err error
    - 2052 + 46
    + - require.NoError(t, err) + newMT.siblings, newMT.currentRoot, err = newMT.initSiblings(initialLeaves)
    - 2053 + 47
    + - return common.BytesToAddress(buf) + if err != nil {
    - 2054 + 48
    + - } + log.Error("error initializing siblings. Error: ", err)
    - 2055 + 49
    + -
    + return nil, err
    - 2056 + 50
    + - // Policies start out as deny lists, since there are no addresses on the + }
    - 2057 + 51
    + - // lists, random addresses will always be allowed + log.Debug("Reset initial count: ", newMT.count)
    - 2058 + 52
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + log.Debug("Reset initial root: ", newMT.currentRoot)
    - 2059 + 53
    + - allow, err := p.CheckPolicy(ctx, policy, randAddr()) + return newMT, nil
    - 2060 + 54
    + - require.NoError(t, err) + }
    - 2061 + 55
    + - require.True(t, allow) +
    - 2062 + + 56 +
    - + - } +   + func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) {
    - 2063 + + 57 +
    - + -
    +   + var (
    - 2064 + + 58 +
    - + - addr := randAddr() +   + nodes [][][]byte +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -2,21 +2,12 @@
    - 2065 + + 2 +
    - + +  
    - 2066 + + 3 +
    - + - // put addr on lists +   + import (
    - 2067 + + 4 +
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +   + "bytes"
    - 2068 + + 5 +
    - + - ctag, err := poolSqlDB.Exec(ctx, "INSERT INTO pool.acl (policy, address) VALUES ($1,$2)", policy, addr.Hex()) + - + "errors"
    - 2069 + + 6 +
    - + - require.NoError(t, err) +   + "math/big"
    - 2070 + + 7 +
    - + - require.Equal(t, int64(1), ctag.RowsAffected()) +   +
    - 2071 + + 8 +
    - + - } +   + "github.com/0xPolygonHermez/zkevm-node/log"
    - 2072 + + 9 +
    - + -
    +   + "github.com/0xPolygonHermez/zkevm-node/state"
    - 2073 + + 10 +
    - + - // addr should not be denied by policy +   + )
    - 2074 + + 11 +
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +   +
    - 2075 + + 12 +
    - + - allow, err := p.CheckPolicy(ctx, policy, addr) + - + var (
    - 2076 + + 13 +
    - + - require.NoError(t, err) + - + // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero
    - 2077 + + 14 +
    - + - require.False(t, allow) + - + ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero")
    - 2078 + + 15 +
    - + - } + - +
    - 2079 + + 16 +
    - + -
    + - + // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero
    - 2080 + + 17 +
    - + - // change policies to allow by acl + - + ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero")
    - 2081 + + 18 +
    - + - ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true") + - + )
    - 2082 + + 19 +
    - + - require.NoError(t, err) + - +
    - 2083 + + 20 +
    - + - require.Equal(t, int64(2), ctag.RowsAffected()) +   + // EffectiveGasPrice implements the effective gas prices calculations and checks
    - 2084 + + 21 +
    - + -
    +   + type EffectiveGasPrice struct {
    - 2085 + + 22 +
    - + - // addr is now allowed +   + cfg EffectiveGasPriceCfg
    - 2086 + +
    @@ -122,33 +113,8 @@
    +
    + 122 +
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +   + bfEffectiveGasPrice.Int(effectiveGasPrice)
    - 2087 + + 123 +
    - + - allow, err := p.CheckPolicy(ctx, policy, addr) +   +
    - 2088 + + 124 +
    - + - require.NoError(t, err) +   + if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 {
    - 2089 + + 125 +
    - + - require.True(t, allow) + - + return nil, ErrEffectiveGasPriceIsZero
    - 2090 + + 126 +
    - + +   }
    - 2091 + + 127 +
    - + +  
    - 2092 + + 128 +
    - + - // random addrs are now denied +   + return effectiveGasPrice, nil
    - 2093 + + 129 +
    - + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +   + }
    - 2094 + + 130 +
    - + - for _, a := range []common.Address{randAddr(), randAddr()} { + - +
    - 2095 + + 131 +
    - + - allow, err := s.CheckPolicy(ctx, policy, a) + - + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 2096 + + 132 +
    - + - require.NoError(t, err) + - + func (e *EffectiveGasPrice) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 2097 + + 133 +
    - + - require.False(t, allow) + - + const bits = 256
    - 2098 + + 134 +
    - + - } + - + var bitsBigInt = big.NewInt(bits)
    - 2099 + + 135 +
    - + - } + - +
    - 2100 + + 136 +
    - + - } -
    -
    -
    + - + if effectiveGasPrice == nil || gasPrice == nil ||
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -292,6 +292,7 @@
    - 292 + + 137 +
    -   - // prior to executing the call. + - + gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 {
    - 293 + + 138 +
    -   - map<string, OverrideAccountV2> state_override = 23; + - + return 0, ErrEffectiveGasPriceEmpty
    - 294 + + 139 +
    -   - DebugV2 debug = 24; + - + }
    - + + 140 -
    -   +
    +
    + -
    - 295 + + 141 +
    -   - } + - + if gasPrice.Cmp(effectiveGasPrice) <= 0 {
    - 296 + + 142 +
    -   -
    + - + return state.MaxEffectivePercentage, nil
    - 297 + + 143 +
    -   - message L1DataV2 { + - + }
    -
    -
    -
    -
    - - - - - + + - - - - - - - - - - - - + + + + + + - - + + + @@ -89204,21 +90483,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    + 144 + +
    + - +
    +
    - 292 + + 145 +
    -   - // prior to executing the call. + - + // Simulate Ceil with integer division
    - 293 + + 146 +
    -   - map<string, OverrideAccountV2> state_override = 23; + - + b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt)
    - 294 + + 147 +
    -   - DebugV2 debug = 24; + - + b = b.Add(b, gasPrice)
    - 295 + + 148 +
    - + - uint64 execution_mode = 25; + - + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd
    - 296 + + 149 +
    -   - } + - + b = b.Div(b, gasPrice)
    - 297 + + 150 +
    -   + - + // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) +
    +
    + 151 + +
    + - + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    + 152 + +
    + -
    - 298 + + 153 +
    -   - message L1DataV2 { + - + return uint8(b.Uint64()), nil +
    +
    + 154 + +
    + - + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - RENAMED - -
    -
    @@ -89226,36 +90490,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -89269,21 +90533,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - + + + + + + + + + - - - - + + + + + + @@ -89484,68 +90808,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -89559,482 +90888,576 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - + + + + + + + + + + + + + +
    -
    @@ -224,6 +224,17 @@
    +
     
    - 224 + 2
      - firstL1InfoRootUpdate := true +
    - 225 + 3
      - skipFirstSleep := true + import (
    - 226 + 4
      -
    + "bytes"
    - + + 5 -
    +
    +
    +   + "math/big" +
    +
    + 6 + +
     
    - + + 7 -
    +
    +
    +   + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 8 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
     
    @@ -89370,97 +90674,117 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 227 + 11
      - for { + // EffectiveGasPrice implements the effective gas prices calculations and checks
    - 228 + 12
      - if skipFirstSleep { + type EffectiveGasPrice struct {
    - 229 + 13
      - skipFirstSleep = false + cfg EffectiveGasPriceCfg
    -
    @@ -271,9 +282,11 @@
    +
     
    - 271 + 113
      - continue + bfEffectiveGasPrice.Int(effectiveGasPrice)
    - 272 + 114
      - } +
    - 273 + 115
      - if l1BlockState.BlockHash != l1BlockEth.Hash() { + if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 {
    - 274 + + 116 +
    - - - log.Warnf("skipping use of l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?)", + + + return nil, state.ErrEffectiveGasPriceIsZero
    - 275 + 117
      - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) + }
    - 276 + + 118 +
    - - - continue +   +
    +
    +
    + 119 + +
    +   + return effectiveGasPrice, nil +
    +
    + 120 + +
    +   + }
    - 277 + + -
    +
    +
      - } +
    - 278 + + -
    +
    +
      - } +
    - 279 + + -
    +
    +
     
    -
    @@ -390,6 +403,7 @@
    +
    + + +
    +   +
    +
    - 390 + + -
    +
    +
      - SkipWriteBlockInfoRoot_V2: true, +
    - 391 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 392 + + -
    +
    +
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, +
    - 393 + + -
    +
    +
      - } +
    - 394 + + -
    +
    +
     
    - 395 + + -
    +
    +
      - txGasPrice := tx.GasPrice +
    -
    @@ -436,7 +450,7 @@
    +
    + + +
    +   +
    +
    - 436 + + -
    +
    +
      - } +
    - 437 + + -
    +
    +
      - } +
    - 438 + + -
    +
    +
     
    - 439 + + -
    - - - egpPercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) +
    +
    +   +
    - 440 + + -
    +
    +
      - if err != nil { +
    - 441 + + -
    +
    +
      - if f.effectiveGasPrice.IsEnabled() { +
    - 442 + + -
    +
    +
      - return nil, err +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice_test.go + RENAMED + +
    +
    +
    +
    + + + - - + + + - - -
    -
    @@ -549,7 +563,7 @@
    +
    @@ -23,8 +24,6 @@
    - 549 + 23
      -
    + )
    - 550 + 24
      - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging +
    - 551 + 25
      - if !egpEnabled { + func TestCalculateEffectiveGasPricePercentage(t *testing.T) {
    - 552 + + 26 +
    - - effectivePercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) + egp := NewEffectiveGasPrice(egpCfg) +
    +
    + 27 + +
    + - +
    - 553 + 28
      - if err != nil { + testCases := []struct {
    - 554 + 29
      - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) + name string
    - 555 + 30
      - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) + breakEven *big.Int
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - + + + - - + + + +
    -
     
    +
    @@ -37,14 +36,14 @@
    - 224 + 37
      - firstL1InfoRootUpdate := true + name: "Nil breakEven or gasPrice",
    - 225 + 38
      - skipFirstSleep := true + gasPrice: big.NewInt(1),
    - 226 + 39
      -
    + expectedValue: uint8(0),
    - 227 + + 40 +
    - + - if f.cfg.L1InfoTreeCheckInterval.Duration.Seconds() == 999999 { //nolint:gomnd + - + err: ErrEffectiveGasPriceEmpty,
    - 228 + + 41 +
    - + - if !f.lastL1InfoTreeValid { +   + },
    - 229 + + 42 +
    - + - f.lastL1InfoTreeCond.L.Lock() +   + {
    - 230 + + 43 +
    - + - f.lastL1InfoTreeValid = true +   + name: "Zero breakEven or gasPrice",
    - 231 + + 44 +
    - + - f.lastL1InfoTreeCond.Broadcast() +   + breakEven: big.NewInt(1),
    - 232 + + 45 +
    - + - f.lastL1InfoTreeCond.L.Unlock() +   + gasPrice: big.NewInt(0),
    - 233 + + 46 +
    - + - } +   + expectedValue: uint8(0),
    - 234 + + 47 +
    - + -
    + - + err: ErrEffectiveGasPriceEmpty,
    - 235 + + 48 +
    - + - return +   + },
    - 236 + + 49 +
    - + - } +   + {
    - 237 + + 50 +
    - + -
    +   + name: "Both positive, gasPrice less than breakEven",
    +
    @@ -104,7 +103,7 @@
    +
    - 238 + 104
      - for { +
    - 239 + 105
      - if skipFirstSleep { + for _, tc := range testCases {
    - 240 + 106
      - skipFirstSleep = false + t.Run(tc.name, func(t *testing.T) {
    -
     
    +
    + 107 + +
    + - + actual, err := egp.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven) +
    - 282 + 108
      - continue + assert.Equal(t, tc.err, err)
    - 283 + 109
      - } + if actual != 0 {
    - 284 + 110
      - if l1BlockState.BlockHash != l1BlockEth.Hash() { + assert.Equal(t, tc.expectedValue, actual) +
    +
    +
    +
    +
    + + + + + - - - - - - - - @@ -90044,147 +91467,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - @@ -90194,7 +91612,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -90269,12 +91687,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go RENAMED
    @@ -90332,68 +91750,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - @@ -90407,33 +91810,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -90452,147 +91855,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - @@ -90602,12 +91990,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go RENAMED
    - - - @@ -90674,30 +92052,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - - - -
    +
     
    - 285 + + 24 +
    - + - warnmsg := fmt.Sprintf("invalid l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?). Stopping syncing l1IntroTreeIndex", +   + )
    - 286 + 25
      - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) +
    - 287 + + 26 +
    - + - log.Warn(warnmsg) +   + func TestCalculateEffectiveGasPricePercentage(t *testing.T) {
    - 288 + + -
    - + - f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) +
    +
    +   +
    - 289 + + -
    - + - return +
    +
    +   +
    - 290 + 27
      - } + testCases := []struct {
    - 291 + 28
      - } + name string
    - 292 + 29
      -
    + breakEven *big.Int
    - 403 + 36
      - SkipWriteBlockInfoRoot_V2: true, + name: "Nil breakEven or gasPrice",
    - 404 + 37
      - SkipVerifyL1InfoRoot_V2: true, + gasPrice: big.NewInt(1),
    - 405 + 38
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + expectedValue: uint8(0),
    - 406 + + 39 +
    + - ExecutionMode: executor.ExecutionMode0, + err: state.ErrEffectiveGasPriceEmpty,
    - 407 + 40
      - } + },
    - 408 + 41
      -
    + {
    - 409 + 42
      - txGasPrice := tx.GasPrice + name: "Zero breakEven or gasPrice",
    -
     
    -
    - 450 + 43
      - } + breakEven: big.NewInt(1),
    - 451 + 44
      - } + gasPrice: big.NewInt(0),
    - 452 + 45
      -
    + expectedValue: uint8(0),
    - 453 + 46
    + - egpPercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) + err: state.ErrEffectiveGasPriceEmpty,
    - 454 + 47
      - if err != nil { + },
    - 455 + 48
      - if f.effectiveGasPrice.IsEnabled() { + {
    - 456 + 49
      - return nil, err + name: "Both positive, gasPrice less than breakEven",
    - 563 + 103
    @@ -90204,62 +91622,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 564 + 104
      - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging + for _, tc := range testCases {
    - 565 + 105
      - if !egpEnabled { + t.Run(tc.name, func(t *testing.T) {
    - 566 + 106
    + - effectivePercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) + actual, err := state.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven)
    - 567 + 107
      - if err != nil { + assert.Equal(t, tc.err, err)
    - 568 + 108
      - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) + if actual != 0 {
    - 569 + 109
      - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) + assert.Equal(t, tc.expectedValue, actual)
    -
    @@ -283,6 +284,7 @@
    +
    @@ -76,4 +76,13 @@
    - 283 + 76
      - ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber), +
    - 284 + 77
      - SkipVerifyL1InfoRoot_V2: true, + // ErrZeroL1GasPrice is returned if the L1 gas price is 0.
    - 285 + 78
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + ErrZeroL1GasPrice = errors.New("L1 gas price 0")
    - 286 - -
    -   - } -
    -
    - 287 + + -
    +
    +
      - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ +
    - 288 + + -
    +
    +
      - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, +
    -
    @@ -582,6 +584,7 @@
    -
    - 582 + + -
    +
    +
      - SkipFirstChangeL2Block_V2: false, +
    - 583 + + -
    +
    +
      - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), +
    - 584 + + -
    +
    +
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, +
    - 585 + + -
    +
    +
      - } +
    - 586 + + -
    +
    +
     
    - 587 + 79
      - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + )
    - 284 + 76
      - ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber), +
    - 285 + 77
      - SkipVerifyL1InfoRoot_V2: true, + // ErrZeroL1GasPrice is returned if the L1 gas price is 0.
    - 286 + 78
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + ErrZeroL1GasPrice = errors.New("L1 gas price 0")
    - 287 + 79
    + - ExecutionMode: executor.ExecutionMode0, +
    - 288 + + 80 +
    -   - } + + + // ErrSenderDisallowedSendTx is returned when transactions by sender are is disallowed by policy
    - 289 + + 81 +
    -   - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + + + ErrSenderDisallowedSendTx = errors.New("sender disallowed send_tx by policy")
    - 290 - -
    -   - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, -
    -
    -
     
    -
    - 584 + + 82 +
    -   - SkipFirstChangeL2Block_V2: false, + + +
    - 585 + + 83 +
    -   - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), + + + // ErrContractDisallowedSendTx is returned when transactions to contract are is disallowed by policy
    - 586 + + 84 +
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + + + ErrContractDisallowedSendTx = errors.New("contract disallowed send_tx by policy")
    - 587 + 85
    + - ExecutionMode: executor.ExecutionMode0, +
    - 588 + + 86 +
    -   - } + + + // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy
    - 589 + + 87 +
    -   -
    + + + ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy")
    - 590 + 88
      - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + )
    -
    @@ -41,4 +41,6 @@
    +
    @@ -38,6 +38,7 @@
    - 41 + 38
      - // gas offset: 100 + MarkWIPTxsAsPending(ctx context.Context) error
    - 42 + 39
      - // final gas: 1100 + GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
    - 43 + 40
      - GasOffset uint64 `mapstructure:"GasOffset"` -
    -
    - - -
    -   -
    + MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
    - 44 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - @@ -90715,7 +92069,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -90725,181 +92079,92 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - -
    -
     
    -
    41 @@ -90705,7 +92059,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - // gas offset: 100 + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
      - // final gas: 1100 + }
      - GasOffset uint64 `mapstructure:"GasOffset"` -
    -
    - 44 - -
    - + - // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx -
    -
    - 45 - -
    - + - MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"` +
    - 46 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - @@ -90958,82 +92223,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - @@ -91043,27 +92298,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -91316,103 +92616,103 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - @@ -91426,78 +92726,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - @@ -91541,23 +92836,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -91571,1267 +92866,1118 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -17,8 +17,8 @@
    -
    - 17 - -
    -   -
    -
    +
    @@ -48,3 +49,12 @@
    - 18 + 48
      - // etherman contains the methods required to interact with ethereum. + GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
    - 19 + 49
      - type etherman interface { -
    -
    - 20 - -
    - - - BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) -
    -
    - 21 - -
    - - - EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) + PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
    - 22 + 50
      - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) + }
    - 23 + + -
    +
    +
      - GetLatestBatchNumber() (uint64, error) +
    - 24 + + -
    +
    +
      - } +
    -
    @@ -41,3 +41,7 @@
    -
    - 41 + + -
    +
    +
      - Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error +
    - 42 + + -
    +
    +
      - ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx) +
    - 43 + + -
    +
    +
      - } +
    - 17 + 38
      -
    + MarkWIPTxsAsPending(ctx context.Context) error
    - 18 + 39
      - // etherman contains the methods required to interact with ethereum. + GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
    - 19 + 40
      - type etherman interface { -
    -
    - 20 - -
    - + - BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error) + MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
    - 21 + + 41 +
    + - EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (*types.Transaction, error) + policy
    - 22 + 42
      - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
    - 23 + 43
      - GetLatestBatchNumber() (uint64, error) + }
    - 24 + 44
      - } +
    - 41 + 49
      - Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error + GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
    - 42 + 50
      - ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx) + PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
    - 43 + 51
    @@ -91073,37 +92328,87 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 44 + 52
    + -
    + type policy interface {
    - 45 + 53
    + - type dataAbilitier interface { + CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error)
    - 46 + 54
    + - PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error) + AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error
    - 47 + 55 + +
    + + + RemoveAddressesFromPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error +
    +
    + 56 + +
    + + + ClearPolicy(ctx context.Context, policy PolicyName) error +
    +
    + 57 + +
    + + + DescribePolicies(ctx context.Context) ([]Policy, error) +
    +
    + 58 + +
    + + + DescribePolicy(ctx context.Context, name PolicyName) (Policy, error) +
    +
    + 59 + +
    + + + ListAcl(ctx context.Context, policy PolicyName, query []common.Address) ([]common.Address, error) +
    +
    + 60
    @@ -91118,12 +92423,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go RENAMED
    -
    @@ -6,13 +6,11 @@
    +
    @@ -0,0 +1,202 @@
    - 6 + + -
    +
    +
      - "fmt" +
    - 7 + + -
    +
    +
      - "time" +
    - 8 + + -
    +
    +
     
    - 9 + + -
    - - - ethman "github.com/0xPolygonHermez/zkevm-node/etherman" +
    +
    +   +
    - 10 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/etherman/types" +
    - 11 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/ethtxmanager" +
    - 12 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/event" +
    - 13 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    - 14 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/state" +
    - 15 + + -
    - - - ethTypes "github.com/ethereum/go-ethereum/core/types" +
    +
    +   +
    - 16 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 17 + + -
    +
    +
      - ) +
    - 18 + + -
    +
    +
     
    -
    @@ -41,16 +39,18 @@
    -
    - 41 + + -
    +
    +
      - ethTxManager ethTxManager +
    - 42 + + -
    +
    +
      - etherman etherman +
    - 43 + + -
    +
    +
      - eventLog *event.EventLog +
    - 44 + + -
    +
    +
      - } +
    - 45 + + -
    +
    +
     
    - 46 + + -
    +
    +
      - // New inits sequence sender +
    - 47 + + -
    - - - func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*SequenceSender, error) { +
    +
    +   +
    - 48 + + -
    +
    +
      - return &SequenceSender{ +
    - 49 + + -
    +
    +
      - cfg: cfg, +
    - 50 + + -
    +
    +
      - state: state, +
    - 51 + + -
    +
    +
      - etherman: etherman, +
    - 52 + + -
    +
    +
      - ethTxManager: manager, +
    - 53 + + -
    +
    +
      - eventLog: eventLog, +
    - 54 + + -
    +
    +
      - }, nil +
    - 55 + + -
    +
    +
      - } +
    - 56 + + -
    +
    +
     
    -
    @@ -185,9 +185,14 @@
    -
    - 185 + + -
    +
    +
      - } +
    - 186 + + -
    +
    +
     
    - 187 + + -
    +
    +
      - // add sequence to be monitored +
    - 188 + + -
    - - - firstSequence := sequences[0] +
    +
    +   +
    - 189 + + -
    +
    +
     
    - 190 + + -
    - - - to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 191 + + -
    +
    +
      - if err != nil { +
    - 192 + + -
    +
    +
      - log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err) +
    - 193 + + -
    +
    +
      - return +
    -
    @@ -218,8 +223,6 @@
    -
    - 218 + + -
    +
    +
      - sequences := []types.Sequence{} +
    - 219 + + -
    +
    +
      - // var estimatedGas uint64 +
    - 220 + + -
    +
    +
     
    - 221 + + -
    - - - var tx *ethTypes.Transaction +
    +
    +   +
    - 222 + + -
    - - +
    +
    +  
    - 223 + + -
    +
    +
      - // Add sequences until too big for a single L1 tx or last batch is reached +
    - 224 + + -
    +
    +
      - for { +
    - 225 + + -
    +
    +
      - //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to +
    -
    @@ -288,31 +291,11 @@
    +
    + + +
    +   +
    +
    - 288 + + -
    +
    +
     
    - 289 + + -
    +
    +
      - sequences = append(sequences, seq) +
    - 290 + + -
    +
    +
      - // Check if can be send +
    - 291 + + -
    - - - firstSequence := sequences[0] +
    +
    +   +
    - 292 + + -
    - - - lastSequence := sequences[len(sequences)-1] +
    +
    +   +
    - 293 + + -
    - - - tx, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 294 + + -
    - - - if err == nil && tx.Size() > s.cfg.MaxTxSizeForL1 { +
    +
    +   +
    - 295 + + -
    - - - log.Infof("oversized Data on TX oldHash %s (txSize %d > %d)", tx.Hash(), tx.Size(), s.cfg.MaxTxSizeForL1) +
    +
    +   +
    - 296 + + -
    - - - err = ErrOversizedData +
    +
    +   +
    - 297 + + -
    - - - } +
    +
    +   +
    - 298 + + -
    - - - if err != nil { +
    +
    +   +
    - 299 + + -
    - - - log.Infof("Handling estimage gas send sequence error: %v", err) +
    +
    +   +
    - 300 + + -
    - - - sequences, err = s.handleEstimateGasSendSequenceErr(ctx, sequences, currentBatchNumToSequence, err) +
    +
    +   +
    - 301 + + -
    - - - if sequences != nil { +
    +
    +   +
    - 302 + + -
    - - - if len(sequences) > 0 { +
    +
    +   +
    - 303 + + -
    - - - // Handling the error gracefully, re-processing the sequence as a sanity check +
    +
    +   +
    - 304 + + -
    - - - lastSequence = sequences[len(sequences)-1] +
    +
    +   +
    - 305 + + -
    - - - _, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 306 + + -
    - - - return sequences, err +
    +
    +   +
    - 307 + + -
    - - - } +
    +
    +   +
    - 308 + + -
    - - - } +
    +
    +   +
    - 309 + + -
    - - - return sequences, err +
    +
    +   +
    - 310 + + -
    - - - } +
    +
    +   +
    - 311 + + -
    - - - // estimatedGas = tx.Gas() +
    +
    +   +
    - 312 + + -
    - - +
    +
    +  
    - 313 + + -
    - - - //Check if the current batch is the last before a change to a new forkid, in this case we need to close and send the sequence to L1 +
    +
    +   +
    - 314 + + -
    - - - if (s.cfg.ForkUpgradeBatchNumber != 0) && (currentBatchNumToSequence == (s.cfg.ForkUpgradeBatchNumber)) { +
    +
    +   +
    - 315 + + -
    - - - log.Infof("sequence should be sent to L1, as we have reached the batch %d from which a new forkid is applied (upgrade)", s.cfg.ForkUpgradeBatchNumber) +
    +
    +   +
    - 316 + + -
    +
    +
      - return sequences, nil +
    - 317 + + -
    +
    +
      - } +
    - 318 + + -
    +
    +
     
    -
    @@ -343,78 +326,6 @@
    +
    + + +
    +   +
    +
    - 343 + + -
    +
    +
      - return nil, nil +
    - 344 + + -
    +
    +
      - } +
    - 345 + + -
    +
    +
     
    - 346 + + -
    - - - // handleEstimateGasSendSequenceErr handles an error on the estimate gas. It will return: +
    +
    +   +
    - 347 + + -
    - - - // nil, error: impossible to handle gracefully +
    +
    +   +
    - 348 + + -
    - - - // sequence, nil: handled gracefully. Potentially manipulating the sequences +
    +
    +   +
    - 349 + + -
    - - - // nil, nil: a situation that requires waiting +
    +
    +   +
    - 350 + + -
    - - - func (s *SequenceSender) handleEstimateGasSendSequenceErr( +
    +
    +   +
    - 351 + + -
    - - - ctx context.Context, +
    +
    +   +
    - 352 + + -
    - - - sequences []types.Sequence, +
    +
    +   +
    - 353 + + -
    - - - currentBatchNumToSequence uint64, +
    +
    +   +
    - 354 + + -
    - - - err error, +
    +
    +   +
    - 355 + + -
    - - - ) ([]types.Sequence, error) { +
    +
    +   +
    - 356 + + -
    - - - // Insufficient allowance +
    +
    +   +
    - 357 + + -
    - - - if errors.Is(err, ethman.ErrInsufficientAllowance) { +
    +
    +   +
    - 358 + + -
    - - - return nil, err +
    +
    +   +
    - 359 + + -
    - - - } +
    +
    +   +
    - 360 + + -
    - - - if isDataForEthTxTooBig(err) { +
    +
    +   +
    - 361 + + -
    - - - // Remove the latest item and send the sequences +
    +
    +   +
    - 362 + + -
    - - - log.Infof( +
    +
    +   +
    - 363 + + -
    - - - "Done building sequences, selected batches to %d. Batch %d caused the L1 tx to be too big", +
    +
    +   +
    - 364 + + -
    - - - currentBatchNumToSequence-1, currentBatchNumToSequence, +
    +
    +   +
    - 365 + + -
    - - - ) +
    +
    +   +
    - 366 + + -
    - - - sequences = sequences[:len(sequences)-1] +
    +
    +   +
    - 367 + + -
    - - - return sequences, nil +
    +
    +   +
    - 368 + + -
    - - - } +
    +
    +   +
    - 369 + + -
    - - +
    +
    +  
    - 370 + + -
    - - - // while estimating gas a new block is not created and the POE SC may return +
    +
    +   +
    - 371 + + -
    - - - // an error regarding timestamp verification, this must be handled +
    +
    +   +
    - 372 + + -
    - - - // if errors.Is(err, ethman.ErrTimestampMustBeInsideRange) { +
    +
    +   +
    - 373 + + -
    - - - // // query the sc about the value of its lastTimestamp variable +
    +
    +   +
    - 374 + + -
    - - - // lastTimestamp, err := s.etherman.GetLastBatchTimestamp() +
    +
    +   +
    - 375 + + -
    - - - // if err != nil { +
    +
    +   +
    - 376 + + -
    - - - // return nil, err +
    +
    +   +
    - 377 + + -
    - - - // } +
    +
    +   +
    - 378 + + -
    - - - // // check POE SC lastTimestamp against sequences' one +
    +
    +   +
    - 379 + + -
    - - - // for _, seq := range sequences { +
    +
    +   +
    - 380 + + -
    - - - // if seq.Timestamp < int64(lastTimestamp) { +
    +
    +   +
    - 381 + + -
    - - - // // TODO: gracefully handle this situation by creating an L2 reorg +
    +
    +   +
    - 382 + + -
    - - - // log.Fatalf("sequence timestamp %d is < POE SC lastTimestamp %d", seq.Timestamp, lastTimestamp) +
    +
    +   +
    - 383 + + -
    - - - // } +
    +
    +   +
    - 384 + + -
    - - - // lastTimestamp = uint64(seq.Timestamp) +
    +
    +   +
    - 385 + + -
    - - - // } +
    +
    +   +
    - 386 + + -
    - - - // blockTimestamp, err := s.etherman.GetLatestBlockTimestamp(ctx) +
    +
    +   +
    - 387 + + -
    - - - // if err != nil { +
    +
    +   +
    - 388 + + -
    - - - // log.Error("error getting block timestamp: ", err) +
    +
    +   +
    - 389 + + -
    - - - // } +
    +
    +   +
    - 390 + + -
    - - - // log.Debugf("block.timestamp: %d is smaller than seq.Timestamp: %d. A new block must be mined in L1 before the gas can be estimated.", blockTimestamp, sequences[0].Timestamp) +
    +
    +   +
    - 391 + + -
    - - - // return nil, nil +
    +
    +   +
    - 392 + + -
    - - - // } +
    +
    +   +
    - 393 + + -
    - - +
    +
    +  
    - 394 + + -
    - - - // Unknown error +
    +
    +   +
    - 395 + + -
    - - - if len(sequences) == 1 { +
    +
    +   +
    - 396 + + -
    - - - // TODO: gracefully handle this situation by creating an L2 reorg +
    +
    +   +
    - 397 + + -
    - - - log.Errorf( +
    +
    +   +
    - 398 + + -
    - - - "Error when estimating gas for BatchNum %d (alone in the sequences): %v", +
    +
    +   +
    - 399 + + -
    - - - currentBatchNumToSequence, err, +
    +
    +   +
    - 400 + + -
    - - - ) +
    +
    +   +
    - 401 + + -
    - - - } +
    +
    +   +
    - 402 + + -
    - - - // Remove the latest item and send the sequences +
    +
    +   +
    - 403 + + -
    - - - log.Infof( +
    +
    +   +
    - 404 + + -
    - - - "Done building sequences, selected batches to %d. Batch %d excluded due to unknown error: %v", +
    +
    +   +
    - 405 + + -
    - - - currentBatchNumToSequence, currentBatchNumToSequence+1, err, +
    +
    +   +
    - 406 + + -
    - - - ) +
    +
    +   +
    - 407 + + -
    - - - sequences = sequences[:len(sequences)-1] +
    +
    +   +
    - 408 + + -
    - - +
    +
    +  
    - 409 + + -
    - - - return sequences, nil +
    +
    +   +
    - 410 - -
    - - - } -
    -
    - 411 - -
    - - -
    -
    -
    - 412 - -
    - - - func isDataForEthTxTooBig(err error) bool { -
    -
    - 413 - -
    - - - return errors.Is(err, ethman.ErrGasRequiredExceedsAllowance) || -
    -
    - 414 - -
    - - - errors.Is(err, ErrOversizedData) || -
    -
    - 415 - -
    - - - errors.Is(err, ethman.ErrContentLengthTooLarge) -
    -
    - 416 - -
    - - - } -
    -
    - 417 - -
    - - -
    -
    -
    - 418 - -
    -   - func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { -
    -
    - 419 - -
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) -
    -
    - 420 - -
    -   - if err != nil && err != state.ErrNotFound { -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    -
    - 6 - -
    -   - "fmt" -
    -
    - 7 - -
    -   - "time" -
    -
    - 8 - -
    -   -
    -
    -
    - + +
    @@ -92839,56 +93985,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 9 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman/types" -
    -
    - 10 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/ethtxmanager" -
    -
    - 11 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/event" -
    -
    - 12 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 13 - -
    -   - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    @@ -92899,401 +93995,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 14 - -
    -   - "github.com/jackc/pgx/v4" -
    -
    - 15 - -
    -   - ) -
    -
    - 16 - -
    -   -
    -
    -
    -
     
    -
    - 39 - -
    -   - ethTxManager ethTxManager -
    -
    - 40 - -
    -   - etherman etherman -
    -
    - 41 - -
    -   - eventLog *event.EventLog -
    -
    - 42 - -
    - + - da dataAbilitier -
    -
    - 43 - -
    -   - } -
    -
    - 44 - -
    -   -
    -
    -
    - 45 - -
    -   - // New inits sequence sender -
    -
    - 46 - -
    - + - func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog, da dataAbilitier) (*SequenceSender, error) { -
    -
    - 47 - -
    -   - return &SequenceSender{ -
    -
    - 48 - -
    -   - cfg: cfg, -
    -
    - 49 - -
    -   - state: state, -
    -
    - 50 - -
    -   - etherman: etherman, -
    -
    - 51 - -
    -   - ethTxManager: manager, -
    -
    - 52 - -
    -   - eventLog: eventLog, -
    -
    - 53 - -
    - + - da: da, -
    -
    - 54 - -
    -   - }, nil -
    -
    - 55 - -
    -   - } -
    -
    - 56 - -
    -   -
    -
    -
    -
     
    -
    - 185 - -
    -   - } -
    -
    - 186 - -
    -   -
    -
    -
    - 187 - -
    -   - // add sequence to be monitored -
    -
    - 188 - -
    - + - dataAvailabilityMessage, err := s.da.PostSequence(ctx, sequences) -
    -
    - 189 - -
    - + - if err != nil { -
    -
    - 190 - -
    - + - log.Error("error posting sequences to the data availability protocol: ", err) -
    -
    - 191 - -
    - + - return -
    -
    - 192 - -
    - + - } -
    -
    - 193 - -
    -   -
    -
    -
    - 194 - -
    - + - firstSequence := sequences[0] -
    -
    - 195 - -
    - + - to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase, dataAvailabilityMessage) -
    -
    - 196 - -
    -   - if err != nil { -
    -
    - 197 - -
    -   - log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err) -
    -
    - 198 - -
    -   - return -
    -
    -
     
    -
    - 223 - -
    -   - sequences := []types.Sequence{} -
    -
    - 224 - -
    -   - // var estimatedGas uint64 -
    -
    - 225 - -
    -   -
    -
    -
    @@ -93314,121 +94015,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 226 - -
    -   - // Add sequences until too big for a single L1 tx or last batch is reached -
    -
    - 227 - -
    -   - for { -
    -
    - 228 - -
    -   - //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to -
    -
    -
     
    -
    - 291 - -
    -   -
    -
    -
    - 292 - -
    -   - sequences = append(sequences, seq) -
    -
    - 293 - -
    -   - // Check if can be send -
    -
    - 294 - -
    - + - if len(sequences) == int(s.cfg.MaxBatchesForL1) { -
    -
    - 295 - -
    - + - log.Info( -
    -
    - 296 - -
    - + - "sequence should be sent to L1, because MaxBatchesForL1 (%d) has been reached", -
    -
    - 297 - -
    - + - s.cfg.MaxBatchesForL1, -
    -
    - 298 - -
    - + - ) -
    -
    @@ -93629,71 +94215,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 299 - -
    -   - return sequences, nil -
    -
    - 300 - -
    -   - } -
    -
    - 301 - -
    -   -
    -
    -
    -
     
    -
    - 326 - -
    -   - return nil, nil -
    -
    - 327 - -
    -   - } -
    -
    - 328 - -
    -   -
    -
    -
    @@ -93944,1353 +94465,2038 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - + + 1 -
    -   -
    +
    +
    + + + package pgpoolstorage
    - + + 2 -
    -   +
    +
    + +
    - + + 3 -
    -   -
    +
    +
    + + + import (
    - + + 4 -
    -   -
    +
    +
    + + + "context"
    - + + 5 -
    -   -
    +
    +
    + + + "errors"
    - + + 6 -
    -   -
    +
    +
    + + + "fmt"
    - + + 7 -
    -   -
    +
    +
    + + + "strings"
    - + + 8 -
    -   +
    +
    + +
    - + + 9 -
    -   -
    +
    +
    + + + "github.com/0xPolygonHermez/zkevm-node/pool"
    - + + 10 -
    -   -
    +
    +
    + + + "github.com/ethereum/go-ethereum/common"
    - + + 11 -
    -   -
    +
    +
    + + + "github.com/jackc/pgx/v4"
    - + + 12 -
    -   -
    +
    +
    + + + )
    - + + 13 -
    -   +
    +
    + +
    - + + 14 -
    -   -
    +
    +
    + + + // CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule
    - + + 15 -
    -   -
    +
    +
    + + + // will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of
    - + + 16 -
    -   -
    +
    +
    + + + // the policy setting.
    - + + 17 -
    -   -
    +
    +
    + + + func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) {
    - + + 18 -
    -   -
    +
    +
    + + + sql := `SELECT
    - + + 19 -
    -   -
    +
    +
    + + + CASE WHEN a.address is null THEN
    - + + 20 -
    -   -
    +
    +
    + + + NOT p.allow
    - + + 21 -
    -   -
    +
    +
    + + + ELSE
    - + + 22 -
    -   -
    +
    +
    + + + p.allow
    - + + 23 -
    -   -
    +
    +
    + + + END
    - + + 24 -
    -   -
    +
    +
    + + + FROM pool.policy p
    - + + 25 -
    -   -
    +
    +
    + + + LEFT JOIN pool.acl a
    - + + 26 -
    -   -
    +
    +
    + + + ON p.name = a.policy
    - + + 27 -
    -   -
    +
    +
    + + + AND a.address = $1
    - + + 28 -
    -   -
    +
    +
    + + + WHERE p.name = $2`
    - + + 29 -
    -   +
    +
    + +
    - + + 30 -
    -   -
    +
    +
    + + + rows, err := p.db.Query(ctx, sql, address.Hex(), policy)
    - + + 31 -
    -   +
    +
    + +
    - + + 32 -
    -   -
    +
    +
    + + + if errors.Is(err, pgx.ErrNoRows) {
    - + + 33 -
    -   -
    +
    +
    + + + return false, pool.ErrNotFound
    - + + 34 -
    -   -
    +
    +
    + + + } else if err != nil {
    - + + 35 -
    -   -
    +
    +
    + + + return false, err
    - + + 36 -
    -   -
    +
    +
    + + + }
    - + + 37 -
    -   +
    +
    + +
    - + + 38 -
    -   -
    +
    +
    + + + defer rows.Close()
    - + + 39 -
    -   -
    +
    +
    + + + if !rows.Next() { // should always be a row if the policy exists
    - + + 40 -
    -   -
    +
    +
    + + + return false, nil
    - + + 41 -
    -   -
    +
    +
    + + + }
    - + + 42 -
    -   +
    +
    + +
    - + + 43 -
    -   -
    +
    +
    + + + var allow bool
    - + + 44 -
    -   -
    +
    +
    + + + err = rows.Scan(&allow)
    - + + 45 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 46 -
    -   -
    +
    +
    + + + return false, err
    - 329 + + 47 +
    -   - func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { + + + }
    - 330 + + 48 +
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) + + + return allow, nil
    - 331 + + 49 +
    -   - if err != nil && err != state.ErrNotFound { -
    -
    -
    + + + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -30,7 +30,7 @@
    - 30 + + 50 +
    -   - stateMock := new(StateMock) + + +
    - 31 + + 51 +
    -   - ethermanMock := new(EthermanMock) + + + // UpdatePolicy sets the allow/deny rule for the named policy
    - 32 + + 52 +
    -   - ethTxManagerMock := new(EthTxManagerMock) + + + func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error {
    - 33 + + 53 +
    - - - ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil) + + + sql := "UPDATE pool.policy SET allow = $1 WHERE name = $2"
    - 34 + + 54 +
    -   - assert.NoError(t, err) + + + _, err := p.db.Exec(ctx, sql, allow, string(policy))
    - 35 + + 55 +
    -   -
    + + + if err != nil {
    - 36 + + 56 +
    -   - testCases := []IsSyncedTestCase{ + + + return err
    -
    + + + 57 + + +
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 30 + + 58 +
    -   - stateMock := new(StateMock) + + + return nil
    - 31 + + 59 +
    -   - ethermanMock := new(EthermanMock) + + + }
    - 32 + + 60 +
    -   - ethTxManagerMock := new(EthTxManagerMock) + + +
    - 33 + + 61 +
    + - ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil, nil) + // AddAddressesToPolicy adds addresses to the named policy
    - 34 + + 62 +
    -   - assert.NoError(t, err) + + + func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
    - 35 + + 63 +
    -   -
    + + + sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING"
    - 36 + + 64 +
    -   - testCases := []IsSyncedTestCase{ + + + tx, err := p.db.Begin(ctx)
    -
    + + + 65 + + +
    + + + if err != nil {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
    @@ -69,6 +69,7 @@
    - 69 + + 66 +
    -   - ChainId: s.cfg.ChainID, + + + return err
    - 70 + + 67 +
    -   - ForkId: request.ForkID, + + + }
    - 71 + + 68 +
    -   - ContextId: uuid.NewString(), + + + defer func(tx pgx.Tx, ctx context.Context) {
    - + + 69 -
    -   -
    +
    +
    + + + _ = tx.Rollback(ctx)
    - 72 + + 70 +
    -   - } + + + }(tx, ctx)
    - 73 + + 71 +
    -   + +
    - 74 + + 72 +
    -   - if request.SkipFirstChangeL2Block_V2 { + + + for _, a := range addresses {
    -
    @@ -131,6 +132,7 @@
    -
    - 131 + + 73 +
    -   - ForkId: forkId, + + + _, err = tx.Exec(ctx, sql, policy, a.Hex())
    - 132 + + 74 +
    -   - ContextId: uuid.NewString(), + + + if err != nil {
    - 133 + + 75 +
    -   - SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot, + + + return err
    - + + 76 -
    -   -
    +
    +
    + + + }
    - 134 + + 77 +
    -   + + }
    - 135 + + 78 +
    -   -
    + + + err = tx.Commit(ctx)
    - 136 + + 79 +
    -   - if forcedBlockHashL1 != nil { + + + if err != nil {
    -
    @@ -231,6 +233,7 @@
    +
    + 80 + +
    + + + return nil +
    - 231 + + 81 +
    -   - ContextId: uuid.NewString(), + + + }
    - 232 + + 82 +
    -   - SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot, + + + return nil
    - 233 + + 83 +
    -   - L1InfoRoot: processingCtx.L1InfoRoot.Bytes(), + + + }
    - + + 84 -
    -   +
    +
    + +
    - 234 + + 85 +
    -   - } + + + // RemoveAddressesFromPolicy removes addresses from the named policy
    - 235 + + 86 +
    -   -
    + + + func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
    - 236 + + 87 +
    -   - if processingCtx.ForcedBlockHashL1 != nil { + + + sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2"
    -
    + + + 88 + + +
    + + + tx, err := p.db.Begin(ctx)
    -
    -
    - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - -
    -
     
    - 69 + + 89 +
    -   - ChainId: s.cfg.ChainID, + + + if err != nil {
    - 70 + + 90 +
    -   - ForkId: request.ForkID, + + + return err
    - 71 + + 91 +
    -   - ContextId: uuid.NewString(), + + + }
    - 72 + 92
    + - ExecutionMode: request.ExecutionMode, + defer func(tx pgx.Tx, ctx context.Context) {
    - 73 + + 93 +
    -   - } + + + _ = tx.Rollback(ctx)
    - 74 + + 94 +
    -   -
    + + + }(tx, ctx)
    - 75 + + 95 +
    -   - if request.SkipFirstChangeL2Block_V2 { + + +
    -
     
    +
    + 96 + +
    + + + for _, a := range addresses { +
    - 132 + + 97 +
    -   - ForkId: forkId, + + + _, err = tx.Exec(ctx, sql, policy, a.Hex())
    - 133 + + 98 +
    -   - ContextId: uuid.NewString(), + + + if err != nil {
    - 134 + + 99 +
    -   - SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot, + + + return err
    - 135 + 100
    + - ExecutionMode: executor.ExecutionMode1, + }
    - 136 + + 101 +
    -   + + }
    - 137 + + 102 +
    -   -
    + + + err = tx.Commit(ctx)
    - 138 + + 103 +
    -   - if forcedBlockHashL1 != nil { + + + if err != nil {
    -
     
    +
    + 104 + +
    + + + return err +
    - 233 + + 105 +
    -   - ContextId: uuid.NewString(), + + + }
    - 234 + + 106 +
    -   - SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot, + + + return nil
    - 235 + + 107 +
    -   - L1InfoRoot: processingCtx.L1InfoRoot.Bytes(), + + + }
    - 236 + 108
    + - ExecutionMode: processingCtx.ExecutionMode, +
    - 237 + + 109 +
    -   - } + + + // ClearPolicy removes _all_ addresses from the named policy
    - 238 + + 110 +
    -   -
    + + + func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error {
    - 239 + + 111 +
    -   - if processingCtx.ForcedBlockHashL1 != nil { + + + sql := "DELETE FROM pool.acl WHERE policy = $1"
    -
    + + + 112 + + +
    + + + _, err := p.db.Exec(ctx, sql, policy)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - -
    -
    @@ -12,6 +12,7 @@
    - 12 + + 113 +
    -   - BlockHash common.Hash + + + if err != nil {
    - 13 + + 114 +
    -   - ParentHash common.Hash + + + return err
    - 14 + + 115 +
    -   - ReceivedAt time.Time + + + }
    - + + 116 -
    -   +
    +
    + + + return nil +
    +
    + 117 + +
    + + + } +
    +
    + 118 + +
    + +
    - 15 + + 119 +
    -   + + + // DescribePolicies return all the policies +
    +
    + 120 + +
    + + + func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error) { +
    +
    + 121 + +
    + + + sql := "SELECT name, allow FROM pool.policy" +
    +
    + 122 + +
    + + + rows, err := p.db.Query(ctx, sql) +
    +
    + 123 + +
    + + + if err != nil { +
    +
    + 124 + +
    + + + if errors.Is(err, pgx.ErrNoRows) { +
    +
    + 125 + +
    + + + return nil, nil +
    +
    + 126 + +
    + + + } else { +
    +
    + 127 + +
    + + + return nil, err +
    +
    + 128 + +
    + + + } +
    +
    + 129 + +
    + + + } +
    +
    + 130 + +
    + + + defer rows.Close() +
    +
    + 131 + +
    + + +
    +
    +
    + 132 + +
    + + + var list []pool.Policy +
    +
    + 133 + +
    + + + for rows.Next() { +
    +
    + 134 + +
    + + + var name string +
    +
    + 135 + +
    + + + var allow bool +
    +
    + 136 + +
    + + + err = rows.Scan(&name, &allow) +
    +
    + 137 + +
    + + + if err != nil { +
    +
    + 138 + +
    + + + return nil, err +
    +
    + 139 + +
    + + + } +
    +
    + 140 + +
    + + + if pool.IsPolicy(name) { // skip unknown +
    +
    + 141 + +
    + + + p := pool.Policy{ +
    +
    + 142 + +
    + + + Name: pool.PolicyName(name), +
    +
    + 143 + +
    + + + Allow: allow, +
    +
    + 144 + +
    + + + } +
    +
    + 145 + +
    + + + list = append(list, p) +
    +
    + 146 + +
    + + + } +
    +
    + 147 + +
    + + + } +
    +
    + 148 + +
    + + + return list, nil +
    +
    + 149 + +
    + + }
    - 16 + + 150 +
    -   + +
    - 17 + + 151 +
    -   - // NewBlock creates a block with the given data. + + + // DescribePolicy returns the named policy
    -
    + + + 152 + + +
    + + + func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error) {
    -
    -
    - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -95300,12 +96506,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go RENAMED
    - - - @@ -95803,7 +96999,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95813,7 +97009,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95823,7 +97019,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95833,7 +97029,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95863,7 +97059,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95873,7 +97069,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95883,7 +97079,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95893,7 +97089,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95903,7 +97099,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95913,7 +97109,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95923,7 +97119,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95933,7 +97129,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95943,7 +97139,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95953,7 +97149,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95963,7 +97159,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95983,7 +97179,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95993,7 +97189,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96003,7 +97199,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96013,7 +97209,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96023,7 +97219,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96033,7 +97229,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96043,7 +97239,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96053,7 +97249,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96063,7 +97259,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96073,7 +97269,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96083,7 +97279,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96093,7 +97289,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96103,7 +97299,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96123,7 +97319,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96133,7 +97329,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96143,7 +97339,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96153,7 +97349,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96163,7 +97359,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96173,7 +97369,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96183,7 +97379,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96193,7 +97389,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -96203,17 +97399,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - @@ -96223,12 +97409,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go RENAMED
    - - - - - - @@ -96316,300 +97482,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
     
    - 12 + + 153 +
    -   - BlockHash common.Hash + + + sql := "SELECT name, allow FROM pool.policy WHERE name = $1 LIMIT 1"
    - 13 + + 154 +
    -   - ParentHash common.Hash + + + row := p.db.QueryRow(ctx, sql, name)
    - 14 + + 155 +
    -   - ReceivedAt time.Time + + + var (
    - 15 + 156
    + - Checked bool + pName string
    - 16 + + 157 +
    -   + + + allow bool +
    +
    + 158 + +
    + + + ) +
    +
    + 159 + +
    + + + err := row.Scan(&pName, &allow) +
    +
    + 160 + +
    + + + if err != nil { +
    +
    + 161 + +
    + + + return pool.Policy{}, err +
    +
    + 162 + +
    + + + } +
    +
    + 163 + +
    + + + return pool.Policy{ +
    +
    + 164 + +
    + + + Name: pool.PolicyName(pName), +
    +
    + 165 + +
    + + + Allow: allow, +
    +
    + 166 + +
    + + + }, nil +
    +
    + 167 + +
    + + }
    - 17 + + 168 +
    -   + +
    - 18 + + 169 +
    -   - // NewBlock creates a block with the given data. + + + // ListAcl returns a list of the addresses associated with the policy +
    +
    + 170 + +
    + + + func (p *PostgresPoolStorage) ListAcl( +
    +
    + 171 + +
    + + + ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error) { +
    +
    + 172 + +
    + + + sql := "SELECT address FROM pool.acl WHERE policy = $1" +
    +
    + 173 + +
    + + +
    +
    +
    + 174 + +
    + + + if len(query) > 0 { +
    +
    + 175 + +
    + + + var addrs []string +
    +
    + 176 + +
    + + + for _, a := range query { +
    +
    + 177 + +
    + + + addrs = append(addrs, a.Hex()) +
    +
    + 178 + +
    + + + } +
    +
    + 179 + +
    + + + sql = sql + fmt.Sprintf(" IN (%v)", strings.Join(addrs, ",")) +
    +
    + 180 + +
    + + + } +
    +
    + 181 + +
    + + +
    +
    +
    + 182 + +
    + + + rows, err := p.db.Query(ctx, sql, string(policy)) +
    +
    + 183 + +
    + + + if err != nil { +
    +
    + 184 + +
    + + + if errors.Is(err, pgx.ErrNoRows) { +
    +
    + 185 + +
    + + + return nil, nil +
    +
    + 186 + +
    + + + } else { +
    +
    + 187 + +
    + + + return nil, err +
    +
    + 188 + +
    + + + } +
    +
    + 189 + +
    + + + } +
    +
    + 190 + +
    + + + defer rows.Close() +
    +
    + 191 + +
    + + +
    +
    +
    + 192 + +
    + + + var addresses []common.Address +
    +
    + 193 + +
    + + + for rows.Next() { +
    +
    + 194 + +
    + + + var addr string +
    +
    + 195 + +
    + + + err = rows.Scan(&addr) +
    +
    + 196 + +
    + + + if err != nil { +
    +
    + 197 + +
    + + + return nil, err +
    +
    + 198 + +
    + + + } +
    +
    + 199 + +
    + + + addresses = append(addresses, common.HexToAddress(addr)) +
    +
    + 200 + +
    + + + } +
    +
    + 201 + +
    + + + return addresses, nil +
    +
    + 202 + +
    + + + }
    -
    @@ -0,0 +1,44 @@
    -
    - - -
    -   -
    -
    +
    @@ -0,0 +1,43 @@
    @@ -95783,7 +96979,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - package state + package pool
    + - import ( + import "github.com/ethereum/go-ethereum/common"
    + - "errors" +
    + - "math/big" + // PolicyName is a named policy
    + - ) + type PolicyName string
    + - // MaxEffectivePercentage is the maximum value that can be used as effective percentage + // SendTx is the name of the policy that governs that an address may send transactions to pool
    + - MaxEffectivePercentage = uint8(255) + SendTx PolicyName = "send_tx"
    + - ) + // Deploy is the name of the policy that governs that an address may deploy a contract
    + -
    + Deploy PolicyName = "deploy"
    + - var ( + )
    + - // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero +
    + - ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") + // Policy describes state of a named policy
    + -
    + type Policy struct {
    + - // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero + Name PolicyName
    + - ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") + Allow bool
    + - ) + }
    + - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage + // Desc returns the string representation of a policy rule
    + - func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { + func (p *Policy) Desc() string {
    + - const bits = 256 + if p.Allow {
    + - var bitsBigInt = big.NewInt(bits) + return "allow"
    + -
    + }
    + - if effectiveGasPrice == nil || gasPrice == nil || + return "deny"
    + - gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 { + }
    + - return 0, ErrEffectiveGasPriceEmpty +
    + - } + // Acl describes exception to a named Policy by address
    + -
    + type Acl struct {
    + - if gasPrice.Cmp(effectiveGasPrice) <= 0 { + PolicyName PolicyName
    + - return MaxEffectivePercentage, nil + Address common.Address
    + - } + }
    + - // Simulate Ceil with integer division + // IsPolicy tests if a string represents a known named Policy
    + - b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt) + func IsPolicy(name string) bool {
    + - b = b.Add(b, gasPrice) + for _, p := range []PolicyName{SendTx, Deploy} {
    + - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd + if name == string(p) {
    + - b = b.Div(b, gasPrice) + return true
    + - // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) + }
    + - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd + }
    + -
    + return false
    + - return uint8(b.Uint64()), nil -
    -
    - 44 - -
    - + - } + }
    -
    @@ -19,8 +19,10 @@
    +
    @@ -93,6 +93,13 @@
    - 19 + 93
      -
    + time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
    - 20 + 94
      - // Genesis contains the information to populate state on creation + }
    - 21 + 95
      - type Genesis struct { -
    -
    - 22 - -
    - - - // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 -
    -
    - 23 - -
    - - - BlockNumber uint64 + }(&cfg, p)
    - 24 + + -
    +
    +
      - // Root hash of the genesis block +
    - 25 + + -
    +
    +
      - Root common.Hash +
    - 26 + + -
    +
    +
      - // Actions is the data to populate into the state trie -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 19 + + -
    +
    +
     
    - 20 + + -
    +
    +
      - // Genesis contains the information to populate state on creation +
    - 21 + 96
      - type Genesis struct { -
    -
    - 22 - -
    - + - // RollupBlockNumber is the block number where the polygonZKEVM smc was deployed on L1 -
    -
    - 23 - -
    - + - RollupBlockNumber uint64 -
    -
    - 24 - -
    - + - // RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1 -
    -
    - 25 - -
    - + - RollupManagerBlockNumber uint64 +
    - 26 + 97
      - // Root hash of the genesis block + return p
    - 27 + 98
      - Root common.Hash + }
    - 28 - -
    -   - // Actions is the data to populate into the state trie -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - -
    -
    @@ -18,8 +18,6 @@
    +
    @@ -686,7 +693,7 @@
    - 18 + 686
      - double = 2 +
    - 19 + 687
      - ether155V = 27 + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 20 + 688
      - etherPre155V = 35 -
    -
    - 21 - -
    - - - // MaxEffectivePercentage is the maximum value that can be used as effective percentage + func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 22 + + 689 +
    - - MaxEffectivePercentage = uint8(255) + return p.effectiveGasPrice.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice)
    - 23 + 690
      - // Decoding constants + }
    - 24 + 691
      - headerByteLength uint64 = 1 +
    - 25 + 692
      - sLength uint64 = 32 + // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not
    -
    -
    -
    -
    - - - + @@ -96633,33 +97692,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -96667,21 +97726,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    @@ -728,3 +735,8 @@
    - 18 + 728
      - double = 2 + }
    - 19 + 729
      - ether155V = 27 + return gas, nil
    - 20 + 730
      - etherPre155V = 35 + }
    - 21 + + -
    +
    +
      - // Decoding constants +
    - 22 + + -
    +
    +
      - headerByteLength uint64 = 1 +
    - 23 + + -
    +
    +
      - sLength uint64 = 32 +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - RENAMED - -
    -
    @@ -96689,305 +97733,211 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -24,6 +24,8 @@
    -
    - 24 - -
    -   - GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error) -
    -
    - 25 - -
    -   - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error) -
    +
     
    - 26 + 93
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
    - 27 + 94
      - AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error + }
    - 28 + 95
      - GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error) + }(&cfg, p)
    - 29 + + 96 +
    -   - GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error) + + + p.refreshBlockedAddresses()
    -
    @@ -146,10 +148,12 @@
    -
    - 146 + + 97 +
    -   - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) + + + go func(cfg *Config, p *Pool) {
    - 147 + + 98 +
    -   - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + + + for {
    - 148 + + 99 +
    -   - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + + + time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration)
    - 149 + + 100 +
    - - - GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error) + + + p.refreshBlockedAddresses()
    - 150 + + 101 +
    -   - GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) + + + }
    - 151 + + 102 +
    -   - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) + + + }(&cfg, p)
    - 152 + 103
    -   - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) -
    -
    - - -
    -   -
    -
    -
    - - -
     
    - 153 + 104
      - GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) + return p
    - 154 + 105
      - GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error) + }
    - 155 - -
    -   - GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) -
    -
    -
    -
    -
    -
    - - - - - - - - @@ -96997,122 +97947,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - @@ -97122,12 +98032,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
    - 24 + 693
      - GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error) +
    - 25 + 694
      - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error) + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 26 + 695
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error) -
    -
    - 27 - -
    - + - GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*Block, error) + func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 28 + + 696 +
    + - UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error + return state.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice)
    - 29 + 697
      - AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error + }
    - 30 + 698
      - GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error) +
    - 31 + 699
      - GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error) + // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not
    - 148 + 735
      - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) + }
    - 149 + 736
      - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + return gas, nil
    - 150 + 737
      - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + }
    - 151 + + 738 +
    + - GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error) -
    -
    - 152 - -
    -   - GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) -
    -
    - 153 - -
    -   - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) -
    -
    - 154 - -
    -   - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 155 + 739
    + - GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) + // CheckPolicy checks if an address is allowed by policy name
    - 156 + 740
    + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) -
    -
    - 157 - -
    -   - GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) + func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) {
    - 158 + + 741 +
    -   - GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error) + + + return p.storage.CheckPolicy(ctx, policy, address)
    - 159 + + 742 +
    -   - GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) + + + }
    -
    @@ -3,7 +3,6 @@
    +
    @@ -2032,3 +2032,69 @@
    - 3 + 2032
      - import ( + require.NoError(t, err)
    - 4 + 2033
      - "context" + return signedTx
    - 5 + 2034
      - "errors" + }
    - 6 + + -
    - - - "fmt" +
    +
    +   +
    - 7 + + -
    +
    +
     
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/l1infotree" +
    - 9 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    -
    @@ -34,20 +33,20 @@
    -
    - 34 + + -
    +
    +
      - if s.l1InfoTree != nil { +
    - 35 + + -
    +
    +
      - return nil +
    - 36 + + -
    +
    +
      - } +
    - 37 + + -
    - - - log.Debugf("Building L1InfoTree cache") +
    +
    +   +
    - 38 + + -
    - - - allLeaves, err := s.storage.GetAllL1InfoRootEntries(ctx, dbTx) +
    +
    +   +
    - 39 + + -
    +
    +
      - if err != nil { +
    - 40 + + -
    - - - log.Error("error getting all leaves. Error: ", err) +
    +
    +   +
    - 41 + + -
    - - - return fmt.Errorf("error getting all leaves. Error: %w", err) +
    +
    +   +
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
      - var leaves [][32]byte +
    - 44 + + -
    +
    +
      - for _, leaf := range allLeaves { +
    - 45 + + -
    +
    +
      - leaves = append(leaves, leaf.Hash()) +
    - 46 + + -
    +
    +
      - } +
    - 47 + + -
    - - - mt, err := l1infotree.NewL1InfoTree(uint8(32), leaves) //nolint:gomnd +
    +
    +   +
    - 48 + + -
    +
    +
      - if err != nil { +
    - 49 + + -
    - - - log.Error("error creating L1InfoTree. Error: ", err) +
    +
    +   +
    - 50 + + -
    - - - return fmt.Errorf("error creating L1InfoTree. Error: %w", err) +
    +
    +   +
    - 51 + + -
    +
    +
      - } +
    - 52 + + -
    +
    +
      - s.l1InfoTree = mt +
    - 53 + + -
    +
    +
      - return nil -
    -
    -
    +
    -
    -
    - - - - - - - - - - - @@ -97474,537 +98365,93 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "context" +
    - 5 + + -
    +
    +
      - "errors" +
    - 6 + + -
    +
    +
     
    - 7 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/l1infotree" +
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    -
     
    +
    + + +
    +   +
    +
    - 33 + + -
    +
    +
      - if s.l1InfoTree != nil { +
    - 34 + + -
    +
    +
      - return nil +
    - 35 + + -
    +
    +
      - } +
    - 36 + + -
    - + - // Reset L1InfoTree siblings and leaves +
    +
    +   +
    - 37 + + -
    - + - allLeaves, err := s.GetAllL1InfoRootEntries(ctx, dbTx) -
    -
    - 38 - -
    -   - if err != nil { -
    -
    - 39 - -
    - + - log.Error("error getting all leaves to reset l1InfoTree. Error: ", err) -
    -
    - 40 - -
    - + - return err -
    -
    - 41 - -
    -   - } -
    -
    - 42 - -
    -   - var leaves [][32]byte -
    -
    - 43 - -
    -   - for _, leaf := range allLeaves { -
    -
    - 44 - -
    -   - leaves = append(leaves, leaf.Hash()) -
    -
    - 45 - -
    -   - } -
    -
    - 46 - -
    - + - mt, err := s.l1InfoTree.ResetL1InfoTree(leaves) -
    -
    - 47 - -
    -   - if err != nil { -
    -
    - 48 - -
    - + - log.Error("error resetting l1InfoTree. Error: ", err) -
    -
    - 49 - -
    - + - return err -
    -
    - 50 - -
    -   - } -
    -
    - 51 - -
    -   - s.l1InfoTree = mt -
    -
    - 52 - -
    -   - return nil -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -98187,301 +98634,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +
    -
    @@ -16,10 +16,10 @@
    -
    - 16 - -
    -   -
    -
    -
    - 17 - -
    -   - // AddBlock adds a new block to the State Store -
    -
    - 18 - -
    -   - func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error { -
    -
    - 19 - -
    - - - const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at) VALUES ($1, $2, $3, $4)" -
    -
    - 20 - -
    -   -
    -
    -
    - 21 - -
    -   - e := p.getExecQuerier(dbTx) -
    -
    - 22 - -
    - - - _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt) -
    -
    - 23 - -
    -   - return err -
    -
    - 24 - -
    -   - } -
    -
    - 25 - -
    -   -
    -
    -
    -
    @@ -30,11 +30,11 @@
    -
    - 30 - -
    -   - parentHash string -
    -
    - 31 - -
    -   - block state.Block -
    -
    - 32 - -
    -   - ) -
    -
    - 33 - -
    - - - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1" -
    -
    - 34 - -
    -   -
    -
    -
    - 35 - -
    -   - q := p.getExecQuerier(dbTx) -
    -
    - 36 - -
    -   -
    -
    -
    - 37 - -
    - - - err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) -
    -
    - 38 - -
    -   - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 39 - -
    -   - return nil, state.ErrStateNotSynchronized -
    -
    - 40 - -
    -   - } -
    -
    -
    @@ -43,6 +43,26 @@
    -
    - 43 - -
    -   - return &block, err -
    -
    - 44 - -
    -   - } -
    -
    - 45 - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    +
    +
    +   +
    - 46 - -
    -   - // GetPreviousBlock gets the offset previous L1 block respect to latest. -
    -
    - 47 - -
    -   - func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) { -
    -
    - 48 - -
    -   - var ( -
    -
    -
    @@ -50,11 +70,11 @@
    -
    - 50 - -
    -   - parentHash string -
    -
    - 51 - -
    -   - block state.Block -
    -
    - 52 - -
    -   - ) -
    -
    - 53 - -
    - - - const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1" -
    -
    - 54 - -
    -   -
    -
    -
    - 55 - -
    -   - q := p.getExecQuerier(dbTx) -
    -
    - 56 - -
    -   -
    -
    -
    - 57 - -
    - - - err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) -
    -
    - 58 - -
    -   - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 59 - -
    -   - return nil, state.ErrNotFound -
    -
    - 60 - -
    -   - } -
    -
    -
    @@ -70,11 +90,11 @@
    -
    - 70 - -
    -   - parentHash string -
    -
    - 71 - -
    -   - block state.Block -
    -
    - 72 - -
    -   - ) -
    -
    - 73 - -
    - - - const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block WHERE block_num = $1" -
    -
    - 74 - -
    -   -
    -
    -
    - 75 - -
    -   - q := p.getExecQuerier(dbTx) -
    -
    - 76 - -
    -   -
    -
    -
    - 77 - -
    - - - err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) -
    -
    - 78 - -
    -   - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 79 - -
    -   - return nil, state.ErrNotFound -
    -
    - 80 - -
    -   - } -
    -
    -
    @@ -82,3 +102,14 @@
    -
    - 82 - -
    -   - block.ParentHash = common.HexToHash(parentHash) -
    -
    - 83 - -
    -   - return &block, err -
    -
    - 84 - -
    -   - } -
    -
    @@ -98608,337 +98760,317 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 16 + 2032
      -
    + require.NoError(t, err)
    - 17 + 2033
      - // AddBlock adds a new block to the State Store + return signedTx
    - 18 + 2034
      - func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error { + }
    - 19 + + 2035 +
    + - const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at, checked) VALUES ($1, $2, $3, $4, $5)" +
    - 20 + + 2036 +
    -   -
    + + + func Test_PolicyAcl(t *testing.T) {
    - 21 + + 2037 +
    -   - e := p.getExecQuerier(dbTx) + + + initOrResetDB(t)
    - 22 + + 2038 +
    + - _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt, block.Checked) +
    - 23 + + 2039 +
    -   - return err + + + poolSqlDB, err := db.NewSQLDB(poolDBCfg)
    - 24 + + 2040 +
    -   - } + + + require.NoError(t, err)
    - 25 + + 2041 +
    -   -
    + + + defer poolSqlDB.Close() //nolint:gosec,errcheck
    -
     
    -
    - 30 + + 2042 +
    -   - parentHash string + + +
    - 31 + + 2043 +
    -   - block state.Block + + + ctx := context.Background()
    - 32 + + 2044 +
    -   - ) + + + s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg)
    - 33 + + 2045 +
    + - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block ORDER BY block_num DESC LIMIT 1" + require.NoError(t, err)
    - 34 + + 2046 +
    -   + +
    - 35 + + 2047 +
    -   - q := p.getExecQuerier(dbTx) + + + p := pool.NewPool(cfg, bc, s, nil, uint64(1), nil)
    - 36 + + 2048 +
    -   + +
    - 37 + + 2049 +
    + - err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) -
    -
    - 38 - -
    -   - if errors.Is(err, pgx.ErrNoRows) { + randAddr := func() common.Address {
    - 39 + + 2050 +
    -   - return nil, state.ErrStateNotSynchronized + + + buf := make([]byte, 20)
    - 40 + + 2051 +
    -   - } + + + _, err = rand.Read(buf)
    -
     
    -
    - 43 + + 2052 +
    -   - return &block, err + + + require.NoError(t, err)
    - 44 + + 2053 +
    -   - } + + + return common.BytesToAddress(buf)
    - 45 + + 2054 +
    -   -
    + + + }
    - 46 + 2055
    + - // GetFirstUncheckedBlock returns the first L1 block that has not been checked from a given block number. +
    - 47 + 2056
    + - func (p *PostgresStorage) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + // Policies start out as deny lists, since there are no addresses on the
    - 48 + 2057
    + - var ( + // lists, random addresses will always be allowed
    - 49 + 2058
    + - blockHash string + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 50 + 2059
    + - parentHash string + allow, err := p.CheckPolicy(ctx, policy, randAddr())
    - 51 + 2060
    + - block state.Block + require.NoError(t, err)
    - 52 + 2061
    + - ) + require.True(t, allow)
    - 53 + 2062
    + - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND checked=false ORDER BY block_num LIMIT 1" + }
    - 54 + 2063
    @@ -98948,17 +99080,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 55 + 2064
    + - q := p.getExecQuerier(dbTx) + addr := randAddr()
    - 56 + 2065
    @@ -98968,497 +99100,535 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 57 + 2066
    + - err := q.QueryRow(ctx, getLastBlockSQL, fromBlockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + // put addr on lists
    - 58 + 2067
    + - if errors.Is(err, pgx.ErrNoRows) { + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 59 + 2068
    + - return nil, state.ErrNotFound + ctag, err := poolSqlDB.Exec(ctx, "INSERT INTO pool.acl (policy, address) VALUES ($1,$2)", policy, addr.Hex())
    - 60 + 2069
    + - } + require.NoError(t, err)
    - 61 + 2070
    + - block.BlockHash = common.HexToHash(blockHash) + require.Equal(t, int64(1), ctag.RowsAffected())
    - 62 + 2071
    + - block.ParentHash = common.HexToHash(parentHash) + }
    - 63 + 2072
    + - return &block, err +
    - 64 + 2073
    + - } + // addr should not be denied by policy
    - 65 + 2074
    + -
    + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 66 + + 2075 +
    -   - // GetPreviousBlock gets the offset previous L1 block respect to latest. + + + allow, err := p.CheckPolicy(ctx, policy, addr)
    - 67 + + 2076 +
    -   - func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) { + + + require.NoError(t, err)
    - 68 + + 2077 +
    -   - var ( + + + require.False(t, allow)
    -
     
    -
    - 70 + + 2078 +
    -   - parentHash string + + + }
    - 71 + + 2079 +
    -   - block state.Block + + +
    - 72 + + 2080 +
    -   - ) + + + // change policies to allow by acl
    - 73 + + 2081 +
    + - const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1" + ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true")
    - 74 + + 2082 +
    -   -
    + + + require.NoError(t, err)
    - 75 + + 2083 +
    -   - q := p.getExecQuerier(dbTx) + + + require.Equal(t, int64(2), ctag.RowsAffected())
    - 76 + + 2084 +
    -   + +
    - 77 + + 2085 +
    + - err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + // addr is now allowed
    - 78 + + 2086 +
    -   - if errors.Is(err, pgx.ErrNoRows) { + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 79 + + 2087 +
    -   - return nil, state.ErrNotFound + + + allow, err := p.CheckPolicy(ctx, policy, addr)
    - 80 + + 2088 +
    -   - } + + + require.NoError(t, err)
    -
     
    -
    - 90 + + 2089 +
    -   - parentHash string + + + require.True(t, allow)
    - 91 + + 2090 +
    -   - block state.Block + + + }
    - 92 + + 2091 +
    -   - ) + + +
    - 93 + + 2092 +
    + - const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num = $1" + // random addrs are now denied
    - 94 + + 2093 +
    -   -
    + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 95 + + 2094 +
    -   - q := p.getExecQuerier(dbTx) + + + for _, a := range []common.Address{randAddr(), randAddr()} {
    - 96 + + 2095 +
    -   -
    + + + allow, err := s.CheckPolicy(ctx, policy, a)
    - 97 + + 2096 +
    + - err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + require.NoError(t, err)
    - 98 + + 2097 +
    -   - if errors.Is(err, pgx.ErrNoRows) { + + + require.False(t, allow)
    - 99 + + 2098 +
    -   - return nil, state.ErrNotFound + + + }
    - 100 + + 2099 +
    -   + + }
    + 2100 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - + + +
    -
     
    +
    @@ -292,6 +292,7 @@
    - 102 + 292
      - block.ParentHash = common.HexToHash(parentHash) + // prior to executing the call.
    - 103 + 293
      - return &block, err + map<string, OverrideAccountV2> state_override = 23;
    - 104 + 294
      - } + DebugV2 debug = 24;
    - 105 + + -
    - + +
    +
    +  
    - 106 + + 295 +
    - + - // UpdateCheckedBlockByNumber update checked flag for a block +   + }
    - 107 + + 296 +
    - + - func (p *PostgresStorage) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error { +   +
    - 108 + + 297 +
    - + - const query = ` +   + message L1DataV2 {
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -99468,12 +99638,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/addrqueue.go RENAMED
    + + + - - + + + + + + @@ -99576,72 +99776,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + @@ -99651,12 +99881,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/datastreamer.go RENAMED
    - - + + + + + +
    +
     
    +
    - 109 + + 292 +
    - + - UPDATE state.block +   + // prior to executing the call.
    - 110 + + 293 +
    - + - SET checked = $1 WHERE block_num = $2` +   + map<string, OverrideAccountV2> state_override = 23;
    - 111 + + 294 +
    - + -
    +   + DebugV2 debug = 24;
    - 112 + 295
    + - e := p.getExecQuerier(dbTx) + uint64 execution_mode = 25;
    - 113 + + 296 +
    - + - _, err := e.Exec(ctx, query, newCheckedStatus, blockNumber) +   + }
    - 114 + + 297 +
    - + - return err +   +
    - 115 + + 298 +
    - + - } +   + message L1DataV2 {
    -
    @@ -112,7 +112,7 @@
    +
    @@ -211,6 +211,10 @@
    - 112 + 211
      - return entry, nil + if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce {
    - 113 + 212
      - } + log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr)
    - 114 + 213
    +   + a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx +
    +
    + + +
     
    - 115 + + -
    - - - func (p *PostgresStorage) GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 116 + 214
      - // TODO: Optimize this query + }
    - 117 + 215
      - const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index +
    - 118 + 216
      - FROM state.exit_root + return a.readyTx, oldReadyTx, txsToDelete
    - 112 + 211
      - return entry, nil + if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce {
    - 113 + 212
      - } + log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr)
    - 114 + 213
      -
    + a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx
    - 115 + + 214 +
    + - func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + } else if oldReadyTx != nil { // if oldReadyTx doesn't have a valid nonce then we add it to the txsToDelete +
    +
    + 215 + +
    + + + reason := runtime.ErrIntrinsicInvalidNonce.Error() +
    +
    + 216 + +
    + + + oldReadyTx.FailedReason = &reason +
    +
    + 217 + +
    + + + txsToDelete = append(txsToDelete, oldReadyTx)
    - 116 + 218
      - // TODO: Optimize this query + }
    - 117 + 219
      - const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index +
    - 118 + 220
      - FROM state.exit_root + return a.readyTx, oldReadyTx, txsToDelete
    -
    @@ -119,7 +119,7 @@
    +
    @@ -42,6 +43,7 @@
    - 119 + 42
      - return common.HexToHash(stateRootStr), nil + l2Transactions = append(l2Transactions, l2Transaction)
    - 120 + 43
      - } + }
    - 121 + 44
    @@ -99704,228 +99934,336 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 122 + + + +
    +   +
    +
    +
    + 45 +
    - - - // GetLogsByBlockNumber get all the logs from a specific block ordered by log index +   + f.dataToStream <- state.DSL2FullBlock{
    - 123 + 46
      - func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) { + DSL2Block: l2Block,
    - 124 + 47
      - const query = ` + Txs: l2Transactions,
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    - 125 + 43
      - SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3 + l2Transactions = append(l2Transactions, l2Transaction) +
    +
    + 44 + +
    +   + } +
    +
    + 45 + +
    +   +
    +
    +
    + 46 + +
    + + + log.Infof("sending l2block %d to datastream channel", blockResponse.BlockNumber) +
    +
    + 47 + +
    +   + f.dataToStream <- state.DSL2FullBlock{ +
    +
    + 48 + +
    +   + DSL2Block: l2Block,
    + 49 + +
    +   + Txs: l2Transactions, +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go + RENAMED + +
    +
    +
    +
    + + + @@ -100668,6 +101006,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + - - -
    -
    @@ -128,7 +128,7 @@
    +
    @@ -38,7 +39,7 @@
    - 128 + 38
      - INNER JOIN state.l2block b ON b.block_num = t.l2_block_num + workerIntf workerInterface
    - 129 + 39
      - INNER JOIN state.receipt r ON r.tx_hash = t.hash + poolIntf txPool
    - 130 + 40
      - WHERE b.block_num = $1 + stateIntf stateInterface
    - 131 + 41
    - - ORDER BY l.log_index ASC` + etherman etherman
    - 132 + 42
      -
    + wipBatch *Batch
    - 133 + 43
      - q := p.getExecQuerier(dbTx) + wipL2Block *L2Block
    - 134 + 44
      - rows, err := q.Query(ctx, query, blockNumber) + batchConstraints state.BatchConstraintsCfg
    -
    @@ -159,7 +159,7 @@
    +
    @@ -87,7 +88,7 @@
    - 159 + 87
      - const queryFilterByBlockHash = `AND b.block_hash = $7 ` + workerIntf workerInterface,
    - 160 + 88
      - const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 ` + poolIntf txPool,
    - 161 + 89
      -
    + stateIntf stateInterface,
    - 162 + 90
    - - const queryOrder = `ORDER BY b.block_num ASC, l.log_index ASC` + etherman etherman,
    - 163 + 91
      -
    + sequencerAddr common.Address,
    - 164 + 92
      - // count queries + isSynced func(ctx context.Context) bool,
    - 165 + 93
      - const queryToCountLogsByBlockHash = "" + + batchConstraints state.BatchConstraintsCfg,
    -
    @@ -355,3 +355,81 @@
    +
    @@ -220,10 +221,98 @@
    - 355 + 220
      - } + f.storedFlushIDCond.L.Unlock()
    - 356 + 221
      - return nativeBlockHashes, nil + }
    - 357 + 222
      - } +
    + 223 + +
    +   + func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { +
    +
    @@ -100708,43 +101056,79 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    -
    -
    - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + - - - + - + + - - - - + + + + + + - - - - - + - + + + + + + + + - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
     
    - 119 + 224
      - return common.HexToHash(stateRootStr), nil + firstL1InfoRootUpdate := true
    - 120 + 225
      - } + skipFirstSleep := true
    - 121 + 226
    @@ -100753,148 +101137,218 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 122 + + -
    - + - // GetLogsByBlockNumber get all the logs from a specific block ordered by tx index and log index +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 123 + 227
      - func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) { + for {
    - 124 + 228
      - const query = ` + if skipFirstSleep {
    - 125 + 229
      - SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3 + skipFirstSleep = false
    -
     
    +
    @@ -244,7 +333,7 @@
    - 128 + 244
      - INNER JOIN state.l2block b ON b.block_num = t.l2_block_num +
    - 129 + 245
      - INNER JOIN state.receipt r ON r.tx_hash = t.hash + l1InfoRoot, err := f.stateIntf.GetLatestL1InfoRoot(ctx, maxBlockNumber)
    - 130 + 246
      - WHERE b.block_num = $1 + if err != nil {
    - 131 + + 247 +
    - + - ORDER BY r.tx_index ASC, l.log_index ASC` + - + log.Errorf("error checking latest L1InfoRoot, error: %v", err)
    - 132 + 248
      -
    + continue
    - 133 + 249
      - q := p.getExecQuerier(dbTx) + }
    - 134 + 250
      - rows, err := q.Query(ctx, query, blockNumber) +
    -
     
    +
    @@ -254,26 +343,19 @@
    - 159 + 254
      - const queryFilterByBlockHash = `AND b.block_hash = $7 ` + }
    - 160 + 255
      - const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 ` +
    - 161 + 256 + +
    +   + if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { +
    +
    + 257 + +
    + - + log.Infof("received new L1InfoRoot, l1InfoTreeIndex: %d, l1InfoTreeRoot: %s, l1Block: %d", +
    +
    + 258 + +
    + - + l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.BlockNumber) +
    +
    + 259
    @@ -100903,18 +101357,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 162 + + 260 +
    - + - const queryOrder = `ORDER BY b.block_num ASC, r.tx_index ASC, l.log_index ASC` + - + // Sanity check l1BlockState (l1InfoRoot.BlockNumber) blockhash matches blockhash on ethereum. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree) +
    +
    + 261 + +
    + - + if l1InfoRoot.BlockNumber > 0 { +
    +
    + 262 + +
    + - + l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil)
    - 163 + 263 + +
    +   + if err != nil { +
    +
    + 264 + +
    + - + log.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err) +
    +
    + 265 + +
    +   + continue +
    +
    + 266 + +
    +   + } +
    +
    + 267
    @@ -100922,434 +101436,723 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 268 + +
    + - + l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber)) +
    +
    + 269 + +
    + - + if err != nil { +
    +
    + 270 + +
    + - + log.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err) +
    +
    + 271 + +
    + - + continue +
    +
    + 272 + +
    + - + } +
    +
    + 273 + +
    + - + if l1BlockState.BlockHash != l1BlockEth.Hash() { +
    +
    + 274 + +
    + - + log.Warnf("skipping use of l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?)", +
    +
    + 275 + +
    + - + l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) +
    +
    + 276 + +
    + - + continue +
    +
    - 164 + 277
      - // count queries + }
    - 165 + 278
      - const queryToCountLogsByBlockHash = "" + + } +
    +
    + 279 + +
    +   +
    -
     
    +
    @@ -283,12 +365,7 @@
    - 355 + 283
      - } + f.lastL1InfoTree = l1InfoRoot
    - 356 + 284
      - return nativeBlockHashes, nil + f.lastL1InfoTreeMux.Unlock()
    - 357 + 285
      - } +
    - 358 + + 286 +
    - + -
    + - + if !f.lastL1InfoTreeValid {
    - 359 + + 287 +
    - + - // GetBatchL2DataByNumber returns the batch L2 data of the given batch number. + - + f.lastL1InfoTreeCond.L.Lock()
    - 360 + + 288 +
    - + - func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) { + - + f.lastL1InfoTreeValid = true
    - 361 + + 289 +
    - + - batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx) + - + f.lastL1InfoTreeCond.Broadcast()
    - 362 + + 290 +
    - + - if err != nil { + - + f.lastL1InfoTreeCond.L.Unlock()
    - 363 + + 291 +
    - + - return nil, err + - + }
    - 364 + + 292 +
    - + +   + } +
    +
    + 293 + +
    +   }
    - 365 + + 294 +
    - + - data, ok := batchData[batchNumber] +   + }
    - 366 + +
    @@ -390,6 +467,7 @@
    +
    + 390 +
    - + - if !ok { +   + SkipWriteBlockInfoRoot_V2: true,
    - 367 + + 391 +
    - + - return nil, state.ErrNotFound +   + SkipVerifyL1InfoRoot_V2: true,
    - 368 + + 392 +
    - + +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, +
    +
    + + +
    +   +
    +
    +
    + 393 + +
    +   }
    - 369 + + 394 +
    - + - return data, nil +   +
    - 370 + + 395 +
    - + - } +   + txGasPrice := tx.GasPrice
    - 371 + +
    @@ -436,7 +514,7 @@
    +
    + 436 +
    - + +   + } +
    +
    + 437 + +
    +   + } +
    +
    + 438 + +
    +  
    - 372 + + 439 +
    - + - // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables. + - + egpPercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 373 + + 440 +
    - + - func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { +   + if err != nil {
    - 374 + + 441 +
    - + - const getBatchL2DataByBatchNumber = ` +   + if f.effectiveGasPrice.IsEnabled() {
    - 375 + + 442 +
    - + - SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1) +   + return nil, err
    - 376 + +
    @@ -549,7 +627,7 @@
    +
    + 549 +
    - + - UNION +   +
    - 377 + + 550 +
    - + - SELECT forced_batch_num, convert_from(decode(raw_txs_data, 'hex'), 'UTF8')::bytea FROM state.forced_batch WHERE forced_batch_num = ANY($2) +   + // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging
    - 378 + + 551 +
    - + - ` +   + if !egpEnabled {
    - 379 + + 552 +
    - + - q := p.getExecQuerier(dbTx) + - + effectivePercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 380 + + 553 +
    - + - rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers, batchNumbers) +   + if err != nil {
    - 381 + + 554 +
    - + - if errors.Is(err, pgx.ErrNoRows) { +   + log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err)
    - 382 + + 555 +
    - + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) +   + tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - -
    +
     
    - 383 + + 39 +
    - + - } else if err != nil { +   + workerIntf workerInterface
    - 384 + + 40 +
    - + - return nil, err +   + poolIntf txPool
    - 385 + + 41 +
    - + - } +   + stateIntf stateInterface
    - 386 + + 42 +
    + - defer rows.Close() + etherman ethermanInterface
    - 387 + + 43 +
    - + -
    +   + wipBatch *Batch
    - 388 + + 44 +
    - + - batchL2DataMap, err := readBatchDataResults(rows, batchNumbers) +   + wipL2Block *L2Block
    - 389 + + 45 + +
    +   + batchConstraints state.BatchConstraintsCfg +
    +
    +
     
    +
    + 88 + +
    +   + workerIntf workerInterface, +
    +
    + 89 + +
    +   + poolIntf txPool, +
    +
    + 90 + +
    +   + stateIntf stateInterface, +
    +
    + 91 +
    + - if err != nil { + etherman ethermanInterface, +
    +
    + 92 + +
    +   + sequencerAddr common.Address, +
    +
    + 93 + +
    +   + isSynced func(ctx context.Context) bool, +
    +
    + 94 + +
    +   + batchConstraints state.BatchConstraintsCfg, +
    +
    +
     
    +
    + 221 + +
    +   + f.storedFlushIDCond.L.Unlock() +
    +
    + 222 + +
    +   + } +
    +
    + 223 + +
    +   +
    - 390 + 224
    + - return nil, err + func (f *finalizer) checkValidL1InfoRoot(ctx context.Context, l1InfoRoot state.L1InfoTreeExitRootStorageEntry) (bool, error) {
    - 391 + 225
    + - } + // Check L1 block hash matches
    - 392 + 226
    + -
    + l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil)
    - 393 + 227
    + - if len(batchL2DataMap) == 0 { + if err != nil {
    - 394 + 228
    + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) + return false, fmt.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err)
    - 395 + 229
    @@ -101359,7 +102162,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 396 + 230
    @@ -101369,217 +102172,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 397 + 231
    + - return batchL2DataMap, nil + l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber))
    - 398 + 232
    + - } + if err != nil {
    - 399 + 233
    + -
    + return false, fmt.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err)
    - 400 + 234
    + - // GetBatchL2DataByNumbersFromBackup returns the batch L2 data of the given batch number from the backup table + }
    - 401 + 235
    + - func (p *PostgresStorage) GetBatchL2DataByNumbersFromBackup(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { +
    - 402 + 236
    + - getBatchL2DataByBatchNumber := ` + if l1BlockState.BlockHash != l1BlockEth.Hash() {
    - 403 + 237
    + - SELECT batch_num, data FROM state.batch_data_backup + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, l1Block: %d. L1 block hash %s doesn't match block hash on ethereum %s (L1 reorg?)",
    - 404 + 238
    + - WHERE batch_num = ANY($1) + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash())
    - 405 + 239
    + - ORDER BY created_at DESC + log.Warnf(warnmsg)
    - 406 + 240
    + - ` + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil)
    - 407 + 241
    + - q := p.getExecQuerier(dbTx) +
    - 408 + 242
    + - rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers) + return false, nil
    - 409 + 243
    + - if errors.Is(err, pgx.ErrNoRows) { + }
    - 410 + 244
    + - return nil, state.ErrNotFound +
    - 411 + 245
    + - } else if err != nil { + // Check l1InfoRootIndex and GER matches. We retrieve the info of the last l1InfoTree event in the block, since in the case we have several l1InfoTree events
    - 412 + 246
    + - return nil, err + // in the same block, the function checkL1InfoTreeUpdate retrieves only the last one and skips the others
    - 413 + 247
    + - } + log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash)
    - 414 + 248
    + - defer rows.Close() + blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber)
    - 415 + 249
    + -
    + if err != nil {
    - 416 + 250
    + - return readBatchDataResults(rows, batchNumbers) + return false, err
    - 417 + 251
    + - } + }
    - 418 + 252
    @@ -101589,706 +102392,782 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 419 + 253
    + - // readBatchDataResults retrieves batch data from the provided result set + //Get L1InfoTree events of the L1 block where the l1InforRoot we need to check was synced
    - 420 + 254
    + - func readBatchDataResults(results pgx.Rows, batchNumbers []uint64) (map[uint64][]byte, error) { + lastGER := state.ZeroHash
    - 421 + 255
    + - batchL2DataMap := make(map[uint64][]byte, len(batchNumbers)) + for _, block := range blocks {
    - 422 + 256
    + - for results.Next() { + blockEventsOrder := eventsOrder[block.BlockHash]
    - 423 + 257
    + - var ( + for _, order := range blockEventsOrder {
    - 424 + 258
    + - batchNum uint64 + if order.Name == ethermanTypes.L1InfoTreeOrder {
    - 425 + 259
    + - batchL2Data []byte + lastGER = block.L1InfoTree[order.Pos].GlobalExitRoot
    - 426 + 260
    + - ) + log.Debugf("l1InfoTree event, pos: %d, GER: %s", order.Pos, lastGER)
    - 427 + 261
    + -
    + }
    - 428 + 262
    + - if err := results.Scan(&batchNum, &batchL2Data); err != nil { + }
    - 429 + 263
    + - return nil, err + }
    - 430 + 264
    + - } +
    - 431 + 265
    + - batchL2DataMap[batchNum] = batchL2Data + // Get the deposit count in the moment when the L1InfoRoot was synced
    - 432 + 266
    + - } + depositCount, err := f.etherman.DepositCount(ctx, &l1InfoRoot.BlockNumber)
    - 433 + 267
    + -
    + if err != nil {
    - 434 + 268
    + - return batchL2DataMap, nil + return false, err
    - 435 + 269
    + - } + }
    -
    + + + 270 + + +
    + + + // l1InfoTree index starts at 0, therefore we need to subtract 1 to the depositCount to get the last index at that moment
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - + + + @@ -102302,55 +103181,125 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + + + + + + + - - + + + - - - - + + + + + + + + + - - + + + + + + - + - + + + + + + + + + + + - - - - + - - - - - - - - - - - - - + + +
    -
    @@ -872,7 +872,7 @@
    - 872 + + 271 +
    -   - ctx := context.Background() + + + index := uint32(depositCount.Uint64())
    - 873 + + 272 +
    -   -
    + + + if index > 0 { // we check this as protection, but depositCount should be greater that 0 in this context
    - 874 + + 273 +
    -   - cfg := state.Config{ + + + index--
    - 875 + + 274 +
    - - - MaxLogsCount: 8, + + + } else {
    - 876 + + 275 +
    -   - MaxLogsBlockRange: 10, + + + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. DepositCount value returned by the smartcontrat is 0 and that isn't possible in this context",
    - 877 + + 276 +
    -   - ForkIDIntervals: stateCfg.ForkIDIntervals, + + + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber)
    - 878 + + 277 +
    -   - } + + + log.Warn(warnmsg)
    -
    @@ -895,39 +895,69 @@
    +
    + 278 + +
    + + + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) +
    - 895 + + 279 +
    -   - time := time.Now() + + +
    - 896 + + 280 +
    -   - blockNumber := big.NewInt(1) + + + return false, nil
    - 897 + + 281 +
    -   + + + } +
    +
    + 282 + +
    + +
    - 898 + + 283 +
    - - - for i := 0; i < 3; i++ { + + + log.Debugf("checking valid l1InfoRoot, index: %d, GER: %s, l1Block: %d, scIndex: %d, scGER: %s",
    - 899 + + 284 +
    - - - tx := types.NewTx(&types.LegacyTx{ + + + l1InfoRoot.BlockNumber, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, index, lastGER)
    - 900 + + 285 +
    - - - Nonce: uint64(i), + + +
    - 901 + + 286 +
    - - - To: nil, + + + if (l1InfoRoot.GlobalExitRoot.GlobalExitRoot != lastGER) || (l1InfoRoot.L1InfoTreeIndex != index) {
    - 902 + + 287 +
    - - - Value: new(big.Int), + + + warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. It doesn't match with smartcontract l1InfoRoot, index: %d, GER: %s",
    - 903 + + 288 +
    - - - Gas: 0, + + + l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, index, lastGER)
    - 904 + + 289 +
    - - - GasPrice: big.NewInt(0), + + + log.Warn(warnmsg)
    - 905 + + 290 +
    - - - }) + + + f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil)
    - 906 + + 291 +
    - - + +
    - 907 + + 292 +
    - - - logs := []*types.Log{} + + + return false, nil
    - 908 + + 293 +
    - - - for j := 0; j < 4; j++ { + + + }
    - 909 + + 294 +
    - - - logs = append(logs, &types.Log{TxHash: tx.Hash(), Index: uint(j)}) + + +
    - 910 + + 295 +
    - - - } + + + return true, nil
    - 911 + + 296 +
    - - + + + } +
    +
    + 297 + +
    + +
    - 912 + + 298 +
    - - - receipt := &types.Receipt{ +   + func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) {
    - 913 + + 299 +
    - - - Type: tx.Type(), + + + broadcastL1InfoTreeValid := func() {
    - 914 + + 300 +
    - - - PostState: state.ZeroHash.Bytes(), + + + if !f.lastL1InfoTreeValid {
    - 915 + + 301 +
    - - - CumulativeGasUsed: 0, + + + f.lastL1InfoTreeCond.L.Lock()
    - 916 + + 302 +
    - - - EffectiveGasPrice: big.NewInt(0), + + + f.lastL1InfoTreeValid = true
    - 917 + + 303 +
    - - - BlockNumber: blockNumber, + + + f.lastL1InfoTreeCond.Broadcast()
    - 918 + + 304 +
    - - - GasUsed: tx.Gas(), + + + f.lastL1InfoTreeCond.L.Unlock()
    - 919 + + 305 +
    - - - TxHash: tx.Hash(), + + + }
    - 920 + + 306 +
    - - - TransactionIndex: 0, + + + }
    - 921 + + 307 +
    - - - Status: types.ReceiptStatusSuccessful, + + +
    - 922 + + 308 +
    - - - Logs: logs, +   + firstL1InfoRootUpdate := true
    - + + 309 -
    +
    +
      -
    + skipFirstSleep := true
    - + + 310 -
    +
    +
     
    - + + 311 -
    -   +
    +
    + + + if f.cfg.L1InfoTreeCheckInterval.Duration.Seconds() == 0 { //nolint:gomnd +
    +
    + 312 + +
    + + + broadcastL1InfoTreeValid() +
    +
    + 313 + +
    + + + return +
    +
    + 314 + +
    + + + } +
    +
    + 315 + +
    + +
    - + + 316 -
    +
    +
      -
    + for {
    - + + 317 -
    +
    +
      -
    + if skipFirstSleep {
    - + + 318 -
    +
    +
      -
    + skipFirstSleep = false
    - + +
     
    -
    +
    + 333 + +
     
    - + + 334 -
    +
    +
      -
    + l1InfoRoot, err := f.stateIntf.GetLatestL1InfoRoot(ctx, maxBlockNumber)
    - + + 335 -
    +
    +
      -
    + if err != nil {
    - + + 336 -
    +
    +
    + + + log.Errorf("error getting latest l1InfoRoot, error: %v", err) +
    +
    + 337 + +
      -
    + continue
    - + + 338 -
    +
    +
      -
    + }
    - + + 339 -
    +
    +
     
    - + +
     
    -
    +
    + 343 + +
      -
    + }
    - + + 344 -
    +
    +
     
    - + + 345 -
    +
    +
      -
    + if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { +
    +
    + 346 + +
    + + + log.Infof("received new l1InfoRoot %s, index: %d, l1Block: %d", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber)
    - + + 347 -
    +
    +
     
    - + + 348 -
    +
    +
    + + + // Check if new l1InfoRoot is valid. We skip it if l1InfoTreeIndex is 0 (it's a special case) +
    +
    + 349 + +
    + + + if l1InfoRoot.L1InfoTreeIndex > 0 { +
    +
    + 350 + +
    + + + valid, err := f.checkValidL1InfoRoot(ctx, l1InfoRoot) +
    +
    + 351 + +
      -
    + if err != nil {
    - + + 352 -
    +
    +
    + + + log.Errorf("error validating new l1InfoRoot, index: %d, error: %v", l1InfoRoot.L1InfoTreeIndex, err) +
    +
    + 353 + +
      -
    + continue
    - + + 354 -
    +
    +
      -
    + }
    - + + 355 -
    +
    +
     
    + 356 + +
    + + + if !valid { +
    +
    + 357 + +
    + + + log.Warnf("invalid l1InfoRoot %s, index: %d, l1Block: %d. Stopping syncing l1InfoTreeIndex", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) +
    +
    + 358 + +
    + + + return +
    +
    @@ -102412,25 +103361,80 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 359 -
    +
    +
    +   + } +
    +
    + 360 + +
    +   + } +
    +
    + 361 + +
     
    - + +
     
    -
    +
    + 365 + +
    +   + f.lastL1InfoTree = l1InfoRoot +
    +
    + 366 + +
    +   + f.lastL1InfoTreeMux.Unlock() +
    +
    + 367 + +
     
    + 368 + +
    + + + broadcastL1InfoTreeValid() +
    +
    @@ -102483,7 +103487,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 923 + 369
    @@ -102493,122 +103497,117 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 924 + 370
      -
    + }
    - 925 + + 371 +
    - - - transactions := []*types.Transaction{tx} +   + }
    - 926 - -
    - - - receipts := []*types.Receipt{receipt} -
    +
    +
     
    - 927 + + 467 +
    - - - stateRoots := []common.Hash{state.ZeroHash} +   + SkipWriteBlockInfoRoot_V2: true,
    - 928 + + 468 +
    - - -
    +   + SkipVerifyL1InfoRoot_V2: true,
    - 929 + 469
      - header := state.NewL2Header(&types.Header{ + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 930 + + 470 +
    - - - Number: big.NewInt(int64(i) + 1), + + + ExecutionMode: executor.ExecutionMode0,
    - 931 + 471
      - ParentHash: state.ZeroHash, + }
    - 932 + 472
      - Coinbase: state.ZeroAddress, +
    - 933 + 473
      - Root: state.ZeroHash, + txGasPrice := tx.GasPrice
    -
    @@ -954,6 +984,8 @@
    +
     
    - 954 + 514
      - require.NoError(t, err) + }
    - 955 + 515
    @@ -102618,7 +103617,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 956 + 516
    @@ -102627,218 +103626,237 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    -
    - + + 517 -
    -   -
    +
    +
    + + + egpPercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 957 + 518
      - type testCase struct { + if err != nil {
    - 958 + 519
      - name string + if f.effectiveGasPrice.IsEnabled() {
    - 959 + 520
      - from uint64 + return nil, err
    -
    @@ -988,20 +1020,227 @@
    +
     
    - 988 + 627
      - name: "logs returned successfully", +
    - 989 + 628
      - from: 1, + // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging
    - 990 + 629
      - to: 2, + if !egpEnabled {
    - 991 + + 630 +
    - - - logCount: 8, + + + effectivePercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 992 + 631
      - expectedError: nil, + if err != nil {
    - 993 + 632
      - }, + log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err)
    - 994 + 633
      - } + tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -102862,213 +103880,246 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + +
    +
    @@ -30,12 +31,14 @@
    - 995 + 30
      -
    + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
    - 996 + 31
      - for _, testCase := range testCases { + }
    - 997 + 32
      - t.Run(testCase.name, func(t *testing.T) { +
    - 998 + 33
    - - logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, dbTx) + // etherman contains the methods required to interact with ethereum.
    - 999 + + 34 +
    - -
    + type etherman interface {
    - 1000 + 35
      - assert.Equal(t, testCase.logCount, len(logs)) + TrustedSequencer() (common.Address, error)
    - 1001 + 36
      - assert.Equal(t, testCase.expectedError, err) + GetLatestBatchNumber() (uint64, error)
    - + + 37 -
    +
    +
      -
    + GetLatestBlockNumber(ctx context.Context) (uint64, error)
    - + + 38 -
    +
    +
      -
    + HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
    - + + 39 -
    +
    +
      -
    + }
    - + + 40 -
    +
    +
     
    - + + 41 -
    +
    +
      -
    + // stateInterface gathers the methods required to interact with the state.
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 31 -
    +
    +
      -
    + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
    - + + 32 -
    +
    +
      -
    + }
    - + + 33 -
    +
    +
     
    - + + 34 -
    -   -
    +
    +
    + + + // ethermanInterface contains the methods required to interact with ethereum.
    - + + 35 -
    -   -
    +
    +
    + + + type ethermanInterface interface {
    - + + 36 -
    +
    +
      -
    + TrustedSequencer() (common.Address, error)
    - + + 37 -
    +
    +
      -
    + GetLatestBatchNumber() (uint64, error)
    - + + 38 -
    +
    +
      -
    + GetLatestBlockNumber(ctx context.Context) (uint64, error)
    - + + 39 -
    +
    +
      -
    + HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
    - + + 40 -
    -   -
    +
    +
    + + + GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]ethermanTypes.Block, map[common.Hash][]ethermanTypes.Order, error)
    - + + 41 -
    -   -
    +
    +
    + + + DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error)
    - + + 42 -
    +
    +
      -
    + }
    - + + 43 -
    +
    +
     
    - + + 44 -
    +
    +
      -
    + // stateInterface gathers the methods required to interact with the state. +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -103082,61 +104133,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - @@ -103422,611 +104493,684 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -283,6 +284,7 @@
    - + + 283 -
    +
    +
      -
    + ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
    - + + 284 -
    +
    +
      -
    + SkipVerifyL1InfoRoot_V2: true,
    - + + 285 -
    +
    +
      -
    + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - + + 286 -
    +
    +
      -
    + }
    - + + 287 -
    +
    +
      -
    + batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
    - + + 288 -
    +
    +
      -
    + GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
    - + +
    @@ -411,6 +413,9 @@
    -
    +
    + 411 + +
      -
    + return err
    - + + 412 -
    +
    +
      -
    + }
    - + + 413 -
    +
    +
     
    @@ -103172,61 +104228,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 414 -
    +
    +
      -
    + // Update txs status in the pool
    - + + 415 -
    +
    +
      -
    + for _, txResponse := range blockResponse.TransactionResponses {
    - + + 416 -
    +
    +
      -
    + // Change Tx status to selected
    - + +
    @@ -420,6 +425,9 @@
    -
    +
    + 420 + +
      -
    + }
    - + + 421 -
    +
    +
      -
    + }
    - + + 422 -
    +
    +
     
    @@ -103262,61 +104323,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 423 -
    +
    +
      -
    + // Send L2 block to data streamer
    - + + 424 -
    +
    +
      -
    + err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
    - + + 425 -
    +
    +
      -
    + if err != nil {
    - + +
    @@ -427,6 +435,9 @@
    -
    +
    + 427 + +
      -
    + log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
    - + + 428 -
    +
    +
      -
    + }
    - + + 429 -
    +
    +
     
    @@ -103352,63 +104418,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 430 -
    +
    +
      -
    + for _, tx := range l2Block.transactions {
    - + + 431 -
    +
    +
      -
    + // Delete the tx from the pending list in the worker (addrQueue)
    - + + 432 -
    +
    +
      -
    + f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From)
    - + +
    @@ -582,6 +593,7 @@
    -
    +
    + 582 + +
      -
    + SkipFirstChangeL2Block_V2: false,
    - + + 583 -
    +
    +
      -
    + Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
    - + + 584 -
    +
    +
      -
    + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - + + 585 -
    +
    +
      -
    + }
    - + + 586 -
    +
    +
     
    - + + 587 -
    +
    +
      -
    + batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - + + 284 -
    +
    +
      -
    + ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
    - + + 285 -
    +
    +
      -
    + SkipVerifyL1InfoRoot_V2: true,
    - + + 286 -
    +
    +
      -
    + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - + + 287 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 288 -
    +
    +
      -
    + }
    - + + 289 -
    +
    +
      -
    + batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
    - + + 290 -
    +
    +
      -
    + GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
    - + +
     
    -
    +
    + 413 + +
      -
    + return err
    - + + 414 -
    +
    +
      -
    + }
    - + + 415 -
    +
    +
     
    - + + 416 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 417 -
    -   -
    +
    +
    + + + log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum)
    - + + 418 -
    -   +
    +
    + +
    - + + 419 -
    +
    +
      -
    + // Update txs status in the pool
    - + + 420 -
    +
    +
      -
    + for _, txResponse := range blockResponse.TransactionResponses {
    - + + 421 -
    +
    +
      -
    + // Change Tx status to selected
    - + +
     
    -
    +
    + 425 + +
      -
    + }
    - + + 426 -
    +
    +
      -
    + }
    - + + 427 -
    +
    +
     
    - + + 428 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 429 -
    -   -
    +
    +
    + + + log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum)
    - + + 430 -
    -   +
    +
    + +
    - + + 431 -
    +
    +
      -
    + // Send L2 block to data streamer
    - + + 432 -
    +
    +
      -
    + err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
    - + + 433 -
    +
    +
      -
    + if err != nil {
    - + +
     
    -
    +
    + 435 + +
      -
    + log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
    - + + 436 -
    +
    +
      -
    + }
    - + + 437 -
    +
    +
     
    - + + 438 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 439 -
    -   -
    +
    +
    + + + log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum)
    - + + 440 -
    -   +
    +
    + +
    - + + 441 -
    +
    +
      -
    + for _, tx := range l2Block.transactions {
    - + + 442 -
    +
    +
      -
    + // Delete the tx from the pending list in the worker (addrQueue)
    - + + 443 -
    +
    +
      -
    + f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From)
    - + +
     
    -
    +
    + 593 + +
      -
    + SkipFirstChangeL2Block_V2: false,
    - + + 594 -
    +
    +
      -
    + Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
    - + + 595 -
    +
    +
      -
    + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - + + 596 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 597 -
    +
    +
      -
    + }
    - + + 598 -
    +
    +
     
    - + + 599 -
    +
    +
      -
    + batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -27,7 +27,7 @@
    +
    - + + 27 -
    +
    +
      -
    + pool txPool
    - + + 28 -
    +
    +
      -
    + stateIntf stateInterface
    - + + 29 -
    +
    +
      -
    + eventLog *event.EventLog
    - + + 30 -
    -   -
    +
    +
    + - + etherman etherman
    - + + 31 -
    +
    +
      -
    + worker *Worker
    - + + 32 -
    +
    +
      -
    + finalizer *finalizer
    - + + 33 -
    +
    +
     
    - + +
    @@ -42,7 +42,7 @@
    -
    +
    + 42 + +
      -
    + }
    - + + 43 -
    +
    +
     
    - + + 44 -
    +
    +
      -
    + // New init sequencer
    - + + 45 -
    -   -
    +
    +
    + - + func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman etherman, eventLog *event.EventLog) (*Sequencer, error) {
    - + + 46 -
    +
    +
      -
    + addr, err := etherman.TrustedSequencer()
    - + + 47 -
    +
    +
      -
    + if err != nil {
    - + + 48 -
    +
    +
      -
    + return nil, fmt.Errorf("failed to get trusted sequencer address, error: %v", err)
    - + +
    @@ -256,6 +256,8 @@
    -
    +
    + 256 + +
      -
    + case state.DSL2FullBlock:
    - + + 257 -
    +
    +
      -
    + l2Block := data
    - + + 258 -
    +
    +
     
    @@ -104052,61 +105196,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 259 -
    +
    +
      -
    + err = s.streamServer.StartAtomicOp()
    - + + 260 -
    +
    +
      -
    + if err != nil {
    - + + 261 -
    +
    +
      -
    + log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - + +
    @@ -267,6 +269,8 @@
    -
    +
    + 267 + +
      -
    + Value: l2Block.L2BlockNumber,
    - + + 268 -
    +
    +
      -
    + }
    - + + 269 -
    +
    +
     
    @@ -104133,70 +105282,65 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1002 + 270
      - }) + _, err = s.streamServer.AddStreamBookmark(bookMark.Encode())
    - + + 271 -
    +
    +
      -
    + if err != nil {
    - + + 272 -
    +
    +
      -
    + log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - - -
    -   -
    -
    +
    +
    @@ -281,6 +285,8 @@
    - + + 281 -
    +
    +
      -
    + Value: l2Block.L2BlockNumber - 1,
    - + + 282 -
    +
    +
      -
    + }
    - + + 283 -
    +
    +
     
    @@ -104222,61 +105366,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 284 -
    +
    +
      -
    + previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
    - + + 285 -
    +
    +
      -
    + if err != nil {
    - + + 286 -
    +
    +
      -
    + log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err)
    - + +
    @@ -303,12 +309,16 @@
    -
    +
    + 303 + +
      -
    + ChainID: uint32(chainID),
    - + + 304 -
    +
    +
      -
    + }
    - + + 305 -
    +
    +
     
    @@ -104302,61 +105451,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 306 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode())
    - 1003 + 307
      - } + if err != nil {
    - + + 308 -
    +
    +
      -
    + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 1004 + 309
      - require.NoError(t, dbTx.Commit(ctx)) + continue
    - + + 310 -
    +
    +
      -
    + }
    - + + 311 -
    +
    +
     
    @@ -104382,61 +105531,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 312 -
    +
    +
      -
    + for _, l2Transaction := range l2Block.Txs {
    - + + 313 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode())
    - + + 314 -
    +
    +
      -
    + if err != nil {
    - + +
    @@ -323,18 +333,25 @@
    -
    +
    + 323 + +
      -
    + StateRoot: l2Block.StateRoot,
    - + + 324 -
    +
    +
      -
    + }
    - + + 325 -
    +
    +
     
    @@ -104462,61 +105616,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 326 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode())
    - + + 327 -
    +
    +
      -
    + if err != nil {
    - + + 328 -
    +
    +
      -
    + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - + + 329 -
    +
    +
      -
    + continue
    - + + 330 -
    +
    +
      -
    + }
    - + + 331 -
    +
    +
     
    @@ -104542,61 +105696,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 332 -
    +
    +
      -
    + err = s.streamServer.CommitAtomicOp()
    - + + 333 -
    +
    +
      -
    + if err != nil {
    - + + 334 -
    +
    +
      -
    + log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - + + 335 -
    +
    +
      -
    + continue
    - + + 336 -
    +
    +
      -
    + }
    - + + 337 -
    +
    +
     
    @@ -104632,363 +105786,392 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 338 -
    +
    +
      -
    + // Stream a bookmark
    - + + 339 -
    +
    +
      -
    + case state.DSBookMark:
    - + + 340 -
    +
    +
      -
    + bookmark := data +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + - - - - - - + + +
    +
     
    - + + 27 -
    +
    +
      -
    + pool txPool
    - + + 28 -
    +
    +
      -
    + stateIntf stateInterface
    - + + 29 -
    +
    +
      -
    + eventLog *event.EventLog
    - + + 30 -
    -   -
    +
    +
    + + + etherman ethermanInterface
    - + + 31 -
    +
    +
      -
    + worker *Worker
    - + + 32 -
    +
    +
      -
    + finalizer *finalizer
    - + + 33 -
    +
    +
     
    - + +
     
    -
    +
    + 42 + +
      -
    + }
    - + + 43 -
    +
    +
     
    - + + 44 -
    +
    +
      -
    + // New init sequencer
    - + + 45 -
    -   -
    +
    +
    + + + func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman ethermanInterface, eventLog *event.EventLog) (*Sequencer, error) {
    - + + 46 -
    +
    +
      -
    + addr, err := etherman.TrustedSequencer()
    - + + 47 -
    +
    +
      -
    + if err != nil {
    - + + 48 -
    +
    +
      -
    + return nil, fmt.Errorf("failed to get trusted sequencer address, error: %v", err)
    - + +
     
    -
    +
    + 256 + +
      -
    + case state.DSL2FullBlock:
    - + + 257 -
    +
    +
      -
    + l2Block := data
    - + + 258 -
    +
    +
     
    - + + 259 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 260 -
    -   -
    +
    +
    + + + log.Infof("start atomic op for l2block %d", l2Block.L2BlockNumber)
    - + + 261 -
    +
    +
      -
    + err = s.streamServer.StartAtomicOp()
    - + + 262 -
    +
    +
      -
    + if err != nil {
    - + + 263 -
    +
    +
      -
    + log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - + +
     
    -
    +
    + 269 + +
      -
    + Value: l2Block.L2BlockNumber,
    - + + 270 -
    +
    +
      -
    + }
    - + + 271 -
    +
    +
     
    - + + 272 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 273 -
    -   -
    +
    +
    + + + log.Infof("add stream bookmark for l2block %d", l2Block.L2BlockNumber)
    - 1005 + 274
      - } + _, err = s.streamServer.AddStreamBookmark(bookMark.Encode())
    - 1006 + 275
      -
    + if err != nil {
    - 1007 + 276
      - func TestGetNativeBlockHashesInRange(t *testing.T) { + log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    -
    @@ -1132,6 +1371,111 @@
    +
     
    - 1132 + 285
      - require.NoError(t, dbTx.Commit(ctx)) + Value: l2Block.L2BlockNumber - 1,
    - 1133 + 286
      - } + }
    - 1134 + 287
    @@ -104997,463 +106180,532 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 288 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 289 -
    -   -
    +
    +
    + + + log.Infof("get previous l2block %d", l2Block.L2BlockNumber-1)
    - + + 290 -
    +
    +
      -
    + previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
    - + + 291 -
    +
    +
      -
    + if err != nil {
    - + + 292 -
    +
    +
      -
    + log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err)
    - - -
    -   -
    -
    +
    +
     
    - + + 309 -
    +
    +
      -
    + ChainID: uint32(chainID),
    - + + 310 -
    +
    +
      -
    + }
    - + + 311 -
    +
    +
     
    - + + 312 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 313 -
    -   -
    +
    +
    + + + log.Infof("add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber)
    - + + 314 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode())
    - + + 315 -
    +
    +
      -
    + if err != nil {
    - + + 316 -
    +
    +
      -
    + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - + + 317 -
    +
    +
      -
    + continue
    - + + 318 -
    +
    +
      -
    + }
    - + + 319 -
    +
    +
     
    - + + 320 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 321 -
    -   -
    +
    +
    + + + log.Infof("adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber)
    - + + 322 -
    +
    +
      -
    + for _, l2Transaction := range l2Block.Txs {
    - + + 323 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode())
    - + + 324 -
    +
    +
      -
    + if err != nil {
    - - -
    +
    +
     
    +
    + 333 + +
      -
    + StateRoot: l2Block.StateRoot,
    - + + 334 -
    +
    +
      -
    + }
    - + + 335 -
    +
    +
     
    - + + 336 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 337 -
    -   -
    +
    +
    + + + log.Infof("add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber)
    - + + 338 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode())
    - + + 339 -
    +
    +
      -
    + if err != nil {
    - + + 340 -
    +
    +
      -
    + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - + + 341 -
    +
    +
      -
    + continue
    - + + 342 -
    +
    +
      -
    + }
    - + + 343 -
    +
    +
     
    - + + 344 -
    +
    +
    + + + //TODO: remove this log +
    +
    + 345 + +
    + + + log.Infof("commit atomic op for l2block %d", l2Block.L2BlockNumber) +
    +
    + 346 + +
      -
    + err = s.streamServer.CommitAtomicOp()
    - + + 347 -
    +
    +
      -
    + if err != nil {
    - + + 348 -
    +
    +
      -
    + log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - + + 349 -
    +
    +
      -
    + continue
    - + + 350 -
    +
    +
      -
    + }
    - + + 351 -
    +
    +
     
    - + + 352 -
    -   +
    +
    + + + //TODO: remove this log +
    +
    + 353 + +
    + + + log.Infof("l2block %d sent to datastream", l2Block.L2BlockNumber) +
    +
    + 354 + +
    + +
    - + + 355 -
    +
    +
      -
    + // Stream a bookmark
    - + + 356 -
    +
    +
      -
    + case state.DSBookMark:
    - + + 357 -
    +
    +
      -
    + bookmark := data +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/worker.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -105467,61 +106719,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - @@ -105897,63 +107174,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -106016,554 +107298,697 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
    @@ -23,6 +23,7 @@
    - + + 23 -
    +
    +
      -
    + state stateInterface
    - + + 24 -
    +
    +
      -
    + batchConstraints state.BatchConstraintsCfg
    - + + 25 -
    +
    +
      -
    + readyTxsCond *timeoutCond
    - + + 26 -
    +
    +
      -
    + }
    - + + 27 -
    +
    +
     
    - + + 28 -
    +
    +
      -
    + // NewWorker creates an init a worker
    - + +
    @@ -60,6 +61,12 @@
    -
    +
    + 60 + +
      -
    + return nil, pool.ErrOutOfCounters
    - + + 61 -
    +
    +
      -
    + }
    - + + 62 -
    +
    +
     
    @@ -105587,61 +106844,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 63 -
    +
    +
      -
    + addr, found := w.pool[tx.FromStr]
    - + + 64 -
    +
    +
      -
    + if !found {
    - + + 65 -
    +
    +
      -
    + // Unlock the worker to let execute other worker functions while creating the new AddrQueue
    - + +
    @@ -174,6 +181,8 @@
    -
    +
    + 174 + +
      -
    + defer w.workerMutex.Unlock()
    - + + 175 -
    +
    +
      -
    + log.Debugf("move tx %s to notReady (from: %s, actualNonce: %d, actualBalance: %s)", txHash.String(), from.String(), actualNonce, actualBalance.String())
    - + + 176 -
    +
    +
     
    @@ -105667,61 +106929,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 177 -
    +
    +
      -
    + addrQueue, found := w.pool[from.String()]
    - + + 178 -
    +
    +
      -
    + if found {
    - + + 179 -
    +
    +
      -
    + // Sanity check. The txHash must be the readyTx
    - + +
    @@ -195,6 +204,8 @@
    -
    +
    + 195 + +
      -
    + w.workerMutex.Lock()
    - + + 196 -
    +
    +
      -
    + defer w.workerMutex.Unlock()
    - + + 197 -
    +
    +
     
    @@ -105747,61 +107014,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 198 -
    +
    +
      -
    + addrQueue, found := w.pool[addr.String()]
    - + + 199 -
    +
    +
      -
    + if found {
    - + + 200 -
    +
    +
      -
    + deletedReadyTx := addrQueue.deleteTx(txHash)
    - + +
    @@ -293,6 +304,8 @@
    -
    +
    + 293 + +
      -
    + w.workerMutex.Lock()
    - + + 294 -
    +
    +
      -
    + defer w.workerMutex.Unlock()
    - + + 295 -
    +
    +
     
    @@ -105827,63 +107099,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 296 -
    +
    +
      -
    + if w.txSortedList.len() == 0 {
    - + + 297 -
    +
    +
      -
    + return nil, ErrTransactionsListEmpty
    - + + 298 -
    +
    +
      -
    + }
    - + +
    @@ -342,6 +355,7 @@
    -
    +
    + 342 + +
     
    - + + 343 -
    +
    +
      -
    + if foundAt != -1 {
    - + + 344 -
    +
    +
      -
    + log.Debugf("best fitting tx %s found at index %d with gasPrice %d", tx.HashStr, foundAt, tx.GasPrice)
    - + + 345 -
    +
    +
      -
    + return tx, nil
    - + + 346 -
    +
    +
      -
    + } else {
    - + + 347 -
    +
    +
      -
    + return nil, ErrNoFittingTransaction
    - + +
    @@ -382,3 +396,9 @@
    -
    +
    + 382 + +
      -
    + w.readyTxsCond.L.Unlock()
    - + + 383 -
    +
    +
      -
    + }
    - + + 384 -
    +
    +
      -
    + }
    +
    +
    +
    +
    + + + + + - - - - - - + + + - - - - - - - - + + + + + + - - + + + - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - + + + + + + + + + + + +
    +
     
    +
    - + + 23 -
    +
    +
      -
    + state stateInterface
    - + + 24 -
    +
    +
      -
    + batchConstraints state.BatchConstraintsCfg
    - + + 25 -
    +
    +
      -
    + readyTxsCond *timeoutCond +
    +
    + 26 + +
    + + + wipTx *TxTracker
    - 1135 + 27
      - func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry { + }
    - 1136 + 28
      - exitRoot := state.L1InfoTreeExitRootStorageEntry{ +
    - 1137 + 29
      - L1InfoTreeLeaf: state.L1InfoTreeLeaf{ + // NewWorker creates an init a worker
    -
    @@ -1333,6 +1677,10 @@
    +
     
    - 1333 + 61
      - require.Equal(t, uint64(2002), fb.BlockNumber) + return nil, pool.ErrOutOfCounters
    - 1334 + 62
      - require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String()) + }
    - 1335 + 63
      - require.Equal(t, []byte{0xb}, fb.RawTxsData) +
    - + + 64 -
    -   -
    +
    +
    + + + if (w.wipTx != nil) && (w.wipTx.FromStr == tx.FromStr) && (w.wipTx.Nonce == tx.Nonce) {
    - + + 65 -
    -   -
    +
    +
    + + + log.Infof("adding tx %s (nonce %d) from address %s that matches current processing tx %s (nonce %d), rejecting it as duplicated nonce", tx.Hash, tx.Nonce, tx.From, w.wipTx.Hash, w.wipTx.Nonce)
    - + + 66 -
    -   -
    +
    +
    + + + w.workerMutex.Unlock()
    - + + 67 -
    -   +
    +
    + + + return nil, ErrDuplicatedNonce +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + +
    - 1336 + 70
      - } + addr, found := w.pool[tx.FromStr]
    - 1337 + 71
      -
    + if !found {
    - 1338 + 72
      - func TestGetLastGER(t *testing.T) { + // Unlock the worker to let execute other worker functions while creating the new AddrQueue
    -
    @@ -1409,5 +1757,41 @@
    +
     
    - 1409 + 181
      - ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) + defer w.workerMutex.Unlock()
    - 1410 + 182
      - require.NoError(t, err) + log.Debugf("move tx %s to notReady (from: %s, actualNonce: %d, actualBalance: %s)", txHash.String(), from.String(), actualNonce, actualBalance.String())
    - 1411 + 183
      - require.Equal(t, common.HexToHash("0x2").String(), ger.String()) +
    - + + 184 -
    -   +
    +
    + + + w.resetWipTx(txHash) +
    +
    + 185 + +
    + +
    - 1412 + 186
      -
    + addrQueue, found := w.pool[from.String()]
    - + + 187 -
    +
    +
      -
    + if found {
    - + + 188 -
    +
    +
      -
    + // Sanity check. The txHash must be the readyTx
    - + +
     
    -
    +
    + 204 + +
      -
    + w.workerMutex.Lock()
    - + + 205 -
    +
    +
      -
    + defer w.workerMutex.Unlock()
    - + + 206 -
    +
    +
     
    - + + 207 -
    -   -
    +
    +
    + + + w.resetWipTx(txHash)
    - + + 208 -
    -   +
    +
    + +
    - + + 209 -
    +
    +
      -
    + addrQueue, found := w.pool[addr.String()]
    - + + 210 -
    +
    +
      -
    + if found {
    - + + 211 -
    +
    +
      -
    + deletedReadyTx := addrQueue.deleteTx(txHash)
    - + +
     
    -
    +
    + 304 + +
      -
    + w.workerMutex.Lock()
    - + + 305 -
    +
    +
      -
    + defer w.workerMutex.Unlock()
    - + + 306 -
    +
    +
     
    - + + 307 -
    -   -
    +
    +
    + + + w.wipTx = nil
    - + + 308 -
    -   +
    +
    + +
    - + + 309 -
    +
    +
      -
    + if w.txSortedList.len() == 0 {
    - + + 310 -
    +
    +
      -
    + return nil, ErrTransactionsListEmpty
    - + + 311 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 355 + +
     
    - + + 356 -
    +
    +
      -
    + if foundAt != -1 {
    - + + 357 -
    +
    +
      -
    + log.Debugf("best fitting tx %s found at index %d with gasPrice %d", tx.HashStr, foundAt, tx.GasPrice)
    - + + 358 -
    -   -
    +
    +
    + + + w.wipTx = tx
    - + + 359 -
    +
    +
      -
    + return tx, nil
    - + + 360 -
    +
    +
      -
    + } else {
    - + + 361 -
    +
    +
      -
    + return nil, ErrNoFittingTransaction
    - + +
     
    -
    +
    + 396 + +
      -
    + w.readyTxsCond.L.Unlock()
    - + + 397 -
    +
    +
      -
    + }
    - + + 398 -
    +
    +
      -
    + }
    - + + 399 -
    -   +
    +
    + +
    - + + 400 -
    -   -
    +
    +
    + + + func (w *Worker) resetWipTx(txHash common.Hash) {
    - + + 401 -
    +
    +
    + + + if (w.wipTx != nil) && (w.wipTx.Hash == txHash) { +
    +
    + 402 + +
    + + + w.wipTx = nil +
    +
    + 403 + +
    + + + } +
    +
    + 404 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - - @@ -106588,7 +108013,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + +
    +
    @@ -41,4 +41,6 @@
    +
    + 41 + +
      -
    + // gas offset: 100
    - + + 42 -
    +
    +
      -
    + // final gas: 1100
    - + + 43 -
    +
    +
      -
    + GasOffset uint64 `mapstructure:"GasOffset"`
    - 1413 + 44
    @@ -106612,362 +108037,380 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 872 + 41
      - ctx := context.Background() + // gas offset: 100
    - 873 + 42
      -
    + // final gas: 1100
    - 874 + 43
      - cfg := state.Config{ + GasOffset uint64 `mapstructure:"GasOffset"`
    - 875 + + 44 +
    + - MaxLogsCount: 40, + // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx
    - 876 + + 45 +
    -   - MaxLogsBlockRange: 10, + + + MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"`
    - 877 + 46
      - ForkIDIntervals: stateCfg.ForkIDIntervals, + }
    - 878 - -
    -   - } +
    +
    - - +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    -
     
    +
    @@ -17,8 +17,8 @@
    - 895 + 17
      - time := time.Now() +
    - 896 + 18
      - blockNumber := big.NewInt(1) + // etherman contains the methods required to interact with ethereum.
    - 897 + 19
      -
    + type etherman interface {
    - 898 + + 20 +
    - + - maxBlocks := 3 + - + BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error)
    - 899 + + 21 +
    - + - txsPerBlock := 4 + - + EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error)
    - 900 + + 22 +
    - + - logsPerTx := 5 +   + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - 901 + + 23 +
    - + -
    +   + GetLatestBatchNumber() (uint64, error)
    - 902 + + 24 +
    - + - nonce := uint64(0) +   + }
    - 903 - -
    - + -
    -
    +
    +
    @@ -41,3 +41,7 @@
    - 904 + + 41 +
    - + - // number of blocks to be created +   + Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
    - 905 + + 42 +
    - + - for b := 0; b < maxBlocks; b++ { +   + ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
    - 906 + + 43 +
    - + - logIndex := uint(0) +   + }
    - 907 + + -
    - + - transactions := make([]*types.Transaction, 0, txsPerBlock) +
    +
    +   +
    - 908 + + -
    - + - receipts := make([]*types.Receipt, 0, txsPerBlock) +
    +
    +   +
    - 909 + + -
    - + - stateRoots := make([]common.Hash, 0, txsPerBlock) +
    +
    +   +
    - 910 + + -
    - + +
    +
    +  
    - 911 - -
    - + - // number of transactions in a block to be created +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - + + +
    +
     
    - 912 + + 17 +
    - + - for t := 0; t < txsPerBlock; t++ { +   +
    - 913 + + 18 +
    - + - nonce++ +   + // etherman contains the methods required to interact with ethereum.
    - 914 + + 19 +
    - + - txIndex := uint(t + 1) +   + type etherman interface {
    - 915 + 20
    + -
    + BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error)
    - 916 + 21
    + - tx := types.NewTx(&types.LegacyTx{ + EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (*types.Transaction, error)
    - 917 + + 22 +
    - + - Nonce: nonce, +   + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - 918 + + 23 +
    - + - To: nil, +   + GetLatestBatchNumber() (uint64, error)
    - 919 + + 24 +
    - + - Value: new(big.Int), +   + }
    - 920 + +
     
    +
    + 41 +
    - + - Gas: 0, +   + Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
    - 921 + + 42 +
    - + - GasPrice: big.NewInt(0), +   + ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
    - 922 + + 43 +
    - + - }) +   + }
    - 923 + 44
    @@ -106977,347 +108420,396 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 924 + 45
    + - logs := []*types.Log{} + type dataAbilitier interface {
    - 925 + 46
    + -
    + PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error)
    - 926 + 47
    + - // if block is even logIndex follows a sequence related to the block + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - + + + + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -6,13 +6,11 @@
    - 927 + + 6 +
    - + - // for odd blocks logIndex follows a sequence related ot the tx +   + "fmt"
    - 928 + + 7 +
    - + - // this is needed to simulate a logIndex difference introduced on Etrog +   + "time"
    - 929 + + 8 +
    - + - // and we need to maintain to be able to synchronize these blocks +   +
    - 930 + + 9 +
    - + - // number of logs in a transaction to be created + - + ethman "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 931 + + 10 +
    - + - for l := 0; l < logsPerTx; l++ { +   + "github.com/0xPolygonHermez/zkevm-node/etherman/types"
    - 932 + + 11 +
    - + - li := logIndex +   + "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
    - 933 + + 12 +
    - + - if b%2 != 0 { // even block +   + "github.com/0xPolygonHermez/zkevm-node/event"
    - 934 + + 13 +
    - + - li = uint(l) +   + "github.com/0xPolygonHermez/zkevm-node/log"
    - 935 + + 14 +
    - + - } +   + "github.com/0xPolygonHermez/zkevm-node/state"
    - 936 + + 15 +
    - + -
    + - + ethTypes "github.com/ethereum/go-ethereum/core/types"
    - 937 + + 16 +
    - + - logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li}) +   + "github.com/jackc/pgx/v4"
    - 938 + + 17 +
    - + - logIndex++ +   + )
    - 939 + + 18 +
    - + - } +   +
    - 940 + +
    @@ -41,16 +39,18 @@
    +
    + 41 +
    - + -
    +   + ethTxManager ethTxManager
    - 941 + + 42 +
    - + - receipt := &types.Receipt{ +   + etherman etherman
    - 942 + + 43 +
    - + - Type: tx.Type(), +   + eventLog *event.EventLog
    - 943 + + -
    - + - PostState: state.ZeroHash.Bytes(), +
    +
    +   +
    - 944 + + 44 +
    - + - CumulativeGasUsed: 0, +   + }
    - 945 + + 45 +
    - + - EffectiveGasPrice: big.NewInt(0), +   +
    - 946 + + 46 +
    - + - BlockNumber: blockNumber, +   + // New inits sequence sender
    - 947 + + 47 +
    - + - GasUsed: tx.Gas(), + - + func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*SequenceSender, error) {
    - 948 + + 48 +
    - + - TxHash: tx.Hash(), +   + return &SequenceSender{
    - 949 + + 49 +
    - + - TransactionIndex: txIndex, +   + cfg: cfg,
    - 950 + + 50 +
    - + - Status: types.ReceiptStatusSuccessful, +   + state: state,
    - 951 + + 51 +
    - + - Logs: logs, +   + etherman: etherman,
    - 952 + + 52 +
    - + - } +   + ethTxManager: manager,
    - 953 + + 53 +
    - + +   + eventLog: eventLog, +
    +
    + + +
    +  
    - 954 + + 54 +
    - + - transactions = append(transactions, tx) +   + }, nil
    - 955 + + 55 +
    - + - receipts = append(receipts, receipt) +   + }
    - 956 + + 56 +
    - + - stateRoots = append(stateRoots, state.ZeroHash) +   +
    +
    @@ -185,9 +185,14 @@
    +
    - 957 + 185
      - } + }
    - 958 + 186
    @@ -107325,6 +108817,26 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 187 + +
    +   + // add sequence to be monitored +
    +
    + 188 + +
    + - + firstSequence := sequences[0] +
    +
    @@ -107367,82 +108879,92 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 959 + 189
      - header := state.NewL2Header(&types.Header{ +
    - 960 + + 190 +
    - + - Number: big.NewInt(int64(b) + 1), + - + to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    + + +
    +   +
    - 961 + 191
      - ParentHash: state.ZeroHash, + if err != nil {
    - 962 + 192
      - Coinbase: state.ZeroAddress, + log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
    - 963 + 193
      - Root: state.ZeroHash, + return
    -
     
    +
    @@ -218,8 +223,6 @@
    - 984 + 218
      - require.NoError(t, err) + sequences := []types.Sequence{}
    - 985 + 219
      - } + // var estimatedGas uint64
    - 986 + 220
    @@ -107451,3533 +108973,3636 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 987 + + 221 +
    - + - require.NoError(t, dbTx.Commit(ctx)) + - + var tx *ethTypes.Transaction
    - 988 + + 222 +
    - + + -
    - 989 + 223
      - type testCase struct { + // Add sequences until too big for a single L1 tx or last batch is reached
    - 990 + 224
      - name string + for {
    - 991 + 225
      - from uint64 + //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
    -
     
    +
    @@ -288,31 +291,11 @@
    - 1020 + 288
      - name: "logs returned successfully", +
    - 1021 + 289
      - from: 1, + sequences = append(sequences, seq)
    - 1022 + 290
      - to: 2, + // Check if can be send
    - 1023 + + 291 +
    - + - logCount: 40, + - + firstSequence := sequences[0]
    - 1024 + + 292 +
    -   - expectedError: nil, + - + lastSequence := sequences[len(sequences)-1]
    - 1025 + + 293 +
    -   - }, + - + tx, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
    - 1026 + + 294 +
    -   - } + - + if err == nil && tx.Size() > s.cfg.MaxTxSizeForL1 {
    - 1027 + + 295 +
    -   -
    + - + log.Infof("oversized Data on TX oldHash %s (txSize %d > %d)", tx.Hash(), tx.Size(), s.cfg.MaxTxSizeForL1)
    - 1028 + + 296 +
    -   - for _, testCase := range testCases { + - + err = ErrOversizedData
    - 1029 + + 297 +
    -   - t.Run(testCase.name, func(t *testing.T) { + - + }
    - 1030 + + 298 +
    - + - logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, nil) + - + if err != nil {
    - + + 299 -
    -   -
    +
    +
    + - + log.Infof("Handling estimage gas send sequence error: %v", err)
    - 1031 + + 300 +
    -   - assert.Equal(t, testCase.logCount, len(logs)) + - + sequences, err = s.handleEstimateGasSendSequenceErr(ctx, sequences, currentBatchNumToSequence, err)
    - 1032 + + 301 +
    -   - assert.Equal(t, testCase.expectedError, err) + - + if sequences != nil {
    - 1033 + + 302 +
    - + -
    + - + if len(sequences) > 0 {
    - 1034 + + 303 +
    - + - // check tx index and log index order + - + // Handling the error gracefully, re-processing the sequence as a sanity check
    - 1035 + + 304 +
    - + - lastBlockNumber := uint64(0) + - + lastSequence = sequences[len(sequences)-1]
    - 1036 + + 305 +
    - + - lastTxIndex := uint(0) + - + _, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
    - 1037 + + 306 +
    - + - lastLogIndex := uint(0) + - + return sequences, err
    - 1038 + + 307 +
    - + -
    + - + }
    - 1039 + + 308 +
    - + - for i, l := range logs { + - + }
    - 1040 + + 309 +
    - + - // if block has changed and it's not the first log, reset lastTxIndex + - + return sequences, err
    - 1041 + + 310 +
    - + - if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 { + - + }
    - 1042 + + 311 +
    - + - lastTxIndex = 0 + - + // estimatedGas = tx.Gas()
    - 1043 + + 312 +
    - + - } + - +
    - 1044 + + 313 +
    - + -
    + - + //Check if the current batch is the last before a change to a new forkid, in this case we need to close and send the sequence to L1
    - 1045 + + 314 +
    - + - if l.TxIndex < lastTxIndex { + - + if (s.cfg.ForkUpgradeBatchNumber != 0) && (currentBatchNumToSequence == (s.cfg.ForkUpgradeBatchNumber)) {
    - 1046 + + 315 +
    - + - t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex) + - + log.Infof("sequence should be sent to L1, as we have reached the batch %d from which a new forkid is applied (upgrade)", s.cfg.ForkUpgradeBatchNumber)
    - 1047 + + 316 +
    - + - } +   + return sequences, nil
    - 1048 + + 317 +
    - + - // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block +   + }
    - 1049 + + 318 +
    - + - // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero +   +
    - 1050 + +
    @@ -343,78 +326,6 @@
    +
    + 343 +
    - + - if l.TxIndex != lastTxIndex && l.Index == 0 { +   + return nil, nil
    - 1051 + + 344 +
    - + - lastLogIndex = 0 +   + }
    - 1052 + + 345 +
    - + - } +   +
    - 1053 + + 346 +
    - + -
    + - + // handleEstimateGasSendSequenceErr handles an error on the estimate gas. It will return:
    - 1054 + + 347 +
    - + - if l.Index < lastLogIndex { + - + // nil, error: impossible to handle gracefully
    - 1055 + + 348 +
    - + - t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index) + - + // sequence, nil: handled gracefully. Potentially manipulating the sequences
    - 1056 + + 349 +
    - + - } + - + // nil, nil: a situation that requires waiting
    - 1057 + + 350 +
    - + -
    + - + func (s *SequenceSender) handleEstimateGasSendSequenceErr(
    - 1058 + + 351 +
    - + - lastBlockNumber = l.BlockNumber + - + ctx context.Context,
    - 1059 + + 352 +
    - + - lastTxIndex = l.TxIndex + - + sequences []types.Sequence,
    - 1060 + + 353 +
    - + - lastLogIndex = l.Index + - + currentBatchNumToSequence uint64,
    - 1061 + + 354 +
    - + - } + - + err error,
    - 1062 + + 355 +
    - + - }) + - + ) ([]types.Sequence, error) {
    - 1063 + + 356 +
    - + - } + - + // Insufficient allowance
    - 1064 + + 357 +
    - + - } + - + if errors.Is(err, ethman.ErrInsufficientAllowance) {
    - 1065 + + 358 +
    - + -
    + - + return nil, err
    - 1066 + + 359 +
    - + - func TestGetLogsByBlockNumber(t *testing.T) { + - + }
    - 1067 + + 360 +
    - + - initOrResetDB() + - + if isDataForEthTxTooBig(err) {
    - 1068 + + 361 +
    - + -
    + - + // Remove the latest item and send the sequences
    - 1069 + + 362 +
    - + - ctx := context.Background() + - + log.Infof(
    - 1070 + + 363 +
    - + -
    + - + "Done building sequences, selected batches to %d. Batch %d caused the L1 tx to be too big",
    - 1071 + + 364 +
    - + - cfg := state.Config{ + - + currentBatchNumToSequence-1, currentBatchNumToSequence,
    - 1072 + + 365 +
    - + - MaxLogsCount: 40, + - + )
    - 1073 + + 366 +
    - + - MaxLogsBlockRange: 10, + - + sequences = sequences[:len(sequences)-1]
    - 1074 + + 367 +
    - + - ForkIDIntervals: stateCfg.ForkIDIntervals, + - + return sequences, nil
    - 1075 + + 368 +
    - + + - }
    - 1076 + + 369 +
    - + + -
    - 1077 + + 370 +
    - + - mt, err := l1infotree.NewL1InfoTree(32, [][32]byte{}) + - + // while estimating gas a new block is not created and the POE SC may return
    - 1078 + + 371 +
    - + - if err != nil { + - + // an error regarding timestamp verification, this must be handled
    - 1079 + + 372 +
    - + - panic(err) + - + // if errors.Is(err, ethman.ErrTimestampMustBeInsideRange) {
    - 1080 + + 373 +
    - + - } + - + // // query the sc about the value of its lastTimestamp variable
    - 1081 + + 374 +
    - + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) + - + // lastTimestamp, err := s.etherman.GetLastBatchTimestamp()
    - 1082 + + 375 +
    - + -
    + - + // if err != nil {
    - 1083 + + 376 +
    - + - dbTx, err := testState.BeginStateTransaction(ctx) + - + // return nil, err
    - 1084 + + 377 +
    - + - require.NoError(t, err) + - + // }
    - 1085 + + 378 +
    - + - err = testState.AddBlock(ctx, block, dbTx) + - + // // check POE SC lastTimestamp against sequences' one
    - 1086 + + 379 +
    - + - assert.NoError(t, err) + - + // for _, seq := range sequences {
    - 1087 + + 380 +
    - + -
    + - + // if seq.Timestamp < int64(lastTimestamp) {
    - 1088 + + 381 +
    - + - batchNumber := uint64(1) + - + // // TODO: gracefully handle this situation by creating an L2 reorg
    - 1089 + + 382 +
    - + - _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num, wip) VALUES ($1, FALSE)", batchNumber) + - + // log.Fatalf("sequence timestamp %d is < POE SC lastTimestamp %d", seq.Timestamp, lastTimestamp)
    - 1090 + + 383 +
    - + - assert.NoError(t, err) + - + // }
    - 1091 + + 384 +
    - + -
    + - + // lastTimestamp = uint64(seq.Timestamp)
    - 1092 + + 385 +
    - + - time := time.Now() + - + // }
    - 1093 + + 386 +
    - + - blockNumber := big.NewInt(1) + - + // blockTimestamp, err := s.etherman.GetLatestBlockTimestamp(ctx)
    - 1094 + + 387 +
    - + -
    + - + // if err != nil {
    - 1095 + + 388 +
    - + - maxBlocks := 3 + - + // log.Error("error getting block timestamp: ", err)
    - 1096 + + 389 +
    - + - txsPerBlock := 4 + - + // }
    - 1097 + + 390 +
    - + - logsPerTx := 5 + - + // log.Debugf("block.timestamp: %d is smaller than seq.Timestamp: %d. A new block must be mined in L1 before the gas can be estimated.", blockTimestamp, sequences[0].Timestamp)
    - 1098 + + 391 +
    - + -
    + - + // return nil, nil
    - 1099 + + 392 +
    - + - nonce := uint64(0) + - + // }
    - 1100 + + 393 +
    - + + -
    - 1101 + + 394 +
    - + - // number of blocks to be created + - + // Unknown error
    - 1102 + + 395 +
    - + - for b := 0; b < maxBlocks; b++ { + - + if len(sequences) == 1 {
    - 1103 + + 396 +
    - + - logIndex := uint(0) + - + // TODO: gracefully handle this situation by creating an L2 reorg
    - 1104 + + 397 +
    - + - transactions := make([]*types.Transaction, 0, txsPerBlock) + - + log.Errorf(
    - 1105 + + 398 +
    - + - receipts := make([]*types.Receipt, 0, txsPerBlock) + - + "Error when estimating gas for BatchNum %d (alone in the sequences): %v",
    - 1106 + + 399 +
    - + - stateRoots := make([]common.Hash, 0, txsPerBlock) + - + currentBatchNumToSequence, err,
    - 1107 + + 400 +
    - + -
    + - + )
    - 1108 + + 401 +
    - + - // number of transactions in a block to be created + - + }
    - 1109 + + 402 +
    - + - for t := 0; t < txsPerBlock; t++ { + - + // Remove the latest item and send the sequences
    - 1110 + + 403 +
    - + - nonce++ + - + log.Infof(
    - 1111 + + 404 +
    - + - txIndex := uint(t + 1) + - + "Done building sequences, selected batches to %d. Batch %d excluded due to unknown error: %v",
    - 1112 + + 405 +
    - + -
    + - + currentBatchNumToSequence, currentBatchNumToSequence+1, err,
    - 1113 + + 406 +
    - + - tx := types.NewTx(&types.LegacyTx{ + - + )
    - 1114 + + 407 +
    - + - Nonce: nonce, + - + sequences = sequences[:len(sequences)-1]
    - 1115 + + 408 +
    - + - To: nil, + - +
    - 1116 + + 409 +
    - + - Value: new(big.Int), + - + return sequences, nil
    - 1117 + + 410 +
    - + - Gas: 0, + - + }
    - 1118 + + 411 +
    - + - GasPrice: big.NewInt(0), + - +
    - 1119 + + 412 +
    - + - }) + - + func isDataForEthTxTooBig(err error) bool {
    - 1120 + + 413 +
    - + -
    + - + return errors.Is(err, ethman.ErrGasRequiredExceedsAllowance) ||
    - 1121 + + 414 +
    - + - logs := []*types.Log{} + - + errors.Is(err, ErrOversizedData) ||
    - 1122 + + 415 +
    - + -
    + - + errors.Is(err, ethman.ErrContentLengthTooLarge)
    - 1123 + + 416 +
    - + - // if block is even logIndex follows a sequence related to the block + - + }
    - 1124 + + 417 +
    - + - // for odd blocks logIndex follows a sequence related ot the tx + - +
    - 1125 - -
    - + - // this is needed to simulate a logIndex difference introduced on Etrog -
    -
    - 1126 + + 418 +
    - + - // and we need to maintain to be able to synchronize these blocks +   + func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
    - 1127 + + 419 +
    - + - // number of logs in a transaction to be created +   + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 1128 + + 420 +
    - + - for l := 0; l < logsPerTx; l++ { +   + if err != nil && err != state.ErrNotFound {
    - 1129 - -
    - + - li := logIndex +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 1130 + + 6 +
    - + - if b%2 != 0 { // even block +   + "fmt"
    - 1131 + + 7 +
    - + - li = uint(l) +   + "time"
    - 1132 + + 8 +
    - + - } +   +
    - 1133 + + -
    - + +
    +
    +  
    - 1134 + + 9 +
    - + - logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li}) +   + "github.com/0xPolygonHermez/zkevm-node/etherman/types"
    - 1135 + + 10 +
    - + - logIndex++ +   + "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
    - 1136 + + 11 +
    - + - } +   + "github.com/0xPolygonHermez/zkevm-node/event"
    - 1137 + + 12 +
    - + -
    +   + "github.com/0xPolygonHermez/zkevm-node/log"
    - 1138 + + 13 +
    - + - receipt := &types.Receipt{ +   + "github.com/0xPolygonHermez/zkevm-node/state"
    - 1139 + + -
    - + - Type: tx.Type(), +
    +
    +   +
    - 1140 + + 14 +
    - + - PostState: state.ZeroHash.Bytes(), +   + "github.com/jackc/pgx/v4"
    - 1141 + + 15 +
    - + - CumulativeGasUsed: 0, +   + )
    - 1142 + + 16 +
    - + - EffectiveGasPrice: big.NewInt(0), +   +
    - 1143 - -
    - + - BlockNumber: blockNumber, -
    +
    +
     
    - 1144 + + 39 +
    - + - GasUsed: tx.Gas(), +   + ethTxManager ethTxManager
    - 1145 + + 40 +
    - + - TxHash: tx.Hash(), +   + etherman etherman
    - 1146 + + 41 +
    - + - TransactionIndex: txIndex, +   + eventLog *event.EventLog
    - 1147 + 42
    + - Status: types.ReceiptStatusSuccessful, + da dataAbilitier
    - 1148 + + 43 +
    - + - Logs: logs, +   + }
    - 1149 + + 44 +
    - + - } +   +
    - 1150 + + 45 +
    - + -
    +   + // New inits sequence sender
    - 1151 + + 46 +
    + - transactions = append(transactions, tx) + func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog, da dataAbilitier) (*SequenceSender, error) {
    - 1152 + + 47 +
    - + - receipts = append(receipts, receipt) +   + return &SequenceSender{
    - 1153 + + 48 +
    - + - stateRoots = append(stateRoots, state.ZeroHash) +   + cfg: cfg,
    - 1154 + + 49 +
    - + - } +   + state: state,
    - 1155 + + 50 +
    - + -
    +   + etherman: etherman,
    - 1156 + + 51 +
    - + - header := state.NewL2Header(&types.Header{ +   + ethTxManager: manager,
    - 1157 + + 52 +
    - + - Number: big.NewInt(int64(b) + 1), +   + eventLog: eventLog,
    - 1158 + 53
    + - ParentHash: state.ZeroHash, + da: da,
    - 1159 + + 54 +
    - + - Coinbase: state.ZeroAddress, +   + }, nil
    - 1160 + + 55 +
    - + - Root: state.ZeroHash, +   + }
    - 1161 + + 56 +
    - + - GasUsed: 1, +   +
    - 1162 - -
    - + - GasLimit: 10, -
    +
    +
     
    - 1163 + + 185 +
    - + - Time: uint64(time.Unix()), +   + }
    - 1164 + 186
      - }) +
    - 1165 + + 187 +
    - + -
    +   + // add sequence to be monitored
    - 1166 + + 188 +
    + - st := trie.NewStackTrie(nil) + dataAvailabilityMessage, err := s.da.PostSequence(ctx, sequences)
    - 1167 + 189
    + - l2Block := state.NewL2Block(header, transactions, []*state.L2Header{}, receipts, st) + if err != nil {
    - 1168 + 190
    + - for _, receipt := range receipts { + log.Error("error posting sequences to the data availability protocol: ", err)
    - 1169 + 191
    + - receipt.BlockHash = l2Block.Hash() + return
    - 1170 + 192
    + - } + }
    - 1171 + + 193 +
    - + +  
    - 1172 + + 194 +
    + - numTxs := len(transactions) + firstSequence := sequences[0]
    - 1173 + 195
    + - storeTxsEGPData := make([]state.StoreTxEGPData, numTxs) + to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase, dataAvailabilityMessage)
    - 1174 + + 196 +
    - + - txsL2Hash := make([]common.Hash, numTxs) +   + if err != nil {
    - 1175 + + 197 +
    - + - for i := range transactions { +   + log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
    - 1176 + + 198 +
    - + - storeTxsEGPData[i] = state.StoreTxEGPData{EGPLog: nil, EffectivePercentage: state.MaxEffectivePercentage} +   + return
    - 1177 + +
     
    +
    + 223 +
    - + - txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i)) +   + sequences := []types.Sequence{}
    - 1178 + + 224 +
    - + - } +   + // var estimatedGas uint64
    - 1179 + + 225 +
    - + +  
    - 1180 + + -
    - + - err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, stateRoots, dbTx) +
    +
    +   +
    - 1181 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1182 + 226
      - } + // Add sequences until too big for a single L1 tx or last batch is reached
    - 1183 + + 227 +
    - + -
    +   + for {
    - 1184 + 228
      - require.NoError(t, dbTx.Commit(ctx)) + //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
    - 1185 + +
     
    +
    + 291 +
    - + +  
    - 1186 + + 292 +
    - + - type testCase struct { +   + sequences = append(sequences, seq)
    - 1187 + + 293 +
    - + - name string +   + // Check if can be send
    - 1188 + + 294 +
    + - blockNumber uint64 + if len(sequences) == int(s.cfg.MaxBatchesForL1) {
    - 1189 + + 295 +
    + - logCount int + log.Info(
    - 1190 + + 296 +
    + - expectedError error + "sequence should be sent to L1, because MaxBatchesForL1 (%d) has been reached",
    - 1191 + + 297 +
    + - } + s.cfg.MaxBatchesForL1,
    - 1192 + + 298 +
    + -
    + )
    - 1193 + + -
    - + - testCases := []testCase{ +
    +
    +   +
    - 1194 + + -
    - + - { +
    +
    +   +
    - 1195 + + -
    - + - name: "logs returned successfully", +
    +
    +   +
    - 1196 + + -
    - + - blockNumber: 1, +
    +
    +   +
    - 1197 + + -
    - + - logCount: 20, +
    +
    +   +
    - 1198 + + -
    - + - expectedError: nil, +
    +
    +   +
    - 1199 + + -
    - + - }, +
    +
    +   +
    - 1200 + + -
    - + - { +
    +
    +   +
    - 1201 + + -
    - + - name: "logs returned successfully", +
    +
    +   +
    - 1202 + + -
    - + - blockNumber: 2, +
    +
    +   +
    - 1203 + + -
    - + - logCount: 20, +
    +
    +   +
    - 1204 + + -
    - + - expectedError: nil, +
    +
    +   +
    - 1205 + + -
    - + - }, +
    +
    +   +
    - 1206 + + -
    - + - } +
    +
    +   +
    - 1207 + + -
    - + +
    +
    +  
    - 1208 + + -
    - + - for _, testCase := range testCases { +
    +
    +   +
    - 1209 + + -
    - + - t.Run(testCase.name, func(t *testing.T) { +
    +
    +   +
    - 1210 + + -
    - + - logs, err := testState.GetLogsByBlockNumber(ctx, testCase.blockNumber, nil) +
    +
    +   +
    - 1211 + + -
    - + - assert.Equal(t, testCase.logCount, len(logs)) +
    +
    +   +
    - 1212 + + -
    - + - assert.Equal(t, testCase.expectedError, err) +
    +
    +   +
    - 1213 + + 299 +
    - + -
    +   + return sequences, nil
    - 1214 + + 300 +
    - + - // check tx index and log index order +   + }
    - 1215 + + 301 +
    - + - lastBlockNumber := uint64(0) +   +
    - 1216 + +
     
    +
    + 326 +
    - + - lastTxIndex := uint(0) +   + return nil, nil
    - 1217 + + 327 +
    - + - lastLogIndex := uint(0) +   + }
    - 1218 + + 328 +
    - + +  
    - 1219 + + -
    - + - for i, l := range logs { +
    +
    +   +
    - 1220 + + -
    - + - // if block has changed and it's not the first log, reset lastTxIndex +
    +
    +   +
    - 1221 + + -
    - + - if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 { +
    +
    +   +
    - 1222 + + -
    - + - lastTxIndex = 0 +
    +
    +   +
    - 1223 + + -
    - + - } +
    +
    +   +
    - 1224 + + -
    - + +
    +
    +  
    - 1225 + + -
    - + - if l.TxIndex < lastTxIndex { +
    +
    +   +
    - 1226 + + -
    - + - t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex) +
    +
    +   +
    - 1227 + + -
    - + - } +
    +
    +   +
    - 1228 + + -
    - + - // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block +
    +
    +   +
    - 1229 + + -
    - + - // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero +
    +
    +   +
    - 1230 + + -
    - + - if l.TxIndex != lastTxIndex && l.Index == 0 { +
    +
    +   +
    - 1231 + + -
    - + - lastLogIndex = 0 +
    +
    +   +
    - 1232 + + -
    - + - } +
    +
    +   +
    - 1233 + + -
    - + +
    +
    +  
    - 1234 + + -
    - + - if l.Index < lastLogIndex { +
    +
    +   +
    - 1235 + + -
    - + - t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index) +
    +
    +   +
    - 1236 + + -
    - + - } +
    +
    +   +
    - 1237 + + -
    - + +
    +
    +  
    - 1238 + + -
    - + - lastBlockNumber = l.BlockNumber +
    +
    +   +
    - 1239 + + -
    - + - lastTxIndex = l.TxIndex +
    +
    +   +
    - 1240 + + -
    - + - lastLogIndex = l.Index +
    +
    +   +
    - 1241 + + -
    - + - } +
    +
    +   +
    - 1242 + + -
    - + - }) +
    +
    +   +
    - 1243 + + -
    - + - } +
    +
    +   +
    - 1244 + + -
    +
    +
      - } +
    - 1245 + + -
    +
    +
     
    - 1246 + + -
    +
    +
      - func TestGetNativeBlockHashesInRange(t *testing.T) { +
    -
     
    +
    + + +
    +   +
    +
    - 1371 + + -
    +
    +
      - require.NoError(t, dbTx.Commit(ctx)) +
    - 1372 + + -
    +
    +
      - } +
    - 1373 + + -
    +
    +
     
    - 1374 + + -
    - + - func TestGetBatchL2DataByNumber(t *testing.T) { +
    +
    +   +
    - 1375 + + -
    - + - // Init database instance +
    +
    +   +
    - 1376 + + -
    - + - initOrResetDB() +
    +
    +   +
    - 1377 + + -
    - + - ctx := context.Background() +
    +
    +   +
    - 1378 + + -
    - + - tx, err := testState.BeginStateTransaction(ctx) +
    +
    +   +
    - 1379 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1380 + + -
    - + - defer func() { require.NoError(t, tx.Commit(ctx)) }() +
    +
    +   +
    - 1381 + + -
    - + +
    +
    +  
    - 1382 + + -
    - + - // empty case +
    +
    +   +
    - 1383 + + -
    - + - var batchNum uint64 = 4 +
    +
    +   +
    - 1384 + + -
    - + - const ( +
    +
    +   +
    - 1385 + + -
    - + - openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)" +
    +
    +   +
    - 1386 + + -
    - + - resetBatchesSQL = "DELETE FROM state.batch" +
    +
    +   +
    - 1387 + + -
    - + - ) +
    +
    +   +
    - 1388 + + -
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil) +
    +
    +   +
    - 1389 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1390 + + -
    - + - data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +
    +
    +   +
    - 1391 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1392 + + -
    - + - assert.Nil(t, data) +
    +
    +   +
    - 1393 + + -
    - + +
    +
    +  
    - 1394 + + -
    - + - // not empty case +
    +
    +   +
    - 1395 + + -
    - + - expectedData := []byte("foo bar") +
    +
    +   +
    - 1396 + + -
    - + - batchNum = 5 +
    +
    +   +
    - 1397 + + -
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) +
    +
    +   +
    - 1398 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1399 + + -
    - + - actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +
    +
    +   +
    - 1400 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1401 + + -
    - + - assert.Equal(t, expectedData, actualData) +
    +
    +   +
    - 1402 + + -
    - + +
    +
    +  
    - 1403 + + -
    - + - multiGet := []uint64{uint64(4), uint64(5), uint64(6)} +
    +
    +   +
    - 1404 + + -
    - + - allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx) +
    +
    +   +
    - 1405 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1406 + + -
    - + - require.Equal(t, expectedData, allData[uint64(5)]) +
    +
    +   +
    - 1407 + + -
    - + +
    +
    +  
    - 1408 + + -
    - + - // Force backup +
    +
    +   +
    - 1409 + + -
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) +
    +
    +   +
    - 1410 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1411 + + -
    - + +
    +
    +  
    - 1412 + + -
    - + - // Get batch 4 from backup +
    +
    +   +
    - 1413 + + -
    - + - batchNum = 4 +
    +
    +   +
    - 1414 + + 329 +
    - + - data, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +   + func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
    - 1415 + + 330 +
    - + - require.NoError(t, err) +   + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 1416 + + 331 +
    - + - assert.Nil(t, data) +   + if err != nil && err != state.ErrNotFound { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -30,7 +30,7 @@
    - 1417 + + 30 +
    - + -
    +   + stateMock := new(StateMock)
    - 1418 + + 31 +
    - + - // Get batch 5 from backup +   + ethermanMock := new(EthermanMock)
    - 1419 + + 32 +
    - + - batchNum = 5 +   + ethTxManagerMock := new(EthTxManagerMock)
    - 1420 + + 33 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) + - + ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil)
    - 1421 + + 34 +
    - + - require.NoError(t, err) +   + assert.NoError(t, err)
    - 1422 + + 35 +
    - + - assert.Equal(t, expectedData, actualData) +   +
    - 1423 + + 36 +
    - + -
    +   + testCases := []IsSyncedTestCase{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - 1424 + + 30 +
    - + - // Update batch 5 and get it from backup +   + stateMock := new(StateMock)
    - 1425 + + 31 +
    - + - expectedData = []byte("new foo bar") +   + ethermanMock := new(EthermanMock)
    - 1426 + + 32 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) +   + ethTxManagerMock := new(EthTxManagerMock)
    - 1427 + + 33 +
    + - require.NoError(t, err) + ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil, nil)
    - 1428 + + 34 +
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) +   + assert.NoError(t, err)
    - 1429 + + 35 +
    - + - require.NoError(t, err) +   +
    - 1430 + + 36 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +   + testCases := []IsSyncedTestCase{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    +
    @@ -69,6 +69,7 @@
    +
    - 1431 + + 69 +
    - + - require.NoError(t, err) +   + ChainId: s.cfg.ChainID,
    - 1432 + + 70 +
    - + - assert.Equal(t, expectedData, actualData) +   + ForkId: request.ForkID,
    - 1433 + + 71 +
    - + - } +   + ContextId: uuid.NewString(),
    - 1434 + + -
    - + +
    +
    +  
    - 1435 + + 72 +
    - + - func TestGetBatchL2DataByNumbers(t *testing.T) { +   + }
    - 1436 + + 73 +
    - + - initOrResetDB() +   +
    - 1437 + + 74 +
    - + - ctx := context.Background() +   + if request.SkipFirstChangeL2Block_V2 {
    - 1438 - -
    - + - tx, err := testState.BeginStateTransaction(ctx) -
    +
    +
    @@ -131,6 +132,7 @@
    - 1439 + + 131 +
    - + - require.NoError(t, err) +   + ForkId: forkId,
    - 1440 + + 132 +
    - + - defer func() { require.NoError(t, tx.Commit(ctx)) }() +   + ContextId: uuid.NewString(),
    - 1441 + + 133 +
    - + -
    +   + SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
    - 1442 + + -
    - + - var i1, i2, i3, i4, i5 = uint64(1), uint64(2), uint64(3), uint64(4), uint64(5) +
    +
    +   +
    - 1443 + + 134 +
    - + - var d1, d2, d4 = []byte("foobar"), []byte("dingbat"), []byte{0xb} +   + }
    - 1444 + + 135 +
    - + +  
    - 1445 + + 136 +
    - + - const insertBatch = "INSERT INTO state.batch (batch_num, raw_txs_data) VALUES ($1, $2)" +   + if forcedBlockHashL1 != nil {
    - 1446 - -
    - + - _, err = tx.Exec(ctx, insertBatch, i1, d1) -
    +
    +
    @@ -231,6 +233,7 @@
    - 1447 + + 231 +
    - + - require.NoError(t, err) +   + ContextId: uuid.NewString(),
    - 1448 + + 232 +
    - + - _, err = tx.Exec(ctx, insertBatch, i2, d2) +   + SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
    - 1449 + + 233 +
    - + - require.NoError(t, err) +   + L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
    - 1450 + + -
    - + - _, err = tx.Exec(ctx, insertBatch, i3, nil) +
    +
    +   +
    - 1451 + + 234 +
    - + - require.NoError(t, err) +   + }
    - 1452 + + 235 +
    - + +  
    - 1453 + + 236 +
    - + - // Add a forced batch too, needs a block +   + if processingCtx.ForcedBlockHashL1 != nil {
    - 1454 - -
    - + - block1 := *block +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + +
    +
     
    - 1455 + + 69 +
    - + - block1.BlockNumber = 1000 +   + ChainId: s.cfg.ChainID,
    - 1456 + + 70 +
    - + - err = testState.AddBlock(ctx, &block1, tx) +   + ForkId: request.ForkID,
    - 1457 + + 71 +
    - + - require.NoError(t, err) +   + ContextId: uuid.NewString(),
    - 1458 + 72
    + - err = tx.Commit(ctx) + ExecutionMode: request.ExecutionMode,
    - 1459 + + 73 +
    - + - require.NoError(t, err) +   + }
    - 1460 + + 74 +
    - + +  
    - 1461 + + 75 +
    - + - tx, err = testState.BeginStateTransaction(ctx) +   + if request.SkipFirstChangeL2Block_V2 {
    - 1462 - -
    - + - require.NoError(t, err) -
    +
    +
     
    - 1463 + + 132 +
    - + -
    +   + ForkId: forkId,
    - 1464 + + 133 +
    - + - const insertForcedBatch = "INSERT INTO state.forced_batch (forced_batch_num, timestamp, raw_txs_data, block_num) VALUES (4, now(),'0b', 1000)" +   + ContextId: uuid.NewString(),
    - 1465 + + 134 +
    - + - _, err = testState.Exec(ctx, insertForcedBatch) +   + SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
    - 1466 + 135
    + - require.NoError(t, err) + ExecutionMode: executor.ExecutionMode1,
    - 1467 + + 136 +
    - + -
    +   + }
    - 1468 + + 137 +
    - + - allData, err := testState.GetBatchL2DataByNumbers(ctx, []uint64{i1, i2, i3, i4, i5}, tx) +   +
    - 1469 + + 138 +
    - + - require.NoError(t, err) +   + if forcedBlockHashL1 != nil {
    - 1470 - -
    - + - assert.Equal(t, d1, allData[i1]) -
    +
    +
     
    - 1471 + + 233 +
    - + - assert.Equal(t, d2, allData[i2]) +   + ContextId: uuid.NewString(),
    - 1472 + + 234 +
    - + - assert.Nil(t, allData[i3]) +   + SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
    - 1473 + + 235 +
    - + - assert.Equal(t, d4, allData[i4]) +   + L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
    - 1474 + 236
    + -
    + ExecutionMode: processingCtx.ExecutionMode,
    - 1475 + + 237 +
    - + - _, ok := allData[i5] +   + }
    - 1476 + + 238 +
    - + - assert.False(t, ok) +   +
    - 1477 + + 239 +
    - + - } +   + if processingCtx.ForcedBlockHashL1 != nil {
    - 1478 - -
    - + -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/block.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + + +
    +
    @@ -12,6 +12,7 @@
    - 1479 + 12
      - func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry { + BlockHash common.Hash
    - 1480 + 13
      - exitRoot := state.L1InfoTreeExitRootStorageEntry{ + ParentHash common.Hash
    - 1481 + 14
      - L1InfoTreeLeaf: state.L1InfoTreeLeaf{ + ReceivedAt time.Time
    -
     
    +
    + + +
    +   +
    +
    - 1677 + 15
      - require.Equal(t, uint64(2002), fb.BlockNumber) + }
    - 1678 + 16
      - require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String()) +
    - 1679 + 17
      - require.Equal(t, []byte{0xb}, fb.RawTxsData) + // NewBlock creates a block with the given data. +
    +
    +
    +
    +
    + + + + + - - - - - - - + + +
    +
     
    - 1680 + + 12 +
    - + -
    +   + BlockHash common.Hash
    - 1681 + + 13 +
    - + - fbData, err := testState.GetBatchL2DataByNumber(ctx, 1, dbTx) +   + ParentHash common.Hash
    - 1682 + + 14 +
    - + - require.NoError(t, err) +   + ReceivedAt time.Time
    - 1683 + 15
    + - require.Equal(t, []byte{0xb}, fbData) + Checked bool
    - 1684 + 16
    @@ -110987,7 +112612,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1685 + 17
    @@ -110997,566 +112622,441 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1686 + 18
      - func TestGetLastGER(t *testing.T) { + // NewBlock creates a block with the given data.
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -0,0 +1,44 @@
    - 1757 + + -
    +
    +
      - ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) +
    - 1758 + + -
    +
    +
      - require.NoError(t, err) +
    - 1759 + + -
    +
    +
      - require.Equal(t, common.HexToHash("0x2").String(), ger.String()) +
    - 1760 + + -
    - + - } +
    +
    +   +
    - 1761 + + -
    +
    +
     
    - 1762 + + -
    - + - func TestGetFirstUncheckedBlock(t *testing.T) { +
    +
    +   +
    - 1763 + + -
    - + - var err error +
    +
    +   +
    - 1764 + + -
    - + - blockNumber := uint64(51001) +
    +
    +   +
    - 1765 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) +
    +
    +   +
    - 1766 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1767 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) +
    +
    +   +
    - 1768 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1769 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) +
    +
    +   +
    - 1770 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1771 + + -
    - + +
    +
    +  
    - 1772 + + -
    - + - block, err := testState.GetFirstUncheckedBlock(context.Background(), blockNumber, nil) +
    +
    +   +
    - 1773 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1774 + + -
    - + - require.Equal(t, uint64(blockNumber+1), block.BlockNumber) +
    +
    +   +
    - 1775 + + -
    - + - } +
    +
    +   +
    - 1776 + + -
    - + +
    +
    +  
    - 1777 + + -
    - + - func TestUpdateCheckedBlockByNumber(t *testing.T) { +
    +
    +   +
    - 1778 + + -
    - + - var err error +
    +
    +   +
    - 1779 + + -
    - + - blockNumber := uint64(54001) +
    +
    +   +
    - 1780 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) +
    +
    +   +
    - 1781 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1782 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) +
    +
    +   +
    - 1783 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1784 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) +
    +
    +   +
    - 1785 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1786 + + -
    - + +
    +
    +  
    - 1787 + + -
    - + - b1, err := testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) +
    +
    +   +
    - 1788 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1789 + + -
    - + - require.True(t, b1.Checked) +
    +
    +   +
    - 1790 + + -
    - + +
    +
    +  
    - 1791 + + -
    - + - err = testState.UpdateCheckedBlockByNumber(context.Background(), uint64(blockNumber), false, nil) +
    +
    +   +
    - 1792 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1793 + + -
    - + +
    +
    +  
    - 1794 + + -
    - + - b1, err = testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) +
    +
    +   +
    - 1795 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1796 + + -
    - + - require.False(t, b1.Checked) -
    -
    - 1797 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -111599,26 +113099,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - - - -
    -
    @@ -13,12 +14,14 @@
    -
    - 13 - -
    -   - // - VerifiedBatches -
    -
    - 14 - -
    -   - // - Entries in exit_root table -
    -
    - 15 - -
    -   - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) -
    -
    - 16 - -
    - - - if err == nil { -
    -
    - 17 - -
    - - - // Discard L1InfoTree cache -
    -
    - 18 - -
    - - - // We can't rebuild cache, because we are inside a transaction, so we dont known -
    -
    - 19 - -
    - - - // is going to be a commit or a rollback. So is going to be rebuild on the next -
    -
    - 20 - -
    - - - // request that needs it. -
    -
    - 21 - -
    - - - s.l1InfoTree = nil -
    -
    - 22 - -
    -   - } -
    -
    - 23 - -
    - - - return err +
    +
    +   +
    - - -
    -   -
    -
    -
    - 24 - -
    -   - } -
    -
    @@ -111634,476 +113114,443 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - 14 + + 1 - +
    -   - // - VerifiedBatches + + + package state
    - - 15 + + 2 - +
    -   - // - Entries in exit_root table + + +
    - - 16 + + 3 - +
    -   - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) + + + import (
    - - 17 + + 4 - +
    + - if err != nil { + "errors"
    - - 18 + + 5 - +
    + - log.Error("error resetting L1BlockNumber. Error: ", err) + "math/big"
    - - 19 + + 6 - +
    + - return err + )
    - - + + 7 - -
    -   + +
    + +
    - - + + 8 - -
    -   -
    + +
    + + + const (
    - - + + 9 - -
    -   -
    + +
    + + + // MaxEffectivePercentage is the maximum value that can be used as effective percentage
    - - 20 + + 10 - +
    -   - } + + + MaxEffectivePercentage = uint8(255)
    - - 21 + + 11 - +
    + - // Discard L1InfoTree cache + )
    - 22 + 12
    + - // We can't rebuild cache, because we are inside a transaction, so we dont known +
    - 23 + 13
    + - // is going to be a commit or a rollback. So is going to be rebuild on the next + var (
    - 24 + 14
    + - // request that needs it. + // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero
    - 25 + 15
    + - s.l1InfoTree = nil + ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero")
    - 26 + 16
    + - return nil +
    - - 27 + + 17 - +
    -   - } -
    - - - - -
    + + + // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -10,6 +10,13 @@
    - 10 + + 18 +
    -   - "google.golang.org/grpc/credentials/insecure" + + + ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero")
    - 11 + + 19 +
    -   + + )
    - 12 + + 20 +
    -   + +
    - + + 21 -
    -   -
    +
    +
    + + + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - + + 22 -
    -   -
    +
    +
    + + + func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - + + 23 -
    -   -
    +
    +
    + + + const bits = 256
    - + + 24 -
    -   -
    +
    +
    + + + var bitsBigInt = big.NewInt(bits)
    - + + 25 -
    -   +
    +
    + +
    - + + 26 -
    -   -
    +
    +
    + + + if effectiveGasPrice == nil || gasPrice == nil ||
    - + + 27 -
    -   -
    +
    +
    + + + gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 {
    - 13 + + 28 +
    -   - // NewExecutorClient is the executor client constructor. + + + return 0, ErrEffectiveGasPriceEmpty
    - 14 + + 29 +
    -   - func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) { + + + }
    - 15 + + 30 +
    -   - opts := []grpc.DialOption{ + + +
    -
    + + + 31 + + +
    + + + if gasPrice.Cmp(effectiveGasPrice) <= 0 {
    -
    -
    - - - - - - - - - - - - - - - - - @@ -112113,12 +113560,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go RENAMED
    - - - - - - - - - - - - - - - - - @@ -112257,32 +113654,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -112301,152 +113698,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - @@ -112456,12 +113803,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go RENAMED
    - - - + + +
    -
     
    - 10 + + 32 +
    -   - "google.golang.org/grpc/credentials/insecure" + + + return MaxEffectivePercentage, nil
    - 11 + + 33 +
    -   - ) + + + }
    - 12 + + 34 +
    -   + +
    - 13 + 35
    + - const ( + // Simulate Ceil with integer division
    - 14 + 36
    + - // ExecutionMode0 is the execution mode for the sequencer and RPC, default one + b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt)
    - 15 + 37
    + - ExecutionMode0 = uint64(0) + b = b.Add(b, gasPrice)
    - 16 + 38
    + - // ExecutionMode1 is the execution mode for the synchronizer + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd
    - 17 + 39
    + - ExecutionMode1 = uint64(1) + b = b.Div(b, gasPrice)
    - 18 + 40
    + - ) + // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte)
    - 19 + 41
    + -
    + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd
    - 20 + + 42 +
    -   - // NewExecutorClient is the executor client constructor. + + +
    - 21 + + 43 +
    -   - func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) { + + + return uint8(b.Uint64()), nil
    - 22 + + 44 +
    -   - opts := []grpc.DialOption{ + + + }
    -
    @@ -78,7 +78,15 @@
    +
    @@ -19,8 +19,10 @@
    - 78 + 19
      - var effectivePercentage []uint8 +
    - 79 + 20
      - for i := 0; i <= count; i++ { + // Genesis contains the information to populate state on creation
    - 80 + 21
      - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) + type Genesis struct {
    - 81 + 22
    - - effectivePercentage = append(effectivePercentage, MaxEffectivePercentage) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1
    - + + 23 -
    -   -
    +
    +
    + - + BlockNumber uint64
    - 82 + 24
      - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + // Root hash of the genesis block
    - 83 + 25
      - } + Root common.Hash
    - 84 + 26
      -
    + // Actions is the data to populate into the state trie
    - 78 + 19
      - var effectivePercentage []uint8 +
    - 79 + 20
      - for i := 0; i <= count; i++ { + // Genesis contains the information to populate state on creation
    - 80 + 21
      - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) + type Genesis struct {
    - 81 + 22
    + - txGasPrice := tx.GasPrice() -
    -
    - 82 - -
    - + - effectiveGasPrice := receipt.EffectiveGasPrice -
    -
    - 83 - -
    - + - egpPercentage, err := CalculateEffectiveGasPricePercentage(txGasPrice, effectiveGasPrice) -
    -
    - 84 - -
    - + - if errors.Is(err, ErrEffectiveGasPriceEmpty) { -
    -
    - 85 - -
    - + - egpPercentage = MaxEffectivePercentage -
    -
    - 86 - -
    - + - } else if err != nil { + // RollupBlockNumber is the block number where the polygonZKEVM smc was deployed on L1
    - 87 + + 23 +
    + - return nil, err + RollupBlockNumber uint64
    - 88 + 24
    + - } + // RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1
    - 89 + 25
    + - effectivePercentage = append(effectivePercentage, egpPercentage) + RollupManagerBlockNumber uint64
    - 90 + 26
      - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + // Root hash of the genesis block
    - 91 + 27
      - } + Root common.Hash
    - 92 + 28
      -
    + // Actions is the data to populate into the state trie
    -
    @@ -509,8 +509,7 @@
    +
    @@ -18,8 +18,6 @@
    - 509 + 18
      - } + double = 2
    - 510 + 19
      - nonce := loadedNonce.Uint64() + ether155V = 27
    - 511 + 20
      -
    + etherPre155V = 35
    - 512 + + 21 +
    - - deltaTimestamp := uint32(uint64(time.Now().Unix()) - l2Block.Time()) + // MaxEffectivePercentage is the maximum value that can be used as effective percentage
    - 513 + 22
    - - transactions := s.BuildChangeL2Block(deltaTimestamp, uint32(0)) + MaxEffectivePercentage = uint8(255)
    - 514 + 23
      -
    + // Decoding constants
    - 515 + 24
      - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) + headerByteLength uint64 = 1
    - 516 + 25
      - if err != nil { + sLength uint64 = 32
    +
    +
    +
    +
    + + + - - - - - - + + +
    -
    @@ -535,22 +534,24 @@
    +
     
    - 535 + 18
      -
    + double = 2
    - 536 + 19
      - // v2 fields + ether155V = 27
    - 537 + 20
      - L1InfoRoot: l2Block.BlockInfoRoot().Bytes(), + etherPre155V = 35
    - 538 + + -
    - - - TimestampLimit: uint64(time.Now().Unix()), +
    +
    +   +
    - 539 + + -
    +
    +
      - SkipFirstChangeL2Block: cFalse, +
    - 540 + 21
      - SkipWriteBlockInfoRoot: cTrue, + // Decoding constants
    - + + 22 -
    +
    +
      -
    + headerByteLength uint64 = 1
    - 541 + 23
      - } + sLength uint64 = 32 +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - + + + + + + + + + - - - - - - + + + @@ -112805,67 +114225,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -112880,32 +114300,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -112924,82 +114324,92 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + @@ -113009,322 +114419,391 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + - - - - - - + + + +
    +
    @@ -24,6 +24,9 @@
    - 542 + 24
      - if noZKEVMCounters { + GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error)
    - 543 + 25
      - processBatchRequestV2.NoCounters = cTrue + GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error)
    - 544 + 26
      - } + GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error)
    - 545 + + -
    +
    +
     
    - 546 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 27 +
    - - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From) +   + AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error
    - 547 + 28
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum) + GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error)
    - 548 + 29
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot)) + GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    +
    @@ -146,10 +149,13 @@
    +
    - 549 + 146
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash)) + GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error)
    - + + 147 -
    +
    +
      -
    + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 550 + 148
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase) + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 551 + + 149 +
    - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId) + GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error)
    - 552 + + 150 +
    - - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId) +   + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    - 553 + 151
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree) + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    +
    + 152 + +
    +   + GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
    - 554 + 153
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId) + GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
    - 555 + 154
      -
    + GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
    - 556 + 155
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot)) + GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error)
    -
    @@ -1015,6 +1016,7 @@
    +
    @@ -159,4 +165,5 @@
    - 1015 + 159
      - TimestampLimit: uint64(time.Now().Unix()), + UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - 1016 + 160
      - SkipFirstChangeL2Block: cTrue, + GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error)
    - 1017 + 161
      - SkipWriteBlockInfoRoot: cTrue, + GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error)
    - 1018 - -
    -   - } -
    -
    - 1019 - -
    -   -
    -
    -
    - 1020 + 162
      - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + }
    - 509 + 24
      - } + GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error)
    - 510 + 25
      - nonce := loadedNonce.Uint64() + GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error)
    - 511 + 26
      -
    + GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error)
    - 512 + + 27 +
    + - transactions := s.BuildChangeL2Block(uint32(0), uint32(0)) + GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*Block, error)
    - + + 28 -
    -   -
    +
    +
    + + + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*Block, error) +
    +
    + 29 + +
    + + + UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error
    - 513 + 30
      -
    + AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error
    - 514 + 31
      - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) + GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error)
    - 515 + 32
      - if err != nil { + GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 534 + 149
      -
    + GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error)
    - 535 + 150
      - // v2 fields + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 536 + 151
      - L1InfoRoot: l2Block.BlockInfoRoot().Bytes(), + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 537 + 152
    + - TimestampLimit: l2Block.Time(), + GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error)
    - 538 + 153
      - SkipFirstChangeL2Block: cFalse, + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    - 539 + 154
      - SkipWriteBlockInfoRoot: cTrue, + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    +
    + 155 + +
    +   + GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
    - 540 + 156
    + - ExecutionMode: executor.ExecutionMode0, + GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error)
    - 541 + + 157 +
    -   - } + + + GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 542 + + 158 +
    -   - if noZKEVMCounters { + + + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 543 + 159
      - processBatchRequestV2.NoCounters = cTrue + GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
    - 544 + 160
      - } + GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
    - 545 + 161
      -
    + GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error)
    - - -
    -   -
    -
    +
    +
     
    - 546 + 165
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum) + UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - 547 + 166
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot)) + GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error)
    - 548 + 167
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash)) + GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error)
    - 549 + 168
    + -
    + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    - 550 + 169
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase) + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + + + + + + - - - + + + - - + + + - - -
    +
    @@ -34,20 +34,20 @@
    - + + 34 -
    +
    +
      -
    + if s.l1InfoTree != nil {
    - + + 35 -
    +
    +
      -
    + return nil
    - 551 + 36
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree) + }
    - 552 + + 37 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId) + - + log.Debugf("Building L1InfoTree cache")
    - 553 + + 38 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId) + - + allLeaves, err := s.storage.GetAllL1InfoRootEntries(ctx, dbTx)
    - 554 + + 39 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From) +   + if err != nil { +
    +
    + 40 + +
    + - + log.Error("error getting all leaves. Error: ", err) +
    +
    + 41 + +
    + - + return fmt.Errorf("error getting all leaves. Error: %w", err)
    - 555 + 42
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId) + }
    - 556 + 43
      -
    + var leaves [][32]byte
    - 557 + 44
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot)) + for _, leaf := range allLeaves {
    -
     
    -
    - 1016 + 45
      - TimestampLimit: uint64(time.Now().Unix()), + leaves = append(leaves, leaf.Hash())
    - 1017 + 46
      - SkipFirstChangeL2Block: cTrue, + } +
    +
    + 47 + +
    + - + mt, err := l1infotree.NewL1InfoTree(uint8(32), leaves) //nolint:gomnd
    - 1018 + 48
      - SkipWriteBlockInfoRoot: cTrue, + if err != nil {
    - 1019 + + 49 +
    - + - ExecutionMode: executor.ExecutionMode0, + - + log.Error("error creating L1InfoTree. Error: ", err) +
    +
    + 50 + +
    + - + return fmt.Errorf("error creating L1InfoTree. Error: %w", err)
    - 1020 + 51
    @@ -113334,111 +114813,97 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1021 + 52
      -
    + s.l1InfoTree = mt
    - 1022 + 53
      - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + return nil
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - RENAMED - -
    -
    -
    -
    - - - + + + + - - - - - - @@ -113452,88 +114917,98 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + + + + - - - - @@ -113568,176 +115043,246 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + +
    -
    @@ -6,9 +6,9 @@
    +
    @@ -55,6 +55,14 @@
    - 6 + 55
      - "fmt" +
    - 7 + 56
      - "math/big" + // AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error
    - 8 + 57
    +   + func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) { +
    +
    + + +
     
    - 9 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    +   +
    - 10 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/log" +
    - 11 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/state" +
    - 12 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 13 + + -
    +
    +
      - ) +
    - 14 + + -
    +
    +
     
    -
    @@ -129,11 +129,14 @@
    +
    + 58 + +
    +   + var newIndex uint32 +
    - 129 + 59
      - } + gerIndex, err := s.GetLatestIndex(ctx, dbTx)
    - 130 + 60
      -
    + if err != nil && !errors.Is(err, ErrNotFound) {
    +
    @@ -74,6 +82,9 @@
    +
    - 131 + 74
      - func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error { + log.Error("error add new leaf to the L1InfoTree. Error: ", err)
    - 132 + + 75 +
    - - - if localL2Block == nil || trustedL2Block == nil || trustedL2Block.Hash == nil { +   + return nil, err
    - 133 + + 76 +
    - - - return fmt.Errorf("%s localL2Block or trustedL2Block or trustedHash are nil", prefixLogs) +   + }
    - 134 + 77
      - } + entry := L1InfoTreeExitRootStorageEntry{
    - 135 + + 78 +
    - - - if localL2Block.Hash() != *trustedL2Block.Hash { +   + L1InfoTreeLeaf: *l1InfoTreeLeaf,
    - 136 + + 79 +
    - - - return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), (*trustedL2Block.Hash).String()) +   + L1InfoTreeRoot: root, +
    +
    +
    +
    +
    + + + + + - - -
    +
     
    - 137 + 34
      - } + if s.l1InfoTree != nil {
    - 138 + 35
      - return nil + return nil
    - 139 + 36
      - } + }
    -
    + + + 37 + + +
    + + + // Reset L1InfoTree siblings and leaves +
    + + + + 38 + + +
    + + + allLeaves, err := s.GetAllL1InfoRootEntries(ctx, dbTx)
    -
    -
    - - - - - + + + + + + - - - - + + + + + + + + + @@ -113747,87 +115292,172 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + @@ -113892,12 +115532,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/block.go RENAMED
    + + + + + + + + + @@ -113931,7 +115601,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113941,7 +115611,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113951,7 +115621,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113961,7 +115631,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113971,7 +115641,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113981,167 +115651,167 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + - - + - - - - - - - - @@ -114195,188 +115865,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - @@ -114390,726 +116065,728 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - -
    -
     
    - 6 + 39
      - "fmt" + if err != nil { +
    +
    + 40 + +
    + + + log.Error("error getting all leaves to reset l1InfoTree. Error: ", err) +
    +
    + 41 + +
    + + + return err
    - 7 + 42
      - "math/big" + }
    - 8 + 43
      -
    + var leaves [][32]byte
    - + + 44 -
    +
    +
      -
    + for _, leaf := range allLeaves {
    - 9 + 45
      - "github.com/0xPolygonHermez/zkevm-node/log" + leaves = append(leaves, leaf.Hash())
    - 10 + 46
      - "github.com/0xPolygonHermez/zkevm-node/state" + }
    - 11 + + 47 +
    + - "github.com/ethereum/go-ethereum/core/types" + mt, err := s.l1InfoTree.ResetL1InfoTree(leaves)
    - 12 + 48
      - "github.com/jackc/pgx/v4" + if err != nil { +
    +
    + 49 + +
    + + + log.Error("error resetting l1InfoTree. Error: ", err) +
    +
    + 50 + +
    + + + return err
    - 13 + 51
      - ) + }
    - 14 + 52
      -
    + s.l1InfoTree = mt +
    +
    + 53 + +
    +   + return nil
    - 129 + 55
      - } +
    - 130 + 56
      -
    + // AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error
    - 131 + 57
      - func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error { + func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) {
    - 132 + + 58 +
    + - if localL2Block == nil || trustedL2Block == nil { + var stateTx *StateTx
    - 133 + + 59 +
    + - return fmt.Errorf("%s localL2Block or trustedL2Block are nil", prefixLogs) + if dbTx != nil {
    - 134 + 60
    + - } + var ok bool
    - 135 + 61
    + - if localL2Block.Hash() != trustedL2Block.Hash() { + stateTx, ok = dbTx.(*StateTx)
    - 136 + 62
    + - return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), trustedL2Block.Hash().String()) + if !ok { +
    +
    + 63 + +
    + + + return nil, fmt.Errorf("error casting dbTx to stateTx") +
    +
    + 64 + +
    + + + } +
    +
    + 65 + +
    + + + }
    - 137 + 66 + +
    +   + var newIndex uint32 +
    +
    + 67 + +
    +   + gerIndex, err := s.GetLatestIndex(ctx, dbTx) +
    +
    + 68 + +
    +   + if err != nil && !errors.Is(err, ErrNotFound) { +
    +
    +
     
    +
    + 82 + +
    +   + log.Error("error add new leaf to the L1InfoTree. Error: ", err) +
    +
    + 83 + +
    +   + return nil, err +
    +
    + 84
    @@ -113836,53 +115466,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 138 + + 85 +
    + - if localL2Block.ParentHash() != trustedL2Block.ParentHash() { + if stateTx != nil {
    - 139 + + 86 +
    + - return fmt.Errorf("%s localL2Block.ParentHash %s and trustedL2Block.ParentHash %s are different", prefixLogs, localL2Block.ParentHash().String(), trustedL2Block.ParentHash().String()) + stateTx.SetL1InfoTreeModified() +
    +
    + 87 + +
    + + + }
    - 140 + 88
      - } + entry := L1InfoTreeExitRootStorageEntry{
    - 141 + 89
      - return nil + L1InfoTreeLeaf: *l1InfoTreeLeaf,
    - 142 + 90
      - } + L1InfoTreeRoot: root,
    -
    @@ -19,7 +18,7 @@
    +
    @@ -16,10 +16,10 @@
    - 19 + 16
      - type CheckL2BlocksTestData struct { +
    +
    +
    + 17 + +
    +   + // AddBlock adds a new block to the State Store +
    +
    + 18 + +
    +   + func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error { +
    +
    + 19 + +
    + - + const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at) VALUES ($1, $2, $3, $4)"
      - sut *actions.CheckL2BlockHash +
      - mockState *mock_syncinterfaces.StateFullInterface + e := p.getExecQuerier(dbTx)
    - - zKEVMClient *mock_syncinterfaces.ZKEVMClientInterface + _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt)
      - } + return err
      -
    + }
      - func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) { +
    -
    @@ -57,7 +56,7 @@
    +
    @@ -30,11 +30,11 @@
    - 57 + 30
      - func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData { + parentHash string
    - 58 + 31
      - res := CheckL2BlocksTestData{ + block state.Block
    - 59 + 32
      - mockState: mock_syncinterfaces.NewStateFullInterface(t), + )
    - 60 + 33
    - - zKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1"
    - 61 + 34
      - } +
    - 62 + 35
      - res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus) + q := p.getExecQuerier(dbTx)
    - 63 + 36
      - return res +
    -
    @@ -97,18 +96,23 @@
    +
    + 37 + +
    + - + err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) +
    - 97 + 38
      -
    + if errors.Is(err, pgx.ErrNoRows) {
    - 98 + 39
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) + return nil, state.ErrStateNotSynchronized
    - 99 + 40
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) + }
    - 100 - -
    - - - l2blockHash := stateBlock.Hash() -
    +
    +
    @@ -43,6 +43,55 @@
    - 101 + + 43 +
    - - - rpcL2Block := rpctypes.Block{ +   + return &block, err
    - 102 + + 44 +
    - - - Hash: &l2blockHash, +   + }
    - 103 + + 45 +
    - - - Number: rpctypes.ArgUint64(lastL2Block), +   +
    - 104 + + -
    - - - } +
    +
    +   +
    - 105 + + -
    +
    +
     
    - 106 + + -
    - - - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil) +
    +
    +   +
    - 107 + + -
    +
    +
      - err := data.sut.CheckL2Block(context.Background(), nil) +
    - 108 + + -
    +
    +
      - require.NoError(t, err) +
    - 109 + + -
    +
    +
      - } +
    - 110 + + -
    +
    +
     
    - 111 + + -
    - - - func TestCheckL2BlockHashMissmatch(t *testing.T) { +
    +
    +   +
    - 112 + + -
    +
    +
      - data := newCheckL2BlocksTestData(t, 1, 10) +
    - 113 + + -
    +
    +
      - lastL2Block := uint64(14) +
    - 114 + + -
    +
    +
      - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) +
    -
    @@ -119,13 +123,14 @@
    +
    + + +
    +   +
    +
    - 119 + + -
    +
    +
     
    - 120 + + -
    +
    +
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) +
    - 121 + + -
    +
    +
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) +
    - 122 + + -
    - - - l2blockHash := common.HexToHash("0x1234") +
    +
    +   +
    - 123 + + -
    - - - rpcL2Block := rpctypes.Block{ +
    +
    +   +
    - 124 + + -
    - - - Hash: &l2blockHash, +
    +
    +   +
    - 125 + + -
    - - - Number: rpctypes.ArgUint64(lastL2Block), +
    +
    +   +
    - 126 + + -
    - - - } +
    +
    +   +
    - 127 + + -
    +
    +
     
    - 128 + + -
    - - - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil) +
    +
    +   +
    - 129 + + -
    +
    +
      - err := data.sut.CheckL2Block(context.Background(), nil) +
    - 130 + + -
    +
    +
      - require.Error(t, err) +
    - 131 + + -
    +
    +
      - } +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - -
    -
     
    - 18 + + -
    +
    +
      - type CheckL2BlocksTestData struct { +
    - 19 + + -
    +
    +
      - sut *actions.CheckL2BlockHash +
    - 20 + + -
    +
    +
      - mockState *mock_syncinterfaces.StateFullInterface +
    - 21 + + -
    - + - zKEVMClient *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface +
    +
    +   +
    - 22 + + -
    +
    +
      - } +
    - 23 + + -
    +
    +
     
    - 24 + + -
    +
    +
      - func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) { +
    -
     
    +
    + + +
    +   +
    +
    - 56 + + -
    +
    +
      - func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData { +
    - 57 + + -
    +
    +
      - res := CheckL2BlocksTestData{ +
    - 58 + + -
    +
    +
      - mockState: mock_syncinterfaces.NewStateFullInterface(t), +
    - 59 + + -
    - + - zKEVMClient: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t), +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 60 + 46
      - } + // GetPreviousBlock gets the offset previous L1 block respect to latest.
    - 61 + 47
      - res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus) + func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) {
    - 62 + 48
      - return res + var (
    -
     
    +
    @@ -50,11 +99,31 @@
    - 96 + 50
      -
    + parentHash string
    - 97 + 51
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) + block state.Block
    - 98 + 52
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) + )
    - 99 + + 53 +
    - + - //l2blockHash := stateBlock.Hash() + - + const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1"
    - 100 + + -
    - + - // rpcL2Block := rpctypes.Block{ +
    +
    +   +
    - 101 + + -
    - + - // Hash: &l2blockHash, +
    +
    +   +
    - 102 + + -
    - + - // Number: rpctypes.ArgUint64(lastL2Block), +
    +
    +   +
    - 103 + + -
    - + - // } +
    +
    +   +
    - 104 + + -
    - + - // create a types.Block object +
    +
    +   +
    - 105 + + -
    - + +
    +
    +  
    - 106 + + -
    - + - rpcL2Block := types.NewBlock(&types.Header{ +
    +
    +   +
    - 107 + + -
    - + - Number: big.NewInt(int64(lastL2Block)), +
    +
    +   +
    - 108 + + -
    - + - }, nil, nil, nil, nil) +
    +
    +   +
    - 109 + + -
    +
    +
     
    - 110 + + -
    - + - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil) +
    +
    +   +
    - 111 + + -
    +
    +
      - err := data.sut.CheckL2Block(context.Background(), nil) +
    - 112 + + -
    +
    +
      - require.NoError(t, err) +
    - 113 + + -
    +
    +
      - } +
    - 114 + + -
    +
    +
     
    - 115 + + -
    - + - func TestCheckL2BlockHashMismatch(t *testing.T) { +
    +
    +   +
    - 116 + + -
    +
    +
      - data := newCheckL2BlocksTestData(t, 1, 10) +
    - 117 + + -
    +
    +
      - lastL2Block := uint64(14) +
    - 118 + + -
    +
    +
      - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) +
    -
     
    -
    - 123 + + -
    +
    +
     
    - 124 + 54
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) +
    - 125 + 55
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) -
    -
    - 126 - -
    - + - //l2blockHash := common.HexToHash("0x1234") + q := p.getExecQuerier(dbTx)
    - 127 + + 56 +
    - + +  
    - 128 - -
    - + - rpcL2Block := types.NewBlock(&types.Header{ -
    -
    - 129 + + 57 +
    - + - Number: big.NewInt(int64(lastL2Block)), + - + err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt)
    - 130 + + 58 +
    - + - ParentHash: common.HexToHash("0x1234"), +   + if errors.Is(err, pgx.ErrNoRows) {
    - 131 + + 59 +
    - + - }, nil, nil, nil, nil) +   + return nil, state.ErrNotFound
    - 132 + 60
      -
    + }
    - 133 - -
    - + - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil) -
    +
    +
    @@ -70,11 +139,11 @@
    - 134 + 70
      - err := data.sut.CheckL2Block(context.Background(), nil) + parentHash string
    - 135 + 71
      - require.Error(t, err) + block state.Block
    - 136 + 72
      - } + )
    -
    + + + 73 + + +
    + - + const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block WHERE block_num = $1"
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - - - - - @@ -115123,33 +116800,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -115163,308 +116840,322 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - + + +
    -
    @@ -3,7 +3,6 @@
    - 3 + 74
      - import ( +
    - 4 + 75
      - "context" + q := p.getExecQuerier(dbTx)
    - 5 + 76
      - "errors" +
    - 6 + + 77 +
    - - "fmt" + err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt)
    - 7 + 78
      - "time" + if errors.Is(err, pgx.ErrNoRows) {
    - 8 + 79
      -
    + return nil, state.ErrNotFound
    - 9 + 80
      - "github.com/0xPolygonHermez/zkevm-node/etherman" + }
    -
    @@ -60,58 +59,12 @@
    +
    @@ -82,3 +151,14 @@
    - 60 + 82
      -
    + block.ParentHash = common.HexToHash(parentHash)
    - 61 + 83
      - sbatch := l1Block.SequencedBatches[order.Pos][0] + return &block, err
    - 62 + 84
      -
    + }
    - 63 + + -
    +
    +
      - if sbatch.SequencedBatchElderberryData == nil { +
    - 64 + + -
    - - - log.Errorf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber) +
    +
    +   +
    - 65 + + -
    - - - return fmt.Errorf("no elderberry sequenced batch data for batch %d", sbatch.BatchNumber) +
    +
    +   +
    - 66 + + -
    +
    +
      - } +
    - 67 + + -
    - - - // We need to check that the sequence match +
    +
    +   +
    - 68 + + -
    - - - err := g.sanityCheckExpectedSequence(sbatch.SequencedBatchElderberryData.InitSequencedBatchNumber, dbTx) +
    +
    +   +
    - 69 + + -
    - - - if err != nil { +
    +
    +   +
    - 70 + + -
    - - - return err +
    +
    +   +
    - 71 + + -
    - - - } +
    +
    +   +
    +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 72 + + 16 +
    - - - // We known that the MaxSequenceTimestamp is the same for all the batches so we can use the first one +   +
    - 73 + + 17 +
    - - - err = g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0), dbTx) +   + // AddBlock adds a new block to the State Store
    - 74 + + 18 +
    - - - // The last L2block timestamp must match MaxSequenceTimestamp +   + func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error {
    - 75 + + 19 +
    - - - if err != nil { + + + const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at, checked) VALUES ($1, $2, $3, $4, $5)"
    - 76 + + 20 +
    - - - return err +   +
    - 77 + + 21 +
    - - - } +   + e := p.getExecQuerier(dbTx)
    - 78 + + 22 +
    - - - // It checks the timestamp of the last L2 block, but it's just log an error instead of refusing the event + + + _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt, block.Checked)
    - 79 + + 23 +
    - - - _ = g.sanityCheckTstampLastL2Block(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp, dbTx) +   + return err
    - 80 + + 24 +
    - - - return nil +   + }
    - 81 - -
    - - - } -
    -
    - 82 + + 25 +
    - - +  
    - 83 + +
     
    +
    + 30 +
    - - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckExpectedSequence(initialBatchNumber uint64, dbTx pgx.Tx) error { +   + parentHash string
    - 84 + + 31 +
    - - - // We need to check that the sequence match +   + block state.Block
    - 85 + + 32 +
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) +   + )
    - 86 + + 33 +
    - - - if err != nil { + + + const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block ORDER BY block_num DESC LIMIT 1"
    - 87 + + 34 +
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +   +
    - 88 + + 35 +
    - - - return err +   + q := p.getExecQuerier(dbTx)
    - 89 + + 36 +
    - - - } +   +
    - 90 + + 37 +
    - - - if lastVirtualBatchNum != initialBatchNumber { + + + err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - 91 + + 38 +
    - - - log.Errorf("The last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event)", lastVirtualBatchNum+1, initialBatchNumber) +   + if errors.Is(err, pgx.ErrNoRows) {
    - 92 + + 39 +
    - - - return fmt.Errorf("the last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event) err:%w", lastVirtualBatchNum+1, initialBatchNumber, ErrInvalidInitialBatchNumber) +   + return nil, state.ErrStateNotSynchronized
    - 93 + + 40 +
    - - +   }
    - 94 + +
     
    +
    + 43 +
    - - - return nil +   + return &block, err
    - 95 + + 44 +
    - - +   }
    - 96 + 45
    @@ -115473,1626 +117164,993 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 97 + + 46 +
    - - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckTstampLastL2Block(timeLimit uint64, dbTx pgx.Tx) error { + + + // GetFirstUncheckedBlock returns the first L1 block that has not been checked from a given block number.
    - 98 + + 47 +
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) + + + func (p *PostgresStorage) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) {
    - 99 + + 48 +
    - - - if err != nil { + + + var (
    - 100 + + 49 +
    - - - log.Errorf("Error getting last virtual batch number: %s", err) + + + blockHash string
    - 101 + + 50 +
    - - - return err + + + parentHash string
    - 102 + + 51 +
    - - - } + + + block state.Block
    - 103 + + 52 +
    - - - lastL2Block, err := g.state.GetLastL2BlockByBatchNumber(context.Background(), lastVirtualBatchNum, dbTx) + + + )
    - 104 + + 53 +
    - - - if err != nil { + + + const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND checked=false ORDER BY block_num LIMIT 1"
    - 105 + + 54 +
    - - - log.Errorf("Error getting last virtual batch number: %s", err) + + +
    - 106 + + 55 +
    - - - return err + + + q := p.getExecQuerier(dbTx)
    - 107 + + 56 +
    - - - } + + +
    - 108 + + 57 +
    - - - if lastL2Block == nil { + + + err := q.QueryRow(ctx, getLastBlockSQL, fromBlockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - 109 + + 58 +
    - - - //TODO: find the previous batch until we find a L2 block to check the timestamp + + + if errors.Is(err, pgx.ErrNoRows) {
    - 110 + + 59 +
    - - - return nil + + + return nil, state.ErrNotFound
    - 111 + + 60 +
    - - + + }
    - 112 + + 61 +
    - - - if uint64(lastL2Block.ReceivedAt.Unix()) > timeLimit { + + + block.BlockHash = common.HexToHash(blockHash)
    - 113 + + 62 +
    - - - log.Errorf("The last L2 block timestamp can't be greater than timeLimit. Expected: %d (L1 event), got: %d (last L2Block)", timeLimit, lastL2Block.ReceivedAt.Unix()) + + + block.ParentHash = common.HexToHash(parentHash)
    - 114 + + 63 +
    - - - return fmt.Errorf("wrong timestamp of last L2 block timestamp with L1 event timestamp") + + + return &block, err
    - 115 + + 64 +
    - - - } + + + }
    - 116 + + 65 +
    - - - return nil + + +
    - 117 + + 66 +
    -   - } -
    -
    -
    + + + func (p *PostgresStorage) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) {
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 3 + + 67 +
    -   - import ( + + + const getUncheckedBlocksSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND block_num<=$2 AND checked=false ORDER BY block_num"
    - 4 + + 68 +
    -   - "context" + + +
    - 5 + + 69 +
    -   - "errors" + + + q := p.getExecQuerier(dbTx)
    - + + 70 -
    -   +
    +
    + +
    - 6 + + 71 +
    -   - "time" + + + rows, err := q.Query(ctx, getUncheckedBlocksSQL, fromBlockNumber, toBlockNumber)
    - 7 + + 72 +
    -   -
    + + + if err != nil {
    - 8 + + 73 +
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman" + + + return nil, err
    -
     
    -
    - 59 + + 74 +
    -   -
    + + + }
    - 60 + + 75 +
    -   - sbatch := l1Block.SequencedBatches[order.Pos][0] + + + defer rows.Close()
    - 61 + + 76 +
    -   + +
    - 62 + 77
    + - executionTime := l1Block.ReceivedAt + var blocks []*state.Block
    - 63 + + 78 +
    -   - if sbatch.SequencedBatchElderberryData == nil { + + + for rows.Next() {
    - 64 + + 79 +
    + - log.Warnf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber) + var (
    - 65 + + 80 +
    + - } else { + blockHash string
    - 66 + 81
    + - executionTime = time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0) + parentHash string
    - 67 + + 82 +
    -   - } + + + block state.Block
    - + + 83 -
    -   -
    +
    +
    + + + )
    - + + 84 -
    -   -
    +
    +
    + + + err := rows.Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - + + 85 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 86 -
    -   -
    +
    +
    + + + return nil, err
    - + + 87 -
    -   -
    +
    +
    + + + }
    - + + 88 -
    -   -
    +
    +
    + + + block.BlockHash = common.HexToHash(blockHash)
    - + + 89 -
    -   -
    +
    +
    + + + block.ParentHash = common.HexToHash(parentHash)
    - + + 90 -
    -   -
    +
    +
    + + + blocks = append(blocks, &block)
    - + + 91 -
    -   -
    +
    +
    + + + }
    - + + 92 -
    -   -
    +
    +
    + + + return blocks, nil
    - + + 93 -
    -   -
    +
    +
    + + + }
    - + + 94 -
    -   +
    +
    + +
    - + + 95 -
    +
    +
      -
    + // GetPreviousBlock gets the offset previous L1 block respect to latest.
    - + + 96 -
    +
    +
      -
    + func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) {
    - + + 97 -
    +
    +
      -
    + var (
    - - -
    -   -
    -
    +
    +
     
    - + + 99 -
    +
    +
      -
    + parentHash string
    - + + 100 -
    +
    +
      -
    + block state.Block
    - + + 101 -
    +
    +
      -
    + )
    - + + 102 -
    -   -
    +
    +
    + + + const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1"
    - + + 103 -
    -   +
    +
    + +
    - + + 104 -
    -   -
    +
    +
    + + + q := p.getExecQuerier(dbTx)
    - + + 105 -
    -   +
    +
    + +
    - + + 106 -
    -   -
    +
    +
    + + + err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - + + 107 -
    -   -
    +
    +
    + + + if errors.Is(err, pgx.ErrNoRows) {
    - + + 108 -
    -   -
    +
    +
    + + + return nil, state.ErrNotFound
    - + + 109 -
    -   -
    +
    +
    + + + }
    - + + 110 -
    -   -
    +
    +
    + + + block.BlockHash = common.HexToHash(blockHash)
    - + + 111 -
    -   -
    +
    +
    + + + block.ParentHash = common.HexToHash(parentHash)
    - 68 + + 112 +
    -   -
    + + + return &block, err
    - 69 + + 113 +
    + - return g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, executionTime, dbTx) + }
    - + + 114 -
    -   +
    +
    + +
    - + + 115 -
    -   -
    +
    +
    + + + // GetPreviousBlockToBlockNumber gets the previous L1 block respect blockNumber.
    - + + 116 -
    -   -
    +
    +
    + + + func (p *PostgresStorage) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) {
    - + + 117 -
    -   -
    +
    +
    + + + var (
    - + + 118 -
    -   -
    +
    +
    + + + blockHash string
    - + + 119 -
    -   -
    +
    +
    + + + parentHash string
    - + + 120 -
    -   -
    +
    +
    + + + block state.Block
    - + + 121 -
    -   -
    +
    +
    + + + )
    - + + 122 -
    -   -
    +
    +
    + + + const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num < $1 ORDER BY block_num DESC LIMIT 1 "
    - + + 123 -
    +
    +
     
    - + + 124 -
    +
    +
      -
    + q := p.getExecQuerier(dbTx)
    - + + 125 -
    +
    +
     
    - + + 126 -
    -   -
    +
    +
    + + + err := q.QueryRow(ctx, getPreviousBlockSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - + + 127 -
    +
    +
      -
    + if errors.Is(err, pgx.ErrNoRows) {
    - + + 128 -
    +
    +
      -
    + return nil, state.ErrNotFound
    - + + 129 -
    +
    +
      -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 70 - -
    -   - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -391,7 +391,7 @@
    -
    - 391 - -
    -   - reason := reorgReasons.String() -
    -
    - 392 - -
    -   -
    -
    -
    - 393 - -
    -   - if p.sync.IsTrustedSequencer() { -
    -
    - 394 - -
    - - - log.Errorf("TRUSTED REORG DETECTED! Batch: %d reson:%s", batch.BatchNumber, reason) -
    -
    - 395 - -
    -   - // Halt function never have to return! it must blocks the process -
    -
    - 396 - -
    -   - p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber)) + }
    - 397 - -
    -   - log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process") -
    -
    -
    -
    -
    -
    - - - - - - - - -
     
    - 391 + 139
      - reason := reorgReasons.String() + parentHash string
    - 392 + 140
      -
    + block state.Block
    - 393 + 141
      - if p.sync.IsTrustedSequencer() { + )
    - 394 + 142
    + - log.Errorf("TRUSTED REORG DETECTED! Batch: %d reason:%s", batch.BatchNumber, reason) -
    -
    - 395 - -
    -   - // Halt function never have to return! it must blocks the process + const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num = $1"
    - 396 + 143
      - p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber)) +
    - 397 + 144
      - log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process") -
    -
    -
    + q := p.getExecQuerier(dbTx)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - -
    -
    @@ -29,6 +29,8 @@
    - 29 + 145
      - AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error +
    - 30 + + 146 +
    -   - Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error + + + err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked)
    - 31 + 147
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + if errors.Is(err, pgx.ErrNoRows) {
    - 32 + 148
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + return nil, state.ErrNotFound
    - 33 + 149
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + }
    - 34 - -
    -   - ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - -
     
    - 29 - -
    -   - AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error -
    -
    - 30 - -
    -   - Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error -
    -
    - 31 - -
    -   - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) -
    -
    - 32 - -
    - + - GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) -
    -
    - 33 - -
    - + - UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error -
    -
    - 34 + 151
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + block.ParentHash = common.HexToHash(parentHash)
    - 35 + 152
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + return &block, err
    - 36 + 153
      - ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_ethereum_compatible_client.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,21 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - package syncinterfaces -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + - "math/big" -
    -
    - 6 - -
    - + -
    -
    -
    - 7 - -
    - + - "github.com/ethereum/go-ethereum/core/types" -
    -
    - 8 - -
    - + - ) + }
    - 9 + 154
    @@ -117102,77 +118160,57 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 10 - -
    - + - // ZKEVMClientEthereumCompatibleInterface contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible -
    -
    - 11 - -
    - + - // -
    -
    - 12 + 155
    + - // Reason behind: the zkEVMClient have some extensions to ethereum-API that are not compatible with all nodes. So if you need to maximize + // UpdateCheckedBlockByNumber update checked flag for a block
    - 13 + 156
    + - // the compatibility the idea is to use a regular ethereum-API compatible client + func (p *PostgresStorage) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error {
    - 14 + 157
    + - type ZKEVMClientEthereumCompatibleInterface interface { + const query = `
    - 15 + 158
    + - ZKEVMClientEthereumCompatibleL2BlockGetter + UPDATE state.block
    - 16 + 159
    + - } + SET checked = $1 WHERE block_num = $2`
    - 17 + 160
    @@ -117182,37 +118220,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 18 + 161
    + - // ZKEVMClientEthereumCompatibleL2BlockGetter contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible for obtain Block information + e := p.getExecQuerier(dbTx)
    - 19 + 162
    + - type ZKEVMClientEthereumCompatibleL2BlockGetter interface { + _, err := e.Exec(ctx, query, newCheckedStatus, blockNumber)
    - 20 + 163
    + - BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) + return err
    - 21 + 164
    @@ -117227,12 +118265,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go RENAMED
    -
    @@ -13,6 +13,8 @@
    +
    @@ -53,7 +53,7 @@
    - 13 + 53
      - SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 14 + 54
      - // TrustedSequencerURL is the rpc url to connect and sync the trusted state + FROM state.exit_root
    - 15 + 55
      - TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` -
    -
    - - -
    -   -
    + WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1
    - + + 56 -
    -   -
    +
    +
    + - + ORDER BY l1_info_tree_index DESC`
    - 16 + 57
    @@ -117311,116 +118339,97 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 17 + 58
      - // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) + entry := state.L1InfoTreeExitRootStorageEntry{}
    - 18 + 59
      - L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` +
    -
    -
    -
    -
    - - - + - - - - - @@ -117428,21 +118437,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    @@ -112,7 +112,7 @@
    - 13 + 112
      - SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` + return entry, nil
    - 14 + 113
      - // TrustedSequencerURL is the rpc url to connect and sync the trusted state + }
    - 15 + 114
      - TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` -
    -
    - 16 - -
    - + - // SyncBlockProtection specify the state to sync (lastest, finalized or safe) +
    - 17 + + 115 +
    - + - SyncBlockProtection string `mapstructure:"SyncBlockProtection"` + - + func (p *PostgresStorage) GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - 18 + 116
      -
    + // TODO: Optimize this query
    - 19 + 117
      - // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) + const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 20 + 118
      - L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` + FROM state.exit_root
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go - RENAMED - -
    -
    @@ -117450,115 +118444,106 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - -
    -
    @@ -31,7 +31,7 @@
    +
     
    - 31 + 53
      - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 32 + 54
      - } + FROM state.exit_root
    - 33 + 55
      -
    + WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1
    - 34 + + 56 +
    - - - ethermanClient, err := etherman.NewClient(cfg, l1Config) + + + ORDER BY l1_info_tree_index DESC LIMIT 1`
    - 35 + 57
      - require.NoError(t, err) +
    - 36 + 58
      - worker := newWorker(ethermanClient) + entry := state.L1InfoTreeExitRootStorageEntry{}
    - 37 + 59
      - ch := make(chan responseRollupInfoByBlockRange) +
    -
    -
    -
    -
    - - - + @@ -117613,12 +118598,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go RENAMED
    + + + + + + - - - - - - - - - - - - - - - - - @@ -117961,461 +118956,403 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
     
    - 31 + 112
      - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + return entry, nil
    - 32 + 113
      - } + }
    - 33 + 114
    @@ -117568,42 +118553,42 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 34 + 115
    + - ethermanClient, err := etherman.NewClient(cfg, l1Config, nil) + func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - 35 + 116
      - require.NoError(t, err) + // TODO: Optimize this query
    - 36 + 117
      - worker := newWorker(ethermanClient) + const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 37 + 118
      - ch := make(chan responseRollupInfoByBlockRange) + FROM state.exit_root
    -
    @@ -136,13 +137,13 @@
    +
    @@ -119,7 +119,7 @@
    - 136 + 119
      - return nil, err + return common.HexToHash(stateRootStr), nil
    - 137 + 120
      - } + }
    - 138 + 121
    @@ -117667,132 +118652,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 139 + 122
    - - leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) + // GetLogsByBlockNumber get all the logs from a specific block ordered by log index
    - 140 + 123
      - if err != nil { + func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) {
    - 141 + 124
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) + const query = `
    - 142 + 125
      - return nil, err + SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3
    +
    @@ -128,7 +128,7 @@
    +
    - 143 + 128
      - } + INNER JOIN state.l2block b ON b.block_num = t.l2_block_num
    - 144 + 129
      - debugStr := data.DebugPrefix + INNER JOIN state.receipt r ON r.tx_hash = t.hash +
    +
    + 130 + +
    +   + WHERE b.block_num = $1
    - 145 + 131
    - - processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leafs, l1InfoRoot), dbTx, debugStr) + ORDER BY l.log_index ASC`
    - 146 + 132
      - if err != nil { +
    - 147 + 133
      - log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) + q := p.getExecQuerier(dbTx)
    - 148 + 134
      - return nil, err + rows, err := q.Query(ctx, query, blockNumber)
    -
    @@ -197,7 +198,7 @@
    +
    @@ -159,7 +159,7 @@
    - 197 + 159
      - return nil, err + const queryFilterByBlockHash = `AND b.block_hash = $7 `
    - 198 + 160
      - } + const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 `
    - 199 + 161
    @@ -117802,152 +118802,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 200 + 162
    - - leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) + const queryOrder = `ORDER BY b.block_num ASC, l.log_index ASC`
    - 201 + 163
      - if err != nil { +
    - 202 + 164
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) + // count queries
    - 203 + 165
      - // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data + const queryToCountLogsByBlockHash = "" +
    -
    @@ -205,7 +206,7 @@
    +
    @@ -355,3 +355,87 @@
    - 205 + 355
      - return nil, syncinterfaces.ErrMissingSyncFromL1 + }
    - 206 + 356
      - } + return nativeBlockHashes, nil
    - 207 + 357
      - debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) + }
    - 208 + + -
    - - - processReq := b.getProcessRequest(data, leafs, l1InfoRoot) +
    +
    +   +
    - 209 + + -
    +
    +
      - processReq.Transactions = PartialBatchL2Data +
    - 210 + + -
    +
    +
      - processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) +
    - 211 + + -
    +
    +
      - if err != nil { +
    -
    @@ -429,6 +430,7 @@
    -
    - 429 + + -
    +
    +
      - Transactions: data.TrustedBatch.BatchL2Data, +
    - 430 + + -
    +
    +
      - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), +
    - 431 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 432 + + -
    +
    +
      - } +
    - 433 + + -
    +
    +
      - return request +
    - 434 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 137 + + -
    +
    +
      - return nil, err +
    - 138 + + -
    +
    +
      - } +
    - 139 + + -
    +
    +
     
    - 140 + + -
    - + - leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) +
    +
    +   +
    - 141 + + -
    +
    +
      - if err != nil { +
    - 142 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 143 + + -
    +
    +
      - return nil, err +
    - 144 + + -
    +
    +
      - } +
    - 145 + + -
    +
    +
      - debugStr := data.DebugPrefix +
    - 146 + + -
    - + - processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leaves, l1InfoRoot), dbTx, debugStr) +
    +
    +   +
    - 147 + + -
    +
    +
      - if err != nil { +
    - 148 + + -
    +
    +
      - log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) +
    - 149 + + -
    +
    +
      - return nil, err +
    -
     
    -
    - 198 + + -
    +
    +
      - return nil, err +
    - 199 + + -
    +
    +
      - } +
    - 200 + + -
    +
    +
     
    - 201 + + -
    - + - leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) +
    +
    +   +
    - 202 + + -
    +
    +
      - if err != nil { +
    - 203 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 204 + + -
    +
    +
      - // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data +
    -
     
    -
    - 206 + + -
    +
    +
      - return nil, syncinterfaces.ErrMissingSyncFromL1 +
    - 207 + + -
    +
    +
      - } +
    - 208 + + -
    +
    +
      - debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) +
    - 209 + + -
    - + - processReq := b.getProcessRequest(data, leaves, l1InfoRoot) +
    +
    +   +
    - 210 + + -
    +
    +
      - processReq.Transactions = PartialBatchL2Data +
    - 211 + + -
    +
    +
      - processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) +
    - 212 + + -
    +
    +
      - if err != nil { +
    -
     
    -
    - 430 + + -
    +
    +
      - Transactions: data.TrustedBatch.BatchL2Data, +
    - 431 + + -
    +
    +
      - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), +
    - 432 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 433 + + -
    - + - ExecutionMode: executor.ExecutionMode1, +
    +
    +   +
    - 434 + + -
    +
    +
      - } +
    - 435 + + -
    +
    +
      - return request +
    - 436 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -118429,176 +119366,143 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -196,6 +196,7 @@
    - 196 + + -
    +
    +
      - OldAccInputHash: batches[1].AccInputHash, +
    - 197 + + -
    +
    +
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    - 198 + + -
    +
    +
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), +
    - 199 + + -
    +
    +
      - } +
    - 200 + + -
    +
    +
      - // check if batch needs to be synchronized +
    - 201 + + -
    +
    +
      - if batches[0] != nil { -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 196 + + -
    +
    +
      - OldAccInputHash: batches[1].AccInputHash, +
    - 197 + + -
    +
    +
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    - 198 + + -
    +
    +
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), +
    - 199 + + -
    - + - ExecutionMode: executor.ExecutionMode1, +
    +
    +   +
    - 200 + + -
    +
    +
      - } +
    - 201 + + -
    +
    +
      - // check if batch needs to be synchronized +
    - 202 + + -
    +
    +
      - if batches[0] != nil { +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -118612,178 +119516,183 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118806,1524 +119715,1537 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    -
    @@ -22,6 +22,7 @@
    - 22 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    - 23 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" +
    - 24 + + -
    +
    +
      - "github.com/ethereum/go-ethereum/common" +
    - 25 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 26 + + -
    +
    +
      - ) +
    - 27 + + -
    +
    +
     
    -
    @@ -52,17 +53,19 @@
    +
    + + +
    +   +
    +
    - 52 + + -
    +
    +
      - etherMan syncinterfaces.EthermanFullInterface +
    - 53 + + -
    +
    +
      - latestFlushID uint64 +
    - 54 + + -
    +
    +
      - // If true the lastFlushID is stored in DB and we don't need to check again +
    - 55 + + -
    - - - latestFlushIDIsFulfilled bool +
    +
    +   +
    - 56 + + -
    - - - etherManForL1 []syncinterfaces.EthermanFullInterface +
    +
    +   +
    - 57 + + -
    - - - state syncinterfaces.StateFullInterface +
    +
    +   +
    - 58 + + -
    - - - pool syncinterfaces.PoolInterface +
    +
    +   +
    - 59 + + -
    - - - ethTxManager syncinterfaces.EthTxManager +
    +
    +   +
    - 60 + + -
    - - - zkEVMClient syncinterfaces.ZKEVMClientInterface +
    +
    +   +
    - 61 + + -
    - - - eventLog syncinterfaces.EventLogInterface +
    +
    +   +
    - 62 + + -
    - - - ctx context.Context +
    +
    +   +
    - 63 + + -
    - - - cancelCtx context.CancelFunc +
    +
    +   +
    - 64 + + -
    - - - genesis state.Genesis +
    +
    +   +
    - 65 + + -
    - - - cfg Config +
    +
    +   +
    +
    +
    +
    +
    + + + + + - - + - - + - - - - - - + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    - 66 + 119
      - // Id of the 'process' of the executor. Each time that it starts this value changes + return common.HexToHash(stateRootStr), nil
    - 67 + 120
      - // This value is obtained from the call state.GetStoredFlushID + }
    - 68 + 121
      - // It starts as an empty string and it is filled in the first call +
    -
    @@ -85,30 +88,40 @@
    +
    + 122 + +
    + + + // GetLogsByBlockNumber get all the logs from a specific block ordered by tx index and log index +
    - 85 + 123
      - pool syncinterfaces.PoolInterface, + func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) {
    - 86 + 124
      - ethTxManager syncinterfaces.EthTxManager, + const query = `
    - 87 + 125
      - zkEVMClient syncinterfaces.ZKEVMClientInterface, + SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3
    - - -
    -   -
    -
    +
    +
     
    - 88 + 128
      - eventLog syncinterfaces.EventLogInterface, + INNER JOIN state.l2block b ON b.block_num = t.l2_block_num
    - 89 + 129
      - genesis state.Genesis, + INNER JOIN state.receipt r ON r.tx_hash = t.hash
    - 90 + 130
      - cfg Config, + WHERE b.block_num = $1
    - 91 + + 131 +
    -   - runInDevelopmentMode bool) (Synchronizer, error) { + + + ORDER BY r.tx_index ASC, l.log_index ASC`
    - 92 + 132
      - ctx, cancel := context.WithCancel(context.Background()) +
    - 93 + 133
      - metrics.Register() + q := p.getExecQuerier(dbTx)
    - + + 134 -
    +
    +
      -
    + rows, err := q.Query(ctx, query, blockNumber)
    - - -
    -   -
    -
    +
    +
     
    - + + 159 -
    +
    +
      -
    + const queryFilterByBlockHash = `AND b.block_hash = $7 `
    - + + 160 -
    +
    +
      -
    + const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 `
    - + + 161 -
    +
    +
     
    - + + 162 -
    -   -
    +
    +
    + + + const queryOrder = `ORDER BY b.block_num ASC, r.tx_index ASC, l.log_index ASC`
    - + + 163 -
    +
    +
     
    - 94 + 164
      - res := &ClientSynchronizer{ + // count queries
    - 95 + + 165 +
    - - - isTrustedSequencer: isTrustedSequencer, +   + const queryToCountLogsByBlockHash = "" +
    - 96 + +
     
    +
    + 355 +
    - - - state: st, +   + }
    - 97 + + 356 +
    - - - etherMan: ethMan, +   + return nativeBlockHashes, nil
    - 98 + + 357 +
    - - - etherManForL1: etherManForL1, +   + }
    - 99 + + 358 +
    - - - pool: pool, + + +
    - 100 + + 359 +
    - - - ctx: ctx, + + + // GetBatchL2DataByNumber returns the batch L2 data of the given batch number.
    - 101 + + 360 +
    - - - cancelCtx: cancel, + + + func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) {
    - 102 + + 361 +
    - - - ethTxManager: ethTxManager, + + + batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx)
    - 103 + + 362 +
    - - - zkEVMClient: zkEVMClient, + + + if err != nil {
    - 104 + + 363 +
    - - - eventLog: eventLog, + + + return nil, err
    - 105 + + 364 +
    - - - genesis: genesis, + + + }
    - 106 + + 365 +
    - - - cfg: cfg, + + + data, ok := batchData[batchNumber]
    - 107 + + 366 +
    - - - proverID: "", + + + if !ok {
    - 108 + + 367 +
    - - - previousExecutorFlushID: 0, + + + return nil, state.ErrNotFound
    - 109 + + 368 +
    - - - l1SyncOrchestration: nil, + + + }
    - 110 + + 369 +
    - - - l1EventProcessors: nil, + + + return data, nil
    - 111 + + 370 +
    - - - halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd + + + }
    - + + 371 -
    -   +
    +
    + +
    - + + 372 -
    -   -
    +
    +
    + + + // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables.
    - 112 + + 373 +
    -   - } + + + func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 113 + + 374 +
    -   -
    + + + const sql = "SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1)"
    - 114 + + 375 +
    -   - if !isTrustedSequencer { + + + return p.getBatchData(ctx, sql, batchNumbers, dbTx)
    -
    @@ -143,7 +156,7 @@
    -
    - 143 + + 376 +
    -   - log.Errorf("error getting last L2Block number from state. Error: %v", err) + + + }
    - 144 + + 377 +
    -   - return nil, err + + +
    - 145 + + 378 +
    -   - } + + + // GetForcedBatchDataByNumbers returns the forced batch data of the given batch numbers
    - 146 + + 379 +
    - - - l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClient, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) + + + func (p *PostgresStorage) GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 147 + + 380 +
    -   - } else { + + + const sql = "SELECT forced_batch_num, convert_from(decode(raw_txs_data, 'hex'), 'UTF8')::bytea FROM state.forced_batch WHERE forced_batch_num = ANY($1)"
    - 148 + + 381 +
    -   - log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") + + + return p.getBatchData(ctx, sql, batchNumbers, dbTx)
    - 149 + + 382 +
    -   - } + + + }
    -
    @@ -163,6 +176,19 @@
    -
    - 163 + + 383 +
    -   - return res, nil + + +
    - 164 + + 384 +
    -   - } + + + func (p *PostgresStorage) getBatchData(ctx context.Context, sql string, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 165 + + 385 +
    -   -
    + + + q := p.getExecQuerier(dbTx)
    - + + 386 -
    -   -
    +
    +
    + + + rows, err := q.Query(ctx, sql, batchNumbers)
    - + + 387 -
    -   -
    +
    +
    + + + if errors.Is(err, pgx.ErrNoRows) {
    - + + 388 -
    -   -
    +
    +
    + + + return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx)
    - + + 389 -
    -   -
    +
    +
    + + + } else if err != nil {
    - + + 390 -
    -   -
    +
    +
    + + + return nil, err
    - + + 391 -
    -   -
    +
    +
    + + + }
    - + + 392 -
    -   -
    +
    +
    + + + defer rows.Close()
    - + + 393 -
    -   +
    +
    + +
    - + + 394 -
    -   -
    +
    +
    + + + batchL2DataMap, err := readBatchDataResults(rows, batchNumbers)
    - + + 395 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 396 -
    -   -
    +
    +
    + + + return nil, err
    - + + 397 -
    -   -
    +
    +
    + + + }
    - + + 398 -
    -   +
    +
    + +
    - 166 + + 399 +
    -   - var waitDuration = time.Duration(0) + + + if len(batchL2DataMap) == 0 {
    - 167 + + 400 +
    -   -
    + + + return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx)
    - 168 + + 401 +
    -   - func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { + + + }
    -
    @@ -234,7 +260,7 @@
    -
    - 234 + + 402 +
    -   - if err != nil { + + +
    - 235 + + 403 +
    -   - if errors.Is(err, state.ErrStateNotSynchronized) { + + + return batchL2DataMap, nil
    - 236 + + 404 +
    -   - log.Info("State is empty, verifying genesis block") + + + }
    - 237 + + 405 +
    - - - valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber) + + +
    - 238 + + 406 +
    -   - if err != nil { + + + // GetBatchL2DataByNumbersFromBackup returns the batch L2 data of the given batch number from the backup table
    - 239 + + 407 +
    -   - log.Error("error checking genesis block number. Error: ", err) + + + func (p *PostgresStorage) GetBatchL2DataByNumbersFromBackup(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 240 + + 408 +
    -   - return rollback(s.ctx, dbTx, err) + + + getBatchL2DataByBatchNumber := `
    -
    @@ -242,12 +268,42 @@
    -
    - 242 + + 409 +
    -   - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") + + + SELECT batch_num, data FROM state.batch_data_backup
    - 243 + + 410 +
    -   - return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) + + + WHERE batch_num = ANY($1)
    - 244 + + 411 +
    -   - } + + + ORDER BY created_at DESC
    - 245 + + 412 +
    - - - log.Info("Setting genesis block") + + + `
    - 246 + + 413 +
    - - - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.BlockNumber)) + + + q := p.getExecQuerier(dbTx)
    - + + 414 -
    -   -
    +
    +
    + + + rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers)
    - + + 415 -
    -   -
    +
    +
    + + + if errors.Is(err, pgx.ErrNoRows) {
    - + + 416 -
    -   -
    +
    +
    + + + return nil, state.ErrNotFound
    - + + 417 -
    -   -
    +
    +
    + + + } else if err != nil {
    - + + 418 -
    -   -
    +
    +
    + + + return nil, err
    - + + 419 -
    -   -
    +
    +
    + + + }
    - + + 420 -
    -   -
    +
    +
    + + + defer rows.Close()
    - + + 421 -
    -   +
    +
    + +
    - + + 422 -
    -   -
    +
    +
    + + + return readBatchDataResults(rows, batchNumbers)
    - + + 423 -
    -   -
    +
    +
    + + + }
    - + + 424 -
    -   +
    +
    + +
    - + + 425 -
    -   -
    +
    +
    + + + // readBatchDataResults retrieves batch data from the provided result set
    - + + 426 -
    -   -
    +
    +
    + + + func readBatchDataResults(results pgx.Rows, batchNumbers []uint64) (map[uint64][]byte, error) {
    - + + 427 -
    -   -
    +
    +
    + + + batchL2DataMap := make(map[uint64][]byte, len(batchNumbers))
    - + + 428 -
    -   -
    +
    +
    + + + for results.Next() {
    - + + 429 -
    -   -
    +
    +
    + + + var (
    - + + 430 -
    -   -
    +
    +
    + + + batchNum uint64
    - + + 431 -
    -   -
    +
    +
    + + + batchL2Data []byte
    - + + 432 -
    -   -
    +
    +
    + + + )
    - + + 433 -
    -   +
    +
    + +
    - + + 434 -
    -   -
    +
    +
    + + + if err := results.Scan(&batchNum, &batchL2Data); err != nil {
    - + + 435 -
    -   -
    +
    +
    + + + return nil, err
    - + + 436 -
    -   -
    +
    +
    + + + }
    - + + 437 -
    -   -
    +
    +
    + + + batchL2DataMap[batchNum] = batchL2Data
    - + + 438 -
    -   -
    +
    +
    + + + }
    - + + 439 -
    -   +
    +
    + +
    - + + 440 -
    -   -
    +
    +
    + + + return batchL2DataMap, nil
    - - -
    -   -
    -
    +
    + 441
    - + +
    + + + } +
    -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -120357,68 +121279,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -120582,158 +121509,188 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - + + + - - + + + - - + + + @@ -120758,212 +121715,207 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - - - - - - - - - - @@ -120977,23 +121929,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -121007,13 +121959,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -121027,43 +121979,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -121077,33 +122029,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -121117,1665 +122069,1551 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    +
    @@ -872,7 +872,7 @@
    - 247 + 872
      - if err != nil { -
    -
    - 248 - -
    - - - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err) + ctx := context.Background()
    - 249 + 873
      - return rollback(s.ctx, dbTx, err) +
    - 250 + 874
      - } + cfg := state.Config{
    - + + 875 -
    -   -
    +
    +
    + - + MaxLogsCount: 8,
    - 251 + 876
      - lastEthBlockSynced = &state.Block{ + MaxLogsBlockRange: 10,
    - 252 + 877
      - BlockNumber: header.Number.Uint64(), + ForkIDIntervals: stateCfg.ForkIDIntervals,
    - 253 + 878
      - BlockHash: header.Hash(), + }
    -
    @@ -487,6 +543,14 @@
    +
    @@ -895,39 +895,69 @@
    - 487 + 895
      -
    + time := time.Now()
    - 488 + 896
      - // This function syncs the node from a specific block to the latest + blockNumber := big.NewInt(1)
    - 489 + 897
      - func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    - + + 898 -
    -   -
    +
    +
    + - + for i := 0; i < 3; i++ {
    - + + 899 -
    -   -
    +
    +
    + - + tx := types.NewTx(&types.LegacyTx{
    - + + 900 -
    -   -
    +
    +
    + - + Nonce: uint64(i),
    - + + 901 -
    -   -
    +
    +
    + - + To: nil,
    - + + 902 -
    -   -
    +
    +
    + - + Value: new(big.Int),
    - + + 903 -
    -   -
    +
    +
    + - + Gas: 0,
    - + + 904 -
    -   -
    +
    +
    + - + GasPrice: big.NewInt(0),
    - + + 905 -
    -   -
    +
    +
    + - + })
    - 490 + + 906 +
    -   - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. + - +
    - 491 + + 907 +
    -   - block, err := s.checkReorg(lastEthBlockSynced) + - + logs := []*types.Log{}
    - 492 + + 908 +
    -   - if err != nil { + - + for j := 0; j < 4; j++ {
    -
    @@ -502,13 +566,6 @@
    +
    + 909 + +
    + - + logs = append(logs, &types.Log{TxHash: tx.Hash(), Index: uint(j)}) +
    - 502 + + 910 +
    -   - return block, nil + - + }
    - 503 + + 911 +
    -   - } + - +
    - 504 + + 912 +
    -   -
    + - + receipt := &types.Receipt{
    - 505 + + 913 +
    - - // Call the blockchain to retrieve data + Type: tx.Type(),
    - 506 + + 914 +
    - - header, err := s.etherMan.HeaderByNumber(s.ctx, nil) + PostState: state.ZeroHash.Bytes(),
    - 507 + + 915 +
    - - if err != nil { + CumulativeGasUsed: 0,
    - 508 + + 916 +
    - - return lastEthBlockSynced, err + EffectiveGasPrice: big.NewInt(0),
    - 509 + + 917 +
    - - } + BlockNumber: blockNumber,
    - 510 + + 918 +
    - - lastKnownBlock := header.Number + GasUsed: tx.Gas(),
    - 511 + + 919 +
    - -
    + TxHash: tx.Hash(),
    - 512 + + 920 +
    -   - var fromBlock uint64 + - + TransactionIndex: 0,
    - 513 + + 921 +
    -   - if lastEthBlockSynced.BlockNumber > 0 { + - + Status: types.ReceiptStatusSuccessful,
    - 514 + + 922 +
    -   - fromBlock = lastEthBlockSynced.BlockNumber + 1 + - + Logs: logs,
    -
    @@ -516,6 +573,9 @@
    +
    + + +
    +   +
    +
    - 516 + + -
    +
    +
     
    - 517 + + -
    +
    +
      - for { +
    - 518 + + -
    +
    +
      - toBlock := fromBlock + s.cfg.SyncChunkSize +
    - 519 + + -
    +
    +
      - log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) +
    - 520 + + -
    +
    +
      - log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) +
    - 521 + + -
    +
    +
      - // This function returns the rollup information contained in the ethereum blocks and an extra param called order. +
    -
    @@ -529,6 +589,22 @@
    +
    + + +
    +   +
    +
    - 529 + + -
    +
    +
      - if err != nil { +
    - 530 + + -
    +
    +
      - return lastEthBlockSynced, err +
    - 531 + + -
    +
    +
      - } +
    - 532 + + -
    +
    +
      - start = time.Now() +
    - 533 + + -
    +
    +
      - err = s.ProcessBlockRange(blocks, order) +
    - 534 + + -
    +
    +
      - metrics.ProcessL1DataTime(time.Since(start)) +
    -
    @@ -722,21 +798,24 @@
    +
    + + +
    +   +
    +
    - 722 + 923
      - func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, error) { + }
    - 723 + 924
      - // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. +
    - 724 + + 925 +
    -   - latestEthBlockSynced := *latestBlock + - + transactions := []*types.Transaction{tx}
    - + + 926 -
    -   -
    +
    +
    + - + receipts := []*types.Receipt{receipt}
    - 725 + + 927 +
    -   - var depth uint64 + - + stateRoots := []common.Hash{state.ZeroHash} +
    +
    + 928 + +
    + - +
    - 726 + 929
      - for { + header := state.NewL2Header(&types.Header{
    - 727 + 930
    - - block, err := s.etherMan.EthBlockByNumber(s.ctx, latestBlock.BlockNumber) + Number: big.NewInt(int64(i) + 1),
    - 728 + 931
      - if err != nil { + ParentHash: state.ZeroHash,
    - 729 + + 932 +
    - - - log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", latestBlock.BlockNumber, err) +   + Coinbase: state.ZeroAddress,
    - 730 + 933
      - return nil, err + Root: state.ZeroHash,
    +
    @@ -954,6 +984,8 @@
    +
    - 731 + 954
      - } + require.NoError(t, err)
    - 732 + + 955 +
    - - - if block.NumberU64() != latestBlock.BlockNumber { +   + } +
    +
    + 956 + +
    +   +
    - 733 + 957
      - err = fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", + type testCase struct {
    - 734 + + 958 +
    - - - latestBlock.BlockNumber, block.NumberU64()) +   + name string
    - 735 + 959
      - log.Error("error: ", err) + from uint64
    +
    @@ -988,20 +1020,227 @@
    +
    - 736 + 988
      - return nil, err + name: "logs returned successfully",
    - 737 + 989
      - } + from: 1,
    - 738 + 990
      - // Compare hashes + to: 2,
    - 739 + 991
    - - if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.BlockNumber { + logCount: 8,
    - 740 + 992
      - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash) + expectedError: nil,
    - 741 + 993
      - log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) + },
    - 742 + 994
      - log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) + }
    -
    @@ -752,7 +831,7 @@
    -
    - 752 + 995
      - log.Errorf("error creating db transaction to get prevoius blocks") +
    - 753 + 996
      - return nil, err + for _, testCase := range testCases {
    - 754 + 997
      - } + t.Run(testCase.name, func(t *testing.T) {
    - 755 + 998
    - - latestBlock, err = s.state.GetPreviousBlock(s.ctx, depth, dbTx) + logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, dbTx)
    - 756 + + 999 +
    -   - errC := dbTx.Commit(s.ctx) + - +
    - 757 + 1000
      - if errC != nil { + assert.Equal(t, testCase.logCount, len(logs))
    - 758 + 1001
      - log.Errorf("error committing dbTx, err: %v", errC) + assert.Equal(t, testCase.expectedError, err)
    -
    @@ -768,16 +847,21 @@
    -
    - 768 + + -
    +
    +
      - log.Warn("error checking reorg: previous block not found in db: ", err) +
    - 769 + + -
    +
    +
      - return &state.Block{}, nil +
    - 770 + + -
    +
    +
      - } else if err != nil { +
    - 771 + + -
    +
    +
      - return nil, err +
    - 772 + + -
    +
    +
      - } +
    - 773 + + -
    +
    +
      - } else { +
    - 774 + + -
    +
    +
      - break +
    - 775 + + -
    +
    +
      - } +
    - 776 + + -
    +
    +
      - } +
    - 777 + + -
    - - - if latestEthBlockSynced.BlockHash != latestBlock.BlockHash { +
    +
    +   +
    - 778 + + -
    +
    +
      - log.Info("Reorg detected in block: ", latestEthBlockSynced.BlockNumber, " last block OK: ", latestBlock.BlockNumber) +
    - 779 + + -
    +
    +
      - return latestBlock, nil +
    - 780 + + -
    +
    +
      - } +
    - 781 + + -
    +
    +
      - return nil, nil +
    - 782 + + -
    +
    +
      - } +
    - 783 + + -
    +
    +
     
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 22 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    - 23 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" +
    - 24 + + -
    +
    +
      - "github.com/ethereum/go-ethereum/common" +
    - 25 + + -
    - + - "github.com/ethereum/go-ethereum/rpc" +
    +
    +   +
    - 26 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 27 + + -
    +
    +
      - ) +
    - 28 + + -
    +
    +
     
    -
     
    +
    + + +
    +   +
    +
    - 53 + 1002
      - etherMan syncinterfaces.EthermanFullInterface + })
    - 54 + 1003
      - latestFlushID uint64 + }
    - 55 + + -
    +
    +
      - // If true the lastFlushID is stored in DB and we don't need to check again +
    - 56 + + -
    - + - latestFlushIDIsFulfilled bool +
    +
    +   +
    - 57 + + -
    - + - syncBlockProtection rpc.BlockNumber +
    +
    +   +
    - 58 + + -
    - + - etherManForL1 []syncinterfaces.EthermanFullInterface +
    +
    +   +
    - 59 + + -
    - + - state syncinterfaces.StateFullInterface +
    +
    +   +
    - 60 + + -
    - + - pool syncinterfaces.PoolInterface +
    +
    +   +
    - 61 + + -
    - + - ethTxManager syncinterfaces.EthTxManager +
    +
    +   +
    - 62 + + -
    - + - zkEVMClient syncinterfaces.ZKEVMClientInterface +
    +
    +   +
    - 63 + + -
    - + - zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface +
    +
    +   +
    - 64 + + -
    - + - eventLog syncinterfaces.EventLogInterface +
    +
    +   +
    - 65 + + -
    - + - ctx context.Context +
    +
    +   +
    - 66 + + -
    - + - cancelCtx context.CancelFunc +
    +
    +   +
    - 67 + + -
    - + - genesis state.Genesis +
    +
    +   +
    - 68 + + -
    - + - cfg Config +
    +
    +   +
    - 69 + + -
    +
    +
      - // Id of the 'process' of the executor. Each time that it starts this value changes +
    - 70 + + -
    +
    +
      - // This value is obtained from the call state.GetStoredFlushID +
    - 71 + + -
    +
    +
      - // It starts as an empty string and it is filled in the first call +
    -
     
    -
    - 88 + + -
    +
    +
      - pool syncinterfaces.PoolInterface, +
    - 89 + + -
    +
    +
      - ethTxManager syncinterfaces.EthTxManager, +
    - 90 + + -
    +
    +
      - zkEVMClient syncinterfaces.ZKEVMClientInterface, +
    - 91 + + -
    - + - zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface, +
    +
    +   +
    - 92 + + -
    +
    +
      - eventLog syncinterfaces.EventLogInterface, +
    - 93 + + -
    +
    +
      - genesis state.Genesis, +
    - 94 + + -
    +
    +
      - cfg Config, +
    - 95 + + -
    +
    +
      - runInDevelopmentMode bool) (Synchronizer, error) { +
    - 96 + + -
    +
    +
      - ctx, cancel := context.WithCancel(context.Background()) +
    - 97 + + -
    +
    +
      - metrics.Register() +
    - 98 + + -
    - + - syncBlockProtection, err := decodeSyncBlockProtection(cfg.SyncBlockProtection) +
    +
    +   +
    - 99 + + -
    - + - if err != nil { +
    +
    +   +
    - 100 + + -
    - + - log.Errorf("error decoding syncBlockProtection. Error: %v", err) +
    +
    +   +
    - 101 + + -
    - + - cancel() +
    +
    +   +
    - 102 + + -
    - + - return nil, err +
    +
    +   +
    - 103 + + -
    - + - } +
    +
    +   +
    - 104 + + -
    - + - log.Info("syncBlockProtection: ", syncBlockProtection) +
    +
    +   +
    - 105 + + -
    +
    +
      - res := &ClientSynchronizer{ +
    - 106 + + -
    - + - isTrustedSequencer: isTrustedSequencer, +
    +
    +   +
    - 107 + + -
    - + - state: st, +
    +
    +   +
    - 108 + + -
    - + - etherMan: ethMan, +
    +
    +   +
    - 109 + + -
    - + - etherManForL1: etherManForL1, +
    +
    +   +
    - 110 + + -
    - + - pool: pool, +
    +
    +   +
    - 111 + + -
    - + - ctx: ctx, +
    +
    +   +
    - 112 + + -
    - + - cancelCtx: cancel, +
    +
    +   +
    - 113 + + -
    - + - ethTxManager: ethTxManager, +
    +
    +   +
    - 114 + + -
    - + - zkEVMClient: zkEVMClient, +
    +
    +   +
    - 115 + + -
    - + - zkEVMClientEthereumCompatible: zkEVMClientEthereumCompatible, +
    +
    +   +
    - 116 + + -
    - + - eventLog: eventLog, +
    +
    +   +
    - 117 + + -
    - + - genesis: genesis, +
    +
    +   +
    - 118 + + -
    - + - cfg: cfg, +
    +
    +   +
    - 119 + + -
    - + - proverID: "", +
    +
    +   +
    - 120 + + -
    - + - previousExecutorFlushID: 0, +
    +
    +   +
    - 121 + + -
    - + - l1SyncOrchestration: nil, +
    +
    +   +
    - 122 + + -
    - + - l1EventProcessors: nil, +
    +
    +   +
    - 123 + + -
    - + - syncBlockProtection: syncBlockProtection, +
    +
    +   +
    - 124 + + -
    - + - halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd +
    +
    +   +
    - 125 + + -
    +
    +
      - } +
    - 126 + + -
    +
    +
     
    - 127 + + -
    +
    +
      - if !isTrustedSequencer { +
    -
     
    -
    - 156 + + -
    +
    +
      - log.Errorf("error getting last L2Block number from state. Error: %v", err) +
    - 157 + + -
    +
    +
      - return nil, err +
    - 158 + + -
    +
    +
      - } +
    - 159 + + -
    - + - l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) +
    +
    +   +
    - 160 + + -
    +
    +
      - } else { +
    - 161 + + -
    +
    +
      - log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") +
    - 162 + + -
    +
    +
      - } +
    -
     
    -
    - 176 + + -
    +
    +
      - return res, nil +
    - 177 + + -
    +
    +
      - } +
    - 178 + + -
    +
    +
     
    - 179 + + -
    - + - func decodeSyncBlockProtection(sBP string) (rpc.BlockNumber, error) { +
    +
    +   +
    - 180 + + -
    - + - switch sBP { +
    +
    +   +
    - 181 + + -
    - + - case "latest": +
    +
    +   +
    - 182 + + -
    - + - return rpc.LatestBlockNumber, nil +
    +
    +   +
    - 183 + + -
    - + - case "finalized": +
    +
    +   +
    - 184 + + -
    - + - return rpc.FinalizedBlockNumber, nil +
    +
    +   +
    - 185 + + -
    - + - case "safe": +
    +
    +   +
    - 186 + + -
    - + - return rpc.SafeBlockNumber, nil +
    +
    +   +
    - 187 + + -
    - + - default: +
    +
    +   +
    - 188 + + -
    - + - return 0, fmt.Errorf("error decoding SyncBlockProtection. Unknown value") +
    +
    +   +
    - 189 + + -
    - + - } +
    +
    +   +
    - 190 + + -
    - + - } +
    +
    +   +
    - 191 + + -
    - + +
    +
    +  
    - 192 + + -
    +
    +
      - var waitDuration = time.Duration(0) +
    - 193 + + -
    +
    +
     
    - 194 + + -
    +
    +
      - func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { +
    -
     
    -
    - 260 + + -
    +
    +
      - if err != nil { +
    - 261 + + -
    +
    +
      - if errors.Is(err, state.ErrStateNotSynchronized) { +
    - 262 + + -
    +
    +
      - log.Info("State is empty, verifying genesis block") +
    - 263 + + -
    - + - valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.RollupBlockNumber) +
    +
    +   +
    - 264 + + -
    +
    +
      - if err != nil { +
    - 265 + + -
    +
    +
      - log.Error("error checking genesis block number. Error: ", err) +
    - 266 + + -
    +
    +
      - return rollback(s.ctx, dbTx, err) +
    -
     
    +
    + + +
    +   +
    +
    - 268 + + -
    +
    +
      - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +
    - 269 + + -
    +
    +
      - return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) +
    - 270 + + -
    +
    +
      - } +
    - 271 + + -
    - + +
    +
    +  
    - 272 + + -
    - + - // Sync events from RollupManager that happen before rollup creation +
    +
    +   +
    - 273 + + -
    - + - log.Info("synchronizing events from RollupManager that happen before rollup creation") +
    +
    +   +
    - 274 + + -
    - + - for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize { +
    +
    +   +
    - 275 - -
    - + - toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1) -
    -
    - 276 - -
    - + - blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock) -
    -
    - 277 - -
    - + - if err != nil { -
    -
    - 278 - -
    - + - log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err) -
    -
    - 279 - -
    - + - rollbackErr := dbTx.Rollback(s.ctx) -
    -
    - 280 - -
    - + - if rollbackErr != nil { -
    -
    - 281 - -
    - + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) -
    -
    - 282 - -
    - + - return rollbackErr -
    -
    - 283 + + -
    - + - } +
    +
    +   +
    - 284 + + -
    - + - return err +
    +
    +   +
    - 285 + + -
    - + - } +
    +
    +   +
    - 286 + + -
    - + - err = s.ProcessBlockRange(blocks, order) +
    +
    +   +
    - 287 + + -
    - + - if err != nil { +
    +
    +   +
    - 288 + + -
    - + - log.Error("error processing blocks before the genesis: ", err) +
    +
    +   +
    - 289 + + -
    - + - rollbackErr := dbTx.Rollback(s.ctx) +
    +
    +   +
    - 290 + + -
    - + - if rollbackErr != nil { +
    +
    +   +
    - 291 + + -
    - + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    +   +
    - 292 + + -
    - + - return rollbackErr +
    +
    +   +
    - 293 + + -
    - + - } +
    +
    +   +
    - 294 + + -
    - + - return err +
    +
    +   +
    - 295 + + -
    - + - } +
    +
    +   +
    - 296 + + -
    - + - if toBlock == s.genesis.RollupBlockNumber-1 { +
    +
    +   +
    - 297 + + -
    - + - break +
    +
    +   +
    - 298 + + -
    - + - } +
    +
    +   +
    - 299 + + -
    - + - } +
    +
    +   +
    - 300 + + -
    - + +
    +
    +  
    - 301 + + -
    - + - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber)) +
    +
    +   +
    - 302 + + -
    +
    +
      - if err != nil { +
    - 303 + + -
    - + - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err) +
    +
    +   +
    - 304 + + -
    +
    +
      - return rollback(s.ctx, dbTx, err) +
    - 305 + 1004
      - } + require.NoError(t, dbTx.Commit(ctx))
    - 306 + + -
    - + - log.Info("synchronizing rollup creation block") +
    +
    +   +
    - 307 + + -
    +
    +
      - lastEthBlockSynced = &state.Block{ +
    - 308 + + -
    +
    +
      - BlockNumber: header.Number.Uint64(), +
    - 309 + + -
    +
    +
      - BlockHash: header.Hash(), +
    -
     
    -
    - 543 + + -
    +
    +
     
    - 544 + + -
    +
    +
      - // This function syncs the node from a specific block to the latest +
    - 545 + + -
    +
    +
      - func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    - 546 + + -
    - + - // Call the blockchain to retrieve data +
    +
    +   +
    - 547 + + -
    - + - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(s.syncBlockProtection.Int64())) +
    +
    +   +
    - 548 + + -
    - + - if err != nil { +
    +
    +   +
    - 549 + + -
    - + - log.Error("error getting header of the latest block in L1. Error: ", err) +
    +
    +   +
    - 550 + + -
    - + - return lastEthBlockSynced, err +
    +
    +   +
    - 551 + + -
    - + - } +
    +
    +   +
    - 552 + + -
    - + - lastKnownBlock := header.Number +
    +
    +   +
    - 553 + + -
    - + +
    +
    +  
    - 554 + + -
    +
    +
      - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. +
    - 555 + + -
    +
    +
      - block, err := s.checkReorg(lastEthBlockSynced) +
    - 556 + + -
    +
    +
      - if err != nil { +
    -
     
    -
    - 566 + + -
    +
    +
      - return block, nil +
    - 567 + + -
    +
    +
      - } +
    - 568 + + -
    +
    +
     
    @@ -122851,947 +123689,898 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 569 + + -
    +
    +
      - var fromBlock uint64 +
    - 570 + + -
    +
    +
      - if lastEthBlockSynced.BlockNumber > 0 { +
    - 571 + + -
    +
    +
      - fromBlock = lastEthBlockSynced.BlockNumber + 1 +
    -
     
    -
    - 573 + + -
    +
    +
     
    - 574 + + -
    +
    +
      - for { +
    - 575 + + -
    +
    +
      - toBlock := fromBlock + s.cfg.SyncChunkSize +
    - 576 + + -
    - + - if toBlock > lastKnownBlock.Uint64() { +
    +
    +   +
    - 577 + + -
    - + - toBlock = lastKnownBlock.Uint64() +
    +
    +   +
    - 578 + + -
    - + - } +
    +
    +   +
    - 579 + + -
    +
    +
      - log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) +
    - 580 + + -
    +
    +
      - log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) +
    - 581 + + -
    +
    +
      - // This function returns the rollup information contained in the ethereum blocks and an extra param called order. +
    -
     
    -
    - 589 + + -
    +
    +
      - if err != nil { +
    - 590 + + -
    +
    +
      - return lastEthBlockSynced, err +
    - 591 + + -
    +
    +
      - } +
    - 592 + + -
    - + +
    +
    +  
    - 593 + + -
    - + - // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange +
    +
    +   +
    - 594 + + -
    - + - block, err := s.checkReorg(lastEthBlockSynced) +
    +
    +   +
    - 595 + + -
    - + - if err != nil { +
    +
    +   +
    - 596 + + -
    - + - log.Errorf("error checking reorgs. Retrying... Err: %v", err) +
    +
    +   +
    - 597 + + -
    - + - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") +
    +
    +   +
    - 598 + + -
    - + - } +
    +
    +   +
    - 599 + + -
    - + - if block != nil { +
    +
    +   +
    - 600 + + -
    - + - err = s.resetState(block.BlockNumber) +
    +
    +   +
    - 601 + + -
    - + - if err != nil { +
    +
    +   +
    - 602 + + -
    - + - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    +   +
    - 603 + + -
    - + - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    +   +
    - 604 + + -
    - + - } +
    +
    +   +
    - 605 + + -
    - + - return block, nil +
    +
    +   +
    - 606 + + -
    - + - } +
    +
    +   +
    - 607 + + -
    - + +
    +
    +  
    - 608 + 1005
      - start = time.Now() + }
    - 609 + 1006
      - err = s.ProcessBlockRange(blocks, order) +
    - 610 + 1007
      - metrics.ProcessL1DataTime(time.Since(start)) + func TestGetNativeBlockHashesInRange(t *testing.T) {
    -
     
    +
    @@ -1132,6 +1371,108 @@
    - 798 + 1132
      - func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, error) { + require.NoError(t, dbTx.Commit(ctx))
    - 799 + 1133
      - // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. + }
    - 800 + 1134
      - latestEthBlockSynced := *latestBlock +
    - 801 + + -
    - + - reorgedBlock := *latestBlock +
    +
    +   +
    - 802 + + -
    +
    +
      - var depth uint64 +
    - 803 + + -
    +
    +
      - for { +
    - 804 + + -
    - + - block, err := s.etherMan.EthBlockByNumber(s.ctx, reorgedBlock.BlockNumber) +
    +
    +   +
    - 805 + + -
    +
    +
      - if err != nil { +
    - 806 + + -
    - + - log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", reorgedBlock.BlockNumber, err) +
    +
    +   +
    - 807 + + -
    +
    +
      - return nil, err +
    - 808 + + -
    -   - } +
    +
    +   +
    - 809 + + -
    - + - log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.Number().Uint64(), block.Hash().String()) +
    +
    +   +
    - 810 + + -
    - + - log.Infof("[checkReorg function] latestBlockNumber: %d latestBlockHash already synced: %s", latestBlock.BlockNumber, latestBlock.BlockHash.String()) +
    +
    +   +
    - 811 + + -
    - + - if block.NumberU64() != reorgedBlock.BlockNumber { +
    +
    +   +
    - 812 + + -
    +
    +
      - err = fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", +
    - 813 + + -
    - + - reorgedBlock.BlockNumber, block.NumberU64()) +
    +
    +   +
    - 814 + + -
    +
    +
      - log.Error("error: ", err) +
    - 815 + + -
    +
    +
      - return nil, err +
    - 816 + + -
    +
    +
      - } +
    - 817 + + -
    +
    +
      - // Compare hashes +
    - 818 + + -
    - + - if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.RollupBlockNumber { +
    +
    +   +
    - 819 + + -
    +
    +
      - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash) +
    - 820 + + -
    +
    +
      - log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) +
    - 821 + + -
    +
    +
      - log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) +
    -
     
    -
    - 831 + + -
    +
    +
      - log.Errorf("error creating db transaction to get prevoius blocks") +
    - 832 + + -
    +
    +
      - return nil, err +
    - 833 + + -
    +
    +
      - } +
    - 834 + + -
    - + - lb, err := s.state.GetPreviousBlock(s.ctx, depth, dbTx) +
    +
    +   +
    - 835 + + -
    +
    +
      - errC := dbTx.Commit(s.ctx) +
    - 836 + + -
    +
    +
      - if errC != nil { +
    - 837 + + -
    +
    +
      - log.Errorf("error committing dbTx, err: %v", errC) +
    -
     
    -
    - 847 + + -
    +
    +
      - log.Warn("error checking reorg: previous block not found in db: ", err) +
    - 848 + + -
    +
    +
      - return &state.Block{}, nil +
    - 849 + + -
    +
    +
      - } else if err != nil { +
    - 850 + + -
    - + - log.Error("error getting previousBlock from db. Error: ", err) +
    +
    +   +
    - 851 + + -
    +
    +
      - return nil, err +
    - 852 + + -
    +
    +
      - } +
    - 853 + + -
    - + - reorgedBlock = *lb +
    +
    +   +
    - 854 + + -
    +
    +
      - } else { +
    - 855 + + -
    - + - log.Debugf("checkReorg: Block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.Hash() == reorgedBlock.BlockHash, block.ParentHash() == reorgedBlock.ParentHash) +
    +
    +   +
    - 856 + + -
    +
    +
      - break +
    - 857 + + -
    +
    +
      - } +
    - 858 + + -
    +
    +
      - } +
    - 859 + + -
    - + - if latestEthBlockSynced.BlockHash != reorgedBlock.BlockHash { +
    +
    +   +
    - 860 + + -
    - + - latestBlock = &reorgedBlock +
    +
    +   +
    - 861 + + -
    +
    +
      - log.Info("Reorg detected in block: ", latestEthBlockSynced.BlockNumber, " last block OK: ", latestBlock.BlockNumber) +
    - 862 + + -
    +
    +
      - return latestBlock, nil +
    - 863 + + -
    +
    +
      - } +
    - 864 + + -
    - + - log.Debugf("No reorg detected in block: %d. BlockHash: %s", latestEthBlockSynced.BlockNumber, latestEthBlockSynced.BlockHash.String()) +
    +
    +   +
    - 865 + + -
    +
    +
      - return nil, nil +
    - 866 + + -
    +
    +
      - } +
    - 867 + + -
    +
    +
     
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -123805,128 +124594,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -123940,278 +124724,273 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -124225,227 +125004,292 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - @@ -124470,51 +125314,51 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -124705,227 +125554,252 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - + + + - - + - - - - - - - - - - - - - - - - + - - - - - - - - @@ -124950,51 +125824,51 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -125185,128 +126064,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -125320,33 +126204,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + @@ -125365,72 +126259,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -125440,897 +126334,817 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + + + + + + + + @@ -126340,820 +127154,797 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -18,6 +18,7 @@
    -
    - 18 + + -
    +
    +
      - syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" +
    - 19 + + -
    +
    +
      - "github.com/ethereum/go-ethereum/common" +
    - 20 + + -
    +
    +
      - ethTypes "github.com/ethereum/go-ethereum/core/types" +
    - 21 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 22 + + -
    +
    +
      - "github.com/stretchr/testify/assert" +
    - 23 + + -
    +
    +
      - "github.com/stretchr/testify/mock" +
    -
    @@ -32,12 +33,13 @@
    -
    - 32 + + -
    +
    +
      - ) +
    - 33 + + -
    +
    +
     
    - 34 + + -
    +
    +
      - type mocks struct { +
    - 35 + + -
    - - - Etherman *mock_syncinterfaces.EthermanFullInterface +
    +
    +   +
    - 36 + + -
    - - - State *mock_syncinterfaces.StateFullInterface +
    +
    +   +
    - 37 + + -
    - - - Pool *mock_syncinterfaces.PoolInterface +
    +
    +   +
    - 38 + + -
    - - - EthTxManager *mock_syncinterfaces.EthTxManager +
    +
    +   +
    - 39 + + -
    - - - DbTx *syncMocks.DbTxMock +
    +
    +   +
    - 40 + + -
    - - - ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +
    +
    +   +
    - 41 + + -
    +
    +
      - //EventLog *eventLogMock +
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
     
    -
    @@ -47,7 +49,7 @@
    -
    - 47 + + -
    +
    +
      - func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { +
    - 48 + + -
    +
    +
      - genesis, cfg, m := setupGenericTest(t) +
    - 49 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 50 + + -
    - - - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    +   +
    - 51 + + -
    +
    +
      - require.NoError(t, err) +
    - 52 + + -
    +
    +
      - sync, ok := syncInterface.(*ClientSynchronizer) +
    - 53 + + -
    +
    +
      - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    -
    @@ -87,7 +89,7 @@
    -
    - 87 + + -
    +
    +
      - func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { +
    - 88 + + -
    +
    +
      - genesis, cfg, m := setupGenericTest(t) +
    - 89 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 90 + + -
    - - - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    +   +
    - 91 + + -
    +
    +
      - require.NoError(t, err) +
    - 92 + + -
    +
    +
      - sync, ok := syncInterface.(*ClientSynchronizer) +
    - 93 + + -
    +
    +
      - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    -
    @@ -119,12 +121,13 @@
    +
    + + +
    +   +
    +
    - 119 + + -
    +
    +
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    - 120 + + -
    +
    +
      - func TestForcedBatchEtrog(t *testing.T) { +
    - 121 + + -
    +
    +
      - genesis := state.Genesis{ +
    - 122 + + -
    - - - BlockNumber: uint64(123456), +
    +
    +   +
    - 123 + + -
    +
    +
      - } +
    - 124 + + -
    +
    +
      - cfg := Config{ +
    - 125 + + -
    +
    +
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    - 126 + + -
    +
    +
      - SyncChunkSize: 10, +
    - 127 + + -
    +
    +
      - L1SynchronizationMode: SequentialMode, +
    - 128 + + -
    +
    +
      - } +
    - 129 + + -
    +
    +
     
    - 130 + + -
    +
    +
      - m := mocks{ +
    -
    @@ -135,7 +138,7 @@
    +
    + + +
    +   +
    +
    - 135 + + -
    +
    +
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    - 136 + + -
    +
    +
      - } +
    - 137 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 138 + + -
    - - - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) +
    +
    +   +
    - 139 + 1135
      - require.NoError(t, err) + func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry {
    - 140 + 1136
      -
    + exitRoot := state.L1InfoTreeExitRootStorageEntry{
    - 141 + 1137
      - // state preparation + L1InfoTreeLeaf: state.L1InfoTreeLeaf{
    -
    @@ -201,7 +204,7 @@
    +
    @@ -1333,6 +1674,13 @@
    - 201 + 1333
      - Return(ethBlock, nil). + require.Equal(t, uint64(2002), fb.BlockNumber)
    - 202 + 1334
      - Once() + require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String())
    - 203 + 1335
      -
    + require.Equal(t, []byte{0xb}, fb.RawTxsData)
    - 204 + + -
    - - - var n *big.Int +
    +
    +   +
    - 205 + + -
    +
    +
      - m.Etherman. +
    - 206 + + -
    +
    +
      - On("HeaderByNumber", mock.Anything, n). +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 207 + 1336 + +
    +   + } +
    +
    + 1337 + +
    +   +
    +
    +
    + 1338
      - Return(ethHeader, nil). + func TestGetLastGER(t *testing.T) {
    -
    @@ -254,12 +257,19 @@
    +
    @@ -1409,5 +1757,99 @@
    - 254 + 1409
      -
    + ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx)
    - 255 + 1410
      - fromBlock := ethBlock.NumberU64() + 1 + require.NoError(t, err)
    - 256 + 1411
      - toBlock := fromBlock + cfg.SyncChunkSize + require.Equal(t, common.HexToHash("0x2").String(), ger.String())
    - 257 + + -
    - - +
    +
    +  
    - 258 + + -
    +
    +
      - m.Etherman. +
    - 259 + + -
    +
    +
      - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    - 260 + + -
    +
    +
      - Return(blocks, order, nil). +
    - 261 + + -
    +
    +
      - Once() +
    - 262 + + -
    +
    +
     
    @@ -124570,128 +125414,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 263 + + -
    +
    +
      - m.ZKEVMClient. +
    - 264 + + -
    +
    +
      - On("BatchNumber", ctx). +
    - 265 + + -
    +
    +
      - Return(uint64(1), nil) +
    -
    @@ -372,12 +382,13 @@
    +
    + + +
    +   +
    +
    - 372 + + -
    +
    +
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    - 373 + + -
    +
    +
      - func TestSequenceForcedBatchIncaberry(t *testing.T) { +
    - 374 + + -
    +
    +
      - genesis := state.Genesis{ +
    - 375 + + -
    - - - BlockNumber: uint64(123456), +
    +
    +   +
    - 376 + + -
    +
    +
      - } +
    - 377 + + -
    +
    +
      - cfg := Config{ +
    - 378 + + -
    +
    +
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    - 379 + + -
    +
    +
      - SyncChunkSize: 10, +
    - 380 + + -
    +
    +
      - L1SynchronizationMode: SequentialMode, +
    - 381 + + -
    +
    +
      - } +
    - 382 + + -
    +
    +
     
    - 383 + + -
    +
    +
      - m := mocks{ +
    -
    @@ -388,7 +399,7 @@
    +
    + + +
    +   +
    +
    - 388 + + -
    +
    +
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    - 389 + + -
    +
    +
      - } +
    - 390 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 391 + + -
    - - - sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) +
    +
    +   +
    - 392 + + -
    +
    +
      - require.NoError(t, err) +
    - 393 + + -
    +
    +
    +   +
    +
    +
    + + +
     
    - 394 + 1412
      - // state preparation +
    -
    @@ -455,7 +466,7 @@
    +
    + + +
    +   +
    +
    - 455 + + -
    +
    +
      - Return(ethBlock, nil). +
    - 456 + + -
    +
    +
      - Once() +
    - 457 + + -
    +
    +
     
    - 458 + + -
    - - - var n *big.Int +
    +
    +   +
    - 459 + + -
    +
    +
      - m.Etherman. +
    - 460 + + -
    +
    +
      - On("HeaderByNumber", ctx, n). +
    - 461 + + -
    +
    +
      - Return(ethHeader, nil). +
    -
    @@ -503,12 +514,19 @@
    +
    + + +
    +   +
    +
    - 503 + + -
    +
    +
     
    - 504 + + -
    +
    +
      - fromBlock := ethBlock.NumberU64() + 1 +
    - 505 + + -
    +
    +
      - toBlock := fromBlock + cfg.SyncChunkSize +
    - 506 + + -
    - - +
    +
    +  
    - 507 + + -
    +
    +
      - m.Etherman. +
    - 508 + + -
    +
    +
      - On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). +
    - 509 + + -
    +
    +
      - Return(blocks, order, nil). +
    - 510 + + -
    +
    +
      - Once() +
    - 511 + + -
    +
    +
     
    @@ -125050,128 +125924,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 512 + + -
    +
    +
      - m.State. +
    - 513 + + -
    +
    +
      - On("BeginStateTransaction", ctx). +
    - 514 + + -
    +
    +
      - Return(m.DbTx, nil). +
    -
    @@ -611,12 +629,13 @@
    +
    + + +
    +   +
    +
    - 611 + + -
    +
    +
     
    - 612 + + -
    +
    +
      - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { +
    - 613 + + -
    +
    +
      - genesis := state.Genesis{ +
    - 614 + + -
    - - - BlockNumber: uint64(123456), +
    +
    +   +
    - 615 + + -
    +
    +
      - } +
    - 616 + + -
    +
    +
      - cfg := Config{ +
    - 617 + + -
    +
    +
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    - 618 + + -
    +
    +
      - SyncChunkSize: 10, +
    - 619 + + -
    +
    +
      - L1SynchronizationMode: SequentialMode, +
    - 620 + + -
    +
    +
      - L1ParallelSynchronization: L1ParallelSynchronizationConfig{ +
    - 621 + + -
    +
    +
      - MaxClients: 2, +
    - 622 + + -
    +
    +
      - MaxPendingNoProcessedBlocks: 2, +
    -
    @@ -631,12 +650,13 @@
    +
    + + +
    +   +
    +
    - 631 + + -
    +
    +
      - } +
    - 632 + + -
    +
    +
     
    - 633 + + -
    +
    +
      - m := mocks{ +
    - 634 + + -
    - - - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    +   +
    - 635 + + -
    - - - State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    +   +
    - 636 + + -
    - - - Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    +   +
    - 637 + + -
    - - - DbTx: syncMocks.NewDbTxMock(t), +
    +
    +   +
    - 638 + + -
    - - - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    +   +
    - 639 + + -
    - - - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    +   +
    - 640 + + -
    +
    +
      - //EventLog: newEventLogMock(t), +
    - 641 + + -
    +
    +
      - } +
    +
    +
    + + +
    +   +
    - 642 + 1413
      - return &genesis, &cfg, &m + }
    - 18 + 872
      - syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" + ctx := context.Background()
    - 19 + 873
      - "github.com/ethereum/go-ethereum/common" +
    - 20 + 874
      - ethTypes "github.com/ethereum/go-ethereum/core/types" + cfg := state.Config{
    - 21 + + 875 +
    + - "github.com/ethereum/go-ethereum/rpc" + MaxLogsCount: 40,
    - 22 + 876
      - "github.com/jackc/pgx/v4" + MaxLogsBlockRange: 10,
    - 23 + 877
      - "github.com/stretchr/testify/assert" + ForkIDIntervals: stateCfg.ForkIDIntervals,
    - 24 + 878
      - "github.com/stretchr/testify/mock" + }
    - 33 + 895
      - ) + time := time.Now()
    - 34 + 896
      -
    + blockNumber := big.NewInt(1)
    - 35 + 897
      - type mocks struct { +
    - 36 + 898
    + - Etherman *mock_syncinterfaces.EthermanFullInterface + maxBlocks := 3
    - 37 + 899
    + - State *mock_syncinterfaces.StateFullInterface + txsPerBlock := 4
    - 38 + 900
    + - Pool *mock_syncinterfaces.PoolInterface + logsPerTx := 5
    - 39 + 901
    + - EthTxManager *mock_syncinterfaces.EthTxManager +
    - 40 + 902
    + - DbTx *syncMocks.DbTxMock + nonce := uint64(0)
    - 41 + 903
    + - ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +
    - 42 + + 904 +
    + - zkEVMClientEthereumCompatible *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface + // number of blocks to be created
    - 43 + + 905 +
    -   - //EventLog *eventLogMock + + + for b := 0; b < maxBlocks; b++ {
    - 44 + + 906 +
    -   - } + + + logIndex := uint(0)
    - 45 + + 907 +
    -   -
    + + + transactions := make([]*types.Transaction, 0, txsPerBlock)
    -
     
    -
    - 49 + + 908 +
    -   - func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { + + + receipts := make([]*types.Receipt, 0, txsPerBlock)
    - 50 + + 909 +
    -   - genesis, cfg, m := setupGenericTest(t) + + + stateRoots := make([]common.Hash, 0, txsPerBlock)
    - 51 + + 910 +
    -   - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + + +
    - 52 + 911
    + - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) + // number of transactions in a block to be created
    - 53 + + 912 +
    -   - require.NoError(t, err) + + + for t := 0; t < txsPerBlock; t++ {
    - 54 + + 913 +
    -   - sync, ok := syncInterface.(*ClientSynchronizer) + + + nonce++
    - 55 + + 914 +
    -   - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") -
    -
    -
     
    -
    - 89 - -
    -   - func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { -
    -
    - 90 - -
    -   - genesis, cfg, m := setupGenericTest(t) -
    -
    - 91 - -
    -   - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + + + txIndex := uint(t + 1)
    - 92 + 915
    + - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) -
    -
    - 93 - -
    -   - require.NoError(t, err) -
    -
    - 94 - -
    -   - sync, ok := syncInterface.(*ClientSynchronizer) -
    -
    - 95 - -
    -   - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") -
    -
    -
     
    -
    - 121 - -
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 -
    -
    - 122 - -
    -   - func TestForcedBatchEtrog(t *testing.T) { +
    - 123 + + 916 +
    -   - genesis := state.Genesis{ + + + tx := types.NewTx(&types.LegacyTx{
    - 124 + 917
    + - RollupBlockNumber: uint64(123456), + Nonce: nonce,
    - 125 + + 918 +
    -   - } + + + To: nil,
    - 126 + + 919 +
    -   - cfg := Config{ + + + Value: new(big.Int),
    - 127 + + 920 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + Gas: 0,
    - 128 + + 921 +
    -   - SyncChunkSize: 10, + + + GasPrice: big.NewInt(0),
    - 129 + + 922 +
    -   - L1SynchronizationMode: SequentialMode, + + + })
    - 130 + 923
    + - SyncBlockProtection: "latest", +
    - 131 + + 924 +
    -   - } + + + logs := []*types.Log{}
    - 132 + + 925 +
    -   + +
    - 133 + + 926 +
    -   - m := mocks{ + + + // if block is even logIndex follows a sequence related to the block
    -
     
    -
    - 138 + + 927 +
    -   - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + + + // for odd blocks logIndex follows a sequence related ot the tx
    - 139 + + 928 +
    -   - } + + + // this is needed to simulate a logIndex difference introduced on Etrog
    - 140 + + 929 +
    -   - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + + + // and we need to maintain to be able to synchronize these blocks
    - 141 + + 930 +
    + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + // number of logs in a transaction to be created
    - 142 + + 931 +
    -   - require.NoError(t, err) + + + for l := 0; l < logsPerTx; l++ {
    - 143 + + 932 +
    -   -
    + + + li := logIndex
    - 144 + + 933 +
    -   - // state preparation + + + if b%2 != 0 { // even block
    -
     
    -
    - 204 + + 934 +
    -   - Return(ethBlock, nil). + + + li = uint(l)
    - 205 + + 935 +
    -   - Once() + + + }
    - 206 + + 936 +
    -   + +
    - 207 + + 937 +
    + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) + logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li})
    - 208 + + 938 +
    -   - m.Etherman. + + + logIndex++
    - 209 + + 939 +
    -   - On("HeaderByNumber", mock.Anything, n). + + + }
    - 210 + + 940 +
    -   - Return(ethHeader, nil). + + +
    -
     
    -
    - 257 + + 941 +
    -   -
    + + + receipt := &types.Receipt{
    - 258 + + 942 +
    -   - fromBlock := ethBlock.NumberU64() + 1 + + + Type: tx.Type(),
    - 259 + + 943 +
    -   - toBlock := fromBlock + cfg.SyncChunkSize + + + PostState: state.ZeroHash.Bytes(),
    - 260 + + 944 +
    + - if toBlock > ethHeader.Number.Uint64() { + CumulativeGasUsed: 0,
    - 261 + 945
    + - toBlock = ethHeader.Number.Uint64() + EffectiveGasPrice: big.NewInt(0),
    - 262 + 946
    + - } + BlockNumber: blockNumber,
    - 263 + + 947 +
    -   - m.Etherman. + + + GasUsed: tx.Gas(),
    - 264 + + 948 +
    -   - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + + + TxHash: tx.Hash(),
    - 265 + + 949 +
    -   - Return(blocks, order, nil). + + + TransactionIndex: txIndex,
    - 266 + + 950 +
    -   - Once() + + + Status: types.ReceiptStatusSuccessful,
    - 267 + + 951 +
    -   -
    + + + Logs: logs,
    - 268 + 952
    + - m.Etherman. + }
    - 269 + 953
    + - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). +
    - 270 + 954
    + - Return(ethBlock, nil). + transactions = append(transactions, tx)
    - 271 + 955
    + - Once() + receipts = append(receipts, receipt)
    - 272 + 956
    + -
    + stateRoots = append(stateRoots, state.ZeroHash)
    - 273 + 957
      - m.ZKEVMClient. + }
    - 274 + 958
      - On("BatchNumber", ctx). +
    - 275 + + -
    +
    +
      - Return(uint64(1), nil) +
    -
     
    +
    + + +
    +   +
    +
    - 382 + + -
    +
    +
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    - 383 + + -
    +
    +
      - func TestSequenceForcedBatchIncaberry(t *testing.T) { +
    - 384 + 959
      - genesis := state.Genesis{ + header := state.NewL2Header(&types.Header{
    - 385 + 960
    + - RollupBlockNumber: uint64(123456), + Number: big.NewInt(int64(b) + 1),
    - 386 + 961
      - } + ParentHash: state.ZeroHash,
    - 387 + 962
      - cfg := Config{ + Coinbase: state.ZeroAddress,
    - 388 + 963
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + Root: state.ZeroHash,
    +
     
    +
    - 389 + 984
      - SyncChunkSize: 10, + require.NoError(t, err)
    - 390 + 985
      - L1SynchronizationMode: SequentialMode, + } +
    +
    + 986 + +
    +   +
    - 391 + 987
    + - SyncBlockProtection: "latest", + require.NoError(t, dbTx.Commit(ctx)) +
    +
    + 988 + +
    + + +
    - 392 + 989
      - } + type testCase struct {
    - 393 + 990
      -
    + name string
    - 394 + 991
      - m := mocks{ + from uint64
    - 399 + 1020
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + name: "logs returned successfully",
    - 400 + 1021
      - } + from: 1,
    - 401 + 1022
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + to: 2,
    - 402 + 1023
    + - sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + logCount: 40,
    - 403 + 1024
      - require.NoError(t, err) + expectedError: nil,
    - 404 + 1025
      -
    + },
    - 405 + 1026
      - // state preparation + }
    -
     
    -
    - 466 + 1027
      - Return(ethBlock, nil). +
    - 467 + 1028
      - Once() + for _, testCase := range testCases {
    - 468 + 1029
      -
    + t.Run(testCase.name, func(t *testing.T) {
    - 469 + 1030
    + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) + logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, nil)
    - 470 + + -
    +
    +
      - m.Etherman. +
    - 471 + 1031
      - On("HeaderByNumber", ctx, n). + assert.Equal(t, testCase.logCount, len(logs))
    - 472 + 1032
      - Return(ethHeader, nil). + assert.Equal(t, testCase.expectedError, err)
    -
     
    +
    + 1033 + +
    + + +
    +
    - 514 + + 1034 +
    -   -
    + + + // check tx index and log index order
    - 515 + + 1035 +
    -   - fromBlock := ethBlock.NumberU64() + 1 + + + lastBlockNumber := uint64(0)
    - 516 + + 1036 +
    -   - toBlock := fromBlock + cfg.SyncChunkSize + + + lastTxIndex := uint(0)
    - 517 + + 1037 +
    + - if toBlock > ethHeader.Number.Uint64() { + lastLogIndex := uint(0)
    - 518 + 1038
    + - toBlock = ethHeader.Number.Uint64() +
    - 519 + 1039
    + - } + for i, l := range logs {
    - 520 + + 1040 +
    -   - m.Etherman. + + + // if block has changed and it's not the first log, reset lastTxIndex
    - 521 + + 1041 +
    -   - On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). + + + if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 {
    - 522 + + 1042 +
    -   - Return(blocks, order, nil). + + + lastTxIndex = 0
    - 523 + + 1043 +
    -   - Once() + + + }
    - 524 + + 1044 +
    -   + +
    - 525 + 1045
    + - m.Etherman. + if l.TxIndex < lastTxIndex {
    - 526 + 1046
    + - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). + t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex)
    - 527 + 1047
    + - Return(ethBlock, nil). + }
    - 528 + 1048
    + - Once() + // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block
    - 529 + 1049
    + -
    + // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero
    - 530 + + 1050 +
    -   - m.State. + + + if l.TxIndex != lastTxIndex && l.Index == 0 {
    - 531 + + 1051 +
    -   - On("BeginStateTransaction", ctx). + + + lastLogIndex = 0
    - 532 + + 1052 +
    -   - Return(m.DbTx, nil). + + + }
    -
     
    +
    + 1053 + +
    + + +
    +
    - 629 + + 1054 +
    -   -
    + + + if l.Index < lastLogIndex {
    - 630 + + 1055 +
    -   - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { + + + t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index)
    - 631 + + 1056 +
    -   - genesis := state.Genesis{ + + + }
    - 632 + + 1057 +
    + - RollupBlockNumber: uint64(123456), +
    - 633 + + 1058 +
    -   - } + + + lastBlockNumber = l.BlockNumber
    - 634 + + 1059 +
    -   - cfg := Config{ + + + lastTxIndex = l.TxIndex
    - 635 + + 1060 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + + + lastLogIndex = l.Index +
    +
    + 1061 + +
    + + + }
    - 636 + 1062
      - SyncChunkSize: 10, + })
    - 637 + 1063
      - L1SynchronizationMode: SequentialMode, + }
    - 638 + 1064
    + - SyncBlockProtection: "latest", + }
    - 639 + + 1065 +
    -   - L1ParallelSynchronization: L1ParallelSynchronizationConfig{ + + +
    - 640 + + 1066 +
    -   - MaxClients: 2, + + + func TestGetLogsByBlockNumber(t *testing.T) {
    - 641 + + 1067 +
    -   - MaxPendingNoProcessedBlocks: 2, + + + initOrResetDB()
    -
     
    +
    + 1068 + +
    + + +
    +
    - 650 + + 1069 +
    -   - } + + + ctx := context.Background()
    - 651 + + 1070 +
    -   + +
    - 652 + + 1071 +
    -   - m := mocks{ + + + cfg := state.Config{
    - 653 + + 1072 +
    + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + MaxLogsCount: 40,
    - 654 + + 1073 +
    + - State: mock_syncinterfaces.NewStateFullInterface(t), + MaxLogsBlockRange: 10,
    - 655 + + 1074 +
    + - Pool: mock_syncinterfaces.NewPoolInterface(t), + ForkIDIntervals: stateCfg.ForkIDIntervals,
    - 656 + + 1075 +
    + - DbTx: syncMocks.NewDbTxMock(t), + }
    - 657 + + 1076 +
    + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    - 658 + + 1077 +
    + - zkEVMClientEthereumCompatible: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t), + mt, err := l1infotree.NewL1InfoTree(32, [][32]byte{})
    - 659 + 1078
    + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + if err != nil {
    - 660 + + 1079 +
    -   - //EventLog: newEventLogMock(t), + + + panic(err)
    - 661 + + 1080 +
    -   + + }
    - 662 + + 1081 +
    -   - return &genesis, &cfg, &m -
    -
    -
    + + + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/CounterAndBlock.sol - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,15 @@
    - + + 1082 -
    -   +
    +
    + +
    - + + 1083 -
    -   -
    +
    +
    + + + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 1084 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1085 -
    -   -
    +
    +
    + + + err = testState.AddBlock(ctx, block, dbTx)
    - + + 1086 -
    -   -
    +
    +
    + + + assert.NoError(t, err)
    - + + 1087 -
    -   +
    +
    + +
    - + + 1088 -
    -   -
    +
    +
    + + + batchNumber := uint64(1)
    - + + 1089 -
    -   -
    +
    +
    + + + _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num, wip) VALUES ($1, FALSE)", batchNumber)
    - + + 1090 -
    -   -
    +
    +
    + + + assert.NoError(t, err)
    - + + 1091 -
    -   +
    +
    + +
    - + + 1092 -
    -   -
    +
    +
    + + + time := time.Now()
    - + + 1093 -
    -   -
    +
    +
    + + + blockNumber := big.NewInt(1)
    - + + 1094 -
    -   +
    +
    + +
    - + + 1095 -
    -   -
    +
    +
    + + + maxBlocks := 3
    - - -
    -   -
    -
    +
    + 1096
    -
    + +
    + + + txsPerBlock := 4
    -
    -
    - - - - - - - -
    -
     
    - 1 + 1097
    + - // SPDX-License-Identifier: GPL-3.0 + logsPerTx := 5
    - 2 + 1098
    @@ -127163,17 +127954,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 3 + 1099
    + - pragma solidity >=0.7.0 <0.9.0; + nonce := uint64(0)
    - 4 + 1100
    @@ -127183,67 +127974,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 5 + 1101
    + - contract CounterAndBlock { + // number of blocks to be created
    - 6 + 1102
    + - uint public count; + for b := 0; b < maxBlocks; b++ {
    - 7 + 1103
    + -
    + logIndex := uint(0)
    - 8 + 1104
    + - function increment() external { + transactions := make([]*types.Transaction, 0, txsPerBlock)
    - 9 + 1105
    + - count += 1; + receipts := make([]*types.Receipt, 0, txsPerBlock)
    - 10 + 1106
    + - } + stateRoots := make([]common.Hash, 0, txsPerBlock)
    - 11 + 1107
    @@ -127253,460 +128044,427 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 12 + 1108
    + - function getCount() public view returns (uint, uint) { + // number of transactions in a block to be created
    - 13 + 1109
    + - return (count, block.timestamp); + for t := 0; t < txsPerBlock; t++ {
    - 14 + 1110
    + - } + nonce++
    - 15 + 1111
    + - } -
    -
    -
    + txIndex := uint(t + 1)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,24 @@
    - + + 1112 -
    -   +
    +
    + +
    - + + 1113 -
    -   -
    +
    +
    + + + tx := types.NewTx(&types.LegacyTx{
    - + + 1114 -
    -   -
    +
    +
    + + + Nonce: nonce,
    - + + 1115 -
    -   -
    +
    +
    + + + To: nil,
    - + + 1116 -
    -   -
    +
    +
    + + + Value: new(big.Int),
    - + + 1117 -
    -   -
    +
    +
    + + + Gas: 0,
    - + + 1118 -
    -   -
    +
    +
    + + + GasPrice: big.NewInt(0),
    - + + 1119 -
    -   -
    +
    +
    + + + })
    - + + 1120 -
    -   +
    +
    + +
    - + + 1121 -
    -   -
    +
    +
    + + + logs := []*types.Log{}
    - + + 1122 -
    -   +
    +
    + +
    - + + 1123 -
    -   -
    +
    +
    + + + // if block is even logIndex follows a sequence related to the block
    - + + 1124 -
    -   -
    +
    +
    + + + // for odd blocks logIndex follows a sequence related ot the tx
    - + + 1125 -
    -   -
    +
    +
    + + + // this is needed to simulate a logIndex difference introduced on Etrog
    - + + 1126 -
    -   -
    +
    +
    + + + // and we need to maintain to be able to synchronize these blocks
    - + + 1127 -
    -   -
    +
    +
    + + + // number of logs in a transaction to be created
    - + + 1128 -
    -   -
    +
    +
    + + + for l := 0; l < logsPerTx; l++ {
    - + + 1129 -
    -   -
    +
    +
    + + + li := logIndex
    - + + 1130 -
    -   -
    +
    +
    + + + if b%2 != 0 { // even block
    - + + 1131 -
    -   -
    +
    +
    + + + li = uint(l)
    - + + 1132 -
    -   -
    +
    +
    + + + }
    - + + 1133 -
    -   +
    +
    + +
    - + + 1134 -
    -   -
    +
    +
    + + + logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li})
    - + + 1135 -
    -   -
    +
    +
    + + + logIndex++
    -
    + + + 1136 + + +
    + + + }
    -
    -
    - - - - - - - -
    -
     
    - 1 + 1137
    + - // SPDX-License-Identifier: MIT +
    - 2 + 1138
    + - pragma solidity >=0.7.0 <0.9.0; + receipt := &types.Receipt{
    - 3 + 1139
    + -
    + Type: tx.Type(),
    - 4 + 1140
    + - contract customModExp { + PostState: state.ZeroHash.Bytes(),
    - 5 + 1141
    + - bytes32 hashResult; + CumulativeGasUsed: 0,
    - 6 + 1142
    + - address retEcrecover; + EffectiveGasPrice: big.NewInt(0),
    - 7 + 1143
    + - bytes dataResult; + BlockNumber: blockNumber,
    - 8 + 1144
    + - uint256 dataRes; + GasUsed: tx.Gas(),
    - 9 + 1145
    + -
    + TxHash: tx.Hash(),
    - 10 + 1146
    + - bytes32[10] arrayStorage; + TransactionIndex: txIndex,
    - 11 + 1147
    + -
    + Status: types.ReceiptStatusSuccessful,
    - 12 + 1148
    + - function modExpGeneric(bytes memory input) public { + Logs: logs,
    - 13 + 1149
    + - bytes32[10] memory output; + }
    - 14 + 1150
    @@ -127716,47 +128474,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 15 + 1151
    + - assembly { + transactions = append(transactions, tx)
    - 16 + 1152
    + - let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140) + receipts = append(receipts, receipt)
    - 17 + 1153
    + - sstore(0x00, success) + stateRoots = append(stateRoots, state.ZeroHash)
    - 18 + 1154
    + - } + }
    - 19 + 1155
    @@ -127766,2990 +128524,2842 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 20 + 1156
    + - for (uint i = 0; i < 10; i++) { + header := state.NewL2Header(&types.Header{
    - 21 + 1157
    + - arrayStorage[i] = output[i]; + Number: big.NewInt(int64(b) + 1),
    - 22 + 1158
    + - } + ParentHash: state.ZeroHash,
    - 23 + 1159
    + - } + Coinbase: state.ZeroAddress,
    - 24 + 1160
    + - } + Root: state.ZeroHash,
    -
    + + + 1161 + + +
    + + + GasUsed: 1,
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/CounterAndBlock/CounterAndBlock.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,287 @@
    - + + 1162 -
    -   -
    +
    +
    + + + GasLimit: 10,
    - + + 1163 -
    -   -
    +
    +
    + + + Time: uint64(time.Unix()),
    - + + 1164 -
    -   -
    +
    +
    + + + })
    - + + 1165 -
    -   +
    +
    + +
    - + + 1166 -
    -   -
    +
    +
    + + + st := trie.NewStackTrie(nil)
    - + + 1167 -
    -   -
    +
    +
    + + + l2Block := state.NewL2Block(header, transactions, []*state.L2Header{}, receipts, st)
    - + + 1168 -
    -   -
    +
    +
    + + + for _, receipt := range receipts {
    - + + 1169 -
    -   -
    +
    +
    + + + receipt.BlockHash = l2Block.Hash()
    - + + 1170 -
    -   -
    +
    +
    + + + }
    - + + 1171 -
    -   +
    +
    + +
    - + + 1172 -
    -   -
    +
    +
    + + + numTxs := len(transactions)
    - + + 1173 -
    -   -
    +
    +
    + + + storeTxsEGPData := make([]state.StoreTxEGPData, numTxs)
    - + + 1174 -
    -   -
    +
    +
    + + + txsL2Hash := make([]common.Hash, numTxs)
    - + + 1175 -
    -   -
    +
    +
    + + + for i := range transactions {
    - + + 1176 -
    -   -
    +
    +
    + + + storeTxsEGPData[i] = state.StoreTxEGPData{EGPLog: nil, EffectivePercentage: state.MaxEffectivePercentage}
    - + + 1177 -
    -   -
    +
    +
    + + + txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i))
    - + + 1178 -
    -   -
    +
    +
    + + + }
    - + + 1179 -
    -   +
    +
    + +
    - + + 1180 -
    -   -
    +
    +
    + + + err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, stateRoots, dbTx)
    - + + 1181 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1182 -
    -   -
    +
    +
    + + + }
    - + + 1183 -
    -   +
    +
    + +
    - + + 1184 -
    +
    +
      -
    + require.NoError(t, dbTx.Commit(ctx))
    - + + 1185 -
    -   +
    +
    + +
    - + + 1186 -
    -   -
    +
    +
    + + + type testCase struct {
    - + + 1187 -
    -   -
    +
    +
    + + + name string
    - + + 1188 -
    -   -
    +
    +
    + + + blockNumber uint64
    - + + 1189 -
    -   -
    +
    +
    + + + logCount int
    - + + 1190 -
    -   -
    +
    +
    + + + expectedError error
    - + + 1191 -
    -   -
    +
    +
    + + + }
    - + + 1192 -
    -   +
    +
    + +
    - + + 1193 -
    -   -
    +
    +
    + + + testCases := []testCase{
    - + + 1194 -
    -   -
    +
    +
    + + + {
    - + + 1195 -
    -   -
    +
    +
    + + + name: "logs returned successfully",
    - + + 1196 -
    -   -
    +
    +
    + + + blockNumber: 1,
    - + + 1197 -
    -   -
    +
    +
    + + + logCount: 20,
    - + + 1198 -
    -   -
    +
    +
    + + + expectedError: nil,
    - + + 1199 -
    -   -
    +
    +
    + + + },
    - + + 1200 -
    -   -
    +
    +
    + + + {
    - + + 1201 -
    -   -
    +
    +
    + + + name: "logs returned successfully",
    - + + 1202 -
    -   -
    +
    +
    + + + blockNumber: 2,
    - + + 1203 -
    -   -
    +
    +
    + + + logCount: 20,
    - + + 1204 -
    -   -
    +
    +
    + + + expectedError: nil,
    - + + 1205 -
    -   -
    +
    +
    + + + },
    - + + 1206 -
    -   -
    +
    +
    + + + }
    - + + 1207 -
    -   +
    +
    + +
    - + + 1208 -
    -   -
    +
    +
    + + + for _, testCase := range testCases {
    - + + 1209 -
    -   -
    +
    +
    + + + t.Run(testCase.name, func(t *testing.T) {
    - + + 1210 -
    -   -
    +
    +
    + + + logs, err := testState.GetLogsByBlockNumber(ctx, testCase.blockNumber, nil)
    - + + 1211 -
    -   -
    +
    +
    + + + assert.Equal(t, testCase.logCount, len(logs))
    - + + 1212 -
    -   -
    +
    +
    + + + assert.Equal(t, testCase.expectedError, err)
    - + + 1213 -
    -   +
    +
    + +
    - + + 1214 -
    -   -
    +
    +
    + + + // check tx index and log index order
    - + + 1215 -
    -   -
    +
    +
    + + + lastBlockNumber := uint64(0)
    - + + 1216 -
    -   -
    +
    +
    + + + lastTxIndex := uint(0)
    - + + 1217 -
    -   -
    +
    +
    + + + lastLogIndex := uint(0)
    - + + 1218 -
    -   +
    +
    + +
    - + + 1219 -
    -   -
    +
    +
    + + + for i, l := range logs {
    - + + 1220 -
    -   -
    +
    +
    + + + // if block has changed and it's not the first log, reset lastTxIndex
    - + + 1221 -
    -   -
    +
    +
    + + + if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 {
    - + + 1222 -
    -   -
    +
    +
    + + + lastTxIndex = 0
    - + + 1223 -
    -   -
    +
    +
    + + + }
    - + + 1224 -
    -   +
    +
    + +
    - + + 1225 -
    -   -
    +
    +
    + + + if l.TxIndex < lastTxIndex {
    - + + 1226 -
    -   -
    +
    +
    + + + t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex)
    - + + 1227 -
    -   -
    +
    +
    + + + }
    - + + 1228 -
    -   -
    +
    +
    + + + // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block
    - + + 1229 -
    -   -
    +
    +
    + + + // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero
    - + + 1230 -
    -   -
    +
    +
    + + + if l.TxIndex != lastTxIndex && l.Index == 0 {
    - + + 1231 -
    -   -
    +
    +
    + + + lastLogIndex = 0
    - + + 1232 -
    -   -
    +
    +
    + + + }
    - + + 1233 -
    -   +
    +
    + +
    - + + 1234 -
    -   -
    +
    +
    + + + if l.Index < lastLogIndex {
    - + + 1235 -
    -   -
    +
    +
    + + + t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index)
    - + + 1236 -
    -   -
    +
    +
    + + + }
    - + + 1237 -
    -   +
    +
    + +
    - + + 1238 -
    -   -
    +
    +
    + + + lastBlockNumber = l.BlockNumber
    - + + 1239 -
    -   -
    +
    +
    + + + lastTxIndex = l.TxIndex
    - + + 1240 -
    -   -
    +
    +
    + + + lastLogIndex = l.Index
    - + + 1241 -
    -   -
    +
    +
    + + + }
    - + + 1242 -
    -   -
    +
    +
    + + + })
    - + + 1243 -
    -   -
    +
    +
    + + + }
    - + + 1244 -
    +
    +
      -
    + }
    - + + 1245 -
    +
    +
     
    - + + 1246 -
    +
    +
      -
    + func TestGetNativeBlockHashesInRange(t *testing.T) {
    - - -
    -   -
    -
    +
    +
     
    - + + 1371 -
    +
    +
      -
    + require.NoError(t, dbTx.Commit(ctx))
    - + + 1372 -
    +
    +
      -
    + }
    - + + 1373 -
    +
    +
     
    - + + 1374 -
    -   -
    +
    +
    + + + func TestGetBatchL2DataByNumber(t *testing.T) {
    - + + 1375 -
    -   -
    +
    +
    + + + // Init database instance
    - + + 1376 -
    -   -
    +
    +
    + + + initOrResetDB()
    - + + 1377 -
    -   -
    +
    +
    + + + ctx := context.Background()
    - + + 1378 -
    -   -
    +
    +
    + + + tx, err := testState.BeginStateTransaction(ctx)
    - + + 1379 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1380 -
    -   -
    +
    +
    + + + defer func() { require.NoError(t, tx.Commit(ctx)) }()
    - + + 1381 -
    -   +
    +
    + +
    - + + 1382 -
    -   -
    +
    +
    + + + // empty case
    - + + 1383 -
    -   -
    +
    +
    + + + var batchNum uint64 = 4
    - + + 1384 -
    -   -
    +
    +
    + + + const (
    - + + 1385 -
    -   -
    +
    +
    + + + openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)"
    - + + 1386 -
    -   -
    +
    +
    + + + resetBatchesSQL = "DELETE FROM state.batch"
    - + + 1387 -
    -   -
    +
    +
    + + + )
    - + + 1388 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil)
    - + + 1389 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1390 -
    -   -
    +
    +
    + + + data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - + + 1391 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1392 -
    -   -
    +
    +
    + + + assert.Nil(t, data)
    - + + 1393 -
    -   +
    +
    + +
    - + + 1394 -
    -   -
    +
    +
    + + + // not empty case
    - + + 1395 -
    -   -
    +
    +
    + + + expectedData := []byte("foo bar")
    - + + 1396 -
    -   -
    +
    +
    + + + batchNum = 5
    - + + 1397 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData)
    - + + 1398 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1399 -
    -   -
    +
    +
    + + + actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - + + 1400 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1401 -
    -   -
    +
    +
    + + + assert.Equal(t, expectedData, actualData)
    - + + 1402 -
    -   +
    +
    + +
    - + + 1403 -
    -   -
    +
    +
    + + + multiGet := []uint64{uint64(4), uint64(5), uint64(6)}
    - + + 1404 -
    -   -
    +
    +
    + + + allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx)
    - + + 1405 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1406 -
    -   -
    +
    +
    + + + require.Equal(t, expectedData, allData[uint64(5)])
    - + + 1407 -
    -   +
    +
    + +
    - + + 1408 -
    -   -
    +
    +
    + + + // Force backup
    - + + 1409 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, resetBatchesSQL)
    - + + 1410 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1411 -
    -   +
    +
    + +
    - + + 1412 -
    -   -
    +
    +
    + + + // Get batch 4 from backup
    - + + 1413 -
    -   -
    +
    +
    + + + batchNum = 4
    - + + 1414 -
    -   -
    +
    +
    + + + data, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - + + 1415 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1416 -
    -   -
    +
    +
    + + + assert.Nil(t, data)
    - + + 1417 -
    -   +
    +
    + +
    - + + 1418 -
    -   -
    +
    +
    + + + // Get batch 5 from backup
    - + + 1419 -
    -   -
    +
    +
    + + + batchNum = 5
    - + + 1420 -
    -   -
    +
    +
    + + + actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - + + 1421 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1422 -
    -   -
    +
    +
    + + + assert.Equal(t, expectedData, actualData)
    - + + 1423 -
    -   +
    +
    + +
    - + + 1424 -
    -   -
    +
    +
    + + + // Update batch 5 and get it from backup
    - + + 1425 -
    -   -
    +
    +
    + + + expectedData = []byte("new foo bar")
    - + + 1426 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData)
    - + + 1427 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1428 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, resetBatchesSQL)
    - + + 1429 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1430 -
    -   -
    +
    +
    + + + actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - + + 1431 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1432 -
    -   -
    +
    +
    + + + assert.Equal(t, expectedData, actualData)
    - + + 1433 -
    -   -
    +
    +
    + + + }
    - + + 1434 -
    -   +
    +
    + +
    - + + 1435 -
    -   -
    +
    +
    + + + func TestGetBatchL2DataByNumbers(t *testing.T) {
    - + + 1436 -
    -   -
    +
    +
    + + + initOrResetDB()
    - + + 1437 -
    -   -
    +
    +
    + + + ctx := context.Background()
    - + + 1438 -
    -   -
    +
    +
    + + + tx, err := testState.BeginStateTransaction(ctx)
    - + + 1439 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1440 -
    -   -
    +
    +
    + + + defer func() { require.NoError(t, tx.Commit(ctx)) }()
    - + + 1441 -
    -   +
    +
    + +
    - + + 1442 -
    -   -
    +
    +
    + + + var i1, i2, i3, i4, i5 = uint64(1), uint64(2), uint64(3), uint64(4), uint64(5)
    - + + 1443 -
    -   -
    +
    +
    + + + var d1, d2, d4 = []byte("foobar"), []byte("dingbat"), []byte{0xb}
    - + + 1444 -
    -   +
    +
    + +
    - + + 1445 -
    -   -
    +
    +
    + + + const insertBatch = "INSERT INTO state.batch (batch_num, raw_txs_data) VALUES ($1, $2)"
    - + + 1446 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, insertBatch, i1, d1)
    - + + 1447 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1448 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, insertBatch, i2, d2)
    - + + 1449 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1450 -
    -   -
    +
    +
    + + + _, err = tx.Exec(ctx, insertBatch, i3, nil)
    - + + 1451 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1452 -
    -   +
    +
    + +
    - + + 1453 -
    -   -
    +
    +
    + + + // Add a forced batch too, needs a block
    - + + 1454 -
    -   -
    +
    +
    + + + block1 := *block
    - + + 1455 -
    -   -
    +
    +
    + + + block1.BlockNumber = 1000
    - + + 1456 -
    -   -
    +
    +
    + + + err = testState.AddBlock(ctx, &block1, tx)
    - + + 1457 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1458 -
    -   -
    +
    +
    + + + err = tx.Commit(ctx)
    - + + 1459 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1460 -
    -   +
    +
    + +
    - + + 1461 -
    -   -
    +
    +
    + + + tx, err = testState.BeginStateTransaction(ctx)
    - + + 1462 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1463 -
    -   +
    +
    + +
    - + + 1464 -
    -   -
    +
    +
    + + + const insertForcedBatch = "INSERT INTO state.forced_batch (forced_batch_num, timestamp, raw_txs_data, block_num) VALUES (4, now(),'0b', 1000)"
    - + + 1465 -
    -   -
    +
    +
    + + + _, err = testState.Exec(ctx, insertForcedBatch)
    - + + 1466 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1467 -
    -   +
    +
    + +
    - + + 1468 -
    -   -
    +
    +
    + + + allData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{i4}, tx)
    - + + 1469 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1470 -
    -   -
    +
    +
    + + + assert.Equal(t, d4, allData[i4])
    - + + 1471 -
    -   +
    +
    + +
    - + + 1472 -
    -   -
    +
    +
    + + + _, ok := allData[i5]
    - + + 1473 -
    -   -
    +
    +
    + + + assert.False(t, ok)
    - + + 1474 -
    -   -
    +
    +
    + + + }
    - + + 1475 -
    -   +
    +
    + +
    - + + 1476 -
    +
    +
      -
    + func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry {
    - + + 1477 -
    +
    +
      -
    + exitRoot := state.L1InfoTreeExitRootStorageEntry{
    - + + 1478 -
    +
    +
      -
    + L1InfoTreeLeaf: state.L1InfoTreeLeaf{
    - + +
     
    -
    +
    + 1674 + +
      -
    + require.Equal(t, uint64(2002), fb.BlockNumber)
    - + + 1675 -
    +
    +
      -
    + require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String())
    - + + 1676 -
    +
    +
      -
    + require.Equal(t, []byte{0xb}, fb.RawTxsData)
    - + + 1677 -
    -   +
    +
    + +
    - + + 1678 -
    -   -
    +
    +
    + + + // also check data retrieval
    - + + 1679 -
    -   -
    +
    +
    + + + fbData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{1}, dbTx)
    - + + 1680 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1681 -
    -   -
    +
    +
    + + + var expected = make(map[uint64][]byte)
    - + + 1682 -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    +
    +
    + + + expected[uint64(1)] = []byte{0xb}
    - + + 1683 -
    -   -
    +
    +
    + + + require.Equal(t, expected, fbData)
    - + + 1684 -
    +
    +
      -
    + }
    - + + 1685 -
    +
    +
     
    - + + 1686 -
    +
    +
      -
    + func TestGetLastGER(t *testing.T) {
    - - -
    -   -
    -
    +
    +
     
    - + + 1757 -
    +
    +
      -
    + ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx)
    - + + 1758 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 1759 -
    +
    +
      -
    + require.Equal(t, common.HexToHash("0x2").String(), ger.String())
    - + + 1760 -
    -   -
    +
    +
    + + + }
    - + + 1761 -
    -   +
    +
    + +
    - + + 1762 -
    -   -
    +
    +
    + + + func TestGetFirstUncheckedBlock(t *testing.T) {
    - + + 1763 -
    -   -
    +
    +
    + + + var err error
    - + + 1764 -
    -   -
    +
    +
    + + + blockNumber := uint64(51001)
    - + + 1765 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil)
    - + + 1766 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1767 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil)
    - + + 1768 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1769 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil)
    - + + 1770 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1771 -
    -   +
    +
    + +
    - + + 1772 -
    -   -
    +
    +
    + + + block, err := testState.GetFirstUncheckedBlock(context.Background(), blockNumber, nil)
    - + + 1773 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1774 -
    -   -
    +
    +
    + + + require.Equal(t, uint64(blockNumber+1), block.BlockNumber)
    - + + 1775 -
    -   -
    +
    +
    + + + }
    - + + 1776 -
    -   +
    +
    + +
    - + + 1777 -
    -   -
    +
    +
    + + + func TestUpdateCheckedBlockByNumber(t *testing.T) {
    - + + 1778 -
    -   -
    +
    +
    + + + var err error
    - + + 1779 -
    -   -
    +
    +
    + + + blockNumber := uint64(54001)
    - + + 1780 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil)
    - + + 1781 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1782 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil)
    - + + 1783 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1784 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil)
    - + + 1785 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1786 -
    -   +
    +
    + +
    - + + 1787 -
    -   -
    +
    +
    + + + b1, err := testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil)
    - + + 1788 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1789 -
    -   -
    +
    +
    + + + require.True(t, b1.Checked)
    - + + 1790 -
    -   +
    +
    + +
    - + + 1791 -
    -   -
    +
    +
    + + + err = testState.UpdateCheckedBlockByNumber(context.Background(), uint64(blockNumber), false, nil)
    - + + 1792 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1793 -
    -   +
    +
    + +
    - + + 1794 -
    -   -
    +
    +
    + + + b1, err = testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil)
    - + + 1795 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1796 -
    -   -
    +
    +
    + + + require.False(t, b1.Checked)
    - + + 1797 -
    -   -
    +
    +
    + + + }
    - + + 1798 -
    +
    +
     
    - + + 1799 -
    -   -
    +
    +
    + + + func TestGetFirstUncheckedBlock(t *testing.T) {
    - + + 1800 -
    -   -
    +
    +
    + + + var err error
    - + + 1801 -
    -   -
    +
    +
    + + + blockNumber := uint64(51001)
    - + + 1802 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil)
    - + + 1803 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1804 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil)
    - + + 1805 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1806 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil)
    - + + 1807 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1808 -
    -   +
    +
    + +
    - + + 1809 -
    -   -
    +
    +
    + + + block, err := testState.GetFirstUncheckedBlock(context.Background(), blockNumber, nil)
    - + + 1810 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1811 -
    -   -
    +
    +
    + + + require.Equal(t, uint64(blockNumber+1), block.BlockNumber)
    - + + 1812 -
    -   -
    +
    +
    + + + }
    - + + 1813 -
    -   +
    +
    + +
    - + + 1814 -
    -   -
    +
    +
    + + + func TestUpdateCheckedBlockByNumber(t *testing.T) {
    - + + 1815 -
    -   -
    +
    +
    + + + var err error
    - + + 1816 -
    -   -
    +
    +
    + + + blockNumber := uint64(54001)
    - + + 1817 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil)
    - + + 1818 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1819 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil)
    - + + 1820 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1821 -
    -   -
    +
    +
    + + + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil)
    - + + 1822 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 1823 -
    -   +
    +
    + +
    - - -
    -   -
    -
    +
    + 1824
    -
    + +
    + + + b1, err := testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil)
    -
    -
    - - - - - - - - - - + +
    -
     
    - 1 + 1825
    + - // Code generated - DO NOT EDIT. + require.NoError(t, err)
    - 2 + 1826
    + - // This file is a generated binding and any manual changes will be lost. + require.True(t, b1.Checked)
    - 3 + 1827
    @@ -130759,957 +131369,1033 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 4 + 1828
    + - package CounterAndBlock + err = testState.UpdateCheckedBlockByNumber(context.Background(), uint64(blockNumber), false, nil)
    - 5 + 1829
    + -
    + require.NoError(t, err)
    - 6 + 1830
    + - import ( +
    - 7 + 1831
    + - "errors" + b1, err = testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil)
    - 8 + 1832
    + - "math/big" + require.NoError(t, err)
    - 9 + 1833
    + - "strings" + require.False(t, b1.Checked)
    - 10 + 1834
    + -
    + }
    - 11 + 1835
    + - ethereum "github.com/ethereum/go-ethereum" +
    - 12 + 1836
    + - "github.com/ethereum/go-ethereum/accounts/abi" + func TestGetUncheckedBlocks(t *testing.T) {
    - 13 + 1837
    + - "github.com/ethereum/go-ethereum/accounts/abi/bind" + var err error
    - 14 + 1838
    + - "github.com/ethereum/go-ethereum/common" + blockNumber := uint64(61001)
    - 15 + 1839
    + - "github.com/ethereum/go-ethereum/core/types" + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil)
    - 16 + 1840
    + - "github.com/ethereum/go-ethereum/event" + require.NoError(t, err)
    - 17 + 1841
    + - ) + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil)
    - 18 + 1842
    + -
    + require.NoError(t, err)
    - 19 + 1843
    + - // Reference imports to suppress errors if they are not otherwise used. + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil)
    - 20 + 1844
    + - var ( + require.NoError(t, err)
    - 21 + 1845
    + - _ = errors.New + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 3, Checked: false}, nil)
    - 22 + 1846
    + - _ = big.NewInt + require.NoError(t, err)
    - 23 + 1847
    + - _ = strings.NewReader + err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 4, Checked: false}, nil)
    - 24 + 1848
    + - _ = ethereum.NotFound + require.NoError(t, err)
    - 25 + 1849
    + - _ = bind.Bind +
    - 26 + 1850
    + - _ = common.Big1 + blocks, err := testState.GetUncheckedBlocks(context.Background(), blockNumber, blockNumber+3, nil)
    - 27 + 1851
    + - _ = types.BloomLookup + require.NoError(t, err)
    - 28 + 1852
    + - _ = event.NewSubscription + require.Equal(t, 2, len(blocks))
    - 29 + 1853
    + - _ = abi.ConvertType + require.Equal(t, uint64(blockNumber+1), blocks[0].BlockNumber)
    - 30 + 1854
    + - ) + require.Equal(t, uint64(blockNumber+3), blocks[1].BlockNumber)
    - 31 + + 1855 +
    - + -
    +   + }
    - 32 - -
    - + - // CounterAndBlockMetaData contains all meta data concerning the CounterAndBlock contract. +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -13,12 +14,19 @@
    - 33 + + 13 +
    - + - var CounterAndBlockMetaData = &bind.MetaData{ +   + // - VerifiedBatches
    - 34 + + 14 +
    - + - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"increment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +   + // - Entries in exit_root table
    - 35 + + 15 +
    - + - Bin: "0x608060405234801561001057600080fd5b5060eb8061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c806306661abd146041578063a87d942c14605c578063d09de08a146071575b600080fd5b604960005481565b6040519081526020015b60405180910390f35b60005460408051918252426020830152016053565b60776079565b005b6001600080828254608991906090565b9091555050565b6000821982111560b057634e487b7160e01b600052601160045260246000fd5b50019056fea26469706673582212205aa9aebefdfb857d27d7bdc8475c08138617cc37e78c2e6bd98acb9a1484994964736f6c634300080c0033", +   + err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx)
    - 36 + + 16 +
    - + - } + - + if err == nil {
    - 37 + + 17 +
    - + -
    + - + // Discard L1InfoTree cache
    - 38 + + 18 +
    - + - // CounterAndBlockABI is the input ABI used to generate the binding from. + - + // We can't rebuild cache, because we are inside a transaction, so we dont known
    - 39 + + 19 +
    - + - // Deprecated: Use CounterAndBlockMetaData.ABI instead. + - + // is going to be a commit or a rollback. So is going to be rebuild on the next
    - 40 + + 20 +
    - + - var CounterAndBlockABI = CounterAndBlockMetaData.ABI + - + // request that needs it.
    - 41 + + 21 +
    - + -
    + - + s.l1InfoTree = nil
    - 42 + + 22 +
    - + - // CounterAndBlockBin is the compiled bytecode used for deploying new contracts. +   + }
    - 43 + + 23 +
    - + - // Deprecated: Use CounterAndBlockMetaData.Bin instead. + - + return err
    - 44 + + -
    - + - var CounterAndBlockBin = CounterAndBlockMetaData.Bin +
    +
    +   +
    - 45 + + -
    - + +
    +
    +  
    - 46 + + -
    - + - // DeployCounterAndBlock deploys a new Ethereum contract, binding an instance of CounterAndBlock to it. +
    +
    +   +
    - 47 + + -
    - + - func DeployCounterAndBlock(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CounterAndBlock, error) { +
    +
    +   +
    - 48 + + -
    - + - parsed, err := CounterAndBlockMetaData.GetAbi() +
    +
    +   +
    - 49 + + -
    - + - if err != nil { +
    +
    +   +
    - 50 + + -
    - + - return common.Address{}, nil, nil, err +
    +
    +   +
    - 51 + + -
    - + - } +
    +
    +   +
    - 52 + + -
    - + - if parsed == nil { +
    +
    +   +
    - 53 + + -
    - + - return common.Address{}, nil, nil, errors.New("GetABI returned nil") +
    +
    +   +
    - 54 + + 24 +
    - + - } +   + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 55 + + 14 +
    - + -
    +   + // - VerifiedBatches
    - 56 + + 15 +
    - + - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CounterAndBlockBin), backend) +   + // - Entries in exit_root table
    - 57 + + 16 +
    - + - if err != nil { +   + err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx)
    - 58 + + 17 +
    + - return common.Address{}, nil, nil, err + if err != nil {
    - 59 + + 18 +
    + - } + log.Error("error resetting L1BlockNumber. Error: ", err)
    - 60 + + 19 +
    + - return address, tx, &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil + return err
    - 61 + + -
    - + - } +
    +
    +   +
    - 62 + + -
    - + +
    +
    +  
    - 63 + + -
    - + - // CounterAndBlock is an auto generated Go binding around an Ethereum contract. +
    +
    +   +
    - 64 + + 20 +
    - + - type CounterAndBlock struct { +   + }
    - 65 + + 21 +
    + - CounterAndBlockCaller // Read-only binding to the contract + s.ResetL1InfoTree()
    - 66 + 22
    + - CounterAndBlockTransactor // Write-only binding to the contract + return nil
    - 67 + 23
    + - CounterAndBlockFilterer // Log filterer for contract events + }
    - 68 + 24
    + - } +
    - 69 + 25
    + -
    + // ResetL1InfoTree resets the L1InfoTree
    - 70 + 26
    + - // CounterAndBlockCaller is an auto generated read-only Go binding around an Ethereum contract. + func (s *State) ResetL1InfoTree() {
    - 71 + 27
    + - type CounterAndBlockCaller struct { + // Discard L1InfoTree cache
    - 72 + 28
    + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + // We can't rebuild cache, because we are inside a transaction, so we dont known
    - 73 + 29
    + - } + // is going to be a commit or a rollback. So is going to be rebuild on the next
    - 74 + 30
    + -
    + // request that needs it.
    - 75 + 31
    + - // CounterAndBlockTransactor is an auto generated write-only Go binding around an Ethereum contract. + s.l1InfoTree = nil
    - 76 + + 32 +
    - + - type CounterAndBlockTransactor struct { +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -10,6 +10,13 @@
    - 77 + + 10 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls +   + "google.golang.org/grpc/credentials/insecure"
    - 78 + + 11 +
    - + - } +   + )
    - 79 + + 12 +
    - + +  
    - 80 + + -
    - + - // CounterAndBlockFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +
    +
    +   +
    - 81 + + -
    - + - type CounterAndBlockFilterer struct { +
    +
    +   +
    - 82 + + -
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    +   +
    - 83 + + -
    - + - } +
    +
    +   +
    - 84 + + -
    - + +
    +
    +  
    - 85 + + -
    - + - // CounterAndBlockSession is an auto generated Go binding around an Ethereum contract, +
    +
    +   +
    - 86 + + -
    - + - // with pre-set call and transact options. +
    +
    +   +
    - 87 + + 13 +
    - + - type CounterAndBlockSession struct { +   + // NewExecutorClient is the executor client constructor.
    - 88 + + 14 +
    - + - Contract *CounterAndBlock // Generic contract binding to set the session for +   + func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - 89 + + 15 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session +   + opts := []grpc.DialOption{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + +
    +
     
    - 90 + + 10 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +   + "google.golang.org/grpc/credentials/insecure"
    - 91 + + 11 +
    - + - } +   + )
    - 92 + + 12 +
    - + +  
    - 93 + 13
    + - // CounterAndBlockCallerSession is an auto generated read-only Go binding around an Ethereum contract, + const (
    - 94 + 14
    + - // with pre-set call options. + // ExecutionMode0 is the execution mode for the sequencer and RPC, default one
    - 95 + 15
    + - type CounterAndBlockCallerSession struct { + ExecutionMode0 = uint64(0)
    - 96 + 16
    + - Contract *CounterAndBlockCaller // Generic contract caller binding to set the session for + // ExecutionMode1 is the execution mode for the synchronizer
    - 97 + 17
    + - CallOpts bind.CallOpts // Call options to use throughout this session + ExecutionMode1 = uint64(1)
    - 98 + 18
    + - } + )
    - 99 + 19
    @@ -131718,478 +132404,531 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 100 + + 20 +
    - + - // CounterAndBlockTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +   + // NewExecutorClient is the executor client constructor.
    - 101 + + 21 +
    - + - // with pre-set transact options. +   + func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - 102 + + 22 +
    - + - type CounterAndBlockTransactorSession struct { +   + opts := []grpc.DialOption{
    - 103 - -
    - + - Contract *CounterAndBlockTransactor // Generic contract transactor binding to set the session for +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -62,13 +62,37 @@
    - 104 + + 62 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +   + return state
    - 105 + + 63 +
    - + +   }
    - 106 + + 64 +
    - + +  
    - 107 + + -
    - + - // CounterAndBlockRaw is an auto generated low-level Go binding around an Ethereum contract. +
    +
    +   +
    - 108 + + -
    - + - type CounterAndBlockRaw struct { +
    +
    +   +
    - 109 + + -
    - + - Contract *CounterAndBlock // Generic contract binding to access the raw methods on +
    +
    +   +
    - 110 + + -
    - + - } +
    +
    +   +
    - 111 + + -
    - + +
    +
    +  
    - 112 + + -
    - + - // CounterAndBlockCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +
    +
    +   +
    - 113 + + -
    - + - type CounterAndBlockCallerRaw struct { +
    +
    +   +
    - 114 + + 65 +
    - + - Contract *CounterAndBlockCaller // Generic read-only contract binding to access the raw methods on +   + // BeginStateTransaction starts a state transaction
    - 115 + + 66 +
    - + - } +   + func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) {
    - 116 + + 67 +
    - + -
    +   + tx, err := s.Begin(ctx)
    - 117 + + 68 +
    - + - // CounterAndBlockTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +   + if err != nil {
    - 118 + + 69 +
    - + - type CounterAndBlockTransactorRaw struct { +   + return nil, err
    - 119 + + 70 +
    - + - Contract *CounterAndBlockTransactor // Generic write-only contract binding to access the raw methods on +   + }
    - 120 + + 71 +
    - + - } + - + return tx, nil
    - 121 + + -
    - + +
    +
    +  
    - 122 + + -
    - + - // NewCounterAndBlock creates a new instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    +   +
    - 123 + + -
    - + - func NewCounterAndBlock(address common.Address, backend bind.ContractBackend) (*CounterAndBlock, error) { +
    +
    +   +
    - 124 + + -
    - + - contract, err := bindCounterAndBlock(address, backend, backend, backend) +
    +
    +   +
    - 125 + + -
    - + - if err != nil { +
    +
    +   +
    - 126 + + -
    - + - return nil, err +
    +
    +   +
    - 127 + + -
    - + - } +
    +
    +   +
    - 128 + + -
    - + - return &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil +
    +
    +   +
    - 129 + + -
    - + - } +
    +
    +   +
    - 130 - -
    - + +
    + + +
    +  
    - 131 + + -
    - + - // NewCounterAndBlockCaller creates a new read-only instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    +   +
    - 132 + + -
    - + - func NewCounterAndBlockCaller(address common.Address, caller bind.ContractCaller) (*CounterAndBlockCaller, error) { +
    +
    +   +
    - 133 + + -
    - + - contract, err := bindCounterAndBlock(address, caller, nil, nil) +
    +
    +   +
    - 134 + + -
    - + - if err != nil { +
    +
    +   +
    - 135 + + -
    - + - return nil, err +
    +
    +   +
    - 136 + + -
    - + - } +
    +
    +   +
    - 137 + + -
    - + - return &CounterAndBlockCaller{contract: contract}, nil +
    +
    +   +
    - 138 + + 72 +
    - + +   }
    - 139 + + 73 +
    - + +  
    - 140 + + 74 +
    - + - // NewCounterAndBlockTransactor creates a new write-only instance of CounterAndBlock, bound to a specific deployed contract. +   + // GetBalance from a given address +
    +
    +
    +
    +
    +
    + + + + + + + + - - + + + - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    + 62 + +
    +   + return state
    - 141 + + 63 +
    - + - func NewCounterAndBlockTransactor(address common.Address, transactor bind.ContractTransactor) (*CounterAndBlockTransactor, error) { +   + } +
    +
    + 64 + +
    +   +
    - 142 + 65
    + - contract, err := bindCounterAndBlock(address, nil, transactor, nil) + // StateTx is the state transaction that extends the database tx
    - 143 + 66
    + - if err != nil { + type StateTx struct {
    - 144 + 67
    + - return nil, err + pgx.Tx
    - 145 + 68
    + - } + stateInstance *State
    - 146 + 69
    + - return &CounterAndBlockTransactor{contract: contract}, nil + L1InfoTreeModified bool
    - 147 + 70
    @@ -132199,7 +132938,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 148 + 71
    @@ -132208,1492 +132947,1579 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 149 + + 72 +
    - + - // NewCounterAndBlockFilterer creates a new log filterer instance of CounterAndBlock, bound to a specific deployed contract. +   + // BeginStateTransaction starts a state transaction
    - 150 + + 73 +
    - + - func NewCounterAndBlockFilterer(address common.Address, filterer bind.ContractFilterer) (*CounterAndBlockFilterer, error) { +   + func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) {
    - 151 + + 74 +
    - + - contract, err := bindCounterAndBlock(address, nil, nil, filterer) +   + tx, err := s.Begin(ctx)
    - 152 + + 75 +
    - + +   if err != nil {
    - 153 + + 76 +
    - + +   return nil, err
    - 154 + + 77 +
    - + +   }
    - 155 + + 78 +
    + - return &CounterAndBlockFilterer{contract: contract}, nil + res := &StateTx{
    - 156 + 79
    + - } + Tx: tx,
    - 157 + 80
    + -
    + stateInstance: s,
    - 158 + 81
    + - // bindCounterAndBlock binds a generic wrapper to an already deployed contract. + }
    - 159 + 82
    + - func bindCounterAndBlock(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + return res, nil
    - 160 + 83
    + - parsed, err := CounterAndBlockMetaData.GetAbi() + }
    - 161 + 84
    + - if err != nil { +
    - 162 + 85
    + - return nil, err + // Rollback do the dbTx rollback + modifications in cache mechanism
    - 163 + 86
    + - } + func (tx *StateTx) Rollback(ctx context.Context) error {
    - 164 + 87
    + - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + if tx.L1InfoTreeModified {
    - 165 + 88
    + - } + tx.stateInstance.ResetL1InfoTree()
    - 166 + 89
    + -
    + }
    - 167 + 90
    + - // Call invokes the (constant) contract method with params as input values and + return tx.Tx.Rollback(ctx)
    - 168 + 91
    + - // sets the output to result. The result type might be a single field for simple + }
    - 169 + 92
    + - // returns, a slice of interfaces for anonymous returns and a struct for named +
    - 170 + 93
    + - // returns. + // SetL1InfoTreeModified sets the flag to true to save that the L1InfoTree has been modified
    - 171 + 94
    + - func (_CounterAndBlock *CounterAndBlockRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + func (tx *StateTx) SetL1InfoTreeModified() {
    - 172 + 95
    + - return _CounterAndBlock.Contract.CounterAndBlockCaller.contract.Call(opts, result, method, params...) + tx.L1InfoTreeModified = true
    - 173 + + 96 +
    - + +   }
    - 174 + + 97 +
    - + +  
    - 175 + + 98 +
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +   + // GetBalance from a given address +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -78,7 +78,15 @@
    - 176 + + 78 +
    - + - // its default method if one is available. +   + var effectivePercentage []uint8
    - 177 + + 79 +
    - + - func (_CounterAndBlock *CounterAndBlockRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +   + for i := 0; i <= count; i++ {
    - 178 + + 80 +
    - + - return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transfer(opts) +   + txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
    - 179 + + 81 +
    - + - } + - + effectivePercentage = append(effectivePercentage, MaxEffectivePercentage)
    - 180 + + -
    - + +
    +
    +  
    - 181 + + -
    - + - // Transact invokes the (paid) contract method with params as input values. +
    +
    +   +
    - 182 + + -
    - + - func (_CounterAndBlock *CounterAndBlockRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    +   +
    - 183 + + -
    - + - return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transact(opts, method, params...) +
    +
    +   +
    - 184 + + -
    - + - } +
    +
    +   +
    - 185 + + -
    - + +
    +
    +  
    - 186 + + -
    - + - // Call invokes the (constant) contract method with params as input values and +
    +
    +   +
    - 187 + + -
    - + - // sets the output to result. The result type might be a single field for simple +
    +
    +   +
    - 188 + + 82 +
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named +   + log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
    - 189 + + 83 +
    - + - // returns. +   + }
    - 190 + + 84 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +   +
    - 191 - -
    - + - return _CounterAndBlock.Contract.contract.Call(opts, result, method, params...) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - + +
    +
     
    - 192 + + 78 +
    - + - } +   + var effectivePercentage []uint8
    - 193 + + 79 +
    - + -
    +   + for i := 0; i <= count; i++ {
    - 194 + + 80 +
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +   + txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
    - 195 + + 81 +
    + - // its default method if one is available. + txGasPrice := tx.GasPrice()
    - 196 + 82
    + - func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + effectiveGasPrice := receipt.EffectiveGasPrice
    - 197 + 83
    + - return _CounterAndBlock.Contract.contract.Transfer(opts) + egpPercentage, err := CalculateEffectiveGasPricePercentage(txGasPrice, effectiveGasPrice)
    - 198 + 84
    + - } + if errors.Is(err, ErrEffectiveGasPriceEmpty) {
    - 199 + 85
    + -
    + egpPercentage = MaxEffectivePercentage
    - 200 + 86
    + - // Transact invokes the (paid) contract method with params as input values. + } else if err != nil {
    - 201 + 87
    + - func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return nil, err
    - 202 + 88
    + - return _CounterAndBlock.Contract.contract.Transact(opts, method, params...) + }
    - 203 + 89
    + - } + effectivePercentage = append(effectivePercentage, egpPercentage)
    - 204 + + 90 +
    - + -
    +   + log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
    - 205 + + 91 +
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. +   + }
    - 206 + + 92 +
    - + - // +   +
    - 207 - -
    - + - // Solidity: function count() view returns(uint256) +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -141,7 +141,7 @@
    - 208 + + 141 +
    - + - func (_CounterAndBlock *CounterAndBlockCaller) Count(opts *bind.CallOpts) (*big.Int, error) { +   + }
    - 209 + + 142 +
    - + - var out []interface{} +   +
    - 210 + + 143 +
    - + - err := _CounterAndBlock.contract.Call(opts, &out, "count") +   + // firstTxToInsert := len(existingTxs)
    - 211 + + 144 +
    - + + -
    - 212 + + 145 +
    - + - if err != nil { +   + for i := 0; i < len(processedTxs); i++ {
    - 213 + + 146 +
    - + - return *new(*big.Int), err +   + processedTx := processedTxs[i]
    - 214 + + 147 +
    - + - } +   + // if the transaction has an intrinsic invalid tx error it means
    - 215 + +
    @@ -169,7 +169,7 @@
    +
    + 169 +
    - + -
    +   + header.BlockInfoRoot = processedBlock.BlockInfoRoot
    - 216 + + 170 +
    - + - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) +   + transactions := []*types.Transaction{&processedTx.Tx}
    - 217 + + 171 +
    - + +  
    - 218 + + 172 +
    - + - return out0, err + - + receipt := GenerateReceipt(header.Number, processedTx, uint(i), forkID)
    - 219 + + 173 +
    - + -
    +   + if !CheckLogOrder(receipt.Logs) {
    - 220 + + 174 +
    - + - } +   + return fmt.Errorf("error: logs received from executor are not in order")
    - 221 + + 175 +
    - + -
    +   + }
    - 222 - -
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. -
    +
    +
    @@ -193,6 +193,7 @@
    - 223 + + 193 +
    - + - // +   + if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil {
    - 224 + + 194 +
    - + - // Solidity: function count() view returns(uint256) +   + return err
    - 225 + + 195 +
    - + - func (_CounterAndBlock *CounterAndBlockSession) Count() (*big.Int, error) { +   + }
    - 226 + + -
    - + - return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) +
    +
    +   +
    - 227 + + 196 +
    - + - } +   + }
    - 228 + + 197 +
    - + -
    +   + }
    - 229 + + 198 +
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. +   + return nil
    - 230 + +
    @@ -509,8 +510,7 @@
    +
    + 509 +
    - + - // +   + }
    - 231 + + 510 +
    - + - // Solidity: function count() view returns(uint256) +   + nonce := loadedNonce.Uint64()
    - 232 + + 511 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerSession) Count() (*big.Int, error) { +   +
    - 233 + + 512 +
    - + - return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) + - + deltaTimestamp := uint32(uint64(time.Now().Unix()) - l2Block.Time())
    - 234 + + 513 +
    - + - } + - + transactions := s.BuildChangeL2Block(deltaTimestamp, uint32(0))
    - 235 + + 514 +
    - + +  
    - 236 + + 515 +
    - + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +   + batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID)
    - 237 + + 516 +
    - + - // +   + if err != nil {
    - 238 + +
    @@ -535,22 +535,24 @@
    +
    + 535 +
    - + - // Solidity: function getCount() view returns(uint256, uint256) +   +
    - 239 + + 536 +
    - + - func (_CounterAndBlock *CounterAndBlockCaller) GetCount(opts *bind.CallOpts) (*big.Int, *big.Int, error) { +   + // v2 fields
    - 240 + + 537 +
    - + - var out []interface{} +   + L1InfoRoot: l2Block.BlockInfoRoot().Bytes(),
    - 241 + + 538 +
    - + - err := _CounterAndBlock.contract.Call(opts, &out, "getCount") + - + TimestampLimit: uint64(time.Now().Unix()),
    - 242 + + 539 +
    - + -
    +   + SkipFirstChangeL2Block: cFalse,
    - 243 + + 540 +
    - + - if err != nil { +   + SkipWriteBlockInfoRoot: cTrue,
    - 244 + + -
    - + - return *new(*big.Int), *new(*big.Int), err +
    +
    +   +
    - 245 + + 541 +
    - + +   }
    - 246 + + 542 +
    - + -
    +   + if noZKEVMCounters {
    - 247 + + 543 +
    - + - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) +   + processBatchRequestV2.NoCounters = cTrue
    - 248 + + 544 +
    - + - out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) +   + }
    - 249 + + 545 +
    - + +  
    - 250 + + 546 +
    - + - return out0, out1, err + - + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
    - 251 + + 547 +
    - + -
    +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum)
    - 252 + + 548 +
    - + - } +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot))
    - 253 + + 549 +
    - + +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash)) +
    +
    + + +
    +  
    - 254 + + 550 +
    - + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase)
    - 255 + + 551 +
    - + - // + - + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId)
    - 256 + + 552 +
    - + - // Solidity: function getCount() view returns(uint256, uint256) + - + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId)
    - 257 + + 553 +
    - + - func (_CounterAndBlock *CounterAndBlockSession) GetCount() (*big.Int, *big.Int, error) { +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree)
    - 258 + + -
    - + - return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) +
    +
    +   +
    - 259 + + -
    - + - } +
    +
    +   +
    - 260 + + -
    - + +
    +
    +  
    - 261 + + 554 +
    - + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId)
    - 262 + + 555 +
    - + - // +   +
    - 263 + + 556 +
    - + - // Solidity: function getCount() view returns(uint256, uint256) +   + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot))
    - 264 + +
    @@ -1015,6 +1017,7 @@
    +
    + 1015 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerSession) GetCount() (*big.Int, *big.Int, error) { +   + TimestampLimit: uint64(time.Now().Unix()),
    - 265 + + 1016 +
    - + - return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) +   + SkipFirstChangeL2Block: cTrue,
    - 266 + + 1017 +
    - + - } +   + SkipWriteBlockInfoRoot: cTrue,
    - 267 + + -
    - + +
    +
    +  
    - 268 + + 1018 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +   + }
    - 269 + + 1019 +
    - + - // +   +
    - 270 + + 1020 +
    - + - // Solidity: function increment() returns() +   + log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - + + + - - -
    +
     
    - 271 + + 141 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactor) Increment(opts *bind.TransactOpts) (*types.Transaction, error) { +   + }
    - 272 + + 142 +
    - + - return _CounterAndBlock.contract.Transact(opts, "increment") +   +
    - 273 + + 143 +
    - + - } +   + // firstTxToInsert := len(existingTxs)
    - 274 + + 144 +
    + -
    + txIndex := 0
    - 275 + + 145 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +   + for i := 0; i < len(processedTxs); i++ {
    - 276 + + 146 +
    - + - // +   + processedTx := processedTxs[i]
    - 277 + + 147 +
    - + - // Solidity: function increment() returns() +   + // if the transaction has an intrinsic invalid tx error it means
    - 278 + +
     
    +
    + 169 +
    - + - func (_CounterAndBlock *CounterAndBlockSession) Increment() (*types.Transaction, error) { +   + header.BlockInfoRoot = processedBlock.BlockInfoRoot
    - 279 + + 170 +
    - + - return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) +   + transactions := []*types.Transaction{&processedTx.Tx}
    - 280 + + 171 +
    - + - } +   +
    - 281 + + 172 +
    + -
    + receipt := GenerateReceipt(header.Number, processedTx, uint(txIndex), forkID)
    - 282 + + 173 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +   + if !CheckLogOrder(receipt.Logs) {
    - 283 + + 174 +
    - + - // +   + return fmt.Errorf("error: logs received from executor are not in order")
    - 284 + + 175 +
    - + - // Solidity: function increment() returns() +   + }
    - 285 + +
     
    +
    + 193 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactorSession) Increment() (*types.Transaction, error) { +   + if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil {
    - 286 + + 194 +
    - + - return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) +   + return err +
    +
    + 195 + +
    +   + }
    - 287 + 196
    + - } + txIndex++
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - + - + + - - - - - - @@ -133707,151 +134533,156 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -133937,203 +134768,237 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
    @@ -0,0 +1,224 @@
    -
    - + + 197 -
    +
    +
      -
    + }
    - + + 198 -
    +
    +
      -
    + }
    - + + 199 -
    +
    +
      -
    + return nil
    - + +
     
    -
    +
    + 510 + +
      -
    + }
    - + + 511 -
    +
    +
      -
    + nonce := loadedNonce.Uint64()
    - + + 512 -
    +
    +
     
    - + + 513 -
    -   -
    +
    +
    + + + transactions := s.BuildChangeL2Block(uint32(0), uint32(0))
    - + + 514 -
    +
    +
     
    - + + 515 -
    +
    +
      -
    + batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID)
    - + + 516 -
    +
    +
      -
    + if err != nil {
    - + +
     
    -
    +
    + 535 + +
     
    - + + 536 -
    +
    +
      -
    + // v2 fields
    - + + 537 -
    +
    +
      -
    + L1InfoRoot: l2Block.BlockInfoRoot().Bytes(),
    - + + 538 -
    -   -
    +
    +
    + + + TimestampLimit: l2Block.Time(),
    - + + 539 -
    +
    +
      -
    + SkipFirstChangeL2Block: cFalse,
    - + + 540 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 541 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 542 -
    +
    +
      -
    + }
    - + + 543 -
    +
    +
      -
    + if noZKEVMCounters {
    - + + 544 -
    +
    +
      -
    + processBatchRequestV2.NoCounters = cTrue
    - + + 545 -
    +
    +
      -
    + }
    - + + 546 -
    +
    +
     
    @@ -133867,53 +134698,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 547 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum)
    - + + 548 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot))
    - + + 549 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash))
    - + + 550 -
    -   +
    +
    + +
    - + + 551 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase)
    - + + 552 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree)
    - + + 553 -
    -   -
    +
    +
    + + + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId)
    - + + 554 -
    -   -
    +
    +
    + + + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId)
    - + + 555 -
    -   -
    +
    +
    + + + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
    - + + 556 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId)
    - + + 557 -
    +
    +
     
    - + + 558 -
    +
    +
      -
    + log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot))
    - + +
     
    -
    +
    + 1017 + +
      -
    + TimestampLimit: uint64(time.Now().Unix()),
    - + + 1018 -
    +
    +
      -
    + SkipFirstChangeL2Block: cTrue,
    - + + 1019 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 1020 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 1021 -
    +
    +
      -
    + }
    - + + 1022 -
    +
    +
     
    - + + 1023 -
    +
    +
      -
    + log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -134147,73 +135012,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - @@ -134247,123 +135117,128 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -134397,83 +135272,88 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - @@ -134507,91 +135387,105 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - + + +
    +
    @@ -6,9 +6,9 @@
    +
    - + + 6 -
    +
    +
      -
    + "fmt"
    - + + 7 -
    +
    +
      -
    + "math/big"
    - + + 8 -
    +
    +
     
    - + + 9 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    - + + 10 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 11 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 12 -
    +
    +
      -
    + "github.com/jackc/pgx/v4"
    - + + 13 -
    +
    +
      -
    + )
    - + + 14 -
    +
    +
     
    - + +
    @@ -36,13 +36,16 @@
    -
    +
    + 36 + +
      -
    + func NewCheckL2BlockHash(state stateGetL2Block,
    - + + 37 -
    +
    +
      -
    + trustedClient trustedRPCGetL2Block,
    - + + 38 -
    +
    +
      -
    + initialL2BlockNumber uint64,
    - + + 39 -
    -   -
    +
    +
    + - + modulusBlockNumber uint64) *CheckL2BlockHash {
    - + + 40 -
    +
    +
      -
    + return &CheckL2BlockHash{
    - + + 41 -
    +
    +
      -
    + state: state,
    - + + 42 -
    +
    +
      -
    + trustedClient: trustedClient,
    - + + 43 -
    +
    +
      -
    + lastL2BlockChecked: initialL2BlockNumber,
    - + + 44 -
    +
    +
      -
    + modulusL2BlockToCheck: modulusBlockNumber,
    - + + 45 -
    -   -
    +
    +
    + - + }
    - + + 46 -
    +
    +
      -
    + }
    - + + 47 -
    +
    +
     
    - + + 48 -
    +
    +
      -
    + // CheckL2Block checks the L2Block hash between the local and the trusted
    - + +
    @@ -74,6 +77,9 @@
    -
    +
    + 74 + +
      -
    + log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber)
    - + + 75 -
    +
    +
      -
    + return false, 0
    - + + 76 -
    +
    +
      -
    + }
    - + + 77 -
    +
    +
      -
    + return true, l2BlockNumber
    - + + 78 -
    +
    +
      -
    + }
    - + + 79 -
    +
    +
     
    - + +
    @@ -129,11 +135,14 @@
    -
    +
    + 129 + +
      -
    + }
    - + + 130 -
    +
    +
     
    - + + 131 -
    +
    +
      -
    + func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error {
    - + + 132 -
    -   -
    +
    +
    + - + if localL2Block == nil || trustedL2Block == nil || trustedL2Block.Hash == nil {
    - + + 133 -
    -   -
    +
    +
    + - + return fmt.Errorf("%s localL2Block or trustedL2Block or trustedHash are nil", prefixLogs)
    - + + 134 -
    +
    +
      -
    + }
    - + + 135 -
    -   -
    +
    +
    + - + if localL2Block.Hash() != *trustedL2Block.Hash {
    - + + 136 -
    -   -
    +
    +
    + - + return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), (*trustedL2Block.Hash).String())
    - + + 137 -
    +
    +
      -
    + }
    - + + 138 -
    +
    +
      -
    + return nil
    - + + 139 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 6 -
    +
    +
      -
    + "fmt"
    - + + 7 -
    +
    +
      -
    + "math/big"
    - + + 8 -
    +
    +
     
    @@ -134607,583 +135501,632 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 9 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 10 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 11 -
    -   -
    +
    +
    + + + "github.com/ethereum/go-ethereum/core/types"
    - + + 12 -
    +
    +
      -
    + "github.com/jackc/pgx/v4"
    - + + 13 -
    +
    +
      -
    + )
    - + + 14 -
    +
    +
     
    - + +
     
    -
    +
    + 36 + +
      -
    + func NewCheckL2BlockHash(state stateGetL2Block,
    - + + 37 -
    +
    +
      -
    + trustedClient trustedRPCGetL2Block,
    - + + 38 -
    +
    +
      -
    + initialL2BlockNumber uint64,
    - + + 39 -
    -   -
    +
    +
    + + + modulusBlockNumber uint64) (*CheckL2BlockHash, error) {
    - + + 40 -
    -   -
    +
    +
    + + + if modulusBlockNumber == 0 {
    - + + 41 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("error: modulusBlockNumber is zero")
    - + + 42 -
    -   -
    +
    +
    + + + }
    - + + 43 -
    +
    +
      -
    + return &CheckL2BlockHash{
    - + + 44 -
    +
    +
      -
    + state: state,
    - + + 45 -
    +
    +
      -
    + trustedClient: trustedClient,
    - + + 46 -
    +
    +
      -
    + lastL2BlockChecked: initialL2BlockNumber,
    - + + 47 -
    +
    +
      -
    + modulusL2BlockToCheck: modulusBlockNumber,
    - + + 48 -
    -   -
    +
    +
    + + + }, nil
    - + + 49 -
    +
    +
      -
    + }
    - + + 50 -
    +
    +
     
    - + + 51 -
    +
    +
      -
    + // CheckL2Block checks the L2Block hash between the local and the trusted
    - + +
     
    -
    +
    + 77 + +
      -
    + log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber)
    - + + 78 -
    +
    +
      -
    + return false, 0
    - + + 79 -
    +
    +
      -
    + }
    - + + 80 -
    -   -
    +
    +
    + + + if l2BlockNumber%p.modulusL2BlockToCheck != 0 {
    - + + 81 -
    -   -
    +
    +
    + + + return false, 0
    - + + 82 -
    -   -
    +
    +
    + + + }
    - + + 83 -
    +
    +
      -
    + return true, l2BlockNumber
    - + + 84 -
    +
    +
      -
    + }
    - + + 85 -
    +
    +
     
    - + +
     
    -
    +
    + 135 + +
      -
    + }
    - + + 136 -
    +
    +
     
    - + + 137 -
    +
    +
      -
    + func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error {
    - + + 138 -
    -   -
    +
    +
    + + + if localL2Block == nil || trustedL2Block == nil {
    - + + 139 -
    -   -
    +
    +
    + + + return fmt.Errorf("%s localL2Block or trustedL2Block are nil", prefixLogs)
    - + + 140 -
    -   -
    +
    +
    + + + }
    - + + 141 -
    -   -
    +
    +
    + + + if localL2Block.Hash() != trustedL2Block.Hash() {
    - + + 142 -
    -   -
    +
    +
    + + + return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), trustedL2Block.Hash().String())
    - + + 143 -
    +
    +
      -
    + }
    - + + 144 -
    -   -
    +
    +
    + + + if localL2Block.ParentHash() != trustedL2Block.ParentHash() {
    - + + 145 -
    -   -
    +
    +
    + + + return fmt.Errorf("%s localL2Block.ParentHash %s and trustedL2Block.ParentHash %s are different", prefixLogs, localL2Block.ParentHash().String(), trustedL2Block.ParentHash().String())
    - + + 146 -
    +
    +
      -
    + }
    - + + 147 -
    +
    +
      -
    + return nil
    - + + 148 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - @@ -135207,33 +136150,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -135247,93 +136190,98 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - @@ -135357,73 +136305,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - @@ -135437,183 +136390,193 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - @@ -135627,23 +136590,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -135687,133 +136650,178 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - + - + + - - - - - - + + + + + + + + + + + + @@ -135827,43 +136835,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + - - - - @@ -135881,2242 +136899,2285 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -19,7 +18,7 @@
    - + + 19 -
    +
    +
      -
    + type CheckL2BlocksTestData struct {
    - + + 20 -
    +
    +
      -
    + sut *actions.CheckL2BlockHash
    - + + 21 -
    +
    +
      -
    + mockState *mock_syncinterfaces.StateFullInterface
    - + + 22 -
    -   -
    +
    +
    + - + zKEVMClient *mock_syncinterfaces.ZKEVMClientInterface
    - + + 23 -
    +
    +
      -
    + }
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) {
    - + +
    @@ -33,12 +32,15 @@
    -
    +
    + 33 + +
      -
    + {1, 10, 10},
    - + + 34 -
    +
    +
      -
    + {9, 10, 10},
    - + + 35 -
    +
    +
      -
    + {10, 10, 20},
    - + + 36 -
    -   -
    +
    +
    + - + {0, 0, 1},
    - + + 37 -
    -   -
    +
    +
    + - + {1, 0, 2},
    - + + 38 -
    +
    +
      -
    + }
    - + + 39 -
    +
    +
      -
    + for _, data := range values {
    - + + 40 -
    +
    +
      -
    + // Call the GetNextL2BlockToCheck method
    - + + 41 -
    -   -
    +
    +
    + - + checkL2Block := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus)
    - + + 42 -
    +
    +
      -
    + nextL2Block := checkL2Block.GetMinimumL2BlockToCheck()
    - + + 43 -
    +
    +
     
    - + + 44 -
    +
    +
      -
    + // Assert the expected result
    - + +
    @@ -57,9 +59,11 @@
    -
    +
    + 57 + +
      -
    + func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData {
    - + + 58 -
    +
    +
      -
    + res := CheckL2BlocksTestData{
    - + + 59 -
    +
    +
      -
    + mockState: mock_syncinterfaces.NewStateFullInterface(t),
    - + + 60 -
    -   -
    +
    +
    + - + zKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t),
    - + + 61 -
    +
    +
      -
    + }
    - + + 62 -
    -   -
    +
    +
    + - + res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus)
    - + + 63 -
    +
    +
      -
    + return res
    - + + 64 -
    +
    +
      -
    + }
    - + + 65 -
    +
    +
      -
    + func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
    - + +
    @@ -78,7 +82,8 @@
    -
    +
    + 78 + +
      -
    + }
    - + + 79 -
    +
    +
     
    - + + 80 -
    +
    +
      -
    + for _, data := range values {
    - + + 81 -
    -   -
    +
    +
    + - + checkL2Block := actions.NewCheckL2BlockHash(nil, nil, 0, 0)
    - + + 82 -
    +
    +
      -
    + shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck)
    - + + 83 -
    +
    +
     
    - + + 84 -
    +
    +
      -
    + assert.Equal(t, data.expectedShouldCheck, shouldCheck, data)
    - + +
    @@ -87,7 +92,7 @@
    -
    +
    + 87 + +
      -
    + }
    - + + 88 -
    +
    +
     
    - + + 89 -
    +
    +
      -
    + func TestCheckL2BlockHashMatch(t *testing.T) {
    - + + 90 -
    -   -
    +
    +
    + - + data := newCheckL2BlocksTestData(t, 1, 10)
    - + + 91 -
    +
    +
      -
    + lastL2Block := uint64(14)
    - + + 92 -
    +
    +
      -
    + lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
    - + + 93 -
    +
    +
      -
    + gethHeader := types.Header{
    - + +
    @@ -97,19 +102,24 @@
    -
    +
    + 97 + +
     
    - + + 98 -
    +
    +
      -
    + data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
    - + + 99 -
    +
    +
      -
    + data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
    - + + 100 -
    -   -
    +
    +
    + - + l2blockHash := stateBlock.Hash()
    - + + 101 -
    -   -
    +
    +
    + - + rpcL2Block := rpctypes.Block{
    - + + 102 -
    -   -
    +
    +
    + - + Hash: &l2blockHash,
    - + + 103 -
    -   -
    +
    +
    + - + Number: rpctypes.ArgUint64(lastL2Block),
    - + + 104 -
    -   -
    +
    +
    + - + }
    - + + 105 -
    +
    +
     
    - + + 106 -
    -   -
    +
    +
    + - + data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil)
    - + + 107 -
    +
    +
      -
    + err := data.sut.CheckL2Block(context.Background(), nil)
    - + + 108 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 109 -
    +
    +
      -
    + }
    - + + 110 -
    +
    +
     
    - + + 111 -
    -   -
    +
    +
    + - + func TestCheckL2BlockHashMissmatch(t *testing.T) {
    - + + 112 -
    -   -
    +
    +
    + - + data := newCheckL2BlocksTestData(t, 1, 10)
    - + + 113 -
    +
    +
      -
    + lastL2Block := uint64(14)
    - + + 114 -
    +
    +
      -
    + lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
    - + + 115 -
    +
    +
      -
    + gethHeader := types.Header{
    - + +
    @@ -119,13 +129,14 @@
    -
    +
    + 119 + +
     
    - + + 120 -
    +
    +
      -
    + data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
    - + + 121 -
    +
    +
      -
    + data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
    - + + 122 -
    -   -
    +
    +
    + - + l2blockHash := common.HexToHash("0x1234") +
    +
    + 123 + +
    + - + rpcL2Block := rpctypes.Block{ +
    +
    + 124 + +
    + - + Hash: &l2blockHash, +
    +
    + 125 + +
    + - + Number: rpctypes.ArgUint64(lastL2Block), +
    +
    + 126 + +
    + - + }
    - + + 127 -
    +
    +
     
    - + + 128 -
    +
    +
    + - + data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil) +
    +
    + 129 + +
      -
    + err := data.sut.CheckL2Block(context.Background(), nil)
    - + + 130 -
    +
    +
      -
    + require.Error(t, err)
    - + + 131 -
    +
    +
      -
    + }
    - 1 + + 18 +
    - + - // Code generated - DO NOT EDIT. +   + type CheckL2BlocksTestData struct {
    - 2 + + 19 +
    - + - // This file is a generated binding and any manual changes will be lost. +   + sut *actions.CheckL2BlockHash
    - 3 + + 20 +
    - + -
    +   + mockState *mock_syncinterfaces.StateFullInterface
    - 4 + + 21 +
    + - package customModExp + zKEVMClient *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface
    - 5 + + 22 +
    - + -
    +   + }
    - 6 + + 23 +
    - + - import ( +   +
    - 7 + + 24 +
    - + - "errors" +   + func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) {
    - 8 - -
    - + - "math/big" -
    +
    +
     
    - 9 + + 32 +
    - + - "strings" +   + {1, 10, 10},
    - 10 + + 33 +
    - + -
    +   + {9, 10, 10},
    - 11 + + 34 +
    - + - ethereum "github.com/ethereum/go-ethereum" +   + {10, 10, 20},
    - 12 + + 35 +
    + - "github.com/ethereum/go-ethereum/accounts/abi" + {0, 1, 1},
    - 13 + + 36 +
    + - "github.com/ethereum/go-ethereum/accounts/abi/bind" + {1, 1, 2},
    - 14 + + 37 +
    - + - "github.com/ethereum/go-ethereum/common" +   + }
    - 15 + 38
    + - "github.com/ethereum/go-ethereum/core/types" + _, err := actions.NewCheckL2BlockHash(nil, nil, 1, 0)
    - 16 + 39
    + - "github.com/ethereum/go-ethereum/event" + require.Error(t, err)
    - 17 + + 40 +
    - + - ) +   + for _, data := range values {
    - 18 + + 41 +
    - + -
    +   + // Call the GetNextL2BlockToCheck method
    - 19 + + 42 +
    + - // Reference imports to suppress errors if they are not otherwise used. + checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus)
    - 20 + 43
    + - var ( + require.NoError(t, err)
    - 21 + + 44 +
    - + - _ = errors.New +   + nextL2Block := checkL2Block.GetMinimumL2BlockToCheck()
    - 22 + + 45 +
    - + - _ = big.NewInt +   +
    - 23 + + 46 +
    - + - _ = strings.NewReader +   + // Assert the expected result
    - 24 - -
    - + - _ = ethereum.NotFound -
    +
    +
     
    - 25 + + 59 +
    - + - _ = bind.Bind +   + func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData {
    - 26 + + 60 +
    - + - _ = common.Big1 +   + res := CheckL2BlocksTestData{
    - 27 + + 61 +
    - + - _ = types.BloomLookup +   + mockState: mock_syncinterfaces.NewStateFullInterface(t),
    - 28 + + 62 +
    + - _ = event.NewSubscription + zKEVMClient: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t),
    - 29 + + 63 +
    - + - _ = abi.ConvertType +   + }
    - 30 + + 64 +
    + - ) + var err error
    - 31 + 65
    + -
    + res.sut, err = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus)
    - 32 + 66
    + - // CustomModExpMetaData contains all meta data concerning the CustomModExp contract. + require.NoError(t, err)
    - 33 + + 67 +
    - + - var CustomModExpMetaData = &bind.MetaData{ +   + return res
    - 34 + + 68 +
    - + - ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"modExpGeneric\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +   + }
    - 35 + + 69 +
    - + - Bin: "0x608060405234801561001057600080fd5b50610208806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5665d6f14610030575b600080fd5b61004361003e3660046100e2565b610045565b005b61004d6100ad565b6101408183516020850160055afa60009081555b600a8110156100a8578181600a811061007c5761007c610193565b6020020151600482600a811061009457610094610193565b0155806100a0816101a9565b915050610061565b505050565b604051806101400160405280600a906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156100f457600080fd5b813567ffffffffffffffff8082111561010c57600080fd5b818401915084601f83011261012057600080fd5b813581811115610132576101326100cc565b604051601f8201601f19908116603f0116810190838211818310171561015a5761015a6100cc565b8160405282815287602084870101111561017357600080fd5b826020860160208301376000928101602001929092525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156101cb57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212206c4940b4c9a7086754420734c8b4921cdb547ec8b31fc3bf8cd884ad9778a5b364736f6c634300080c0033", +   + func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) {
    - 36 + +
     
    +
    + 82 +
    - + - } +   + }
    - 37 + + 83 +
    - + +  
    - 38 + + 84 +
    - + - // CustomModExpABI is the input ABI used to generate the binding from. +   + for _, data := range values {
    - 39 + + 85 +
    + - // Deprecated: Use CustomModExpMetaData.ABI instead. + checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, 0, 1)
    - 40 + 86
    + - var CustomModExpABI = CustomModExpMetaData.ABI + require.NoError(t, err)
    - 41 + + 87 +
    - + -
    +   + shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck)
    - 42 + + 88 +
    - + - // CustomModExpBin is the compiled bytecode used for deploying new contracts. +   +
    - 43 + + 89 +
    - + - // Deprecated: Use CustomModExpMetaData.Bin instead. +   + assert.Equal(t, data.expectedShouldCheck, shouldCheck, data)
    - 44 + +
     
    +
    + 92 +
    - + - var CustomModExpBin = CustomModExpMetaData.Bin +   + }
    - 45 + + 93 +
    - + +  
    - 46 + + 94 +
    - + - // DeployCustomModExp deploys a new Ethereum contract, binding an instance of CustomModExp to it. +   + func TestCheckL2BlockHashMatch(t *testing.T) {
    - 47 + + 95 +
    + - func DeployCustomModExp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CustomModExp, error) { + data := newCheckL2BlocksTestData(t, 1, 14)
    - 48 + + 96 +
    - + - parsed, err := CustomModExpMetaData.GetAbi() +   + lastL2Block := uint64(14)
    - 49 + + 97 +
    - + - if err != nil { +   + lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
    - 50 + + 98 +
    - + - return common.Address{}, nil, nil, err +   + gethHeader := types.Header{
    - 51 + +
     
    +
    + 102 +
    - + - } +   +
    - 52 + + 103 +
    - + - if parsed == nil { +   + data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
    - 53 + + 104 +
    - + - return common.Address{}, nil, nil, errors.New("GetABI returned nil") +   + data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
    - 54 + + 105 +
    + - } + //l2blockHash := stateBlock.Hash()
    - 55 + + 106 +
    + -
    + // rpcL2Block := rpctypes.Block{
    - 56 + + 107 +
    + - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CustomModExpBin), backend) + // Hash: &l2blockHash,
    - 57 + + 108 +
    + - if err != nil { + // Number: rpctypes.ArgUint64(lastL2Block),
    - 58 + + 109 +
    + - return common.Address{}, nil, nil, err + // }
    - 59 + 110
    + - } + // create a types.Block object
    - 60 + + 111 +
    - + - return address, tx, &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil +   +
    - 61 + + 112 +
    + - } + rpcL2Block := types.NewBlock(&types.Header{
    - 62 + 113
    + -
    + Number: big.NewInt(int64(lastL2Block)),
    - 63 + 114
    + - // CustomModExp is an auto generated Go binding around an Ethereum contract. + }, nil, nil, nil, nil)
    - 64 + 115
    + - type CustomModExp struct { +
    - 65 + 116
    + - CustomModExpCaller // Read-only binding to the contract + data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil)
    - 66 + + 117 +
    - + - CustomModExpTransactor // Write-only binding to the contract +   + err := data.sut.CheckL2Block(context.Background(), nil)
    - 67 + + 118 +
    - + - CustomModExpFilterer // Log filterer for contract events +   + require.NoError(t, err)
    - 68 + + 119 +
    - + +   }
    - 69 + + 120 +
    - + +  
    - 70 + + 121 +
    + - // CustomModExpCaller is an auto generated read-only Go binding around an Ethereum contract. + func TestCheckL2BlockHashMismatch(t *testing.T) {
    - 71 + + 122 +
    + - type CustomModExpCaller struct { + data := newCheckL2BlocksTestData(t, 1, 14)
    - 72 + + 123 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls +   + lastL2Block := uint64(14)
    - 73 + + 124 +
    - + - } +   + lastL2BlockBigInt := big.NewInt(int64(lastL2Block))
    - 74 + + 125 +
    - + -
    +   + gethHeader := types.Header{
    - 75 + +
     
    +
    + 129 +
    - + - // CustomModExpTransactor is an auto generated write-only Go binding around an Ethereum contract. +   +
    - 76 + + 130 +
    - + - type CustomModExpTransactor struct { +   + data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil)
    - 77 + + 131 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls +   + data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil)
    - 78 + + 132 +
    + - } + //l2blockHash := common.HexToHash("0x1234")
    - 79 + + 133 +
    +
    - 80 + + 134 +
    + - // CustomModExpFilterer is an auto generated log filtering Go binding around an Ethereum contract events. + rpcL2Block := types.NewBlock(&types.Header{
    - 81 + + 135 +
    + - type CustomModExpFilterer struct { + Number: big.NewInt(int64(lastL2Block)),
    - 82 + + 136 +
    + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + ParentHash: common.HexToHash("0x1234"),
    - 83 + 137
    + - } + }, nil, nil, nil, nil)
    - 84 + + 138 +
    - + +  
    - 85 + + 139 +
    + - // CustomModExpSession is an auto generated Go binding around an Ethereum contract, + data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil)
    - 86 + + 140 +
    - + - // with pre-set call and transact options. +   + err := data.sut.CheckL2Block(context.Background(), nil)
    - 87 + + 141 +
    - + - type CustomModExpSession struct { +   + require.Error(t, err)
    - 88 + + 142 +
    - + - Contract *CustomModExp // Generic contract binding to set the session for +   + }
    - 89 - -
    - + - CallOpts bind.CallOpts // Call options to use throughout this session +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -3,7 +3,6 @@
    - 90 + + 3 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +   + import (
    - 91 + + 4 +
    - + - } +   + "context"
    - 92 + + 5 +
    - + -
    +   + "errors"
    - 93 + + 6 +
    - + - // CustomModExpCallerSession is an auto generated read-only Go binding around an Ethereum contract, + - + "fmt"
    - 94 + + 7 +
    - + - // with pre-set call options. +   + "time"
    - 95 + + 8 +
    - + - type CustomModExpCallerSession struct { +   +
    - 96 + + 9 +
    - + - Contract *CustomModExpCaller // Generic contract caller binding to set the session for +   + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 97 + +
    @@ -60,58 +59,12 @@
    +
    + 60 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session +   +
    - 98 + + 61 +
    - + - } +   + sbatch := l1Block.SequencedBatches[order.Pos][0]
    - 99 + + 62 +
    - + +  
    - 100 + + -
    - + - // CustomModExpTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +
    +
    +   +
    - 101 + + 63 +
    - + - // with pre-set transact options. +   + if sbatch.SequencedBatchElderberryData == nil {
    - 102 + + 64 +
    - + - type CustomModExpTransactorSession struct { + - + log.Errorf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 103 + + 65 +
    - + - Contract *CustomModExpTransactor // Generic contract transactor binding to set the session for + - + return fmt.Errorf("no elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 104 + + -
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +
    +
    +   +
    - 105 + + 66 +
    - + - } +   + }
    - 106 + + 67 +
    - + -
    + - + // We need to check that the sequence match
    - 107 + + 68 +
    - + - // CustomModExpRaw is an auto generated low-level Go binding around an Ethereum contract. + - + err := g.sanityCheckExpectedSequence(sbatch.SequencedBatchElderberryData.InitSequencedBatchNumber, dbTx)
    - 108 + + 69 +
    - + - type CustomModExpRaw struct { + - + if err != nil {
    - 109 + + 70 +
    - + - Contract *CustomModExp // Generic contract binding to access the raw methods on + - + return err
    - 110 + + 71 +
    - + - } + - + }
    - 111 + + 72 +
    - + -
    + - + // We known that the MaxSequenceTimestamp is the same for all the batches so we can use the first one
    - 112 + + 73 +
    - + - // CustomModExpCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. + - + err = g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0), dbTx)
    - 113 + + 74 +
    - + - type CustomModExpCallerRaw struct { + - + // The last L2block timestamp must match MaxSequenceTimestamp
    - 114 + + 75 +
    - + - Contract *CustomModExpCaller // Generic read-only contract binding to access the raw methods on + - + if err != nil {
    - 115 + + 76 +
    - + - } + - + return err
    - 116 + + 77 +
    - + -
    + - + }
    - 117 + + 78 +
    - + - // CustomModExpTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. + - + // It checks the timestamp of the last L2 block, but it's just log an error instead of refusing the event
    - 118 + + 79 +
    - + - type CustomModExpTransactorRaw struct { + - + _ = g.sanityCheckTstampLastL2Block(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp, dbTx)
    - 119 + + 80 +
    - + - Contract *CustomModExpTransactor // Generic write-only contract binding to access the raw methods on + - + return nil
    - 120 + + 81 +
    - + + - }
    - 121 + + 82 +
    - + + -
    - 122 + + 83 +
    - + - // NewCustomModExp creates a new instance of CustomModExp, bound to a specific deployed contract. + - + func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckExpectedSequence(initialBatchNumber uint64, dbTx pgx.Tx) error {
    - 123 + + 84 +
    - + - func NewCustomModExp(address common.Address, backend bind.ContractBackend) (*CustomModExp, error) { + - + // We need to check that the sequence match
    - 124 + + 85 +
    - + - contract, err := bindCustomModExp(address, backend, backend, backend) + - + lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx)
    - 125 + + 86 +
    - + + - if err != nil {
    - 126 + + 87 +
    - + - return nil, err + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 127 + + 88 +
    - + - } + - + return err
    - 128 + + 89 +
    - + - return &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil + - + }
    - 129 + + 90 +
    - + - } + - + if lastVirtualBatchNum != initialBatchNumber {
    - 130 + + 91 +
    - + -
    + - + log.Errorf("The last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event)", lastVirtualBatchNum+1, initialBatchNumber)
    - 131 + + 92 +
    - + - // NewCustomModExpCaller creates a new read-only instance of CustomModExp, bound to a specific deployed contract. + - + return fmt.Errorf("the last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event) err:%w", lastVirtualBatchNum+1, initialBatchNumber, ErrInvalidInitialBatchNumber)
    - 132 + + 93 +
    - + - func NewCustomModExpCaller(address common.Address, caller bind.ContractCaller) (*CustomModExpCaller, error) { + - + }
    - 133 + + 94 +
    - + - contract, err := bindCustomModExp(address, caller, nil, nil) + - + return nil
    - 134 + + 95 +
    - + - if err != nil { + - + }
    - 135 + + 96 +
    - + - return nil, err +   +
    - 136 + + 97 +
    - + - } + - + func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckTstampLastL2Block(timeLimit uint64, dbTx pgx.Tx) error {
    - 137 + + 98 +
    - + - return &CustomModExpCaller{contract: contract}, nil + - + lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx)
    - 138 + + 99 +
    - + - } + - + if err != nil {
    - 139 + + 100 +
    - + -
    + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 140 + + 101 +
    - + - // NewCustomModExpTransactor creates a new write-only instance of CustomModExp, bound to a specific deployed contract. + - + return err
    - 141 + + 102 +
    - + - func NewCustomModExpTransactor(address common.Address, transactor bind.ContractTransactor) (*CustomModExpTransactor, error) { + - + }
    - 142 + + 103 +
    - + - contract, err := bindCustomModExp(address, nil, transactor, nil) + - + lastL2Block, err := g.state.GetLastL2BlockByBatchNumber(context.Background(), lastVirtualBatchNum, dbTx)
    - 143 + + 104 +
    - + + - if err != nil {
    - 144 + + 105 +
    - + - return nil, err + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 145 + + 106 +
    - + - } + - + return err
    - 146 + + 107 +
    - + - return &CustomModExpTransactor{contract: contract}, nil + - + }
    - 147 + + 108 +
    - + - } + - + if lastL2Block == nil {
    - 148 + + 109 +
    - + -
    + - + //TODO: find the previous batch until we find a L2 block to check the timestamp
    - 149 + + 110 +
    - + - // NewCustomModExpFilterer creates a new log filterer instance of CustomModExp, bound to a specific deployed contract. + - + return nil
    - 150 + + 111 +
    - + - func NewCustomModExpFilterer(address common.Address, filterer bind.ContractFilterer) (*CustomModExpFilterer, error) { + - + }
    - 151 + + 112 +
    - + - contract, err := bindCustomModExp(address, nil, nil, filterer) + - + if uint64(lastL2Block.ReceivedAt.Unix()) > timeLimit {
    - 152 + + 113 +
    - + - if err != nil { + - + log.Errorf("The last L2 block timestamp can't be greater than timeLimit. Expected: %d (L1 event), got: %d (last L2Block)", timeLimit, lastL2Block.ReceivedAt.Unix())
    - 153 + + 114 +
    - + - return nil, err + - + return fmt.Errorf("wrong timestamp of last L2 block timestamp with L1 event timestamp")
    - 154 + + 115 +
    - + + - }
    - 155 + + 116 +
    - + - return &CustomModExpFilterer{contract: contract}, nil + - + return nil
    - 156 + + 117 +
    - + +   }
    - 157 - -
    - + -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -138127,12 +139188,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go RENAMED
    @@ -138235,72 +139296,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -138310,12 +139371,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/reorg_error.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -138533,393 +139584,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -139166,349 +139847,19 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -139993,12 +140294,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/async_l1_block_checker.go RENAMED
    + + +
    +
     
    - 158 + + 3 +
    - + - // bindCustomModExp binds a generic wrapper to an already deployed contract. +   + import (
    - 159 + + 4 +
    - + - func bindCustomModExp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { +   + "context"
    - 160 + + 5 +
    - + - parsed, err := CustomModExpMetaData.GetAbi() +   + "errors"
    - 161 + + -
    - + - if err != nil { +
    +
    +   +
    - 162 + + 6 +
    - + - return nil, err +   + "time"
    - 163 + + 7 +
    - + - } +   +
    - 164 + + 8 +
    - + - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +   + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 165 + +
     
    +
    + 59 +
    - + - } +   +
    - 166 + + 60 +
    - + -
    +   + sbatch := l1Block.SequencedBatches[order.Pos][0]
    - 167 + + 61 +
    - + - // Call invokes the (constant) contract method with params as input values and +   +
    - 168 + 62
    + - // sets the output to result. The result type might be a single field for simple + executionTime := l1Block.ReceivedAt
    - 169 + + 63 +
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named +   + if sbatch.SequencedBatchElderberryData == nil {
    - 170 + + 64 +
    + - // returns. + log.Warnf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 171 + + 65 +
    + - func (_CustomModExp *CustomModExpRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + } else {
    - 172 + 66
    + - return _CustomModExp.Contract.CustomModExpCaller.contract.Call(opts, result, method, params...) + executionTime = time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0)
    - 173 + + 67 +
    - + - } +   + }
    - 174 + + -
    - + +
    +
    +  
    - 175 + + -
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    +   +
    - 176 + + -
    - + - // its default method if one is available. +
    +
    +   +
    - 177 + + -
    - + - func (_CustomModExp *CustomModExpRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    +   +
    - 178 + + -
    - + - return _CustomModExp.Contract.CustomModExpTransactor.contract.Transfer(opts) +
    +
    +   +
    - 179 + + -
    - + - } +
    +
    +   +
    - 180 + + -
    - + +
    +
    +  
    - 181 + + -
    - + - // Transact invokes the (paid) contract method with params as input values. +
    +
    +   +
    - 182 + + -
    - + - func (_CustomModExp *CustomModExpRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    +   +
    - 183 + + -
    - + - return _CustomModExp.Contract.CustomModExpTransactor.contract.Transact(opts, method, params...) +
    +
    +   +
    - 184 + + -
    - + - } +
    +
    +   +
    - 185 + + -
    - + +
    +
    +  
    - 186 + + -
    - + - // Call invokes the (constant) contract method with params as input values and +
    +
    +   +
    - 187 + + -
    - + - // sets the output to result. The result type might be a single field for simple +
    +
    +   +
    - 188 + + -
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    +   +
    - 189 + + -
    - + - // returns. +
    +
    +   +
    - 190 + + -
    - + - func (_CustomModExp *CustomModExpCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    +   +
    - 191 + + -
    - + - return _CustomModExp.Contract.contract.Call(opts, result, method, params...) +
    +
    +   +
    - 192 + + -
    - + - } +
    +
    +   +
    - 193 + + -
    - + +
    +
    +  
    - 194 + + -
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    +   +
    - 195 + + -
    - + - // its default method if one is available. +
    +
    +   +
    - 196 + + -
    - + - func (_CustomModExp *CustomModExpTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    +   +
    - 197 + + -
    - + - return _CustomModExp.Contract.contract.Transfer(opts) +
    +
    +   +
    - 198 + + -
    - + - } +
    +
    +   +
    - 199 + + -
    - + +
    +
    +  
    - 200 + + -
    - + - // Transact invokes the (paid) contract method with params as input values. +
    +
    +   +
    - 201 + + -
    - + - func (_CustomModExp *CustomModExpTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    +   +
    - 202 + + -
    - + - return _CustomModExp.Contract.contract.Transact(opts, method, params...) +
    +
    +   +
    - 203 + + 68 +
    - + - } +   +
    - 204 + + 69 +
    + -
    + return g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, executionTime, dbTx)
    - 205 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 206 + + -
    - + - // +
    +
    +   +
    - 207 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 208 + + -
    - + - func (_CustomModExp *CustomModExpTransactor) ModExpGeneric(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 209 + + -
    - + - return _CustomModExp.contract.Transact(opts, "modExpGeneric", input) +
    +
    +   +
    - 210 + + -
    - + - } +
    +
    +   +
    - 211 + + -
    - + +
    +
    +  
    - 212 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 213 + + -
    - + - // +
    +
    +   +
    - 214 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 215 + + -
    - + - func (_CustomModExp *CustomModExpSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 216 + + -
    - + - return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    +   +
    - 217 + + -
    - + - } +
    +
    +   +
    - 218 + + -
    - + +
    +
    +  
    - 219 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 220 + + -
    - + - // +
    +
    +   +
    - 221 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 222 + + -
    - + - func (_CustomModExp *CustomModExpTransactorSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 223 + + -
    - + - return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    +   +
    - 224 + + 70 +
    - + +   }
    -
    @@ -32,7 +32,7 @@
    +
    @@ -391,7 +391,7 @@
    - 32 + 391
      - // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. + reason := reorgReasons.String()
    - 33 + 392
      - var TriggerErrorsMetaData = &bind.MetaData{ +
    - 34 + 393
      - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + if p.sync.IsTrustedSequencer() {
    - 35 + 394
    - - Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122097beacfaa873e4896937143dfea406cc278b929a28023f7e7020b6dea6e9fc7364736f6c634300080c0033", + log.Errorf("TRUSTED REORG DETECTED! Batch: %d reson:%s", batch.BatchNumber, reason)
    - 36 + 395
      - } + // Halt function never have to return! it must blocks the process
    - 37 + 396
      -
    + p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber))
    - 38 + 397
      - // TriggerErrorsABI is the input ABI used to generate the binding from. + log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process")
    - 32 + 391
      - // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. + reason := reorgReasons.String()
    - 33 + 392
      - var TriggerErrorsMetaData = &bind.MetaData{ +
    - 34 + 393
      - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + if p.sync.IsTrustedSequencer() {
    - 35 + 394
    + - Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212208f01c5dc055b1f376f5da5deb33e2c96ee776174bf48874c5ebba0f606de2ac564736f6c634300080c0033", + log.Errorf("TRUSTED REORG DETECTED! Batch: %d reason:%s", batch.BatchNumber, reason)
    - 36 + 395
      - } + // Halt function never have to return! it must blocks the process
    - 37 + 396
      -
    + p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber))
    - 38 + 397
      - // TriggerErrorsABI is the input ABI used to generate the binding from. + log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process")
    -
    @@ -2,7 +2,7 @@
    +
    @@ -0,0 +1,44 @@
    - 2 + + -
    +
    +
      - networks: +
    - 3 + + -
    +
    +
      - default: +
    - 4 + + -
    +
    +
      - name: zkevm +
    - 5 + + -
    - - - +
    +
    +   +
    - 6 + + -
    +
    +
      - services: +
    - 7 + + -
    +
    +
      - grafana: +
    - 8 + + -
    +
    +
      - container_name: grafana +
    -
    @@ -453,7 +453,7 @@
    -
    - 453 + + -
    +
    +
     
    - 454 + + -
    +
    +
      - zkevm-mock-l1-network: +
    - 455 + + -
    +
    +
      - container_name: zkevm-mock-l1-network +
    - 456 + + -
    - - - image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0 +
    +
    +   +
    - 457 + + -
    +
    +
      - ports: +
    - 458 + + -
    +
    +
      - - 8545:8545 +
    - 459 + + -
    +
    +
      - - 8546:8546 +
    -
    @@ -519,6 +519,8 @@
    -
    - 519 + + -
    +
    +
      - - 50071:50071 # Executor +
    - 520 + + -
    +
    +
      - volumes: +
    - 521 + + -
    +
    +
      - - ./config/test.prover.config.json:/usr/src/app/config.json +
    - 522 + + -
    +
    +
      - command: > +
    - 523 + + -
    +
    +
      - zkProver -c /usr/src/app/config.json -
    -
    - 524 - -
    -   -
    -
    -
    -
    @@ -628,7 +630,7 @@
    -
    - 628 - -
    -   - zkevm-sh: -
    -
    - 629 - -
    -   - container_name: zkevm-sh -
    -
    - 630 - -
    -   - image: zkevm-node -
    -
    - 631 - -
    - - - stdin_open: true -
    -
    - 632 - -
    -   - tty: true -
    -
    - 633 - -
    -   - environment: -
    -
    - 634 - -
    -   - - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db -
    -
    -
    @@ -638,3 +640,51 @@
    -
    - 638 - -
    -   - - ./config/test.genesis.config.json:/app/genesis.json -
    -
    - 639 - -
    -   - command: -
    -
    - 640 - -
    -   - - "/bin/sh" -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    +
     
    - 2 - -
    -   - networks: -
    -
    - 3 - -
    -   - default: -
    -
    - 4 - -
    -   - name: zkevm -
    -
    - 5 - -
    - + -
    -
    -
    - 6 - -
    -   - services: -
    -
    - 7 - -
    -   - grafana: -
    -
    - 8 - -
    -   - container_name: grafana -
    -
    -
     
    -
    - 453 - -
    -   -
    -
    -
    - 454 - -
    -   - zkevm-mock-l1-network: -
    -
    - 455 - -
    -   - container_name: zkevm-mock-l1-network -
    -
    - 456 - -
    - + - image: 0xpolygon/cdk-validium-contracts:forkId8 -
    -
    - 457 - -
    -   - ports: -
    -
    - 458 - -
    -   - - 8545:8545 -
    -
    - 459 - -
    -   - - 8546:8546 -
    -
    -
     
    -
    - 519 - -
    -   - - 50071:50071 # Executor -
    -
    - 520 - -
    -   - volumes: -
    -
    - 521 - -
    -   - - ./config/test.prover.config.json:/usr/src/app/config.json -
    -
    - 522 - -
    - + - environment: -
    -
    - 523 + 1
    + - - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 -
    -
    - 524 - -
    -   - command: > -
    -
    - 525 - -
    -   - zkProver -c /usr/src/app/config.json -
    -
    - 526 - -
    -   -
    -
    -
    -
     
    -
    - 630 - -
    -   - zkevm-sh: -
    -
    - 631 - -
    -   - container_name: zkevm-sh -
    -
    - 632 - -
    -   - image: zkevm-node -
    -
    - 633 - -
    - + - stdin_open: true -
    -
    - 634 - -
    -   - tty: true -
    -
    - 635 - -
    -   - environment: -
    -
    - 636 - -
    -   - - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db -
    -
    -
     
    -
    - 640 - -
    -   - - ./config/test.genesis.config.json:/app/genesis.json -
    -
    - 641 - -
    -   - command: -
    -
    - 642 - -
    -   - - "/bin/sh" + package common
    - 643 + 2
    @@ -139518,277 +139869,267 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 644 - -
    - + - zkevm-node-forced-DAC: -
    -
    - 645 + 3
    + - container_name: zkevm-node-forced-DAC + import "fmt"
    - 646 + 4
    + - image: zkevm-node +
    - 647 + 5
    + - ports: + // ReorgError is an error that is raised when a reorg is detected
    - 648 + 6
    + - - 8125:8125 + type ReorgError struct {
    - 649 + 7
    + - environment: + // BlockNumber is the block number that caused the reorg
    - 650 + 8
    + - - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false + BlockNumber uint64
    - 651 + 9
    + - - ZKEVM_NODE_STATEDB_USER=test_user + Err error
    - 652 + 10
    + - - ZKEVM_NODE_STATEDB_PASSWORD=test_password + }
    - 653 + 11
    + - - ZKEVM_NODE_STATEDB_NAME=state_db +
    - 654 + 12
    + - - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db + // NewReorgError creates a new ReorgError
    - 655 + 13
    + - - ZKEVM_NODE_POOL_DB_USER=test_user + func NewReorgError(blockNumber uint64, err error) *ReorgError {
    - 656 + 14
    + - - ZKEVM_NODE_POOL_DB_PASSWORD=test_password + return &ReorgError{
    - 657 + 15
    + - - ZKEVM_NODE_POOL_DB_NAME=pool_db + BlockNumber: blockNumber,
    - 658 + 16
    + - - ZKEVM_NODE_POOL_DB_HOST=zkevm-permissionless-db + Err: err,
    - 659 + 17
    + - - ZKEVM_NODE_RPC_PORT=8125 + }
    - 660 + 18
    + - - ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-node-json-rpc:8123 + }
    - 661 + 19
    + - - ZKEVM_NODE_SYNCHRONIZER_TRUSTEDSEQUENCERURL=http://you-cant-touch-this:8123 +
    - 662 + 20
    + - - ZKEVM_NODE_MTCLIENT_URI=zkevm-permissionless-prover:50061 + func (e *ReorgError) Error() string {
    - 663 + 21
    + - - ZKEVM_NODE_EXECUTOR_URI=zkevm-permissionless-prover:50071 + return fmt.Sprintf("%s blockNumber: %d", e.Err.Error(), e.BlockNumber)
    - 664 + 22
    + - volumes: + }
    - 665 + 23
    + - - ./config/test.node.config.toml:/app/config.toml +
    - 666 + 24
    + - - ./config/test.genesis.config.json:/app/genesis.json + // IsReorgError checks if an error is a ReorgError
    - 667 + 25
    + - command: + func IsReorgError(err error) bool {
    - 668 + 26
    + - - "/bin/sh" + _, ok := err.(*ReorgError)
    - 669 + 27
    + - - "-c" + return ok
    - 670 + 28
    + - - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\"" + }
    - 671 + 29
    @@ -139798,192 +140139,152 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 672 - -
    - + - zkevm-data-node-db: -
    -
    - 673 - -
    - + - container_name: zkevm-data-node-db -
    -
    - 674 - -
    - + - restart: unless-stopped -
    -
    - 675 - -
    - + - image: postgres -
    -
    - 676 + 30
    + - healthcheck: + // GetReorgErrorBlockNumber returns the block number that caused the reorg
    - 677 + 31
    + - test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] + func GetReorgErrorBlockNumber(err error) uint64 {
    - 678 + 32
    + - interval: 10s + if reorgErr, ok := err.(*ReorgError); ok {
    - 679 + 33
    + - timeout: 5s + return reorgErr.BlockNumber
    - 680 + 34
    + - retries: 5 + }
    - 681 + 35
    + - ports: + return 0
    - 682 + 36
    + - - 5444:5432 + }
    - 683 + 37
    + - environment: +
    - 684 + 38
    + - - POSTGRES_USER=committee_user + // GetReorgError returns the error that caused the reorg
    - 685 + 39
    + - - POSTGRES_PASSWORD=committee_password + func GetReorgError(err error) error {
    - 686 + 40
    + - - POSTGRES_DB=committee_db + if reorgErr, ok := err.(*ReorgError); ok {
    - 687 + 41
    + - command: + return reorgErr.Err
    - 688 + 42
    + - - "postgres" + }
    - 689 + 43
    + - - "-N" + return nil
    - 690 + 44
    + - - "500" + }
    -
    @@ -0,0 +1,270 @@
    +
    @@ -0,0 +1,40 @@
    @@ -140415,484 +140716,517 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    - + + 1 -
    -   -
    +
    +
    + + + package syncinterfaces
    - + + 2 -
    -   +
    +
    + +
    - + + 3 -
    -   -
    +
    +
    + + + import (
    - + + 4 -
    -   -
    +
    +
    + + + "context"
    - + + 5 -
    -   -
    +
    +
    + + + "fmt"
    - + + 6 -
    -   +
    +
    + +
    - + + 7 -
    -   -
    +
    +
    + + + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 8 -
    -   -
    +
    +
    + + + )
    - + + 9 -
    -   +
    +
    + +
    - + + 10 -
    -   -
    +
    +
    + + + type IterationResult struct {
    - + + 11 -
    -   -
    +
    +
    + + + Err error
    - + + 12 -
    -   -
    +
    +
    + + + ReorgDetected bool
    - + + 13 -
    -   -
    +
    +
    + + + BlockNumber uint64
    - + + 14 -
    -   -
    +
    +
    + + + ReorgMessage string
    - + + 15 -
    -   -
    +
    +
    + + + }
    - + + 16 -
    -   +
    +
    + +
    - + + 17 -
    -   -
    +
    +
    + + + func (ir *IterationResult) String() string {
    - + + 18 -
    -   -
    +
    +
    + + + if ir.Err == nil {
    - + + 19 -
    -   -
    +
    +
    + + + if ir.ReorgDetected {
    - + + 20 -
    -   -
    +
    +
    + + + return fmt.Sprintf("IterationResult{ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage)
    - + + 21 -
    -   -
    +
    +
    + + + } else {
    - + + 22 -
    -   -
    +
    +
    + + + return "IterationResult{None}"
    - + + 23 -
    -   -
    +
    +
    + + + }
    - + + 24 -
    -   -
    +
    +
    + + + } else {
    - + + 25 -
    -   -
    +
    +
    + + + return fmt.Sprintf("IterationResult{Err: %s, ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.Err.Error(), ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage)
    - + + 26 -
    -   -
    +
    +
    + + + }
    - + + 27 -
    -   -
    +
    +
    + + + }
    - + + 28 -
    -   +
    +
    + +
    - + + 29 -
    -   -
    +
    +
    + + + type AsyncL1BlockChecker interface {
    - + + 30 -
    -   -
    +
    +
    + + + Run(ctx context.Context, onFinish func())
    - + + 31 -
    -   -
    +
    +
    + + + RunSynchronous(ctx context.Context) IterationResult
    - + + 32 -
    -   -
    +
    +
    + + + Stop()
    - + + 33 -
    -   -
    +
    +
    + + + GetResult() *IterationResult
    - + + 34 -
    -   -
    +
    +
    + + + }
    - + + 35 -
    -   +
    +
    + +
    - + + 36 -
    -   -
    +
    +
    + + + type L1BlockCheckerIntegrator interface {
    - + + 37 -
    -   -
    +
    +
    + + + OnStart(ctx context.Context) error
    - + + 38 -
    -   -
    +
    +
    + + + OnResetState(ctx context.Context)
    - + + 39 -
    -   -
    +
    +
    + + + CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error)
    - + + 40 -
    -   -
    +
    +
    + + + }
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - @@ -140926,73 +141260,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + +
    +
    @@ -14,10 +14,12 @@
    - + + 14 -
    +
    +
      -
    + HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error)
    - + + 15 -
    +
    +
      -
    + GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)
    - + + 16 -
    +
    +
      -
    + EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error)
    - + + 17 -
    -   -
    +
    +
    + - + GetLatestBatchNumber() (uint64, error)
    - + + 18 -
    +
    +
      -
    + GetTrustedSequencerURL() (string, error)
    - + + 19 -
    +
    +
      -
    + VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error)
    - + + 20 -
    +
    +
      -
    + GetLatestVerifiedBatchNum() (uint64, error)
    - + + 21 -
    +
    +
      -
    + }
    - + + 22 -
    +
    +
     
    - + + 23 -
    +
    +
      -
    + type EthermanGetLatestBatchNumber interface {
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - @@ -141006,123 +141344,152 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 14 -
    +
    +
      -
    + HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error)
    - + + 15 -
    +
    +
      -
    + GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)
    - + + 16 -
    +
    +
      -
    + EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error)
    - + + 17 -
    +
    +
      -
    + GetTrustedSequencerURL() (string, error)
    - + + 18 -
    +
    +
      -
    + VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error)
    - + + 19 -
    +
    +
      -
    + GetLatestVerifiedBatchNum() (uint64, error)
    - + + 20 -
    -   +
    +
    + +
    - + + 21 -
    -   -
    +
    +
    + + + EthermanGetLatestBatchNumber
    - + + 22 -
    -   -
    +
    +
    + + + GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
    - + + 23 -
    +
    +
      -
    + }
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + type EthermanGetLatestBatchNumber interface { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -141136,13 +141503,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -141166,63 +141533,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -141246,174 +141618,222 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + +
    +
    @@ -28,7 +28,10 @@
    - + + 28 -
    +
    +
      -
    + AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, dbTx pgx.Tx) error
    - + + 29 -
    +
    +
      -
    + AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error
    - + + 30 -
    +
    +
      -
    + Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error
    - + + 31 -
    +
    +
      -
    + GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 32 -
    +
    +
      -
    + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 33 -
    +
    +
      -
    + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - + + 34 -
    +
    +
      -
    + ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - + +
    @@ -73,4 +76,6 @@
    -
    +
    + 73 + +
      -
    + UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
    - + + 74 -
    +
    +
      -
    + GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 75 -
    +
    +
      -
    + GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
    - + + 76 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
     
    - + + 28 -
    +
    +
      -
    + AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, dbTx pgx.Tx) error
    - + + 29 -
    +
    +
      -
    + AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error
    - + + 30 -
    +
    +
      -
    + Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error
    - + + 31 -
    -   -
    +
    +
    + + + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 32 -
    +
    +
      -
    + GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 33 -
    -   -
    +
    +
    + + + GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 34 -
    -   -
    +
    +
    + + + UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error
    - + + 35 -
    +
    +
      -
    + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 36 -
    +
    +
      -
    + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - + + 37 -
    +
    +
      -
    + ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - + +
     
    -
    +
    + 76 + +
      -
    + UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
    - + + 77 -
    +
    +
      -
    + GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 78 -
    +
    +
      -
    + GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
    - + + 79 -
    -   -
    +
    +
    + + + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error)
    - + + 80 -
    -   -
    +
    +
    + + + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 81 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_ethereum_compatible_client.go + RENAMED + +
    +
    +
    +
    + + + + + + + +
    +
    @@ -0,0 +1,21 @@
    @@ -141625,69 +142045,292 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    - + + 1 -
    -   -
    +
    +
    + + + package syncinterfaces
    - + + 2 -
    -   +
    +
    + +
    - + + 3 -
    -   -
    +
    +
    + + + import (
    - + + 4 -
    -   -
    +
    +
    + + + "context"
    - + + 5 -
    -   -
    +
    +
    + + + "math/big"
    - + + 6 -
    -   +
    +
    + +
    - + + 7 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 8 + +
    + + + ) +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + // ZKEVMClientEthereumCompatibleInterface contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible +
    +
    + 11 + +
    + + + // +
    +
    + 12 + +
    + + + // Reason behind: the zkEVMClient have some extensions to ethereum-API that are not compatible with all nodes. So if you need to maximize +
    +
    + 13 + +
    + + + // the compatibility the idea is to use a regular ethereum-API compatible client +
    +
    + 14 + +
    + + + type ZKEVMClientEthereumCompatibleInterface interface { +
    +
    + 15 + +
    + + + ZKEVMClientEthereumCompatibleL2BlockGetter +
    +
    + 16 + +
    + + + } +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + // ZKEVMClientEthereumCompatibleL2BlockGetter contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible for obtain Block information +
    +
    + 19 + +
    + + + type ZKEVMClientEthereumCompatibleL2BlockGetter interface { +
    +
    + 20 + +
    + + + BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) +
    +
    + 21 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,6 +1,8 @@
    +
    + 1 + +
    +   + package synchronizer +
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    +
    @@ -141705,6 +142348,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 4 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/config/types" +
    +
    + 5 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync" +
    +
    + 6 + +
    +   + ) +
    +
    +
    @@ -13,6 +15,8 @@
    +
    + 13 + +
    +   + SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` +
    +
    + 14 + +
    +   + // TrustedSequencerURL is the rpc url to connect and sync the trusted state +
    +
    + 15 + +
    +   + TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` +
    +
    @@ -141725,6 +142433,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 16 + +
    +   +
    +
    +
    + 17 + +
    +   + // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) +
    +
    + 18 + +
    +   + L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` +
    +
    +
    @@ -20,6 +24,7 @@
    +
    + 20 + +
    +   + // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) +
    +
    + 21 + +
    +   + L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` +
    +
    + 22 + +
    +   +
    +
    +
    @@ -141735,6 +142508,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 23 + +
    +   + // L1SynchronizationMode define how to synchronize with L1: +
    +
    + 24 + +
    +   + // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data +
    +
    + 25 + +
    +   + // - sequential: Request data to L1 and execute +
    +
    +
    @@ -30,6 +35,35 @@
    +
    + 30 + +
    +   + L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` +
    +
    + 31 + +
    +   + } +
    +
    + 32 + +
    +   +
    +
    +
    @@ -142025,6 +142863,674 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 33 + +
    +   + // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') +
    +
    + 34 + +
    +   + type L1ParallelSynchronizationConfig struct { +
    +
    + 35 + +
    +   + // MaxClients Number of clients used to synchronize with L1 +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    +   + package synchronizer +
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    + + + "fmt" +
    +
    + 5 + +
    + + +
    +
    +
    + 6 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/config/types" +
    +
    + 7 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync" +
    +
    + 8 + +
    +   + ) +
    +
    +
     
    +
    + 15 + +
    +   + SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` +
    +
    + 16 + +
    +   + // TrustedSequencerURL is the rpc url to connect and sync the trusted state +
    +
    + 17 + +
    +   + TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` +
    +
    + 18 + +
    + + + // SyncBlockProtection specify the state to sync (lastest, finalized or safe) +
    +
    + 19 + +
    + + + SyncBlockProtection string `mapstructure:"SyncBlockProtection"` +
    +
    + 20 + +
    +   +
    +
    +
    + 21 + +
    +   + // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) +
    +
    + 22 + +
    +   + L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` +
    +
    +
     
    +
    + 24 + +
    +   + // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) +
    +
    + 25 + +
    +   + L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` +
    +
    + 26 + +
    +   +
    +
    +
    + 27 + +
    + + + L1BlockCheck L1BlockCheckConfig `mapstructure:"L1BlockCheck"` +
    +
    + 28 + +
    +   + // L1SynchronizationMode define how to synchronize with L1: +
    +
    + 29 + +
    +   + // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data +
    +
    + 30 + +
    +   + // - sequential: Request data to L1 and execute +
    +
    +
     
    +
    + 35 + +
    +   + L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` +
    +
    + 36 + +
    +   + } +
    +
    + 37 + +
    +   +
    +
    +
    + 38 + +
    + + + // L1BlockCheckConfig Configuration for L1 Block Checker +
    +
    + 39 + +
    + + + type L1BlockCheckConfig struct { +
    +
    + 40 + +
    + + + // Enable if is true then the check l1 Block Hash is active +
    +
    + 41 + +
    + + + Enable bool `mapstructure:"Enable"` +
    +
    + 42 + +
    + + + // L1SafeBlockPoint is the point that a block is considered safe enough to be checked +
    +
    + 43 + +
    + + + // it can be: finalized, safe,pending or latest +
    +
    + 44 + +
    + + + L1SafeBlockPoint string `mapstructure:"L1SafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` +
    +
    + 45 + +
    + + + // L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point +
    +
    + 46 + +
    + + + // it can be positive or negative +
    +
    + 47 + +
    + + + // Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block +
    +
    + 48 + +
    + + + L1SafeBlockOffset int `mapstructure:"L1SafeBlockOffset"` +
    +
    + 49 + +
    + + + // ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks +
    +
    + 50 + +
    + + + ForceCheckBeforeStart bool `mapstructure:"ForceCheckBeforeStart"` +
    +
    + 51 + +
    + + +
    +
    +
    + 52 + +
    + + + // PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock +
    +
    + 53 + +
    + + + PreCheckEnable bool `mapstructure:"PreCheckEnable"` +
    +
    + 54 + +
    + + + // L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked +
    +
    + 55 + +
    + + + // it can be: finalized, safe,pending or latest +
    +
    + 56 + +
    + + + L1PreSafeBlockPoint string `mapstructure:"L1PreSafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` +
    +
    + 57 + +
    + + + // L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point +
    +
    + 58 + +
    + + + // it can be positive or negative +
    +
    + 59 + +
    + + + // Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block +
    +
    + 60 + +
    + + + L1PreSafeBlockOffset int `mapstructure:"L1PreSafeBlockOffset"` +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + func (c *L1BlockCheckConfig) String() string { +
    +
    + 64 + +
    + + + return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enable, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart) +
    +
    + 65 + +
    + + + } +
    +
    + 66 + +
    + + +
    +
    +
    + 67 + +
    +   + // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') +
    +
    + 68 + +
    +   + type L1ParallelSynchronizationConfig struct { +
    +
    + 69 + +
    +   + // MaxClients Number of clients used to synchronize with L1 +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async.go + RENAMED + +
    +
    +
    +
    + + + + + - - -
    +
    @@ -0,0 +1,183 @@
    +
    @@ -142715,12 +144221,101850 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "sync" +
    +
    + 6 + +
    + + + "time" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 9 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + 11 + +
    + + + ) +
    +
    + 12 + +
    + + +
    +
    +
    + 13 + +
    + + + // L1BlockChecker is an interface that defines the method to check L1 blocks +
    +
    + 14 + +
    + + + type L1BlockChecker interface { +
    +
    + 15 + +
    + + + Step(ctx context.Context) error +
    +
    + 16 + +
    + + + } +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + const ( +
    +
    + 19 + +
    + + + defaultPeriodTime = time.Second +
    +
    + 20 + +
    + + + ) +
    +
    + 21 + +
    + + +
    +
    +
    + 22 + +
    + + + // AsyncCheck is a wrapper for L1BlockChecker to become asynchronous +
    +
    + 23 + +
    + + + type AsyncCheck struct { +
    +
    + 24 + +
    + + + checker L1BlockChecker +
    +
    + 25 + +
    + + + mutex sync.Mutex +
    +
    + 26 + +
    + + + lastResult *syncinterfaces.IterationResult +
    +
    + 27 + +
    + + + onFinishCall func() +
    +
    + 28 + +
    + + + periodTime time.Duration +
    +
    + 29 + +
    + + + // Wg is a wait group to wait for the result +
    +
    + 30 + +
    + + + Wg sync.WaitGroup +
    +
    + 31 + +
    + + + ctx context.Context +
    +
    + 32 + +
    + + + cancelCtx context.CancelFunc +
    +
    + 33 + +
    + + + isRunning bool +
    +
    + 34 + +
    + + + } +
    +
    + 35 + +
    + + +
    +
    +
    + 36 + +
    + + + // NewAsyncCheck creates a new AsyncCheck +
    +
    + 37 + +
    + + + func NewAsyncCheck(checker L1BlockChecker) *AsyncCheck { +
    +
    + 38 + +
    + + + return &AsyncCheck{ +
    +
    + 39 + +
    + + + checker: checker, +
    +
    + 40 + +
    + + + periodTime: defaultPeriodTime, +
    +
    + 41 + +
    + + + } +
    +
    + 42 + +
    + + + } +
    +
    + 43 + +
    + + +
    +
    +
    + 44 + +
    + + + // SetPeriodTime sets the period time between relaunch checker.Step +
    +
    + 45 + +
    + + + func (a *AsyncCheck) SetPeriodTime(periodTime time.Duration) { +
    +
    + 46 + +
    + + + a.periodTime = periodTime +
    +
    + 47 + +
    + + + } +
    +
    + 48 + +
    + + +
    +
    +
    + 49 + +
    + + + // Run is a method that starts the async check +
    +
    + 50 + +
    + + + func (a *AsyncCheck) Run(ctx context.Context, onFinish func()) { +
    +
    + 51 + +
    + + + a.mutex.Lock() +
    +
    + 52 + +
    + + + defer a.mutex.Unlock() +
    +
    + 53 + +
    + + + a.onFinishCall = onFinish +
    +
    + 54 + +
    + + + if a.isRunning { +
    +
    + 55 + +
    + + + log.Infof("%s L1BlockChecker: already running, changing onFinish call", logPrefix) +
    +
    + 56 + +
    + + + return +
    +
    + 57 + +
    + + + } +
    +
    + 58 + +
    + + + a.lastResult = nil +
    +
    + 59 + +
    + + + a.ctx, a.cancelCtx = context.WithCancel(ctx) +
    +
    + 60 + +
    + + + a.launchChecker(a.ctx) +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + // Stop is a method that stops the async check +
    +
    + 64 + +
    + + + func (a *AsyncCheck) Stop() { +
    +
    + 65 + +
    + + + a.cancelCtx() +
    +
    + 66 + +
    + + + a.Wg.Wait() +
    +
    + 67 + +
    + + + } +
    +
    + 68 + +
    + + +
    +
    +
    + 69 + +
    + + + // RunSynchronous is a method that forces the check to be synchronous before starting the async check +
    +
    + 70 + +
    + + + func (a *AsyncCheck) RunSynchronous(ctx context.Context) syncinterfaces.IterationResult { +
    +
    + 71 + +
    + + + return a.executeIteration(ctx) +
    +
    + 72 + +
    + + + } +
    +
    + 73 + +
    + + +
    +
    +
    + 74 + +
    + + + // GetResult returns the last result of the check: +
    +
    + 75 + +
    + + + // - Nil -> still running +
    +
    + 76 + +
    + + + // - Not nil -> finished, and this is the result. You must call again Run to start a new check +
    +
    + 77 + +
    + + + func (a *AsyncCheck) GetResult() *syncinterfaces.IterationResult { +
    +
    + 78 + +
    + + + a.mutex.Lock() +
    +
    + 79 + +
    + + + defer a.mutex.Unlock() +
    +
    + 80 + +
    + + + return a.lastResult +
    +
    + 81 + +
    + + + } +
    +
    + 82 + +
    + + +
    +
    +
    + 83 + +
    + + + // https://stackoverflow.com/questions/32840687/timeout-for-waitgroup-wait +
    +
    + 84 + +
    + + + // waitTimeout waits for the waitgroup for the specified max timeout. +
    +
    + 85 + +
    + + + // Returns true if waiting timed out. +
    +
    + 86 + +
    + + + func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { +
    +
    + 87 + +
    + + + c := make(chan struct{}) +
    +
    + 88 + +
    + + + go func() { +
    +
    + 89 + +
    + + + defer close(c) +
    +
    + 90 + +
    + + + wg.Wait() +
    +
    + 91 + +
    + + + }() +
    +
    + 92 + +
    + + + select { +
    +
    + 93 + +
    + + + case <-c: +
    +
    + 94 + +
    + + + return false // completed normally +
    +
    + 95 + +
    + + + case <-time.After(timeout): +
    +
    + 96 + +
    + + + return true // timed out +
    +
    + 97 + +
    + + + } +
    +
    + 98 + +
    + + + } +
    +
    + 99 + +
    + + +
    +
    +
    + 100 + +
    + + + // GetResultBlockingUntilAvailable wait the time specific in timeout, if reach timeout returns current +
    +
    + 101 + +
    + + + // result, if not, wait until the result is available. +
    +
    + 102 + +
    + + + // if timeout is 0, it waits indefinitely +
    +
    + 103 + +
    + + + func (a *AsyncCheck) GetResultBlockingUntilAvailable(timeout time.Duration) *syncinterfaces.IterationResult { +
    +
    + 104 + +
    + + + if timeout == 0 { +
    +
    + 105 + +
    + + + a.Wg.Wait() +
    +
    + 106 + +
    + + + } else { +
    +
    + 107 + +
    + + + waitTimeout(&a.Wg, timeout) +
    +
    + 108 + +
    + + + } +
    +
    + 109 + +
    + + + return a.GetResult() +
    +
    + 110 + +
    + + + } +
    +
    + 111 + +
    + + +
    +
    +
    + 112 + +
    + + + func (a *AsyncCheck) setResult(result syncinterfaces.IterationResult) { +
    +
    + 113 + +
    + + + a.mutex.Lock() +
    +
    + 114 + +
    + + + defer a.mutex.Unlock() +
    +
    + 115 + +
    + + + a.lastResult = &result +
    +
    + 116 + +
    + + + } +
    +
    + 117 + +
    + + +
    +
    +
    + 118 + +
    + + + func (a *AsyncCheck) launchChecker(ctx context.Context) { +
    +
    + 119 + +
    + + + // add waitGroup to wait for a result +
    +
    + 120 + +
    + + + a.Wg.Add(1) +
    +
    + 121 + +
    + + + a.isRunning = true +
    +
    + 122 + +
    + + + go func() { +
    +
    + 123 + +
    + + + log.Infof("%s L1BlockChecker: starting background process", logPrefix) +
    +
    + 124 + +
    + + + for { +
    +
    + 125 + +
    + + + result := a.step(ctx) +
    +
    + 126 + +
    + + + if result != nil { +
    +
    + 127 + +
    + + + a.setResult(*result) +
    +
    + 128 + +
    + + + // Result is set wg is done +
    +
    + 129 + +
    + + + break +
    +
    + 130 + +
    + + + } +
    +
    + 131 + +
    + + + } +
    +
    + 132 + +
    + + + log.Infof("%s L1BlockChecker: finished background process", logPrefix) +
    +
    + 133 + +
    + + + a.Wg.Done() +
    +
    + 134 + +
    + + + a.mutex.Lock() +
    +
    + 135 + +
    + + + onFinishCall := a.onFinishCall +
    +
    + 136 + +
    + + + a.isRunning = false +
    +
    + 137 + +
    + + + a.mutex.Unlock() +
    +
    + 138 + +
    + + + // call onFinish function with no mutex +
    +
    + 139 + +
    + + + if onFinishCall != nil { +
    +
    + 140 + +
    + + + onFinishCall() +
    +
    + 141 + +
    + + + } +
    +
    + 142 + +
    + + + }() +
    +
    + 143 + +
    + + + } +
    +
    + 144 + +
    + + +
    +
    +
    + 145 + +
    + + + // step is a method that executes until executeItertion +
    +
    + 146 + +
    + + + // returns an error or a reorg +
    +
    + 147 + +
    + + + func (a *AsyncCheck) step(ctx context.Context) *syncinterfaces.IterationResult { +
    +
    + 148 + +
    + + + select { +
    +
    + 149 + +
    + + + case <-ctx.Done(): +
    +
    + 150 + +
    + + + log.Debugf("%s L1BlockChecker: context done", logPrefix) +
    +
    + 151 + +
    + + + return &syncinterfaces.IterationResult{Err: ctx.Err()} +
    +
    + 152 + +
    + + + default: +
    +
    + 153 + +
    + + + result := a.executeIteration(ctx) +
    +
    + 154 + +
    + + + if result.ReorgDetected { +
    +
    + 155 + +
    + + + return &result +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + + log.Debugf("%s L1BlockChecker:returned %s waiting %s to relaunch", logPrefix, result.String(), a.periodTime) +
    +
    + 158 + +
    + + + time.Sleep(a.periodTime) +
    +
    + 159 + +
    + + + } +
    +
    + 160 + +
    + + + return nil +
    +
    + 161 + +
    + + + } +
    +
    + 162 + +
    + + +
    +
    +
    + 163 + +
    + + + // executeIteration executes a single iteration of the checker +
    +
    + 164 + +
    + + + func (a *AsyncCheck) executeIteration(ctx context.Context) syncinterfaces.IterationResult { +
    +
    + 165 + +
    + + + res := syncinterfaces.IterationResult{} +
    +
    + 166 + +
    + + + log.Debugf("%s calling checker.Step(...)", logPrefix) +
    +
    + 167 + +
    + + + res.Err = a.checker.Step(ctx) +
    +
    + 168 + +
    + + + log.Debugf("%s returned checker.Step(...) %w", logPrefix, res.Err) +
    +
    + 169 + +
    + + + if res.Err != nil { +
    +
    + 170 + +
    + + + log.Errorf("%s Fail check L1 Blocks: %w", logPrefix, res.Err) +
    +
    + 171 + +
    + + + if common.IsReorgError(res.Err) { +
    +
    + 172 + +
    + + + // log error +
    +
    + 173 + +
    + + + blockNumber := common.GetReorgErrorBlockNumber(res.Err) +
    +
    + 174 + +
    + + + log.Infof("%s Reorg detected at block %d", logPrefix, blockNumber) +
    +
    + 175 + +
    + + + // It keeps blocked until the channel is read +
    +
    + 176 + +
    + + + res.BlockNumber = blockNumber +
    +
    + 177 + +
    + + + res.ReorgDetected = true +
    +
    + 178 + +
    + + + res.ReorgMessage = res.Err.Error() +
    +
    + 179 + +
    + + + res.Err = nil +
    +
    + 180 + +
    + + + } +
    +
    + 181 + +
    + + + } +
    +
    + 182 + +
    + + + return res +
    +
    + 183 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,138 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block_test +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "fmt" +
    +
    + 6 + +
    + + + "sync" +
    +
    + 7 + +
    + + + "testing" +
    +
    + 8 + +
    + + + "time" +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 11 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 12 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 13 + +
    + + + ) +
    +
    + 14 + +
    + + +
    +
    +
    + 15 + +
    + + + var ( +
    +
    + 16 + +
    + + + errGenericToTestAsync = fmt.Errorf("error_async") +
    +
    + 17 + +
    + + + errReorgToTestAsync = common.NewReorgError(uint64(1234), fmt.Errorf("fake reorg to test")) +
    +
    + 18 + +
    + + + timeoutContextForAsyncTests = time.Second +
    +
    + 19 + +
    + + + ) +
    +
    + 20 + +
    + + +
    +
    +
    + 21 + +
    + + + type mockChecker struct { +
    +
    + 22 + +
    + + + Wg *sync.WaitGroup +
    +
    + 23 + +
    + + + ErrorsToReturn []error +
    +
    + 24 + +
    + + + } +
    +
    + 25 + +
    + + +
    +
    +
    + 26 + +
    + + + func (m *mockChecker) Step(ctx context.Context) error { +
    +
    + 27 + +
    + + + defer m.Wg.Done() +
    +
    + 28 + +
    + + + err := m.ErrorsToReturn[0] +
    +
    + 29 + +
    + + + if len(m.ErrorsToReturn) > 0 { +
    +
    + 30 + +
    + + + m.ErrorsToReturn = m.ErrorsToReturn[1:] +
    +
    + 31 + +
    + + + } +
    +
    + 32 + +
    + + + return err +
    +
    + 33 + +
    + + + } +
    +
    + 34 + +
    + + +
    +
    +
    + 35 + +
    + + + // If checker.step() returns ok, the async object will relaunch the call +
    +
    + 36 + +
    + + + func TestAsyncRelaunchCheckerUntilReorgDetected(t *testing.T) { +
    +
    + 37 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 38 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 39 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 40 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 41 + +
    + + + defer cancel() +
    +
    + 42 + +
    + + + mockChecker.Wg.Add(4) +
    +
    + 43 + +
    + + +
    +
    +
    + 44 + +
    + + + sut.Run(ctx, nil) +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + mockChecker.Wg.Wait() +
    +
    + 47 + +
    + + + result := sut.GetResultBlockingUntilAvailable(0) +
    +
    + 48 + +
    + + + require.NotNil(t, result) +
    +
    + 49 + +
    + + + require.Equal(t, uint64(1234), result.BlockNumber) +
    +
    + 50 + +
    + + + require.Equal(t, true, result.ReorgDetected) +
    +
    + 51 + +
    + + + require.Equal(t, nil, result.Err) +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + +
    +
    +
    + 54 + +
    + + + func TestAsyncGetResultIsNilUntilStops(t *testing.T) { +
    +
    + 55 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 56 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 57 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 58 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 59 + +
    + + + defer cancel() +
    +
    + 60 + +
    + + + mockChecker.Wg.Add(4) +
    +
    + 61 + +
    + + + require.Nil(t, sut.GetResult(), "before start result is Nil") +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + sut.Run(ctx, nil) +
    +
    + 64 + +
    + + +
    +
    +
    + 65 + +
    + + + require.Nil(t, sut.GetResult(), "after start result is Nil") +
    +
    + 66 + +
    + + + mockChecker.Wg.Wait() +
    +
    + 67 + +
    + + + result := sut.GetResultBlockingUntilAvailable(0) +
    +
    + 68 + +
    + + + require.NotNil(t, result) +
    +
    + 69 + +
    + + + } +
    +
    + 70 + +
    + + +
    +
    +
    + 71 + +
    + + + // RunSynchronous it returns the first result, doesnt mind if a reorg or not +
    +
    + 72 + +
    + + + func TestAsyncGRunSynchronousReturnTheFirstResult(t *testing.T) { +
    +
    + 73 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 74 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 75 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 76 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 77 + +
    + + + defer cancel() +
    +
    + 78 + +
    + + + mockChecker.Wg.Add(1) +
    +
    + 79 + +
    + + +
    +
    +
    + 80 + +
    + + + result := sut.RunSynchronous(ctx) +
    +
    + 81 + +
    + + +
    +
    +
    + 82 + +
    + + + require.NotNil(t, result) +
    +
    + 83 + +
    + + + require.Equal(t, uint64(0), result.BlockNumber) +
    +
    + 84 + +
    + + + require.Equal(t, false, result.ReorgDetected) +
    +
    + 85 + +
    + + + require.Equal(t, errGenericToTestAsync, result.Err) +
    +
    + 86 + +
    + + + } +
    +
    + 87 + +
    + + +
    +
    +
    + 88 + +
    + + + func TestAsyncGRunSynchronousDontAffectGetResult(t *testing.T) { +
    +
    + 89 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 90 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 91 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 92 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 93 + +
    + + + defer cancel() +
    +
    + 94 + +
    + + + mockChecker.Wg.Add(1) +
    +
    + 95 + +
    + + +
    +
    +
    + 96 + +
    + + + result := sut.RunSynchronous(ctx) +
    +
    + 97 + +
    + + +
    +
    +
    + 98 + +
    + + + require.NotNil(t, result) +
    +
    + 99 + +
    + + + require.Nil(t, sut.GetResult()) +
    +
    + 100 + +
    + + + } +
    +
    + 101 + +
    + + +
    +
    +
    + 102 + +
    + + + func TestAsyncStop(t *testing.T) { +
    +
    + 103 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 104 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 105 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 106 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 107 + +
    + + + defer cancel() +
    +
    + 108 + +
    + + + require.Nil(t, sut.GetResult(), "before start result is Nil") +
    +
    + 109 + +
    + + + mockChecker.Wg.Add(4) +
    +
    + 110 + +
    + + + sut.Run(ctx, nil) +
    +
    + 111 + +
    + + + sut.Stop() +
    +
    + 112 + +
    + + + sut.Stop() +
    +
    + 113 + +
    + + +
    +
    +
    + 114 + +
    + + + result := sut.GetResultBlockingUntilAvailable(0) +
    +
    + 115 + +
    + + + require.NotNil(t, result) +
    +
    + 116 + +
    + + + mockChecker.Wg = &sync.WaitGroup{} +
    +
    + 117 + +
    + + + mockChecker.Wg.Add(4) +
    +
    + 118 + +
    + + + mockChecker.ErrorsToReturn = []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync} +
    +
    + 119 + +
    + + + sut.Run(ctx, nil) +
    +
    + 120 + +
    + + + mockChecker.Wg.Wait() +
    +
    + 121 + +
    + + + result = sut.GetResultBlockingUntilAvailable(0) +
    +
    + 122 + +
    + + + require.NotNil(t, result) +
    +
    + 123 + +
    + + + } +
    +
    + 124 + +
    + + +
    +
    +
    + 125 + +
    + + + func TestAsyncMultipleRun(t *testing.T) { +
    +
    + 126 + +
    + + + mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    + 127 + +
    + + + sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    + 128 + +
    + + + sut.SetPeriodTime(0) +
    +
    + 129 + +
    + + + ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    + 130 + +
    + + + defer cancel() +
    +
    + 131 + +
    + + + require.Nil(t, sut.GetResult(), "before start result is Nil") +
    +
    + 132 + +
    + + + mockChecker.Wg.Add(4) +
    +
    + 133 + +
    + + + sut.Run(ctx, nil) +
    +
    + 134 + +
    + + + sut.Run(ctx, nil) +
    +
    + 135 + +
    + + + sut.Run(ctx, nil) +
    +
    + 136 + +
    + + + result := sut.GetResultBlockingUntilAvailable(0) +
    +
    + 137 + +
    + + + require.NotNil(t, result) +
    +
    + 138 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,146 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "errors" +
    +
    + 6 + +
    + + + "fmt" +
    +
    + 7 + +
    + + + "math/big" +
    +
    + 8 + +
    + + + "time" +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 11 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 12 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 14 + +
    + + + "github.com/jackc/pgx/v4" +
    +
    + 15 + +
    + + + ) +
    +
    + 16 + +
    + + +
    +
    +
    + 17 + +
    + + + // This object check old L1block to double-check that the L1block hash is correct +
    +
    + 18 + +
    + + + // - Get first not checked block +
    +
    + 19 + +
    + + + // - Get last block on L1 (safe/finalized/ or minus -n) +
    +
    + 20 + +
    + + +
    +
    +
    + 21 + +
    + + + // L1Requester is an interface for GETH client +
    +
    + 22 + +
    + + + type L1Requester interface { +
    +
    + 23 + +
    + + + HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) +
    +
    + 24 + +
    + + + } +
    +
    + 25 + +
    + + +
    +
    +
    + 26 + +
    + + + // StateInterfacer is an interface for the state +
    +
    + 27 + +
    + + + type StateInterfacer interface { +
    +
    + 28 + +
    + + + GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    + 29 + +
    + + + UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error +
    +
    + 30 + +
    + + + } +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + // SafeL1BlockNumberFetcher is an interface for fetching the L1 block number reference point (safe, finalized,...) +
    +
    + 33 + +
    + + + type SafeL1BlockNumberFetcher interface { +
    +
    + 34 + +
    + + + GetSafeBlockNumber(ctx context.Context, l1Client L1Requester) (uint64, error) +
    +
    + 35 + +
    + + + Description() string +
    +
    + 36 + +
    + + + } +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + // CheckL1BlockHash is a struct that implements a checker of L1Block hash +
    +
    + 39 + +
    + + + type CheckL1BlockHash struct { +
    +
    + 40 + +
    + + + L1Client L1Requester +
    +
    + 41 + +
    + + + State StateInterfacer +
    +
    + 42 + +
    + + + SafeBlockNumberFetcher SafeL1BlockNumberFetcher +
    +
    + 43 + +
    + + + } +
    +
    + 44 + +
    + + +
    +
    +
    + 45 + +
    + + + // NewCheckL1BlockHash creates a new CheckL1BlockHash +
    +
    + 46 + +
    + + + func NewCheckL1BlockHash(l1Client L1Requester, state StateInterfacer, safeBlockNumberFetcher SafeL1BlockNumberFetcher) *CheckL1BlockHash { +
    +
    + 47 + +
    + + + return &CheckL1BlockHash{ +
    +
    + 48 + +
    + + + L1Client: l1Client, +
    +
    + 49 + +
    + + + State: state, +
    +
    + 50 + +
    + + + SafeBlockNumberFetcher: safeBlockNumberFetcher, +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + +
    +
    +
    + 54 + +
    + + + // Name is a method that returns the name of the checker +
    +
    + 55 + +
    + + + func (p *CheckL1BlockHash) Name() string { +
    +
    + 56 + +
    + + + return logPrefix + " main_checker: " +
    +
    + 57 + +
    + + + } +
    +
    + 58 + +
    + + +
    +
    +
    + 59 + +
    + + + // Step is a method that checks the L1 block hash, run until all blocks are checked and returns +
    +
    + 60 + +
    + + + func (p *CheckL1BlockHash) Step(ctx context.Context) error { +
    +
    + 61 + +
    + + + stateBlock, err := p.State.GetFirstUncheckedBlock(ctx, uint64(0), nil) +
    +
    + 62 + +
    + + + if errors.Is(err, state.ErrNotFound) { +
    +
    + 63 + +
    + + + log.Debugf("%s: No unchecked blocks to check", p.Name()) +
    +
    + 64 + +
    + + + return nil +
    +
    + 65 + +
    + + + } +
    +
    + 66 + +
    + + + if err != nil { +
    +
    + 67 + +
    + + + return err +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + + if stateBlock == nil { +
    +
    + 70 + +
    + + + log.Warnf("%s: function CheckL1Block receive a nil pointer", p.Name()) +
    +
    + 71 + +
    + + + return nil +
    +
    + 72 + +
    + + + } +
    +
    + 73 + +
    + + + safeBlockNumber, err := p.SafeBlockNumberFetcher.GetSafeBlockNumber(ctx, p.L1Client) +
    +
    + 74 + +
    + + + if err != nil { +
    +
    + 75 + +
    + + + return err +
    +
    + 76 + +
    + + + } +
    +
    + 77 + +
    + + + log.Debugf("%s: checking from block (%s) %d first block to check: %d....", p.Name(), p.SafeBlockNumberFetcher.Description(), safeBlockNumber, stateBlock.BlockNumber) +
    +
    + 78 + +
    + + + return p.doAllBlocks(ctx, *stateBlock, safeBlockNumber) +
    +
    + 79 + +
    + + + } +
    +
    + 80 + +
    + + +
    +
    +
    + 81 + +
    + + + func (p *CheckL1BlockHash) doAllBlocks(ctx context.Context, firstStateBlock state.Block, safeBlockNumber uint64) error { +
    +
    + 82 + +
    + + + var err error +
    +
    + 83 + +
    + + + startTime := time.Now() +
    +
    + 84 + +
    + + + stateBlock := &firstStateBlock +
    +
    + 85 + +
    + + + numBlocksChecked := 0 +
    +
    + 86 + +
    + + + for { +
    +
    + 87 + +
    + + + lastStateBlockNumber := stateBlock.BlockNumber +
    +
    + 88 + +
    + + + if stateBlock.BlockNumber > safeBlockNumber { +
    +
    + 89 + +
    + + + log.Debugf("%s: block %d to check is not still safe enough (%s) %d ", p.Name(), stateBlock.BlockNumber, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, logPrefix) +
    +
    + 90 + +
    + + + return nil +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + + err = p.doBlock(ctx, stateBlock) +
    +
    + 93 + +
    + + + if err != nil { +
    +
    + 94 + +
    + + + return err +
    +
    + 95 + +
    + + + } +
    +
    + 96 + +
    + + + numBlocksChecked++ +
    +
    + 97 + +
    + + + stateBlock, err = p.State.GetFirstUncheckedBlock(ctx, lastStateBlockNumber, nil) +
    +
    + 98 + +
    + + + if errors.Is(err, state.ErrNotFound) { +
    +
    + 99 + +
    + + + diff := time.Since(startTime) +
    +
    + 100 + +
    + + + log.Infof("%s: checked all blocks (%d) (using as safe Block Point(%s): %d) time:%s", p.Name(), numBlocksChecked, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, diff) +
    +
    + 101 + +
    + + + return nil +
    +
    + 102 + +
    + + + } +
    +
    + 103 + +
    + + + } +
    +
    + 104 + +
    + + + } +
    +
    + 105 + +
    + + +
    +
    +
    + 106 + +
    + + + func (p *CheckL1BlockHash) doBlock(ctx context.Context, stateBlock *state.Block) error { +
    +
    + 107 + +
    + + + err := CheckBlockHash(ctx, stateBlock, p.L1Client, p.Name()) +
    +
    + 108 + +
    + + + if err != nil { +
    +
    + 109 + +
    + + + return err +
    +
    + 110 + +
    + + + } +
    +
    + 111 + +
    + + + log.Infof("%s: L1Block: %d hash: %s is correct marking as checked", p.Name(), stateBlock.BlockNumber, +
    +
    + 112 + +
    + + + stateBlock.BlockHash.String()) +
    +
    + 113 + +
    + + + err = p.State.UpdateCheckedBlockByNumber(ctx, stateBlock.BlockNumber, true, nil) +
    +
    + 114 + +
    + + + if err != nil { +
    +
    + 115 + +
    + + + log.Errorf("%s: Error updating block %d as checked. err: %s", p.Name(), stateBlock.BlockNumber, err.Error()) +
    +
    + 116 + +
    + + + return err +
    +
    + 117 + +
    + + + } +
    +
    + 118 + +
    + + + return nil +
    +
    + 119 + +
    + + + } +
    +
    + 120 + +
    + + +
    +
    +
    + 121 + +
    + + + // CheckBlockHash is a method that checks the L1 block hash +
    +
    + 122 + +
    + + + func CheckBlockHash(ctx context.Context, stateBlock *state.Block, L1Client L1Requester, checkerName string) error { +
    +
    + 123 + +
    + + + if stateBlock == nil { +
    +
    + 124 + +
    + + + log.Warn("%s function CheckL1Block receive a nil pointer", checkerName) +
    +
    + 125 + +
    + + + return nil +
    +
    + 126 + +
    + + + } +
    +
    + 127 + +
    + + + l1Block, err := L1Client.HeaderByNumber(ctx, big.NewInt(int64(stateBlock.BlockNumber))) +
    +
    + 128 + +
    + + + if err != nil { +
    +
    + 129 + +
    + + + return err +
    +
    + 130 + +
    + + + } +
    +
    + 131 + +
    + + + if l1Block == nil { +
    +
    + 132 + +
    + + + err = fmt.Errorf("%s request of block: %d to L1 returns a nil", checkerName, stateBlock.BlockNumber) +
    +
    + 133 + +
    + + + log.Error(err.Error()) +
    +
    + 134 + +
    + + + return err +
    +
    + 135 + +
    + + + } +
    +
    + 136 + +
    + + + if l1Block.Hash() != stateBlock.BlockHash { +
    +
    + 137 + +
    + + + msg := fmt.Sprintf("%s Reorg detected at block %d l1Block.Hash=%s != stateBlock.Hash=%s. ", checkerName, stateBlock.BlockNumber, +
    +
    + 138 + +
    + + + l1Block.Hash().String(), stateBlock.BlockHash.String()) +
    +
    + 139 + +
    + + + if l1Block.ParentHash != stateBlock.ParentHash { +
    +
    + 140 + +
    + + + msg += fmt.Sprintf(" ParentHash are also different. l1Block.ParentHash=%s != stateBlock.ParentHash=%s", l1Block.ParentHash.String(), stateBlock.ParentHash.String()) +
    +
    + 141 + +
    + + + } +
    +
    + 142 + +
    + + + log.Errorf(msg) +
    +
    + 143 + +
    + + + return common.NewReorgError(stateBlock.BlockNumber, fmt.Errorf(msg)) +
    +
    + 144 + +
    + + + } +
    +
    + 145 + +
    + + + return nil +
    +
    + 146 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,128 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block_test +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "fmt" +
    +
    + 6 + +
    + + + "math/big" +
    +
    + 7 + +
    + + + "testing" +
    +
    + 8 + +
    + + +
    +
    +
    + 9 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 10 + +
    + + + commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 11 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 12 + +
    + + + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 14 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 15 + +
    + + + "github.com/stretchr/testify/mock" +
    +
    + 16 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 17 + +
    + + + ) +
    +
    + 18 + +
    + + +
    +
    +
    + 19 + +
    + + + type testData struct { +
    +
    + 20 + +
    + + + mockL1Client *mock_l1_check_block.L1Requester +
    +
    + 21 + +
    + + + mockState *mock_l1_check_block.StateInterfacer +
    +
    + 22 + +
    + + + mockBlockNumberFetch *mock_l1_check_block.SafeL1BlockNumberFetcher +
    +
    + 23 + +
    + + + sut *l1_check_block.CheckL1BlockHash +
    +
    + 24 + +
    + + + ctx context.Context +
    +
    + 25 + +
    + + + stateBlock *state.Block +
    +
    + 26 + +
    + + + } +
    +
    + 27 + +
    + + +
    +
    +
    + 28 + +
    + + + func newTestData(t *testing.T) *testData { +
    +
    + 29 + +
    + + + mockL1Client := mock_l1_check_block.NewL1Requester(t) +
    +
    + 30 + +
    + + + mockState := mock_l1_check_block.NewStateInterfacer(t) +
    +
    + 31 + +
    + + + mockBlockNumberFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) +
    +
    + 32 + +
    + + + mockBlockNumberFetch.EXPECT().Description().Return("mock").Maybe() +
    +
    + 33 + +
    + + + sut := l1_check_block.NewCheckL1BlockHash(mockL1Client, mockState, mockBlockNumberFetch) +
    +
    + 34 + +
    + + + require.NotNil(t, sut) +
    +
    + 35 + +
    + + + ctx := context.Background() +
    +
    + 36 + +
    + + + return &testData{ +
    +
    + 37 + +
    + + + mockL1Client: mockL1Client, +
    +
    + 38 + +
    + + + mockState: mockState, +
    +
    + 39 + +
    + + + mockBlockNumberFetch: mockBlockNumberFetch, +
    +
    + 40 + +
    + + + sut: sut, +
    +
    + 41 + +
    + + + ctx: ctx, +
    +
    + 42 + +
    + + + stateBlock: &state.Block{ +
    +
    + 43 + +
    + + + BlockNumber: 1234, +
    +
    + 44 + +
    + + + BlockHash: common.HexToHash("0xb07e1289b32edefd8f3c702d016fb73c81d5950b2ebc790ad9d2cb8219066b4c"), +
    +
    + 45 + +
    + + + }, +
    +
    + 46 + +
    + + + } +
    +
    + 47 + +
    + + + } +
    +
    + 48 + +
    + + +
    +
    +
    + 49 + +
    + + + func TestCheckL1BlockHashNoBlocksOnDB(t *testing.T) { +
    +
    + 50 + +
    + + + data := newTestData(t) +
    +
    + 51 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, state.ErrNotFound) +
    +
    + 52 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 53 + +
    + + + require.NoError(t, res) +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + func TestCheckL1BlockHashErrorGettingFirstUncheckedBlockFromDB(t *testing.T) { +
    +
    + 57 + +
    + + + data := newTestData(t) +
    +
    + 58 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, fmt.Errorf("error")) +
    +
    + 59 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 60 + +
    + + + require.Error(t, res) +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + func TestCheckL1BlockHashErrorGettingGetSafeBlockNumber(t *testing.T) { +
    +
    + 64 + +
    + + + data := newTestData(t) +
    +
    + 65 + +
    + + +
    +
    +
    + 66 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    + 67 + +
    + + + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(0), fmt.Errorf("error")) +
    +
    + 68 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 69 + +
    + + + require.Error(t, res) +
    +
    + 70 + +
    + + + } +
    +
    + 71 + +
    + + +
    +
    +
    + 72 + +
    + + + // The first block to check is below the safe point, nothing to do +
    +
    + 73 + +
    + + + func TestCheckL1BlockHashSafePointIsInFuture(t *testing.T) { +
    +
    + 74 + +
    + + + data := newTestData(t) +
    +
    + 75 + +
    + + +
    +
    +
    + 76 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    + 77 + +
    + + + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber-1, nil) +
    +
    + 78 + +
    + + +
    +
    +
    + 79 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 80 + +
    + + + require.NoError(t, res) +
    +
    + 81 + +
    + + + } +
    +
    + 82 + +
    + + +
    +
    +
    + 83 + +
    + + + func TestCheckL1BlockHashL1ClientReturnsANil(t *testing.T) { +
    +
    + 84 + +
    + + + data := newTestData(t) +
    +
    + 85 + +
    + + +
    +
    +
    + 86 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    + 87 + +
    + + + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber+10, nil) +
    +
    + 88 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(nil, nil) +
    +
    + 89 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 90 + +
    + + + require.Error(t, res) +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + +
    +
    +
    + 93 + +
    + + + // Check a block that is OK +
    +
    + 94 + +
    + + + func TestCheckL1BlockHashMatchHashUpdateCheckMarkOnDB(t *testing.T) { +
    +
    + 95 + +
    + + + data := newTestData(t) +
    +
    + 96 + +
    + + +
    +
    +
    + 97 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    + 98 + +
    + + + data.mockBlockNumberFetch.EXPECT().Description().Return("mock") +
    +
    + 99 + +
    + + + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) +
    +
    + 100 + +
    + + + l1Block := &types.Header{ +
    +
    + 101 + +
    + + + Number: big.NewInt(100), +
    +
    + 102 + +
    + + + } +
    +
    + 103 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) +
    +
    + 104 + +
    + + + data.mockState.EXPECT().UpdateCheckedBlockByNumber(data.ctx, data.stateBlock.BlockNumber, true, nil).Return(nil) +
    +
    + 105 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, mock.Anything, nil).Return(nil, state.ErrNotFound) +
    +
    + 106 + +
    + + +
    +
    +
    + 107 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 108 + +
    + + + require.NoError(t, res) +
    +
    + 109 + +
    + + + } +
    +
    + 110 + +
    + + +
    +
    +
    + 111 + +
    + + + // The first block to check is equal to the safe point, must be processed +
    +
    + 112 + +
    + + + func TestCheckL1BlockHashMismatch(t *testing.T) { +
    +
    + 113 + +
    + + + data := newTestData(t) +
    +
    + 114 + +
    + + +
    +
    +
    + 115 + +
    + + + data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    + 116 + +
    + + + data.stateBlock.BlockHash = common.HexToHash("0x1234") // Wrong hash to trigger a mismatch +
    +
    + 117 + +
    + + + data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) +
    +
    + 118 + +
    + + + l1Block := &types.Header{ +
    +
    + 119 + +
    + + + Number: big.NewInt(100), +
    +
    + 120 + +
    + + + } +
    +
    + 121 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) +
    +
    + 122 + +
    + + +
    +
    +
    + 123 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 124 + +
    + + + require.Error(t, res) +
    +
    + 125 + +
    + + + resErr, ok := res.(*commonsync.ReorgError) +
    +
    + 126 + +
    + + + require.True(t, ok) +
    +
    + 127 + +
    + + + require.Equal(t, data.stateBlock.BlockNumber, resErr.BlockNumber) +
    +
    + 128 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/common.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,5 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + const ( +
    +
    + 4 + +
    + + + logPrefix = "checkL1block:" +
    +
    + 5 + +
    + + + ) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,205 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "time" +
    +
    + 6 + +
    + + +
    +
    +
    + 7 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 9 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + 10 + +
    + + + "github.com/jackc/pgx/v4" +
    +
    + 11 + +
    + + + ) +
    +
    + 12 + +
    + + +
    +
    +
    + 13 + +
    + + + // StateForL1BlockCheckerIntegration is an interface for the state +
    +
    + 14 + +
    + + + type StateForL1BlockCheckerIntegration interface { +
    +
    + 15 + +
    + + + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    + 16 + +
    + + + } +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + // L1BlockCheckerIntegration is a struct that integrates the L1BlockChecker with the synchronizer +
    +
    + 19 + +
    + + + type L1BlockCheckerIntegration struct { +
    +
    + 20 + +
    + + + forceCheckOnStart bool +
    +
    + 21 + +
    + + + checker syncinterfaces.AsyncL1BlockChecker +
    +
    + 22 + +
    + + + preChecker syncinterfaces.AsyncL1BlockChecker +
    +
    + 23 + +
    + + + state StateForL1BlockCheckerIntegration +
    +
    + 24 + +
    + + + sync SyncCheckReorger +
    +
    + 25 + +
    + + + timeBetweenRetries time.Duration +
    +
    + 26 + +
    + + + } +
    +
    + 27 + +
    + + +
    +
    +
    + 28 + +
    + + + // SyncCheckReorger is an interface that defines the methods required from Synchronizer object +
    +
    + 29 + +
    + + + type SyncCheckReorger interface { +
    +
    + 30 + +
    + + + ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error +
    +
    + 31 + +
    + + + OnDetectedMismatchL1BlockReorg() +
    +
    + 32 + +
    + + + } +
    +
    + 33 + +
    + + +
    +
    +
    + 34 + +
    + + + // NewL1BlockCheckerIntegration creates a new L1BlockCheckerIntegration +
    +
    + 35 + +
    + + + func NewL1BlockCheckerIntegration(checker syncinterfaces.AsyncL1BlockChecker, preChecker syncinterfaces.AsyncL1BlockChecker, state StateForL1BlockCheckerIntegration, sync SyncCheckReorger, forceCheckOnStart bool, timeBetweenRetries time.Duration) *L1BlockCheckerIntegration { +
    +
    + 36 + +
    + + + return &L1BlockCheckerIntegration{ +
    +
    + 37 + +
    + + + forceCheckOnStart: forceCheckOnStart, +
    +
    + 38 + +
    + + + checker: checker, +
    +
    + 39 + +
    + + + preChecker: preChecker, +
    +
    + 40 + +
    + + + state: state, +
    +
    + 41 + +
    + + + sync: sync, +
    +
    + 42 + +
    + + + timeBetweenRetries: timeBetweenRetries, +
    +
    + 43 + +
    + + + } +
    +
    + 44 + +
    + + + } +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + // OnStart is a method that is called before starting the synchronizer +
    +
    + 47 + +
    + + + func (v *L1BlockCheckerIntegration) OnStart(ctx context.Context) error { +
    +
    + 48 + +
    + + + if v.forceCheckOnStart { +
    +
    + 49 + +
    + + + log.Infof("%s Forcing L1BlockChecker check before start", logPrefix) +
    +
    + 50 + +
    + + + result := v.runCheckerSync(ctx, v.checker) +
    +
    + 51 + +
    + + + if result.ReorgDetected { +
    +
    + 52 + +
    + + + v.executeResult(ctx, result) +
    +
    + 53 + +
    + + + } else { +
    +
    + 54 + +
    + + + log.Infof("%s Forcing L1BlockChecker check:OK ", logPrefix) +
    +
    + 55 + +
    + + + if v.preChecker != nil { +
    +
    + 56 + +
    + + + log.Infof("%s Forcing L1BlockChecker preCheck before start", logPrefix) +
    +
    + 57 + +
    + + + result = v.runCheckerSync(ctx, v.preChecker) +
    +
    + 58 + +
    + + + if result.ReorgDetected { +
    +
    + 59 + +
    + + + v.executeResult(ctx, result) +
    +
    + 60 + +
    + + + } else { +
    +
    + 61 + +
    + + + log.Infof("%s Forcing L1BlockChecker preCheck:OK", logPrefix) +
    +
    + 62 + +
    + + + } +
    +
    + 63 + +
    + + + } +
    +
    + 64 + +
    + + + } +
    +
    + 65 + +
    + + + } +
    +
    + 66 + +
    + + + v.launch(ctx) +
    +
    + 67 + +
    + + + return nil +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + +
    +
    +
    + 70 + +
    + + + func (v *L1BlockCheckerIntegration) runCheckerSync(ctx context.Context, checker syncinterfaces.AsyncL1BlockChecker) syncinterfaces.IterationResult { +
    +
    + 71 + +
    + + + for { +
    +
    + 72 + +
    + + + result := checker.RunSynchronous(ctx) +
    +
    + 73 + +
    + + + if result.Err == nil { +
    +
    + 74 + +
    + + + return result +
    +
    + 75 + +
    + + + } else { +
    +
    + 76 + +
    + + + time.Sleep(v.timeBetweenRetries) +
    +
    + 77 + +
    + + + } +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + + } +
    +
    + 80 + +
    + + +
    +
    +
    + 81 + +
    + + + // OnStartL1Sync is a method that is called before starting the L1 sync +
    +
    + 82 + +
    + + + func (v *L1BlockCheckerIntegration) OnStartL1Sync(ctx context.Context) bool { +
    +
    + 83 + +
    + + + return v.checkBackgroundResult(ctx, "before start L1 sync") +
    +
    + 84 + +
    + + + } +
    +
    + 85 + +
    + + +
    +
    +
    + 86 + +
    + + + // OnStartL2Sync is a method that is called before starting the L2 sync +
    +
    + 87 + +
    + + + func (v *L1BlockCheckerIntegration) OnStartL2Sync(ctx context.Context) bool { +
    +
    + 88 + +
    + + + return v.checkBackgroundResult(ctx, "before start 2 sync") +
    +
    + 89 + +
    + + + } +
    +
    + 90 + +
    + + +
    +
    +
    + 91 + +
    + + + // OnResetState is a method that is called after a resetState +
    +
    + 92 + +
    + + + func (v *L1BlockCheckerIntegration) OnResetState(ctx context.Context) { +
    +
    + 93 + +
    + + + log.Infof("%s L1BlockChecker: after a resetState relaunch background process", logPrefix) +
    +
    + 94 + +
    + + + v.launch(ctx) +
    +
    + 95 + +
    + + + } +
    +
    + 96 + +
    + + +
    +
    +
    + 97 + +
    + + + // CheckReorgWrapper is a wrapper over reorg function of synchronizer. +
    +
    + 98 + +
    + + + // it checks the result of the function and the result of background process and decides which return +
    +
    + 99 + +
    + + + func (v *L1BlockCheckerIntegration) CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) { +
    +
    + 100 + +
    + + + resultBackground := v.getMergedResults() +
    +
    + 101 + +
    + + + if resultBackground != nil && resultBackground.ReorgDetected { +
    +
    + 102 + +
    + + + // Background process detected a reorg, decide which return +
    +
    + 103 + +
    + + + firstOkBlockBackgroundCheck, err := v.state.GetPreviousBlockToBlockNumber(ctx, resultBackground.BlockNumber, nil) +
    +
    + 104 + +
    + + + if err != nil { +
    +
    + 105 + +
    + + + log.Warnf("%s Error getting previous block to block number where a reorg have been detected %d: %s. So we reorgFunc values", logPrefix, resultBackground.BlockNumber, err) +
    +
    + 106 + +
    + + + return reorgFirstBlockOk, errReportedByReorgFunc +
    +
    + 107 + +
    + + + } +
    +
    + 108 + +
    + + + if reorgFirstBlockOk == nil || errReportedByReorgFunc != nil { +
    +
    + 109 + +
    + + + log.Infof("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function no. Returning it", logPrefix, +
    +
    + 110 + +
    + + + resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) +
    +
    + 111 + +
    + + + return firstOkBlockBackgroundCheck, nil +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + + if firstOkBlockBackgroundCheck.BlockNumber < reorgFirstBlockOk.BlockNumber { +
    +
    + 114 + +
    + + + // Background process detected a reorg at oldest block +
    +
    + 115 + +
    + + + log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Returning from %d", +
    +
    + 116 + +
    + + + logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) +
    +
    + 117 + +
    + + + return firstOkBlockBackgroundCheck, nil +
    +
    + 118 + +
    + + + } else { +
    +
    + 119 + +
    + + + // Regular reorg function detected a reorg at oldest block +
    +
    + 120 + +
    + + + log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Executing from %d", +
    +
    + 121 + +
    + + + logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, reorgFirstBlockOk.BlockNumber) +
    +
    + 122 + +
    + + + return reorgFirstBlockOk, errReportedByReorgFunc +
    +
    + 123 + +
    + + + } +
    +
    + 124 + +
    + + + } +
    +
    + 125 + +
    + + + if resultBackground != nil && !resultBackground.ReorgDetected { +
    +
    + 126 + +
    + + + // Relaunch checker, if there is a reorg, It is going to be relaunched after (OnResetState) +
    +
    + 127 + +
    + + + v.launch(ctx) +
    +
    + 128 + +
    + + + } +
    +
    + 129 + +
    + + + // Background process doesnt have anything to we return the regular reorg function result +
    +
    + 130 + +
    + + + return reorgFirstBlockOk, errReportedByReorgFunc +
    +
    + 131 + +
    + + + } +
    +
    + 132 + +
    + + +
    +
    +
    + 133 + +
    + + + func (v *L1BlockCheckerIntegration) checkBackgroundResult(ctx context.Context, positionMessage string) bool { +
    +
    + 134 + +
    + + + log.Debugf("%s Checking L1BlockChecker %s", logPrefix, positionMessage) +
    +
    + 135 + +
    + + + result := v.getMergedResults() +
    +
    + 136 + +
    + + + if result != nil { +
    +
    + 137 + +
    + + + if result.ReorgDetected { +
    +
    + 138 + +
    + + + log.Warnf("%s Checking L1BlockChecker %s: reorg detected %s", logPrefix, positionMessage, result.String()) +
    +
    + 139 + +
    + + + v.executeResult(ctx, *result) +
    +
    + 140 + +
    + + + } +
    +
    + 141 + +
    + + + v.launch(ctx) +
    +
    + 142 + +
    + + + return result.ReorgDetected +
    +
    + 143 + +
    + + + } +
    +
    + 144 + +
    + + + return false +
    +
    + 145 + +
    + + + } +
    +
    + 146 + +
    + + +
    +
    +
    + 147 + +
    + + + func (v *L1BlockCheckerIntegration) getMergedResults() *syncinterfaces.IterationResult { +
    +
    + 148 + +
    + + + result := v.checker.GetResult() +
    +
    + 149 + +
    + + + var preResult *syncinterfaces.IterationResult +
    +
    + 150 + +
    + + + preResult = nil +
    +
    + 151 + +
    + + + if v.preChecker != nil { +
    +
    + 152 + +
    + + + preResult = v.preChecker.GetResult() +
    +
    + 153 + +
    + + + } +
    +
    + 154 + +
    + + + if preResult == nil { +
    +
    + 155 + +
    + + + return result +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + + if result == nil { +
    +
    + 158 + +
    + + + return preResult +
    +
    + 159 + +
    + + + } +
    +
    + 160 + +
    + + + // result and preResult have values +
    +
    + 161 + +
    + + + if result.ReorgDetected && preResult.ReorgDetected { +
    +
    + 162 + +
    + + + // That is the common case, checker must detect oldest blocks than preChecker +
    +
    + 163 + +
    + + + if result.BlockNumber < preResult.BlockNumber { +
    +
    + 164 + +
    + + + return result +
    +
    + 165 + +
    + + + } +
    +
    + 166 + +
    + + + return preResult +
    +
    + 167 + +
    + + + } +
    +
    + 168 + +
    + + + if preResult.ReorgDetected { +
    +
    + 169 + +
    + + + return preResult +
    +
    + 170 + +
    + + + } +
    +
    + 171 + +
    + + + return result +
    +
    + 172 + +
    + + + } +
    +
    + 173 + +
    + + +
    +
    +
    + 174 + +
    + + + func (v *L1BlockCheckerIntegration) onFinishChecker() { +
    +
    + 175 + +
    + + + log.Infof("%s L1BlockChecker: finished background process, calling to synchronizer", logPrefix) +
    +
    + 176 + +
    + + + // Stop both processes +
    +
    + 177 + +
    + + + v.checker.Stop() +
    +
    + 178 + +
    + + + if v.preChecker != nil { +
    +
    + 179 + +
    + + + v.preChecker.Stop() +
    +
    + 180 + +
    + + + } +
    +
    + 181 + +
    + + + v.sync.OnDetectedMismatchL1BlockReorg() +
    +
    + 182 + +
    + + + } +
    +
    + 183 + +
    + + +
    +
    +
    + 184 + +
    + + + func (v *L1BlockCheckerIntegration) launch(ctx context.Context) { +
    +
    + 185 + +
    + + + log.Infof("%s L1BlockChecker: starting background process...", logPrefix) +
    +
    + 186 + +
    + + + v.checker.Run(ctx, v.onFinishChecker) +
    +
    + 187 + +
    + + + if v.preChecker != nil { +
    +
    + 188 + +
    + + + log.Infof("%s L1BlockChecker: starting background precheck process...", logPrefix) +
    +
    + 189 + +
    + + + v.preChecker.Run(ctx, v.onFinishChecker) +
    +
    + 190 + +
    + + + } +
    +
    + 191 + +
    + + + } +
    +
    + 192 + +
    + + +
    +
    +
    + 193 + +
    + + + func (v *L1BlockCheckerIntegration) executeResult(ctx context.Context, result syncinterfaces.IterationResult) bool { +
    +
    + 194 + +
    + + + if result.ReorgDetected { +
    +
    + 195 + +
    + + + for { +
    +
    + 196 + +
    + + + err := v.sync.ExecuteReorgFromMismatchBlock(result.BlockNumber, result.ReorgMessage) +
    +
    + 197 + +
    + + + if err == nil { +
    +
    + 198 + +
    + + + return true +
    +
    + 199 + +
    + + + } +
    +
    + 200 + +
    + + + log.Errorf("%s Error executing reorg: %s", logPrefix, err) +
    +
    + 201 + +
    + + + time.Sleep(v.timeBetweenRetries) +
    +
    + 202 + +
    + + + } +
    +
    + 203 + +
    + + + } +
    +
    + 204 + +
    + + + return false +
    +
    + 205 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,298 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block_test +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "fmt" +
    +
    + 6 + +
    + + + "testing" +
    +
    + 7 + +
    + + + "time" +
    +
    + 8 + +
    + + +
    +
    +
    + 9 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + 11 + +
    + + + mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" +
    +
    + 12 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 13 + +
    + + + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +
    +
    + 14 + +
    + + + "github.com/stretchr/testify/mock" +
    +
    + 15 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 16 + +
    + + + ) +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + var ( +
    +
    + 19 + +
    + + + genericErrorToTest = fmt.Errorf("error") +
    +
    + 20 + +
    + + + ) +
    +
    + 21 + +
    + + +
    +
    +
    + 22 + +
    + + + type testDataIntegration struct { +
    +
    + 23 + +
    + + + mockChecker *mock_syncinterfaces.AsyncL1BlockChecker +
    +
    + 24 + +
    + + + mockPreChecker *mock_syncinterfaces.AsyncL1BlockChecker +
    +
    + 25 + +
    + + + mockState *mock_l1_check_block.StateForL1BlockCheckerIntegration +
    +
    + 26 + +
    + + + mockSync *mock_l1_check_block.SyncCheckReorger +
    +
    + 27 + +
    + + + sut *l1_check_block.L1BlockCheckerIntegration +
    +
    + 28 + +
    + + + ctx context.Context +
    +
    + 29 + +
    + + + resultOk syncinterfaces.IterationResult +
    +
    + 30 + +
    + + + resultError syncinterfaces.IterationResult +
    +
    + 31 + +
    + + + resultReorg syncinterfaces.IterationResult +
    +
    + 32 + +
    + + + } +
    +
    + 33 + +
    + + +
    +
    +
    + 34 + +
    + + + func newDataIntegration(t *testing.T, forceCheckOnStart bool) *testDataIntegration { +
    +
    + 35 + +
    + + + return newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) +
    +
    + 36 + +
    + + + } +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + func newDataIntegrationWithPreChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { +
    +
    + 39 + +
    + + + res := newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) +
    +
    + 40 + +
    + + + res.mockPreChecker = mock_syncinterfaces.NewAsyncL1BlockChecker(t) +
    +
    + 41 + +
    + + + res.sut = l1_check_block.NewL1BlockCheckerIntegration(res.mockChecker, res.mockPreChecker, res.mockState, res.mockSync, forceCheckOnStart, time.Millisecond) +
    +
    + 42 + +
    + + + return res +
    +
    + 43 + +
    + + + } +
    +
    + 44 + +
    + + +
    +
    +
    + 45 + +
    + + + func newDataIntegrationOnlyMainChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { +
    +
    + 46 + +
    + + + mockChecker := mock_syncinterfaces.NewAsyncL1BlockChecker(t) +
    +
    + 47 + +
    + + + mockSync := mock_l1_check_block.NewSyncCheckReorger(t) +
    +
    + 48 + +
    + + + mockState := mock_l1_check_block.NewStateForL1BlockCheckerIntegration(t) +
    +
    + 49 + +
    + + + sut := l1_check_block.NewL1BlockCheckerIntegration(mockChecker, nil, mockState, mockSync, forceCheckOnStart, time.Millisecond) +
    +
    + 50 + +
    + + + return &testDataIntegration{ +
    +
    + 51 + +
    + + + mockChecker: mockChecker, +
    +
    + 52 + +
    + + + mockPreChecker: nil, +
    +
    + 53 + +
    + + + mockSync: mockSync, +
    +
    + 54 + +
    + + + mockState: mockState, +
    +
    + 55 + +
    + + + sut: sut, +
    +
    + 56 + +
    + + + ctx: context.Background(), +
    +
    + 57 + +
    + + + resultReorg: syncinterfaces.IterationResult{ +
    +
    + 58 + +
    + + + ReorgDetected: true, +
    +
    + 59 + +
    + + + BlockNumber: 1234, +
    +
    + 60 + +
    + + + }, +
    +
    + 61 + +
    + + + resultOk: syncinterfaces.IterationResult{ +
    +
    + 62 + +
    + + + ReorgDetected: false, +
    +
    + 63 + +
    + + + }, +
    +
    + 64 + +
    + + + resultError: syncinterfaces.IterationResult{ +
    +
    + 65 + +
    + + + Err: genericErrorToTest, +
    +
    + 66 + +
    + + + ReorgDetected: false, +
    +
    + 67 + +
    + + + }, +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + + } +
    +
    + 70 + +
    + + +
    +
    +
    + 71 + +
    + + + func TestIntegrationIfNoForceCheckOnlyLaunchBackgroudChecker(t *testing.T) { +
    +
    + 72 + +
    + + + data := newDataIntegration(t, false) +
    +
    + 73 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 74 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 75 + +
    + + + require.NoError(t, err) +
    +
    + 76 + +
    + + + } +
    +
    + 77 + +
    + + +
    +
    +
    + 78 + +
    + + + func TestIntegrationIfForceCheckRunsSynchronousOneTimeAndAfterLaunchBackgroudChecker(t *testing.T) { +
    +
    + 79 + +
    + + + data := newDataIntegration(t, true) +
    +
    + 80 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) +
    +
    + 81 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 82 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 83 + +
    + + + require.NoError(t, err) +
    +
    + 84 + +
    + + + } +
    +
    + 85 + +
    + + +
    +
    +
    + 86 + +
    + + + func TestIntegrationIfSyncCheckReturnsReorgExecuteIt(t *testing.T) { +
    +
    + 87 + +
    + + + data := newDataIntegration(t, true) +
    +
    + 88 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    + 89 + +
    + + + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), "").Return(nil) +
    +
    + 90 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 91 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 92 + +
    + + + require.NoError(t, err) +
    +
    + 93 + +
    + + + } +
    +
    + 94 + +
    + + +
    +
    +
    + 95 + +
    + + + func TestIntegrationIfSyncCheckReturnErrorRetry(t *testing.T) { +
    +
    + 96 + +
    + + + data := newDataIntegration(t, true) +
    +
    + 97 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultError).Once() +
    +
    + 98 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk).Once() +
    +
    + 99 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 100 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 101 + +
    + + + require.NoError(t, err) +
    +
    + 102 + +
    + + + } +
    +
    + 103 + +
    + + +
    +
    +
    + 104 + +
    + + + func TestIntegrationIfSyncCheckReturnsReorgExecuteItAndFailsRetry(t *testing.T) { +
    +
    + 105 + +
    + + + data := newDataIntegration(t, true) +
    +
    + 106 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    + 107 + +
    + + + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(genericErrorToTest).Once() +
    +
    + 108 + +
    + + + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() +
    +
    + 109 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 110 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 111 + +
    + + + require.NoError(t, err) +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + +
    +
    +
    + 114 + +
    + + + // OnStart if check and preCheck execute both, and launch both in background +
    +
    + 115 + +
    + + + func TestIntegrationCheckAndPreCheckOnStartForceCheck(t *testing.T) { +
    +
    + 116 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 117 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) +
    +
    + 118 + +
    + + + data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) +
    +
    + 119 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 120 + +
    + + + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 121 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 122 + +
    + + + require.NoError(t, err) +
    +
    + 123 + +
    + + + } +
    +
    + 124 + +
    + + +
    +
    +
    + 125 + +
    + + + // OnStart if mainChecker returns reorg doesnt need to run preCheck +
    +
    + 126 + +
    + + + func TestIntegrationCheckAndPreCheckOnStartMainCheckerReturnReorg(t *testing.T) { +
    +
    + 127 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 128 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    + 129 + +
    + + + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() +
    +
    + 130 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 131 + +
    + + + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 132 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 133 + +
    + + + require.NoError(t, err) +
    +
    + 134 + +
    + + + } +
    +
    + 135 + +
    + + +
    +
    +
    + 136 + +
    + + + // If mainCheck is OK, but preCheck returns reorg, it should execute reorg +
    +
    + 137 + +
    + + + func TestIntegrationCheckAndPreCheckOnStartPreCheckerReturnReorg(t *testing.T) { +
    +
    + 138 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 139 + +
    + + + data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) +
    +
    + 140 + +
    + + + data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    + 141 + +
    + + + data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() +
    +
    + 142 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 143 + +
    + + + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 144 + +
    + + + err := data.sut.OnStart(data.ctx) +
    +
    + 145 + +
    + + + require.NoError(t, err) +
    +
    + 146 + +
    + + + } +
    +
    + 147 + +
    + + +
    +
    +
    + 148 + +
    + + + // The process is running on background, no results yet +
    +
    + 149 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgRunningOnBackground(t *testing.T) { +
    +
    + 150 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 151 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 152 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    + 153 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 154 + +
    + + + require.Nil(t, block) +
    +
    + 155 + +
    + + + require.NoError(t, err) +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + +
    +
    +
    + 158 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgOneProcessHaveResultOK(t *testing.T) { +
    +
    + 159 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 160 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(&data.resultOk) +
    +
    + 161 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    + 162 + +
    + + + // One have been stopped, so must relaunch both +
    +
    + 163 + +
    + + + data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 164 + +
    + + + data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    + 165 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 166 + +
    + + + require.Nil(t, block) +
    +
    + 167 + +
    + + + require.NoError(t, err) +
    +
    + 168 + +
    + + + } +
    +
    + 169 + +
    + + +
    +
    +
    + 170 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgMainCheckerReorg(t *testing.T) { +
    +
    + 171 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 172 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    + 173 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    + 174 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    + 175 + +
    + + + BlockNumber: data.resultReorg.BlockNumber - 1, +
    +
    + 176 + +
    + + + }, nil) +
    +
    + 177 + +
    + + + // One have been stopped,but is going to be launched OnResetState call after the reset +
    +
    + 178 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 179 + +
    + + + require.NotNil(t, block) +
    +
    + 180 + +
    + + + require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) +
    +
    + 181 + +
    + + + require.NoError(t, err) +
    +
    + 182 + +
    + + + } +
    +
    + 183 + +
    + + +
    +
    +
    + 184 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgPreCheckerReorg(t *testing.T) { +
    +
    + 185 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 186 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 187 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    + 188 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    + 189 + +
    + + + BlockNumber: data.resultReorg.BlockNumber - 1, +
    +
    + 190 + +
    + + + }, nil) +
    +
    + 191 + +
    + + + // One have been stopped,but is going to be launched OnResetState call after the reset +
    +
    + 192 + +
    + + +
    +
    +
    + 193 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 194 + +
    + + + require.NotNil(t, block) +
    +
    + 195 + +
    + + + require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) +
    +
    + 196 + +
    + + + require.NoError(t, err) +
    +
    + 197 + +
    + + + } +
    +
    + 198 + +
    + + +
    +
    +
    + 199 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest1(t *testing.T) { +
    +
    + 200 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 201 + +
    + + + reorgMain := data.resultReorg +
    +
    + 202 + +
    + + + reorgMain.BlockNumber = 1235 +
    +
    + 203 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(&reorgMain) +
    +
    + 204 + +
    + + + reorgPre := data.resultReorg +
    +
    + 205 + +
    + + + reorgPre.BlockNumber = 1236 +
    +
    + 206 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) +
    +
    + 207 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ +
    +
    + 208 + +
    + + + BlockNumber: 1234, +
    +
    + 209 + +
    + + + }, nil) +
    +
    + 210 + +
    + + +
    +
    +
    + 211 + +
    + + + // Both have been stopped,but is going to be launched OnResetState call after the reset +
    +
    + 212 + +
    + + +
    +
    +
    + 213 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 214 + +
    + + + require.NotNil(t, block) +
    +
    + 215 + +
    + + + require.Equal(t, uint64(1234), block.BlockNumber) +
    +
    + 216 + +
    + + + require.NoError(t, err) +
    +
    + 217 + +
    + + + } +
    +
    + 218 + +
    + + +
    +
    +
    + 219 + +
    + + + func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest2(t *testing.T) { +
    +
    + 220 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 221 + +
    + + + reorgMain := data.resultReorg +
    +
    + 222 + +
    + + + reorgMain.BlockNumber = 1236 +
    +
    + 223 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(&reorgMain) +
    +
    + 224 + +
    + + + reorgPre := data.resultReorg +
    +
    + 225 + +
    + + + reorgPre.BlockNumber = 1235 +
    +
    + 226 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) +
    +
    + 227 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ +
    +
    + 228 + +
    + + + BlockNumber: 1234, +
    +
    + 229 + +
    + + + }, nil) +
    +
    + 230 + +
    + + + // Both have been stopped,but is going to be launched OnResetState call after the reset +
    +
    + 231 + +
    + + +
    +
    +
    + 232 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    + 233 + +
    + + + require.NotNil(t, block) +
    +
    + 234 + +
    + + + require.Equal(t, uint64(1234), block.BlockNumber) +
    +
    + 235 + +
    + + + require.NoError(t, err) +
    +
    + 236 + +
    + + + } +
    +
    + 237 + +
    + + +
    +
    +
    + 238 + +
    + + + func TestIntegrationCheckReorgWrapperBypassReorgFuncIfNoBackgroundData(t *testing.T) { +
    +
    + 239 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 240 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 241 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    + 242 + +
    + + + reorgFuncBlock := &state.Block{ +
    +
    + 243 + +
    + + + BlockNumber: 1234, +
    +
    + 244 + +
    + + + } +
    +
    + 245 + +
    + + + reorgFuncErr := fmt.Errorf("error") +
    +
    + 246 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) +
    +
    + 247 + +
    + + + require.Equal(t, reorgFuncBlock, block) +
    +
    + 248 + +
    + + + require.Equal(t, reorgFuncErr, err) +
    +
    + 249 + +
    + + + } +
    +
    + 250 + +
    + + +
    +
    +
    + 251 + +
    + + + func TestIntegrationCheckReorgWrapperChooseOldestReorgFunc(t *testing.T) { +
    +
    + 252 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 253 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 254 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    + 255 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    + 256 + +
    + + + BlockNumber: 1233, +
    +
    + 257 + +
    + + + }, nil) +
    +
    + 258 + +
    + + +
    +
    +
    + 259 + +
    + + + reorgFuncBlock := &state.Block{ +
    +
    + 260 + +
    + + + BlockNumber: 1230, +
    +
    + 261 + +
    + + + } +
    +
    + 262 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) +
    +
    + 263 + +
    + + + require.Equal(t, reorgFuncBlock, block) +
    +
    + 264 + +
    + + + require.NoError(t, err) +
    +
    + 265 + +
    + + + } +
    +
    + 266 + +
    + + +
    +
    +
    + 267 + +
    + + + func TestIntegrationCheckReorgWrapperChooseOldestBackgroundCheck(t *testing.T) { +
    +
    + 268 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 269 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 270 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    + 271 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    + 272 + +
    + + + BlockNumber: 1233, +
    +
    + 273 + +
    + + + }, nil) +
    +
    + 274 + +
    + + +
    +
    +
    + 275 + +
    + + + reorgFuncBlock := &state.Block{ +
    +
    + 276 + +
    + + + BlockNumber: 1240, +
    +
    + 277 + +
    + + + } +
    +
    + 278 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) +
    +
    + 279 + +
    + + + require.Equal(t, uint64(1233), block.BlockNumber) +
    +
    + 280 + +
    + + + require.NoError(t, err) +
    +
    + 281 + +
    + + + } +
    +
    + 282 + +
    + + +
    +
    +
    + 283 + +
    + + + func TestIntegrationCheckReorgWrapperIgnoreReorgFuncIfError(t *testing.T) { +
    +
    + 284 + +
    + + + data := newDataIntegrationWithPreChecker(t, true) +
    +
    + 285 + +
    + + + data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    + 286 + +
    + + + data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    + 287 + +
    + + + data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    + 288 + +
    + + + BlockNumber: 1233, +
    +
    + 289 + +
    + + + }, nil) +
    +
    + 290 + +
    + + +
    +
    +
    + 291 + +
    + + + reorgFuncBlock := &state.Block{ +
    +
    + 292 + +
    + + + BlockNumber: 1230, +
    +
    + 293 + +
    + + + } +
    +
    + 294 + +
    + + + reorgFuncErr := fmt.Errorf("error") +
    +
    + 295 + +
    + + + block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) +
    +
    + 296 + +
    + + + require.Equal(t, uint64(1233), block.BlockNumber) +
    +
    + 297 + +
    + + + require.NoError(t, err) +
    +
    + 298 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,139 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + // This make a pre-check of blocks but don't mark them as checked +
    +
    + 4 + +
    + + + // It checks blocks between a segment: example: +
    +
    + 5 + +
    + + + // real check point SAFE: +
    +
    + 6 + +
    + + + // pre check: (SAFE+1) -> (LATEST-32) +
    +
    + 7 + +
    + + + // It gets all pending blocks +
    +
    + 8 + +
    + + + // - Start cheking +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + import ( +
    +
    + 11 + +
    + + + "context" +
    +
    + 12 + +
    + + + "errors" +
    +
    + 13 + +
    + + + "fmt" +
    +
    + 14 + +
    + + + "time" +
    +
    + 15 + +
    + + +
    +
    +
    + 16 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 17 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 18 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 19 + +
    + + + "github.com/jackc/pgx/v4" +
    +
    + 20 + +
    + + + ) +
    +
    + 21 + +
    + + +
    +
    +
    + 22 + +
    + + + var ( +
    +
    + 23 + +
    + + + // ErrDeSync is an error that indicates that from the starting of verification to end something have been changed on state +
    +
    + 24 + +
    + + + ErrDeSync = errors.New("DeSync: a block hash is different from the state block hash") +
    +
    + 25 + +
    + + + ) +
    +
    + 26 + +
    + + +
    +
    +
    + 27 + +
    + + + // StatePreCheckInterfacer is an interface for the state +
    +
    + 28 + +
    + + + type StatePreCheckInterfacer interface { +
    +
    + 29 + +
    + + + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) +
    +
    + 30 + +
    + + + } +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + // PreCheckL1BlockHash is a struct that implements a checker of L1Block hash +
    +
    + 33 + +
    + + + type PreCheckL1BlockHash struct { +
    +
    + 34 + +
    + + + L1Client L1Requester +
    +
    + 35 + +
    + + + State StatePreCheckInterfacer +
    +
    + 36 + +
    + + + InitialSegmentBlockNumber SafeL1BlockNumberFetcher +
    +
    + 37 + +
    + + + EndSegmentBlockNumber SafeL1BlockNumberFetcher +
    +
    + 38 + +
    + + + } +
    +
    + 39 + +
    + + +
    +
    +
    + 40 + +
    + + + // NewPreCheckL1BlockHash creates a new CheckL1BlockHash +
    +
    + 41 + +
    + + + func NewPreCheckL1BlockHash(l1Client L1Requester, state StatePreCheckInterfacer, +
    +
    + 42 + +
    + + + initial, end SafeL1BlockNumberFetcher) *PreCheckL1BlockHash { +
    +
    + 43 + +
    + + + return &PreCheckL1BlockHash{ +
    +
    + 44 + +
    + + + L1Client: l1Client, +
    +
    + 45 + +
    + + + State: state, +
    +
    + 46 + +
    + + + InitialSegmentBlockNumber: initial, +
    +
    + 47 + +
    + + + EndSegmentBlockNumber: end, +
    +
    + 48 + +
    + + + } +
    +
    + 49 + +
    + + + } +
    +
    + 50 + +
    + + +
    +
    +
    + 51 + +
    + + + // Name is a method that returns the name of the checker +
    +
    + 52 + +
    + + + func (p *PreCheckL1BlockHash) Name() string { +
    +
    + 53 + +
    + + + return logPrefix + ":memory_check: " +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + // Step is a method that checks the L1 block hash, run until all blocks are checked and returns +
    +
    + 57 + +
    + + + func (p *PreCheckL1BlockHash) Step(ctx context.Context) error { +
    +
    + 58 + +
    + + + from, err := p.InitialSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) +
    +
    + 59 + +
    + + + if err != nil { +
    +
    + 60 + +
    + + + return err +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + + to, err := p.EndSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) +
    +
    + 63 + +
    + + + if err != nil { +
    +
    + 64 + +
    + + + return err +
    +
    + 65 + +
    + + + } +
    +
    + 66 + +
    + + + if from > to { +
    +
    + 67 + +
    + + + log.Warnf("%s: fromBlockNumber(%s) %d is greater than toBlockNumber(%s) %d, Check configuration", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to) +
    +
    + 68 + +
    + + + return nil +
    +
    + 69 + +
    + + + } +
    +
    + 70 + +
    + + +
    +
    +
    + 71 + +
    + + + blocksToCheck, err := p.State.GetUncheckedBlocks(ctx, from, to, nil) +
    +
    + 72 + +
    + + + if err != nil { +
    +
    + 73 + +
    + + + log.Warnf("%s can't get unchecked blocks, so it discard the reorg error", p.Name()) +
    +
    + 74 + +
    + + + return err +
    +
    + 75 + +
    + + + } +
    +
    + 76 + +
    + + + msg := fmt.Sprintf("%s: Checking blocks from (%s) %d to (%s) %d -> len(blocks)=%d", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck)) +
    +
    + 77 + +
    + + + if len(blocksToCheck) == 0 { +
    +
    + 78 + +
    + + + log.Debugf(msg) +
    +
    + 79 + +
    + + + return nil +
    +
    + 80 + +
    + + + } +
    +
    + 81 + +
    + + + log.Infof(msg) +
    +
    + 82 + +
    + + + startTime := time.Now() +
    +
    + 83 + +
    + + + for _, block := range blocksToCheck { +
    +
    + 84 + +
    + + + // check block +
    +
    + 85 + +
    + + + err = CheckBlockHash(ctx, block, p.L1Client, p.Name()) +
    +
    + 86 + +
    + + + if common.IsReorgError(err) { +
    +
    + 87 + +
    + + + // Double-check the state block that still is the same +
    +
    + 88 + +
    + + + log.Debugf("%s: Reorg detected at blockNumber: %d, checking that the block on State doesn't have change", p.Name(), block.BlockNumber) +
    +
    + 89 + +
    + + + isTheSame, errBlockIsTheSame := p.checkThatStateBlockIsTheSame(ctx, block) +
    +
    + 90 + +
    + + + if errBlockIsTheSame != nil { +
    +
    + 91 + +
    + + + log.Warnf("%s can't double-check that blockNumber %d haven't changed, so it discard the reorg error", p.Name(), block.BlockNumber) +
    +
    + 92 + +
    + + + return err +
    +
    + 93 + +
    + + + } +
    +
    + 94 + +
    + + + if !isTheSame { +
    +
    + 95 + +
    + + + log.Infof("%s: DeSync detected, blockNumber: %d is different now that when we started the check", p.Name(), block.BlockNumber) +
    +
    + 96 + +
    + + + return ErrDeSync +
    +
    + 97 + +
    + + + } +
    +
    + 98 + +
    + + + log.Infof("%s: Reorg detected and verified the state block, blockNumber: %d", p.Name(), block.BlockNumber) +
    +
    + 99 + +
    + + + return err +
    +
    + 100 + +
    + + + } +
    +
    + 101 + +
    + + + if err != nil { +
    +
    + 102 + +
    + + + return err +
    +
    + 103 + +
    + + + } +
    +
    + 104 + +
    + + + } +
    +
    + 105 + +
    + + + elapsed := time.Since(startTime) +
    +
    + 106 + +
    + + + log.Infof("%s: Checked blocks from (%s) %d to (%s) %d -> len(blocks):%d elapsed: %s", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck), elapsed.String()) +
    +
    + 107 + +
    + + +
    +
    +
    + 108 + +
    + + + return nil +
    +
    + 109 + +
    + + + } +
    +
    + 110 + +
    + + +
    +
    +
    + 111 + +
    + + + // CheckBlockHash is a method that checks the L1 block hash +
    +
    + 112 + +
    + + + // returns true if is the same +
    +
    + 113 + +
    + + + func (p *PreCheckL1BlockHash) checkThatStateBlockIsTheSame(ctx context.Context, block *state.Block) (bool, error) { +
    +
    + 114 + +
    + + + blocks, err := p.State.GetUncheckedBlocks(ctx, block.BlockNumber, block.BlockNumber, nil) +
    +
    + 115 + +
    + + + if err != nil { +
    +
    + 116 + +
    + + + log.Warnf("%s: Fails to get blockNumber %d in state .Err:%s", p.Name(), block.BlockNumber, err.Error()) +
    +
    + 117 + +
    + + + return false, err +
    +
    + 118 + +
    + + + } +
    +
    + 119 + +
    + + + if len(blocks) == 0 { +
    +
    + 120 + +
    + + + // The block is checked or deleted, so it is not the same +
    +
    + 121 + +
    + + + log.Debugf("%s: The blockNumber %d is no longer in the state (or checked or deleted)", p.Name(), block.BlockNumber) +
    +
    + 122 + +
    + + + return false, nil +
    +
    + 123 + +
    + + + } +
    +
    + 124 + +
    + + + stateBlock := blocks[0] +
    +
    + 125 + +
    + + + if stateBlock.BlockNumber != block.BlockNumber { +
    +
    + 126 + +
    + + + msg := fmt.Sprintf("%s: The blockNumber returned by state %d is different from the state blockNumber %d", +
    +
    + 127 + +
    + + + p.Name(), block.BlockNumber, stateBlock.BlockNumber) +
    +
    + 128 + +
    + + + log.Warn(msg) +
    +
    + 129 + +
    + + + return false, fmt.Errorf(msg) +
    +
    + 130 + +
    + + + } +
    +
    + 131 + +
    + + + if stateBlock.BlockHash != block.BlockHash { +
    +
    + 132 + +
    + + + msg := fmt.Sprintf("%s: The blockNumber %d differs the hash checked %s from current in state %s", +
    +
    + 133 + +
    + + + p.Name(), block.BlockNumber, block.BlockHash.String(), stateBlock.BlockHash.String()) +
    +
    + 134 + +
    + + + log.Warn(msg) +
    +
    + 135 + +
    + + + return false, nil +
    +
    + 136 + +
    + + + } +
    +
    + 137 + +
    + + + // The block is the same +
    +
    + 138 + +
    + + + return true, nil +
    +
    + 139 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,144 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block_test +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "math/big" +
    +
    + 6 + +
    + + + "testing" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 9 + +
    + + + commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 11 + +
    + + + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +
    +
    + 12 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 14 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 15 + +
    + + + ) +
    +
    + 16 + +
    + + +
    +
    +
    + 17 + +
    + + + type testPreCheckData struct { +
    +
    + 18 + +
    + + + sut *l1_check_block.PreCheckL1BlockHash +
    +
    + 19 + +
    + + + mockL1Client *mock_l1_check_block.L1Requester +
    +
    + 20 + +
    + + + mockState *mock_l1_check_block.StatePreCheckInterfacer +
    +
    + 21 + +
    + + + mockInitialFetch *mock_l1_check_block.SafeL1BlockNumberFetcher +
    +
    + 22 + +
    + + + mockEndFetch *mock_l1_check_block.SafeL1BlockNumberFetcher +
    +
    + 23 + +
    + + + ctx context.Context +
    +
    + 24 + +
    + + + stateBlocks []*state.Block +
    +
    + 25 + +
    + + + } +
    +
    + 26 + +
    + + +
    +
    +
    + 27 + +
    + + + func newPreCheckData(t *testing.T) *testPreCheckData { +
    +
    + 28 + +
    + + + mockL1Client := mock_l1_check_block.NewL1Requester(t) +
    +
    + 29 + +
    + + + mockState := mock_l1_check_block.NewStatePreCheckInterfacer(t) +
    +
    + 30 + +
    + + + mockInitialFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) +
    +
    + 31 + +
    + + + mockEndFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) +
    +
    + 32 + +
    + + + sut := l1_check_block.NewPreCheckL1BlockHash(mockL1Client, mockState, mockInitialFetch, mockEndFetch) +
    +
    + 33 + +
    + + + return &testPreCheckData{ +
    +
    + 34 + +
    + + + sut: sut, +
    +
    + 35 + +
    + + + mockL1Client: mockL1Client, +
    +
    + 36 + +
    + + + mockState: mockState, +
    +
    + 37 + +
    + + + mockInitialFetch: mockInitialFetch, +
    +
    + 38 + +
    + + + mockEndFetch: mockEndFetch, +
    +
    + 39 + +
    + + + ctx: context.Background(), +
    +
    + 40 + +
    + + + stateBlocks: []*state.Block{ +
    +
    + 41 + +
    + + + { +
    +
    + 42 + +
    + + + BlockNumber: 1234, +
    +
    + 43 + +
    + + + BlockHash: common.HexToHash("0xd77dd3a9ee6f9202ca5a75024b7d9cbd3d7436b2910d450f88c261c0089c0cd9"), +
    +
    + 44 + +
    + + + }, +
    +
    + 45 + +
    + + + { +
    +
    + 46 + +
    + + + BlockNumber: 1237, +
    +
    + 47 + +
    + + + BlockHash: common.HexToHash("0x8faffac37f561c18917c33ff3540262ecfbe11a367b4e1c48181326cd8ba347f"), +
    +
    + 48 + +
    + + + }, +
    +
    + 49 + +
    + + + }, +
    +
    + 50 + +
    + + + } +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + +
    +
    +
    + 53 + +
    + + + // If from > to, it ignore because there are no blocks to check +
    +
    + 54 + +
    + + + func TestPreCheckL1BlockFromGreaterThanTo(t *testing.T) { +
    +
    + 55 + +
    + + + data := newPreCheckData(t) +
    +
    + 56 + +
    + + + data.mockInitialFetch.EXPECT().Description().Return("initial") +
    +
    + 57 + +
    + + + data.mockEndFetch.EXPECT().Description().Return("end") +
    +
    + 58 + +
    + + + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    +
    + 59 + +
    + + + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1230), nil) +
    +
    + 60 + +
    + + +
    +
    +
    + 61 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 62 + +
    + + + require.NoError(t, res) +
    +
    + 63 + +
    + + + } +
    +
    + 64 + +
    + + +
    +
    +
    + 65 + +
    + + + // No blocks on state -> nothing to do +
    +
    + 66 + +
    + + + func TestPreCheckL1BlockNoBlocksOnState(t *testing.T) { +
    +
    + 67 + +
    + + + data := newPreCheckData(t) +
    +
    + 68 + +
    + + + data.mockInitialFetch.EXPECT().Description().Return("initial") +
    +
    + 69 + +
    + + + data.mockEndFetch.EXPECT().Description().Return("end") +
    +
    + 70 + +
    + + + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    +
    + 71 + +
    + + + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) +
    +
    + 72 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(nil, nil) +
    +
    + 73 + +
    + + +
    +
    +
    + 74 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 75 + +
    + + + require.NoError(t, res) +
    +
    + 76 + +
    + + + } +
    +
    + 77 + +
    + + +
    +
    +
    + 78 + +
    + + + func TestPreCheckL1BlockBlocksMatch(t *testing.T) { +
    +
    + 79 + +
    + + + data := newPreCheckData(t) +
    +
    + 80 + +
    + + + data.mockInitialFetch.EXPECT().Description().Return("initial") +
    +
    + 81 + +
    + + + data.mockEndFetch.EXPECT().Description().Return("end") +
    +
    + 82 + +
    + + + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    +
    + 83 + +
    + + + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) +
    +
    + 84 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) +
    +
    + 85 + +
    + + + l1Block1 := &types.Header{ +
    +
    + 86 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), +
    +
    + 87 + +
    + + + } +
    +
    + 88 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) +
    +
    + 89 + +
    + + + l1Block2 := &types.Header{ +
    +
    + 90 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) +
    +
    + 93 + +
    + + + //data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[0:1], nil) +
    +
    + 94 + +
    + + +
    +
    +
    + 95 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 96 + +
    + + + require.NoError(t, res) +
    +
    + 97 + +
    + + + } +
    +
    + 98 + +
    + + +
    +
    +
    + 99 + +
    + + + func TestPreCheckL1BlockBlocksMismatch(t *testing.T) { +
    +
    + 100 + +
    + + + data := newPreCheckData(t) +
    +
    + 101 + +
    + + + data.mockInitialFetch.EXPECT().Description().Return("initial") +
    +
    + 102 + +
    + + + data.mockEndFetch.EXPECT().Description().Return("end") +
    +
    + 103 + +
    + + + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    +
    + 104 + +
    + + + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) +
    +
    + 105 + +
    + + + data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") +
    +
    + 106 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) +
    +
    + 107 + +
    + + + l1Block1 := &types.Header{ +
    +
    + 108 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), +
    +
    + 109 + +
    + + + } +
    +
    + 110 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) +
    +
    + 111 + +
    + + + l1Block2 := &types.Header{ +
    +
    + 112 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), +
    +
    + 113 + +
    + + + } +
    +
    + 114 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) +
    +
    + 115 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[1:2], nil) +
    +
    + 116 + +
    + + +
    +
    +
    + 117 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 118 + +
    + + + require.Error(t, res) +
    +
    + 119 + +
    + + + resErr, ok := res.(*commonsync.ReorgError) +
    +
    + 120 + +
    + + + require.True(t, ok, "The error must be ReorgError") +
    +
    + 121 + +
    + + + require.Equal(t, uint64(1237), resErr.BlockNumber) +
    +
    + 122 + +
    + + + } +
    +
    + 123 + +
    + + +
    +
    +
    + 124 + +
    + + + func TestPreCheckL1BlockBlocksMismatchButIsNoLongerInState(t *testing.T) { +
    +
    + 125 + +
    + + + data := newPreCheckData(t) +
    +
    + 126 + +
    + + + data.mockInitialFetch.EXPECT().Description().Return("initial") +
    +
    + 127 + +
    + + + data.mockEndFetch.EXPECT().Description().Return("end") +
    +
    + 128 + +
    + + + data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    +
    + 129 + +
    + + + data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) +
    +
    + 130 + +
    + + + data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") +
    +
    + 131 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) +
    +
    + 132 + +
    + + + l1Block1 := &types.Header{ +
    +
    + 133 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), +
    +
    + 134 + +
    + + + } +
    +
    + 135 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) +
    +
    + 136 + +
    + + + l1Block2 := &types.Header{ +
    +
    + 137 + +
    + + + Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), +
    +
    + 138 + +
    + + + } +
    +
    + 139 + +
    + + + data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) +
    +
    + 140 + +
    + + + data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(nil, nil) +
    +
    + 141 + +
    + + +
    +
    +
    + 142 + +
    + + + res := data.sut.Step(data.ctx) +
    +
    + 143 + +
    + + + require.ErrorIs(t, res, l1_check_block.ErrDeSync) +
    +
    + 144 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,120 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "fmt" +
    +
    + 6 + +
    + + + "math/big" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 9 + +
    + + + "github.com/ethereum/go-ethereum/rpc" +
    +
    + 10 + +
    + + + ) +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + // L1BlockPoint is an enum that represents the point of the L1 block +
    +
    + 13 + +
    + + + type L1BlockPoint int +
    +
    + 14 + +
    + + +
    +
    +
    + 15 + +
    + + + const ( +
    +
    + 16 + +
    + + + // FinalizedBlockNumber is the finalized block number +
    +
    + 17 + +
    + + + FinalizedBlockNumber L1BlockPoint = 3 +
    +
    + 18 + +
    + + + // SafeBlockNumber is the safe block number +
    +
    + 19 + +
    + + + SafeBlockNumber L1BlockPoint = 2 +
    +
    + 20 + +
    + + + // PendingBlockNumber is the pending block number +
    +
    + 21 + +
    + + + PendingBlockNumber L1BlockPoint = 1 +
    +
    + 22 + +
    + + + // LastBlockNumber is the last block number +
    +
    + 23 + +
    + + + LastBlockNumber L1BlockPoint = 0 +
    +
    + 24 + +
    + + + ) +
    +
    + 25 + +
    + + +
    +
    +
    + 26 + +
    + + + // ToString converts a L1BlockPoint to a string +
    +
    + 27 + +
    + + + func (v L1BlockPoint) ToString() string { +
    +
    + 28 + +
    + + + switch v { +
    +
    + 29 + +
    + + + case FinalizedBlockNumber: +
    +
    + 30 + +
    + + + return "finalized" +
    +
    + 31 + +
    + + + case SafeBlockNumber: +
    +
    + 32 + +
    + + + return "safe" +
    +
    + 33 + +
    + + + case PendingBlockNumber: +
    +
    + 34 + +
    + + + return "pending" +
    +
    + 35 + +
    + + + case LastBlockNumber: +
    +
    + 36 + +
    + + + return "latest" +
    +
    + 37 + +
    + + + } +
    +
    + 38 + +
    + + + return "Unknown" +
    +
    + 39 + +
    + + + } +
    +
    + 40 + +
    + + +
    +
    +
    + 41 + +
    + + + // StringToL1BlockPoint converts a string to a L1BlockPoint +
    +
    + 42 + +
    + + + func StringToL1BlockPoint(s string) L1BlockPoint { +
    +
    + 43 + +
    + + + switch s { +
    +
    + 44 + +
    + + + case "finalized": +
    +
    + 45 + +
    + + + return FinalizedBlockNumber +
    +
    + 46 + +
    + + + case "safe": +
    +
    + 47 + +
    + + + return SafeBlockNumber +
    +
    + 48 + +
    + + + case "pending": +
    +
    + 49 + +
    + + + return PendingBlockNumber +
    +
    + 50 + +
    + + + case "latest": +
    +
    + 51 + +
    + + + return LastBlockNumber +
    +
    + 52 + +
    + + + default: +
    +
    + 53 + +
    + + + return FinalizedBlockNumber +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + + } +
    +
    + 56 + +
    + + +
    +
    +
    + 57 + +
    + + + // ToGethRequest converts a L1BlockPoint to a big.Int used for request to GETH +
    +
    + 58 + +
    + + + func (v L1BlockPoint) ToGethRequest() *big.Int { +
    +
    + 59 + +
    + + + switch v { +
    +
    + 60 + +
    + + + case FinalizedBlockNumber: +
    +
    + 61 + +
    + + + return big.NewInt(int64(rpc.FinalizedBlockNumber)) +
    +
    + 62 + +
    + + + case PendingBlockNumber: +
    +
    + 63 + +
    + + + return big.NewInt(int64(rpc.PendingBlockNumber)) +
    +
    + 64 + +
    + + + case SafeBlockNumber: +
    +
    + 65 + +
    + + + return big.NewInt(int64(rpc.SafeBlockNumber)) +
    +
    + 66 + +
    + + + case LastBlockNumber: +
    +
    + 67 + +
    + + + return nil +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + + return big.NewInt(int64(v)) +
    +
    + 70 + +
    + + + } +
    +
    + 71 + +
    + + +
    +
    +
    + 72 + +
    + + + // SafeL1BlockNumberFetch is a struct that implements a safe L1 block number fetch +
    +
    + 73 + +
    + + + type SafeL1BlockNumberFetch struct { +
    +
    + 74 + +
    + + + // SafeBlockPoint is the block number that is reference to l1 Block +
    +
    + 75 + +
    + + + SafeBlockPoint L1BlockPoint +
    +
    + 76 + +
    + + + // Offset is a vaule add to the L1 block +
    +
    + 77 + +
    + + + Offset int +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + +
    +
    +
    + 80 + +
    + + + // NewSafeL1BlockNumberFetch creates a new SafeL1BlockNumberFetch +
    +
    + 81 + +
    + + + func NewSafeL1BlockNumberFetch(safeBlockPoint L1BlockPoint, offset int) *SafeL1BlockNumberFetch { +
    +
    + 82 + +
    + + + return &SafeL1BlockNumberFetch{ +
    +
    + 83 + +
    + + + SafeBlockPoint: safeBlockPoint, +
    +
    + 84 + +
    + + + Offset: offset, +
    +
    + 85 + +
    + + + } +
    +
    + 86 + +
    + + + } +
    +
    + 87 + +
    + + +
    +
    +
    + 88 + +
    + + + // Description returns a string representation of SafeL1BlockNumberFetch +
    +
    + 89 + +
    + + + func (p *SafeL1BlockNumberFetch) Description() string { +
    +
    + 90 + +
    + + + return fmt.Sprintf("%s/%d", p.SafeBlockPoint.ToString(), p.Offset) +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + +
    +
    +
    + 93 + +
    + + + // GetSafeBlockNumber gets the safe block number from L1 +
    +
    + 94 + +
    + + + func (p *SafeL1BlockNumberFetch) GetSafeBlockNumber(ctx context.Context, requester L1Requester) (uint64, error) { +
    +
    + 95 + +
    + + + l1SafePointBlock, err := requester.HeaderByNumber(ctx, p.SafeBlockPoint.ToGethRequest()) +
    +
    + 96 + +
    + + + if err != nil { +
    +
    + 97 + +
    + + + log.Errorf("%s: Error getting L1 block %d. err: %s", logPrefix, p.String(), err.Error()) +
    +
    + 98 + +
    + + + return uint64(0), err +
    +
    + 99 + +
    + + + } +
    +
    + 100 + +
    + + + result := l1SafePointBlock.Number.Uint64() +
    +
    + 101 + +
    + + + if p.Offset < 0 { +
    +
    + 102 + +
    + + + if result < uint64(-p.Offset) { +
    +
    + 103 + +
    + + + result = 0 +
    +
    + 104 + +
    + + + } else { +
    +
    + 105 + +
    + + + result += uint64(p.Offset) +
    +
    + 106 + +
    + + + } +
    +
    + 107 + +
    + + + } else { +
    +
    + 108 + +
    + + + result = l1SafePointBlock.Number.Uint64() + uint64(p.Offset) +
    +
    + 109 + +
    + + + } +
    +
    + 110 + +
    + + + if p.SafeBlockPoint == LastBlockNumber { +
    +
    + 111 + +
    + + + result = min(result, l1SafePointBlock.Number.Uint64()) +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + +
    +
    +
    + 114 + +
    + + + return result, nil +
    +
    + 115 + +
    + + + } +
    +
    + 116 + +
    + + +
    +
    +
    + 117 + +
    + + + // String returns a string representation of SafeL1BlockNumberFetch +
    +
    + 118 + +
    + + + func (p *SafeL1BlockNumberFetch) String() string { +
    +
    + 119 + +
    + + + return fmt.Sprintf("SafeBlockPoint: %s, Offset: %d", p.SafeBlockPoint.ToString(), p.Offset) +
    +
    + 120 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,113 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package l1_check_block_test +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "math/big" +
    +
    + 6 + +
    + + + "testing" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 9 + +
    + + + mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +
    +
    + 10 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 11 + +
    + + + "github.com/ethereum/go-ethereum/rpc" +
    +
    + 12 + +
    + + + "github.com/stretchr/testify/assert" +
    +
    + 13 + +
    + + + "github.com/stretchr/testify/mock" +
    +
    + 14 + +
    + + + ) +
    +
    + 15 + +
    + + +
    +
    +
    + 16 + +
    + + + func TestGetSafeBlockNumber(t *testing.T) { +
    +
    + 17 + +
    + + + ctx := context.Background() +
    +
    + 18 + +
    + + + mockRequester := mock_l1_check_block.NewL1Requester(t) +
    +
    + 19 + +
    + + + //safeBlockPoint := big.NewInt(50) +
    +
    + 20 + +
    + + + offset := 10 +
    +
    + 21 + +
    + + + safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint("safe"), offset) +
    +
    + 22 + +
    + + +
    +
    +
    + 23 + +
    + + + mockRequester.EXPECT().HeaderByNumber(ctx, mock.Anything).Return(&types.Header{ +
    +
    + 24 + +
    + + + Number: big.NewInt(100), +
    +
    + 25 + +
    + + + }, nil) +
    +
    + 26 + +
    + + + blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) +
    +
    + 27 + +
    + + + assert.NoError(t, err) +
    +
    + 28 + +
    + + + expectedBlockNumber := uint64(100 + offset) +
    +
    + 29 + +
    + + + assert.Equal(t, expectedBlockNumber, blockNumber) +
    +
    + 30 + +
    + + + } +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + func TestGetSafeBlockNumberMutliplesCases(t *testing.T) { +
    +
    + 33 + +
    + + + tests := []struct { +
    +
    + 34 + +
    + + + name string +
    +
    + 35 + +
    + + + blockPoint string +
    +
    + 36 + +
    + + + offset int +
    +
    + 37 + +
    + + + l1ReturnBlockNumber uint64 +
    +
    + 38 + +
    + + + expectedCallToGeth *big.Int +
    +
    + 39 + +
    + + + expectedBlockNumber uint64 +
    +
    + 40 + +
    + + + }{ +
    +
    + 41 + +
    + + + { +
    +
    + 42 + +
    + + + name: "SafeBlockNumber+10", +
    +
    + 43 + +
    + + + blockPoint: "safe", +
    +
    + 44 + +
    + + + offset: 10, +
    +
    + 45 + +
    + + + l1ReturnBlockNumber: 100, +
    +
    + 46 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.SafeBlockNumber)), +
    +
    + 47 + +
    + + + expectedBlockNumber: 110, +
    +
    + 48 + +
    + + + }, +
    +
    + 49 + +
    + + + { +
    +
    + 50 + +
    + + + name: "FinalizedBlockNumber+10", +
    +
    + 51 + +
    + + + blockPoint: "finalized", +
    +
    + 52 + +
    + + + offset: 10, +
    +
    + 53 + +
    + + + l1ReturnBlockNumber: 100, +
    +
    + 54 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), +
    +
    + 55 + +
    + + + expectedBlockNumber: 110, +
    +
    + 56 + +
    + + + }, +
    +
    + 57 + +
    + + + { +
    +
    + 58 + +
    + + + name: "PendingBlockNumber+10", +
    +
    + 59 + +
    + + + blockPoint: "pending", +
    +
    + 60 + +
    + + + offset: 10, +
    +
    + 61 + +
    + + + l1ReturnBlockNumber: 100, +
    +
    + 62 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.PendingBlockNumber)), +
    +
    + 63 + +
    + + + expectedBlockNumber: 110, +
    +
    + 64 + +
    + + + }, +
    +
    + 65 + +
    + + + { +
    +
    + 66 + +
    + + + name: "LastBlockNumber+10, can't add 10 to latest block number. So must return latest block number and ignore positive offset", +
    +
    + 67 + +
    + + + blockPoint: "latest", +
    +
    + 68 + +
    + + + offset: 10, +
    +
    + 69 + +
    + + + l1ReturnBlockNumber: 100, +
    +
    + 70 + +
    + + + expectedCallToGeth: nil, +
    +
    + 71 + +
    + + + expectedBlockNumber: 100, +
    +
    + 72 + +
    + + + }, +
    +
    + 73 + +
    + + + { +
    +
    + 74 + +
    + + + name: "FinalizedBlockNumber-1000. negative blockNumbers are not welcome. So must return 0", +
    +
    + 75 + +
    + + + blockPoint: "finalized", +
    +
    + 76 + +
    + + + offset: -1000, +
    +
    + 77 + +
    + + + l1ReturnBlockNumber: 100, +
    +
    + 78 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), +
    +
    + 79 + +
    + + + expectedBlockNumber: 0, +
    +
    + 80 + +
    + + + }, +
    +
    + 81 + +
    + + + { +
    +
    + 82 + +
    + + + name: "FinalizedBlockNumber(1000)-1000. is 0 ", +
    +
    + 83 + +
    + + + blockPoint: "finalized", +
    +
    + 84 + +
    + + + offset: -1000, +
    +
    + 85 + +
    + + + l1ReturnBlockNumber: 1000, +
    +
    + 86 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), +
    +
    + 87 + +
    + + + expectedBlockNumber: 0, +
    +
    + 88 + +
    + + + }, +
    +
    + 89 + +
    + + + { +
    +
    + 90 + +
    + + + name: "FinalizedBlockNumber(1001)-1000. is 1 ", +
    +
    + 91 + +
    + + + blockPoint: "finalized", +
    +
    + 92 + +
    + + + offset: -1000, +
    +
    + 93 + +
    + + + l1ReturnBlockNumber: 1001, +
    +
    + 94 + +
    + + + expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), +
    +
    + 95 + +
    + + + expectedBlockNumber: 1, +
    +
    + 96 + +
    + + + }, +
    +
    + 97 + +
    + + + } +
    +
    + 98 + +
    + + +
    +
    +
    + 99 + +
    + + + for _, tt := range tests { +
    +
    + 100 + +
    + + + t.Run(tt.name, func(t *testing.T) { +
    +
    + 101 + +
    + + + ctx := context.Background() +
    +
    + 102 + +
    + + + mockRequester := mock_l1_check_block.NewL1Requester(t) +
    +
    + 103 + +
    + + + safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(tt.blockPoint), tt.offset) +
    +
    + 104 + +
    + + +
    +
    +
    + 105 + +
    + + + mockRequester.EXPECT().HeaderByNumber(ctx, tt.expectedCallToGeth).Return(&types.Header{ +
    +
    + 106 + +
    + + + Number: big.NewInt(int64(tt.l1ReturnBlockNumber)), +
    +
    + 107 + +
    + + + }, nil) +
    +
    + 108 + +
    + + + blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) +
    +
    + 109 + +
    + + + assert.NoError(t, err) +
    +
    + 110 + +
    + + + assert.Equal(t, tt.expectedBlockNumber, blockNumber) +
    +
    + 111 + +
    + + + }) +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -3,6 +3,7 @@
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "context" +
    +
    + 5 + +
    +   + "errors" +
    +
    + + +
    +   +
    +
    +
    + 6 + +
    +   + "sync" +
    +
    + 7 + +
    +   + "time" +
    +
    + 8 + +
    +   +
    +
    +
    +
    @@ -22,7 +24,6 @@
    +
    + 22 + +
    +   + errContextCanceled = errors.New("consumer:context canceled") +
    +
    + 23 + +
    +   + errConsumerStopped = errors.New("consumer:stopped by request") +
    +
    + 24 + +
    +   + errConsumerStoppedBecauseIsSynchronized = errors.New("consumer:stopped because is synchronized") +
    +
    + 25 + +
    + - + errL1Reorg = errors.New("consumer: L1 reorg detected") +
    +
    + 26 + +
    +   + errConsumerAndProducerDesynchronized = errors.New("consumer: consumer and producer are desynchronized") +
    +
    + 27 + +
    +   + ) +
    +
    + 28 + +
    +   +
    +
    +
    +
    @@ -155,13 +156,12 @@
    +
    + 155 + +
    +   + } +
    +
    + 156 + +
    +   + if cachedBlock.BlockNumber == rollupInfo.previousBlockOfRange.NumberU64() { +
    +
    + 157 + +
    +   + if cachedBlock.BlockHash != rollupInfo.previousBlockOfRange.Hash() { +
    +
    + 158 + +
    + - + log.Errorf("consumer: Previous block %d hash is not the same", cachedBlock.BlockNumber) +
    +
    + 159 + +
    + - + return errL1Reorg +
    +
    + 160 + +
    + - + } +
    +
    + 161 + +
    + - + if cachedBlock.ParentHash != rollupInfo.previousBlockOfRange.ParentHash() { +
    +
    + 162 + +
    + - + log.Errorf("consumer: Previous block %d parentHash is not the same", cachedBlock.BlockNumber) +
    +
    + 163 + +
    + - + return errL1Reorg +
    +
    + 164 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 165 + +
    +   + log.Infof("consumer: Verified previous block %d not the same: OK", cachedBlock.BlockNumber) +
    +
    + 166 + +
    +   + } +
    +
    + 167 + +
    +   + return nil +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "context" +
    +
    + 5 + +
    +   + "errors" +
    +
    + 6 + +
    + + + "fmt" +
    +
    + 7 + +
    +   + "sync" +
    +
    + 8 + +
    +   + "time" +
    +
    + 9 + +
    +   +
    +
    +
    +
     
    +
    + 24 + +
    +   + errContextCanceled = errors.New("consumer:context canceled") +
    +
    + 25 + +
    +   + errConsumerStopped = errors.New("consumer:stopped by request") +
    +
    + 26 + +
    +   + errConsumerStoppedBecauseIsSynchronized = errors.New("consumer:stopped because is synchronized") +
    +
    + + +
    +   +
    +
    +
    + 27 + +
    +   + errConsumerAndProducerDesynchronized = errors.New("consumer: consumer and producer are desynchronized") +
    +
    + 28 + +
    +   + ) +
    +
    + 29 + +
    +   +
    +
    +
    +
     
    +
    + 156 + +
    +   + } +
    +
    + 157 + +
    +   + if cachedBlock.BlockNumber == rollupInfo.previousBlockOfRange.NumberU64() { +
    +
    + 158 + +
    +   + if cachedBlock.BlockHash != rollupInfo.previousBlockOfRange.Hash() { +
    +
    + 159 + +
    + + + err := fmt.Errorf("consumer: Previous block %d hash is not the same. state.Hash:%s != l1.Hash:%s", +
    +
    + 160 + +
    + + + cachedBlock.BlockNumber, cachedBlock.BlockHash, rollupInfo.previousBlockOfRange.Hash()) +
    +
    + 161 + +
    + + + log.Errorf(err.Error()) +
    +
    + 162 + +
    + + + return syncCommon.NewReorgError(cachedBlock.BlockNumber, err) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 163 + +
    +   + } +
    +
    + 164 + +
    + + +
    +
    +
    + 165 + +
    +   + log.Infof("consumer: Verified previous block %d not the same: OK", cachedBlock.BlockNumber) +
    +
    + 166 + +
    +   + } +
    +
    + 167 + +
    +   + return nil +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -31,7 +31,7 @@
    +
    + 31 + +
    +   + GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), +
    +
    + 32 + +
    +   + } +
    +
    + 33 + +
    +   +
    +
    +
    + 34 + +
    + - + ethermanClient, err := etherman.NewClient(cfg, l1Config) +
    +
    + 35 + +
    +   + require.NoError(t, err) +
    +
    + 36 + +
    +   + worker := newWorker(ethermanClient) +
    +
    + 37 + +
    +   + ch := make(chan responseRollupInfoByBlockRange) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 31 + +
    +   + GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), +
    +
    + 32 + +
    +   + } +
    +
    + 33 + +
    +   +
    +
    +
    + 34 + +
    + + + ethermanClient, err := etherman.NewClient(cfg, l1Config, nil, nil) +
    +
    + 35 + +
    +   + require.NoError(t, err) +
    +
    + 36 + +
    +   + worker := newWorker(ethermanClient) +
    +
    + 37 + +
    +   + ch := make(chan responseRollupInfoByBlockRange) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -171,6 +171,10 @@
    +
    + 171 + +
    +   +
    +
    +
    + 172 + +
    +   + // ProcessTrustedBatch processes a trusted batch and return the new state +
    +
    + 173 + +
    +   + func (s *ProcessorTrustedBatchSync) ProcessTrustedBatch(ctx context.Context, trustedBatch *types.Batch, status TrustedState, dbTx pgx.Tx, debugPrefix string) (*TrustedState, error) { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 174 + +
    +   + log.Debugf("%s Processing trusted batch: %v", debugPrefix, trustedBatch.Number) +
    +
    + 175 + +
    +   + stateCurrentBatch, statePreviousBatch := s.GetCurrentAndPreviousBatchFromCache(&status) +
    +
    + 176 + +
    +   + if s.l1SyncChecker != nil { +
    +
    +
    @@ -374,7 +378,9 @@
    +
    + 374 + +
    +   + result.OldAccInputHash = statePreviousBatch.AccInputHash +
    +
    + 375 + +
    +   + result.Now = s.timeProvider.Now() +
    +
    + 376 + +
    +   + result.DebugPrefix = fmt.Sprintf("%s mode %s:", debugPrefix, result.Mode) +
    +
    + 377 + +
    + - +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 378 + +
    +   + if isTrustedBatchEmptyAndClosed(trustedNodeBatch) { +
    +
    + 379 + +
    +   + if s.Cfg.AcceptEmptyClosedBatches { +
    +
    + 380 + +
    +   + log.Infof("%s Batch %v: TrustedBatch Empty and closed, accepted due configuration", result.DebugPrefix, trustedNodeBatch.Number) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 171 + +
    +   +
    +
    +
    + 172 + +
    +   + // ProcessTrustedBatch processes a trusted batch and return the new state +
    +
    + 173 + +
    +   + func (s *ProcessorTrustedBatchSync) ProcessTrustedBatch(ctx context.Context, trustedBatch *types.Batch, status TrustedState, dbTx pgx.Tx, debugPrefix string) (*TrustedState, error) { +
    +
    + 174 + +
    + + + if trustedBatch == nil { +
    +
    + 175 + +
    + + + log.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix) +
    +
    + 176 + +
    + + + return nil, fmt.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix) +
    +
    + 177 + +
    + + + } +
    +
    + 178 + +
    +   + log.Debugf("%s Processing trusted batch: %v", debugPrefix, trustedBatch.Number) +
    +
    + 179 + +
    +   + stateCurrentBatch, statePreviousBatch := s.GetCurrentAndPreviousBatchFromCache(&status) +
    +
    + 180 + +
    +   + if s.l1SyncChecker != nil { +
    +
    +
     
    +
    + 378 + +
    +   + result.OldAccInputHash = statePreviousBatch.AccInputHash +
    +
    + 379 + +
    +   + result.Now = s.timeProvider.Now() +
    +
    + 380 + +
    +   + result.DebugPrefix = fmt.Sprintf("%s mode %s:", debugPrefix, result.Mode) +
    +
    + 381 + +
    + + + if result.BatchMustBeClosed { +
    +
    + 382 + +
    + + + result.DebugPrefix += " (must_be_closed)" +
    +
    + 383 + +
    + + + } +
    +
    + 384 + +
    +   + if isTrustedBatchEmptyAndClosed(trustedNodeBatch) { +
    +
    + 385 + +
    +   + if s.Cfg.AcceptEmptyClosedBatches { +
    +
    + 386 + +
    +   + log.Infof("%s Batch %v: TrustedBatch Empty and closed, accepted due configuration", result.DebugPrefix, trustedNodeBatch.Number) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,117 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package test_l2_shared +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "math/big" +
    +
    + 6 + +
    + + + "testing" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    + 9 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 11 + +
    + + + mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" +
    +
    + 12 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" +
    +
    + 13 + +
    + + + l2sharedmocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared/mocks" +
    +
    + 14 + +
    + + + syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" +
    +
    + 15 + +
    + + + "github.com/stretchr/testify/mock" +
    +
    + 16 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 17 + +
    + + + ) +
    +
    + 18 + +
    + + +
    +
    +
    + 19 + +
    + + + type testDataTrustedBatchRetrieve struct { +
    +
    + 20 + +
    + + + mockBatchProcessor *l2sharedmocks.BatchProcessor +
    +
    + 21 + +
    + + + mockZkEVMClient *mock_syncinterfaces.ZKEVMClientTrustedBatchesGetter +
    +
    + 22 + +
    + + + mockState *l2sharedmocks.StateInterface +
    +
    + 23 + +
    + + + mockSync *mock_syncinterfaces.SynchronizerFlushIDManager +
    +
    + 24 + +
    + + + mockTimer *common.MockTimerProvider +
    +
    + 25 + +
    + + + mockDbTx *syncMocks.DbTxMock +
    +
    + 26 + +
    + + + TrustedStateMngr *l2_shared.TrustedStateManager +
    +
    + 27 + +
    + + + sut *l2_shared.TrustedBatchesRetrieve +
    +
    + 28 + +
    + + + ctx context.Context +
    +
    + 29 + +
    + + + } +
    +
    + 30 + +
    + + +
    +
    +
    + 31 + +
    + + + func newTestDataTrustedBatchRetrieve(t *testing.T) *testDataTrustedBatchRetrieve { +
    +
    + 32 + +
    + + + mockBatchProcessor := l2sharedmocks.NewBatchProcessor(t) +
    +
    + 33 + +
    + + + mockZkEVMClient := mock_syncinterfaces.NewZKEVMClientTrustedBatchesGetter(t) +
    +
    + 34 + +
    + + + mockState := l2sharedmocks.NewStateInterface(t) +
    +
    + 35 + +
    + + + mockSync := mock_syncinterfaces.NewSynchronizerFlushIDManager(t) +
    +
    + 36 + +
    + + + mockTimer := &common.MockTimerProvider{} +
    +
    + 37 + +
    + + + mockDbTx := syncMocks.NewDbTxMock(t) +
    +
    + 38 + +
    + + + TrustedStateMngr := l2_shared.NewTrustedStateManager(mockTimer, 0) +
    +
    + 39 + +
    + + + sut := l2_shared.NewTrustedBatchesRetrieve(mockBatchProcessor, mockZkEVMClient, mockState, mockSync, *TrustedStateMngr) +
    +
    + 40 + +
    + + + ctx := context.TODO() +
    +
    + 41 + +
    + + + return &testDataTrustedBatchRetrieve{ +
    +
    + 42 + +
    + + + mockBatchProcessor: mockBatchProcessor, +
    +
    + 43 + +
    + + + mockZkEVMClient: mockZkEVMClient, +
    +
    + 44 + +
    + + + mockState: mockState, +
    +
    + 45 + +
    + + + mockSync: mockSync, +
    +
    + 46 + +
    + + + mockTimer: mockTimer, +
    +
    + 47 + +
    + + + mockDbTx: mockDbTx, +
    +
    + 48 + +
    + + + TrustedStateMngr: TrustedStateMngr, +
    +
    + 49 + +
    + + + sut: sut, +
    +
    + 50 + +
    + + + ctx: ctx, +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + +
    +
    +
    + 54 + +
    + + + const ( +
    +
    + 55 + +
    + + + closedBatch = true +
    +
    + 56 + +
    + + + notClosedBatch = false +
    +
    + 57 + +
    + + + ) +
    +
    + 58 + +
    + + +
    +
    +
    + 59 + +
    + + + // This test must do from 100 to 104. +
    +
    + 60 + +
    + + + // But the batch 100 is open on TrustedNode so it stop processing +
    +
    + 61 + +
    + + + func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatch(t *testing.T) { +
    +
    + 62 + +
    + + + data := newTestDataTrustedBatchRetrieve(t) +
    +
    + 63 + +
    + + + data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) +
    +
    + 64 + +
    + + +
    +
    +
    + 65 + +
    + + + expectationsForSyncTrustedStateIteration(t, 100, notClosedBatch, data) +
    +
    + 66 + +
    + + +
    +
    +
    + 67 + +
    + + + err := data.sut.SyncTrustedState(data.ctx, 100, 104) +
    +
    + 68 + +
    + + + require.NoError(t, err) +
    +
    + 69 + +
    + + + } +
    +
    + 70 + +
    + + +
    +
    +
    + 71 + +
    + + + // This must process 100 (that is closed) +
    +
    + 72 + +
    + + + // and stop processing at 101 because is not yet close this batch +
    +
    + 73 + +
    + + + func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase2(t *testing.T) { +
    +
    + 74 + +
    + + + data := newTestDataTrustedBatchRetrieve(t) +
    +
    + 75 + +
    + + + data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) +
    +
    + 76 + +
    + + +
    +
    +
    + 77 + +
    + + + expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data) +
    +
    + 78 + +
    + + + expectationsForSyncTrustedStateIteration(t, 101, notClosedBatch, data) +
    +
    + 79 + +
    + + +
    +
    +
    + 80 + +
    + + + err := data.sut.SyncTrustedState(data.ctx, 100, 104) +
    +
    + 81 + +
    + + + require.NoError(t, err) +
    +
    + 82 + +
    + + + } +
    +
    + 83 + +
    + + +
    +
    +
    + 84 + +
    + + + // This test must do from 100 to 102. Is for check manually that the logs +
    +
    + 85 + +
    + + + // That is not tested but must not emit the log: +
    +
    + 86 + +
    + + + // - Batch 101 is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state +
    +
    + 87 + +
    + + + func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase3(t *testing.T) { +
    +
    + 88 + +
    + + + data := newTestDataTrustedBatchRetrieve(t) +
    +
    + 89 + +
    + + + data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) +
    +
    + 90 + +
    + + + expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data) +
    +
    + 91 + +
    + + + expectationsForSyncTrustedStateIteration(t, 101, closedBatch, data) +
    +
    + 92 + +
    + + + expectationsForSyncTrustedStateIteration(t, 102, notClosedBatch, data) +
    +
    + 93 + +
    + + +
    +
    +
    + 94 + +
    + + + err := data.sut.SyncTrustedState(data.ctx, 100, 102) +
    +
    + 95 + +
    + + + require.NoError(t, err) +
    +
    + 96 + +
    + + + } +
    +
    + 97 + +
    + + +
    +
    +
    + 98 + +
    + + + func expectationsForSyncTrustedStateIteration(t *testing.T, batchNumber uint64, closed bool, data *testDataTrustedBatchRetrieve) { +
    +
    + 99 + +
    + + + batch100 := &types.Batch{ +
    +
    + 100 + +
    + + + Number: types.ArgUint64(batchNumber), +
    +
    + 101 + +
    + + + Closed: closed, +
    +
    + 102 + +
    + + + } +
    +
    + 103 + +
    + + + data.mockZkEVMClient.EXPECT().BatchByNumber(data.ctx, big.NewInt(0).SetUint64(batchNumber)).Return(batch100, nil) +
    +
    + 104 + +
    + + + data.mockState.EXPECT().BeginStateTransaction(data.ctx).Return(data.mockDbTx, nil) +
    +
    + 105 + +
    + + + // Get Previous Batch 99 from State +
    +
    + 106 + +
    + + + stateBatch99 := &state.Batch{ +
    +
    + 107 + +
    + + + BatchNumber: batchNumber - 1, +
    +
    + 108 + +
    + + + } +
    +
    + 109 + +
    + + + data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber-1), data.mockDbTx).Return(stateBatch99, nil) +
    +
    + 110 + +
    + + + stateBatch100 := &state.Batch{ +
    +
    + 111 + +
    + + + BatchNumber: batchNumber, +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + + data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber), data.mockDbTx).Return(stateBatch100, nil) +
    +
    + 114 + +
    + + + data.mockBatchProcessor.EXPECT().ProcessTrustedBatch(data.ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil) +
    +
    + 115 + +
    + + + data.mockSync.EXPECT().CheckFlushID(mock.Anything).Return(nil) +
    +
    + 116 + +
    + + + data.mockDbTx.EXPECT().Commit(data.ctx).Return(nil) +
    +
    + 117 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -109,6 +109,16 @@
    +
    + 109 + +
    +   + return lastTrustedStateBatchNumber < latestSyncedBatch +
    +
    + 110 + +
    +   + } +
    +
    + 111 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 112 + +
    +   + func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, latestSyncedBatch uint64, lastTrustedStateBatchNumber uint64) error { +
    +
    + 113 + +
    +   + batchNumberToSync := max(latestSyncedBatch, s.firstBatchNumberToSync) +
    +
    + 114 + +
    +   + for batchNumberToSync <= lastTrustedStateBatchNumber { +
    +
    +
    @@ -120,6 +130,11 @@
    +
    + 120 + +
    +   + log.Warnf("%s failed to get batch %d from trusted state. Error: %v", debugPrefix, batchNumberToSync, err) +
    +
    + 121 + +
    +   + return err +
    +
    + 122 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 123 + +
    +   +
    +
    +
    + 124 + +
    +   + dbTx, err := s.state.BeginStateTransaction(ctx) +
    +
    + 125 + +
    +   + if err != nil { +
    +
    +
    @@ -161,6 +176,10 @@
    +
    + 161 + +
    +   + s.TrustedStateMngr.Clear() +
    +
    + 162 + +
    +   + } +
    +
    + 163 + +
    +   + batchNumberToSync++ +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 164 + +
    +   + } +
    +
    + 165 + +
    +   +
    +
    +
    + 166 + +
    +   + log.Infof("syncTrustedState: Trusted state fully synchronized from %d to %d", latestSyncedBatch, lastTrustedStateBatchNumber) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 109 + +
    +   + return lastTrustedStateBatchNumber < latestSyncedBatch +
    +
    + 110 + +
    +   + } +
    +
    + 111 + +
    +   +
    +
    +
    + 112 + +
    + + + func sanityCheckBatchReturnedByTrusted(batch *types.Batch, expectedBatchNumber uint64) error { +
    +
    + 113 + +
    + + + if batch == nil { +
    +
    + 114 + +
    + + + return fmt.Errorf("batch %d is nil", expectedBatchNumber) +
    +
    + 115 + +
    + + + } +
    +
    + 116 + +
    + + + if uint64(batch.Number) != expectedBatchNumber { +
    +
    + 117 + +
    + + + return fmt.Errorf("batch %d is not the expected batch %d", batch.Number, expectedBatchNumber) +
    +
    + 118 + +
    + + + } +
    +
    + 119 + +
    + + + return nil +
    +
    + 120 + +
    + + + } +
    +
    + 121 + +
    + + +
    +
    +
    + 122 + +
    +   + func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, latestSyncedBatch uint64, lastTrustedStateBatchNumber uint64) error { +
    +
    + 123 + +
    +   + batchNumberToSync := max(latestSyncedBatch, s.firstBatchNumberToSync) +
    +
    + 124 + +
    +   + for batchNumberToSync <= lastTrustedStateBatchNumber { +
    +
    +
     
    +
    + 130 + +
    +   + log.Warnf("%s failed to get batch %d from trusted state. Error: %v", debugPrefix, batchNumberToSync, err) +
    +
    + 131 + +
    +   + return err +
    +
    + 132 + +
    +   + } +
    +
    + 133 + +
    + + + err = sanityCheckBatchReturnedByTrusted(batchToSync, batchNumberToSync) +
    +
    + 134 + +
    + + + if err != nil { +
    +
    + 135 + +
    + + + log.Warnf("%s sanity check over Batch returned by Trusted-RPC failed: %v", debugPrefix, err) +
    +
    + 136 + +
    + + + return err +
    +
    + 137 + +
    + + + } +
    +
    + 138 + +
    +   +
    +
    +
    + 139 + +
    +   + dbTx, err := s.state.BeginStateTransaction(ctx) +
    +
    + 140 + +
    +   + if err != nil { +
    +
    +
     
    +
    + 176 + +
    +   + s.TrustedStateMngr.Clear() +
    +
    + 177 + +
    +   + } +
    +
    + 178 + +
    +   + batchNumberToSync++ +
    +
    + 179 + +
    + + + if !batchToSync.Closed && batchNumberToSync <= lastTrustedStateBatchNumber { +
    +
    + 180 + +
    + + + log.Infof("%s Batch %d is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state", debugPrefix, batchToSync.Number) +
    +
    + 181 + +
    + + + return nil +
    +
    + 182 + +
    + + + } +
    +
    + 183 + +
    +   + } +
    +
    + 184 + +
    +   +
    +
    +
    + 185 + +
    +   + log.Infof("syncTrustedState: Trusted state fully synchronized from %d to %d", latestSyncedBatch, lastTrustedStateBatchNumber) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -136,13 +137,13 @@
    +
    + 136 + +
    +   + return nil, err +
    +
    + 137 + +
    +   + } +
    +
    + 138 + +
    +   +
    +
    +
    + 139 + +
    + - + leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) +
    +
    + 140 + +
    +   + if err != nil { +
    +
    + 141 + +
    +   + log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    +
    + 142 + +
    +   + return nil, err +
    +
    + 143 + +
    +   + } +
    +
    + 144 + +
    +   + debugStr := data.DebugPrefix +
    +
    + 145 + +
    + - + processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leafs, l1InfoRoot), dbTx, debugStr) +
    +
    + 146 + +
    +   + if err != nil { +
    +
    + 147 + +
    +   + log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) +
    +
    + 148 + +
    +   + return nil, err +
    +
    +
    @@ -197,7 +198,7 @@
    +
    + 197 + +
    +   + return nil, err +
    +
    + 198 + +
    +   + } +
    +
    + 199 + +
    +   +
    +
    +
    + 200 + +
    + - + leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) +
    +
    + 201 + +
    +   + if err != nil { +
    +
    + 202 + +
    +   + log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    +
    + 203 + +
    +   + // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data +
    +
    +
    @@ -205,7 +206,7 @@
    +
    + 205 + +
    +   + return nil, syncinterfaces.ErrMissingSyncFromL1 +
    +
    + 206 + +
    +   + } +
    +
    + 207 + +
    +   + debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) +
    +
    + 208 + +
    + - + processReq := b.getProcessRequest(data, leafs, l1InfoRoot) +
    +
    + 209 + +
    +   + processReq.Transactions = PartialBatchL2Data +
    +
    + 210 + +
    +   + processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) +
    +
    + 211 + +
    +   + if err != nil { +
    +
    +
    @@ -429,6 +430,7 @@
    +
    + 429 + +
    +   + Transactions: data.TrustedBatch.BatchL2Data, +
    +
    + 430 + +
    +   + ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), +
    +
    + 431 + +
    +   + SkipVerifyL1InfoRoot_V2: true, +
    +
    + + +
    +   +
    +
    +
    + 432 + +
    +   + } +
    +
    + 433 + +
    +   + return request +
    +
    + 434 + +
    +   + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 137 + +
    +   + return nil, err +
    +
    + 138 + +
    +   + } +
    +
    + 139 + +
    +   +
    +
    +
    + 140 + +
    + + + leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) +
    +
    + 141 + +
    +   + if err != nil { +
    +
    + 142 + +
    +   + log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    +
    + 143 + +
    +   + return nil, err +
    +
    + 144 + +
    +   + } +
    +
    + 145 + +
    +   + debugStr := data.DebugPrefix +
    +
    + 146 + +
    + + + processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leaves, l1InfoRoot), dbTx, debugStr) +
    +
    + 147 + +
    +   + if err != nil { +
    +
    + 148 + +
    +   + log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) +
    +
    + 149 + +
    +   + return nil, err +
    +
    +
     
    +
    + 198 + +
    +   + return nil, err +
    +
    + 199 + +
    +   + } +
    +
    + 200 + +
    +   +
    +
    +
    + 201 + +
    + + + leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) +
    +
    + 202 + +
    +   + if err != nil { +
    +
    + 203 + +
    +   + log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    +
    + 204 + +
    +   + // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data +
    +
    +
     
    +
    + 206 + +
    +   + return nil, syncinterfaces.ErrMissingSyncFromL1 +
    +
    + 207 + +
    +   + } +
    +
    + 208 + +
    +   + debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) +
    +
    + 209 + +
    + + + processReq := b.getProcessRequest(data, leaves, l1InfoRoot) +
    +
    + 210 + +
    +   + processReq.Transactions = PartialBatchL2Data +
    +
    + 211 + +
    +   + processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) +
    +
    + 212 + +
    +   + if err != nil { +
    +
    +
     
    +
    + 430 + +
    +   + Transactions: data.TrustedBatch.BatchL2Data, +
    +
    + 431 + +
    +   + ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), +
    +
    + 432 + +
    +   + SkipVerifyL1InfoRoot_V2: true, +
    +
    + 433 + +
    + + + ExecutionMode: executor.ExecutionMode1, +
    +
    + 434 + +
    +   + } +
    +
    + 435 + +
    +   + return request +
    +
    + 436 + +
    +   + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -196,6 +196,7 @@
    +
    + 196 + +
    +   + OldAccInputHash: batches[1].AccInputHash, +
    +
    + 197 + +
    +   + Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    +
    + 198 + +
    +   + Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), +
    +
    + + +
    +   +
    +
    +
    + 199 + +
    +   + } +
    +
    + 200 + +
    +   + // check if batch needs to be synchronized +
    +
    + 201 + +
    +   + if batches[0] != nil { +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 196 + +
    +   + OldAccInputHash: batches[1].AccInputHash, +
    +
    + 197 + +
    +   + Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    +
    + 198 + +
    +   + Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), +
    +
    + 199 + +
    + + + ExecutionMode: executor.ExecutionMode1, +
    +
    + 200 + +
    +   + } +
    +
    + 201 + +
    +   + // check if batch needs to be synchronized +
    +
    + 202 + +
    +   + if batches[0] != nil { +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -16,12 +16,14 @@
    +
    + 16 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/processor_manager" +
    +
    + 17 + +
    +   + syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 18 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + + +
    +   +
    +
    +
    + 19 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_parallel_sync" +
    +
    + 20 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" +
    +
    + 21 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" +
    +
    + 22 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    +
    + 23 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" +
    +
    + 24 + +
    +   + "github.com/ethereum/go-ethereum/common" +
    +
    + + +
    +   +
    +
    +
    + 25 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 26 + +
    +   + ) +
    +
    + 27 + +
    +   +
    +
    +
    +
    @@ -52,17 +54,19 @@
    +
    + 52 + +
    +   + etherMan syncinterfaces.EthermanFullInterface +
    +
    + 53 + +
    +   + latestFlushID uint64 +
    +
    + 54 + +
    +   + // If true the lastFlushID is stored in DB and we don't need to check again +
    +
    + 55 + +
    + - + latestFlushIDIsFulfilled bool +
    +
    + 56 + +
    + - + etherManForL1 []syncinterfaces.EthermanFullInterface +
    +
    + 57 + +
    + - + state syncinterfaces.StateFullInterface +
    +
    + 58 + +
    + - + pool syncinterfaces.PoolInterface +
    +
    + 59 + +
    + - + ethTxManager syncinterfaces.EthTxManager +
    +
    + 60 + +
    + - + zkEVMClient syncinterfaces.ZKEVMClientInterface +
    +
    + 61 + +
    + - + eventLog syncinterfaces.EventLogInterface +
    +
    + 62 + +
    + - + ctx context.Context +
    +
    + 63 + +
    + - + cancelCtx context.CancelFunc +
    +
    + 64 + +
    + - + genesis state.Genesis +
    +
    + 65 + +
    + - + cfg Config +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 66 + +
    +   + // Id of the 'process' of the executor. Each time that it starts this value changes +
    +
    + 67 + +
    +   + // This value is obtained from the call state.GetStoredFlushID +
    +
    + 68 + +
    +   + // It starts as an empty string and it is filled in the first call +
    +
    +
    @@ -74,6 +78,7 @@
    +
    + 74 + +
    +   + l1EventProcessors *processor_manager.L1EventProcessors +
    +
    + 75 + +
    +   + syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor +
    +
    + 76 + +
    +   + halter syncinterfaces.CriticalErrorHandler +
    +
    + + +
    +   +
    +
    +
    + 77 + +
    +   + } +
    +
    + 78 + +
    +   +
    +
    +
    + 79 + +
    +   + // NewSynchronizer creates and initializes an instance of Synchronizer +
    +
    +
    @@ -85,30 +90,65 @@
    +
    + 85 + +
    +   + pool syncinterfaces.PoolInterface, +
    +
    + 86 + +
    +   + ethTxManager syncinterfaces.EthTxManager, +
    +
    + 87 + +
    +   + zkEVMClient syncinterfaces.ZKEVMClientInterface, +
    +
    + + +
    +   +
    +
    +
    + 88 + +
    +   + eventLog syncinterfaces.EventLogInterface, +
    +
    + 89 + +
    +   + genesis state.Genesis, +
    +
    + 90 + +
    +   + cfg Config, +
    +
    + 91 + +
    +   + runInDevelopmentMode bool) (Synchronizer, error) { +
    +
    + 92 + +
    +   + ctx, cancel := context.WithCancel(context.Background()) +
    +
    + 93 + +
    +   + metrics.Register() +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 94 + +
    +   + res := &ClientSynchronizer{ +
    +
    + 95 + +
    + - + isTrustedSequencer: isTrustedSequencer, +
    +
    + 96 + +
    + - + state: st, +
    +
    + 97 + +
    + - + etherMan: ethMan, +
    +
    + 98 + +
    + - + etherManForL1: etherManForL1, +
    +
    + 99 + +
    + - + pool: pool, +
    +
    + 100 + +
    + - + ctx: ctx, +
    +
    + 101 + +
    + - + cancelCtx: cancel, +
    +
    + 102 + +
    + - + ethTxManager: ethTxManager, +
    +
    + 103 + +
    + - + zkEVMClient: zkEVMClient, +
    +
    + 104 + +
    + - + eventLog: eventLog, +
    +
    + 105 + +
    + - + genesis: genesis, +
    +
    + 106 + +
    + - + cfg: cfg, +
    +
    + 107 + +
    + - + proverID: "", +
    +
    + 108 + +
    + - + previousExecutorFlushID: 0, +
    +
    + 109 + +
    + - + l1SyncOrchestration: nil, +
    +
    + 110 + +
    + - + l1EventProcessors: nil, +
    +
    + 111 + +
    + - + halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 112 + +
    +   + } +
    +
    + 113 + +
    +   +
    +
    +
    + 114 + +
    +   + if !isTrustedSequencer { +
    +
    +
    @@ -143,7 +183,11 @@
    +
    + 143 + +
    +   + log.Errorf("error getting last L2Block number from state. Error: %v", err) +
    +
    + 144 + +
    +   + return nil, err +
    +
    + 145 + +
    +   + } +
    +
    + 146 + +
    + - + l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClient, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 147 + +
    +   + } else { +
    +
    + 148 + +
    +   + log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") +
    +
    + 149 + +
    +   + } +
    +
    +
    @@ -163,6 +207,19 @@
    +
    + 163 + +
    +   + return res, nil +
    +
    + 164 + +
    +   + } +
    +
    + 165 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 166 + +
    +   + var waitDuration = time.Duration(0) +
    +
    + 167 + +
    +   +
    +
    +
    + 168 + +
    +   + func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { +
    +
    +
    @@ -225,6 +282,10 @@
    +
    + 225 + +
    +   + // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block +
    +
    + 226 + +
    +   + // Get the latest synced block. If there is no block on db, use genesis block +
    +
    + 227 + +
    +   + log.Info("Sync started") +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 228 + +
    +   + dbTx, err := s.state.BeginStateTransaction(s.ctx) +
    +
    + 229 + +
    +   + if err != nil { +
    +
    + 230 + +
    +   + log.Errorf("error creating db transaction to get latest block. Error: %v", err) +
    +
    +
    @@ -234,7 +295,7 @@
    +
    + 234 + +
    +   + if err != nil { +
    +
    + 235 + +
    +   + if errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 236 + +
    +   + log.Info("State is empty, verifying genesis block") +
    +
    + 237 + +
    + - + valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber) +
    +
    + 238 + +
    +   + if err != nil { +
    +
    + 239 + +
    +   + log.Error("error checking genesis block number. Error: ", err) +
    +
    + 240 + +
    +   + return rollback(s.ctx, dbTx, err) +
    +
    +
    @@ -242,12 +303,42 @@
    +
    + 242 + +
    +   + log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +
    +
    + 243 + +
    +   + return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) +
    +
    + 244 + +
    +   + } +
    +
    + 245 + +
    + - + log.Info("Setting genesis block") +
    +
    + 246 + +
    + - + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.BlockNumber)) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 247 + +
    +   + if err != nil { +
    +
    + 248 + +
    + - + log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err) +
    +
    + 249 + +
    +   + return rollback(s.ctx, dbTx, err) +
    +
    + 250 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 251 + +
    +   + lastEthBlockSynced = &state.Block{ +
    +
    + 252 + +
    +   + BlockNumber: header.Number.Uint64(), +
    +
    + 253 + +
    +   + BlockHash: header.Hash(), +
    +
    +
    @@ -346,6 +437,7 @@
    +
    + 346 + +
    +   + continue +
    +
    + 347 + +
    +   + } +
    +
    + 348 + +
    +   + log.Infof("latestSequencedBatchNumber: %d, latestSyncedBatch: %d, lastVerifiedBatchNumber: %d", latestSequencedBatchNumber, latestSyncedBatch, lastVerifiedBatchNumber) +
    +
    + + +
    +   +
    +
    +
    + 349 + +
    +   + // Sync trusted state +
    +
    + 350 + +
    +   + // latestSyncedBatch -> Last batch on DB +
    +
    + 351 + +
    +   + // latestSequencedBatchNumber -> last batch on SMC +
    +
    +
    @@ -353,6 +445,13 @@
    +
    + 353 + +
    +   + startTrusted := time.Now() +
    +
    + 354 + +
    +   + if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { +
    +
    + 355 + +
    +   + log.Info("Syncing trusted state (permissionless)") +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 356 + +
    +   + err = s.syncTrustedState(latestSyncedBatch) +
    +
    + 357 + +
    +   + metrics.FullTrustedSyncTime(time.Since(startTrusted)) +
    +
    + 358 + +
    +   + if err != nil { +
    +
    +
    @@ -361,10 +460,14 @@
    +
    + 361 + +
    +   + if errors.Is(err, syncinterfaces.ErrFatalDesyncFromL1) { +
    +
    + 362 + +
    +   + l1BlockNumber := err.(*l2_shared.DeSyncPermissionlessAndTrustedNodeError).L1BlockNumber +
    +
    + 363 + +
    +   + log.Error("Trusted and permissionless desync! reseting to last common point: L1Block (%d-1)", l1BlockNumber) +
    +
    + 364 + +
    + - + err = s.resetState(l1BlockNumber - 1) +
    +
    + 365 + +
    + - + if err != nil { +
    +
    + 366 + +
    + - + log.Errorf("error resetting the state to a discrepancy block. Retrying... Err: %v", err) +
    +
    + 367 + +
    + - + continue +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 368 + +
    +   + } +
    +
    + 369 + +
    +   + } else if errors.Is(err, syncinterfaces.ErrMissingSyncFromL1) { +
    +
    + 370 + +
    +   + log.Info("Syncing from trusted node need data from L1") +
    +
    +
    @@ -381,6 +484,11 @@
    +
    + 381 + +
    +   + waitDuration = s.cfg.SyncInterval.Duration +
    +
    + 382 + +
    +   + } +
    +
    + 383 + +
    +   + //Sync L1Blocks +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 384 + +
    +   + startL1 := time.Now() +
    +
    + 385 + +
    +   + if s.l1SyncOrchestration != nil && (latestSyncedBatch < latestSequencedBatchNumber || !s.cfg.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized) { +
    +
    + 386 + +
    +   + log.Infof("Syncing L1 blocks in parallel lastEthBlockSynced=%d", lastEthBlockSynced.BlockNumber) +
    +
    +
    @@ -395,6 +503,19 @@
    +
    + 395 + +
    +   + lastEthBlockSynced, err = s.syncBlocksSequential(lastEthBlockSynced) +
    +
    + 396 + +
    +   + } +
    +
    + 397 + +
    +   + metrics.FullL1SyncTime(time.Since(startL1)) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 398 + +
    +   + if err != nil { +
    +
    + 399 + +
    +   + log.Warn("error syncing blocks: ", err) +
    +
    + 400 + +
    +   + s.CleanTrustedState() +
    +
    +
    @@ -465,57 +586,35 @@
    +
    + 465 + +
    +   + // This function syncs the node from a specific block to the latest +
    +
    + 466 + +
    +   + // lastEthBlockSynced -> last block synced in the db +
    +
    + 467 + +
    +   + func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    +
    + 468 + +
    + - + // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. +
    +
    + 469 + +
    + - + block, err := s.checkReorg(lastEthBlockSynced) +
    +
    + 470 + +
    + - + if err != nil { +
    +
    + 471 + +
    + - + log.Errorf("error checking reorgs. Retrying... Err: %v", err) +
    +
    + 472 + +
    + - + return lastEthBlockSynced, fmt.Errorf("error checking reorgs") +
    +
    + 473 + +
    + - + } +
    +
    + 474 + +
    + - + if block != nil { +
    +
    + 475 + +
    + - + log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, block.BlockNumber) +
    +
    + 476 + +
    + - + err = s.resetState(block.BlockNumber) +
    +
    + 477 + +
    + - + if err != nil { +
    +
    + 478 + +
    + - + log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    + 479 + +
    + - + s.l1SyncOrchestration.Reset(lastEthBlockSynced.BlockNumber) +
    +
    + 480 + +
    + - + return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    + 481 + +
    + - + } +
    +
    + 482 + +
    + - + return block, nil +
    +
    + 483 + +
    + - + } +
    +
    + 484 + +
    +   + log.Infof("Starting L1 sync orchestrator in parallel block: %d", lastEthBlockSynced.BlockNumber) +
    +
    + 485 + +
    +   + return s.l1SyncOrchestration.Start(lastEthBlockSynced) +
    +
    + 486 + +
    +   + } +
    +
    + 487 + +
    +   +
    +
    +
    + 488 + +
    +   + // This function syncs the node from a specific block to the latest +
    +
    + 489 + +
    +   + func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    +
    + 490 + +
    + - + // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. +
    +
    + 491 + +
    + - + block, err := s.checkReorg(lastEthBlockSynced) +
    +
    + 492 + +
    + - + if err != nil { +
    +
    + 493 + +
    + - + log.Errorf("error checking reorgs. Retrying... Err: %v", err) +
    +
    + 494 + +
    + - + return lastEthBlockSynced, fmt.Errorf("error checking reorgs") +
    +
    + 495 + +
    + - + } +
    +
    + 496 + +
    + - + if block != nil { +
    +
    + 497 + +
    + - + err = s.resetState(block.BlockNumber) +
    +
    + 498 + +
    + - + if err != nil { +
    +
    + 499 + +
    + - + log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    + 500 + +
    + - + return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    + 501 + +
    + - + } +
    +
    + 502 + +
    + - + return block, nil +
    +
    + 503 + +
    + - + } +
    +
    + 504 + +
    + - +
    +
    +
    + 505 + +
    +   + // Call the blockchain to retrieve data +
    +
    + 506 + +
    + - + header, err := s.etherMan.HeaderByNumber(s.ctx, nil) +
    +
    + 507 + +
    +   + if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 508 + +
    +   + return lastEthBlockSynced, err +
    +
    + 509 + +
    +   + } +
    +
    + 510 + +
    +   + lastKnownBlock := header.Number +
    +
    + 511 + +
    +   +
    +
    +
    + 512 + +
    +   + var fromBlock uint64 +
    +
    + 513 + +
    +   + if lastEthBlockSynced.BlockNumber > 0 { +
    +
    + 514 + +
    + - + fromBlock = lastEthBlockSynced.BlockNumber + 1 +
    +
    + 515 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 516 + +
    +   +
    +
    +
    + 517 + +
    +   + for { +
    +
    + 518 + +
    + - + toBlock := fromBlock + s.cfg.SyncChunkSize +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 519 + +
    +   + log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) +
    +
    + 520 + +
    +   + log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) +
    +
    + 521 + +
    +   + // This function returns the rollup information contained in the ethereum blocks and an extra param called order. +
    +
    +
    @@ -529,6 +628,53 @@
    +
    + 529 + +
    +   + if err != nil { +
    +
    + 530 + +
    +   + return lastEthBlockSynced, err +
    +
    + 531 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 532 + +
    +   + start = time.Now() +
    +
    + 533 + +
    +   + err = s.ProcessBlockRange(blocks, order) +
    +
    + 534 + +
    +   + metrics.ProcessL1DataTime(time.Since(start)) +
    +
    +
    @@ -543,47 +689,36 @@
    +
    + 543 + +
    +   + ReceivedAt: blocks[len(blocks)-1].ReceivedAt, +
    +
    + 544 + +
    +   + } +
    +
    + 545 + +
    +   + for i := range blocks { +
    +
    + 546 + +
    + - + log.Debug("Position: ", i, ". BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) +
    +
    + 547 + +
    +   + } +
    +
    + 548 + +
    +   + } +
    +
    + 549 + +
    + - + fromBlock = toBlock + 1 +
    +
    + 550 + +
    +   +
    +
    +
    + 551 + +
    +   + if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 { +
    +
    + 552 + +
    +   + waitDuration = s.cfg.SyncInterval.Duration +
    +
    + 553 + +
    +   + break +
    +
    + 554 + +
    +   + } +
    +
    + 555 + +
    + - + if len(blocks) == 0 { // If there is no events in the checked blocks range and lastKnownBlock > fromBlock. +
    +
    + 556 + +
    + - + // Store the latest block of the block range. Get block info and process the block +
    +
    + 557 + +
    + - + fb, err := s.etherMan.EthBlockByNumber(s.ctx, toBlock) +
    +
    + 558 + +
    + - + if err != nil { +
    +
    + 559 + +
    + - + return lastEthBlockSynced, err +
    +
    + 560 + +
    + - + } +
    +
    + 561 + +
    + - + b := etherman.Block{ +
    +
    + 562 + +
    + - + BlockNumber: fb.NumberU64(), +
    +
    + 563 + +
    + - + BlockHash: fb.Hash(), +
    +
    + 564 + +
    + - + ParentHash: fb.ParentHash(), +
    +
    + 565 + +
    + - + ReceivedAt: time.Unix(int64(fb.Time()), 0), +
    +
    + 566 + +
    + - + } +
    +
    + 567 + +
    + - + err = s.ProcessBlockRange([]etherman.Block{b}, order) +
    +
    + 568 + +
    + - + if err != nil { +
    +
    + 569 + +
    + - + return lastEthBlockSynced, err +
    +
    + 570 + +
    + - + } +
    +
    + 571 + +
    + - + block := state.Block{ +
    +
    + 572 + +
    + - + BlockNumber: fb.NumberU64(), +
    +
    + 573 + +
    + - + BlockHash: fb.Hash(), +
    +
    + 574 + +
    + - + ParentHash: fb.ParentHash(), +
    +
    + 575 + +
    + - + ReceivedAt: time.Unix(int64(fb.Time()), 0), +
    +
    + 576 + +
    + - + } +
    +
    + 577 + +
    + - + lastEthBlockSynced = &block +
    +
    + 578 + +
    + - + log.Debug("Storing empty block. BlockNumber: ", b.BlockNumber, ". BlockHash: ", b.BlockHash) +
    +
    + 579 + +
    + - + } +
    +
    + 580 + +
    +   + } +
    +
    + 581 + +
    +   +
    +
    +
    + 582 + +
    +   + return lastEthBlockSynced, nil +
    +
    + 583 + +
    +   + } +
    +
    + 584 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 585 + +
    +   + // ProcessBlockRange process the L1 events and stores the information in the db +
    +
    + 586 + +
    +   + func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 587 + +
    +   + // New info has to be included into the db using the state +
    +
    + 588 + +
    +   + for i := range blocks { +
    +
    + 589 + +
    +   + // Begin db transaction +
    +
    +
    @@ -598,9 +733,13 @@
    +
    + 598 + +
    +   + ParentHash: blocks[i].ParentHash, +
    +
    + 599 + +
    +   + ReceivedAt: blocks[i].ReceivedAt, +
    +
    + 600 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 601 + +
    +   + // Add block information +
    +
    + 602 + +
    +   + err = s.state.AddBlock(s.ctx, &b, dbTx) +
    +
    + 603 + +
    +   + if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 604 + +
    +   + log.Errorf("error storing block. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err) +
    +
    + 605 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 606 + +
    +   + if rollbackErr != nil { +
    +
    +
    @@ -618,7 +757,7 @@
    +
    + 618 + +
    +   + log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) +
    +
    + 619 + +
    +   + } else { +
    +
    + 620 + +
    +   + forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) +
    +
    + 621 + +
    + - + log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, "forkId: ", forkId) +
    +
    + 622 + +
    +   + } +
    +
    + 623 + +
    +   + forkIdTyped := actions.ForkIdType(forkId) +
    +
    + 624 + +
    +   + // Process event received from l1 +
    +
    +
    @@ -637,6 +776,7 @@
    +
    + 637 + +
    +   + log.Debug("Checking FlushID to commit L1 data to db") +
    +
    + 638 + +
    +   + err = s.checkFlushID(dbTx) +
    +
    + 639 + +
    +   + if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 640 + +
    +   + log.Errorf("error checking flushID. Error: %v", err) +
    +
    + 641 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 642 + +
    +   + if rollbackErr != nil { +
    +
    +
    @@ -647,6 +787,7 @@
    +
    + 647 + +
    +   + } +
    +
    + 648 + +
    +   + err = dbTx.Commit(s.ctx) +
    +
    + 649 + +
    +   + if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 650 + +
    +   + log.Errorf("error committing state to store block. BlockNumber: %d, err: %v", blocks[i].BlockNumber, err) +
    +
    + 651 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 652 + +
    +   + if rollbackErr != nil { +
    +
    +
    @@ -705,12 +846,118 @@
    +
    + 705 + +
    +   + log.Error("error committing the resetted state. Error: ", err) +
    +
    + 706 + +
    +   + return err +
    +
    + 707 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 708 + +
    +   + if s.l1SyncOrchestration != nil { +
    +
    + 709 + +
    + - + s.l1SyncOrchestration.Reset(blockNumber) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 710 + +
    +   + } +
    +
    + 711 + +
    +   + return nil +
    +
    + 712 + +
    +   + } +
    +
    + 713 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 714 + +
    +   + /* +
    +
    + 715 + +
    +   + This function will check if there is a reorg. +
    +
    + 716 + +
    +   + As input param needs the last ethereum block synced. Retrieve the block info from the blockchain +
    +
    +
    @@ -719,31 +966,47 @@
    +
    + 719 + +
    +   + must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check +
    +
    + 720 + +
    +   + hash and has parent. This operation has to be done until a match is found. +
    +
    + 721 + +
    +   + */ +
    +
    + 722 + +
    + - + func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, error) { +
    +
    + + +
    +   +
    +
    +
    + 723 + +
    +   + // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. +
    +
    + 724 + +
    + - + latestEthBlockSynced := *latestBlock +
    +
    + + +
    +   +
    +
    +
    + 725 + +
    +   + var depth uint64 +
    +
    + + +
    +   +
    +
    +
    + 726 + +
    +   + for { +
    +
    + 727 + +
    + - + block, err := s.etherMan.EthBlockByNumber(s.ctx, latestBlock.BlockNumber) +
    +
    + 728 + +
    + - + if err != nil { +
    +
    + 729 + +
    + - + log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", latestBlock.BlockNumber, err) +
    +
    + 730 + +
    + - + return nil, err +
    +
    + 731 + +
    + - + } +
    +
    + 732 + +
    + - + if block.NumberU64() != latestBlock.BlockNumber { +
    +
    + 733 + +
    + - + err = fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", +
    +
    + 734 + +
    + - + latestBlock.BlockNumber, block.NumberU64()) +
    +
    + 735 + +
    + - + log.Error("error: ", err) +
    +
    + 736 + +
    + - + return nil, err +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 737 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 738 + +
    +   + // Compare hashes +
    +
    + 739 + +
    + - + if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.BlockNumber { +
    +
    + 740 + +
    + - + log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash) +
    +
    + 741 + +
    + - + log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) +
    +
    + 742 + +
    + - + log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) +
    +
    + 743 + +
    + - + log.Debug("[checkReorg function] => latestBlockHashParent: ", latestBlock.ParentHash) +
    +
    + 744 + +
    + - + log.Debug("[checkReorg function] => BlockNumber: ", latestBlock.BlockNumber, block.NumberU64()) +
    +
    + 745 + +
    + - + log.Debug("[checkReorg function] => BlockHash: ", block.Hash()) +
    +
    + 746 + +
    + - + log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash()) +
    +
    + 747 + +
    +   + depth++ +
    +
    + 748 + +
    +   + log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) +
    +
    + 749 + +
    +   + // Reorg detected. Getting previous block +
    +
    +
    @@ -752,7 +1015,7 @@
    +
    + 752 + +
    +   + log.Errorf("error creating db transaction to get prevoius blocks") +
    +
    + 753 + +
    +   + return nil, err +
    +
    + 754 + +
    +   + } +
    +
    + 755 + +
    + - + latestBlock, err = s.state.GetPreviousBlock(s.ctx, depth, dbTx) +
    +
    + 756 + +
    +   + errC := dbTx.Commit(s.ctx) +
    +
    + 757 + +
    +   + if errC != nil { +
    +
    + 758 + +
    +   + log.Errorf("error committing dbTx, err: %v", errC) +
    +
    +
    @@ -765,19 +1028,26 @@
    +
    + 765 + +
    +   + return nil, errC +
    +
    + 766 + +
    +   + } +
    +
    + 767 + +
    +   + if errors.Is(err, state.ErrNotFound) { +
    +
    + 768 + +
    + - + log.Warn("error checking reorg: previous block not found in db: ", err) +
    +
    + 769 + +
    + - + return &state.Block{}, nil +
    +
    + 770 + +
    +   + } else if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 771 + +
    +   + return nil, err +
    +
    + 772 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 773 + +
    +   + } else { +
    +
    + + +
    +   +
    +
    +
    + 774 + +
    +   + break +
    +
    + 775 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 776 + +
    +   + } +
    +
    + 777 + +
    + - + if latestEthBlockSynced.BlockHash != latestBlock.BlockHash { +
    +
    + 778 + +
    + - + log.Info("Reorg detected in block: ", latestEthBlockSynced.BlockNumber, " last block OK: ", latestBlock.BlockNumber) +
    +
    + 779 + +
    + - + return latestBlock, nil +
    +
    + + +
    +   +
    +
    +
    + 780 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 781 + +
    +   + return nil, nil +
    +
    + 782 + +
    +   + } +
    +
    + 783 + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 16 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/processor_manager" +
    +
    + 17 + +
    +   + syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    + 18 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + 19 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +
    +
    + 20 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_parallel_sync" +
    +
    + 21 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" +
    +
    + 22 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" +
    +
    + 23 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    +
    + 24 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" +
    +
    + 25 + +
    +   + "github.com/ethereum/go-ethereum/common" +
    +
    + 26 + +
    + + + "github.com/ethereum/go-ethereum/rpc" +
    +
    + 27 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 28 + +
    +   + ) +
    +
    + 29 + +
    +   +
    +
    +
    +
     
    +
    + 54 + +
    +   + etherMan syncinterfaces.EthermanFullInterface +
    +
    + 55 + +
    +   + latestFlushID uint64 +
    +
    + 56 + +
    +   + // If true the lastFlushID is stored in DB and we don't need to check again +
    +
    + 57 + +
    + + + latestFlushIDIsFulfilled bool +
    +
    + 58 + +
    + + + syncBlockProtection rpc.BlockNumber +
    +
    + 59 + +
    + + + etherManForL1 []syncinterfaces.EthermanFullInterface +
    +
    + 60 + +
    + + + state syncinterfaces.StateFullInterface +
    +
    + 61 + +
    + + + pool syncinterfaces.PoolInterface +
    +
    + 62 + +
    + + + ethTxManager syncinterfaces.EthTxManager +
    +
    + 63 + +
    + + + zkEVMClient syncinterfaces.ZKEVMClientInterface +
    +
    + 64 + +
    + + + zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface +
    +
    + 65 + +
    + + + eventLog syncinterfaces.EventLogInterface +
    +
    + 66 + +
    + + + ctx context.Context +
    +
    + 67 + +
    + + + cancelCtx context.CancelFunc +
    +
    + 68 + +
    + + + genesis state.Genesis +
    +
    + 69 + +
    + + + cfg Config +
    +
    + 70 + +
    +   + // Id of the 'process' of the executor. Each time that it starts this value changes +
    +
    + 71 + +
    +   + // This value is obtained from the call state.GetStoredFlushID +
    +
    + 72 + +
    +   + // It starts as an empty string and it is filled in the first call +
    +
    +
     
    +
    + 78 + +
    +   + l1EventProcessors *processor_manager.L1EventProcessors +
    +
    + 79 + +
    +   + syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor +
    +
    + 80 + +
    +   + halter syncinterfaces.CriticalErrorHandler +
    +
    + 81 + +
    + + + asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator +
    +
    + 82 + +
    +   + } +
    +
    + 83 + +
    +   +
    +
    +
    + 84 + +
    +   + // NewSynchronizer creates and initializes an instance of Synchronizer +
    +
    +
     
    +
    + 90 + +
    +   + pool syncinterfaces.PoolInterface, +
    +
    + 91 + +
    +   + ethTxManager syncinterfaces.EthTxManager, +
    +
    + 92 + +
    +   + zkEVMClient syncinterfaces.ZKEVMClientInterface, +
    +
    + 93 + +
    + + + zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface, +
    +
    + 94 + +
    +   + eventLog syncinterfaces.EventLogInterface, +
    +
    + 95 + +
    +   + genesis state.Genesis, +
    +
    + 96 + +
    +   + cfg Config, +
    +
    + 97 + +
    +   + runInDevelopmentMode bool) (Synchronizer, error) { +
    +
    + 98 + +
    +   + ctx, cancel := context.WithCancel(context.Background()) +
    +
    + 99 + +
    +   + metrics.Register() +
    +
    + 100 + +
    + + + syncBlockProtection, err := decodeSyncBlockProtection(cfg.SyncBlockProtection) +
    +
    + 101 + +
    + + + if err != nil { +
    +
    + 102 + +
    + + + log.Errorf("error decoding syncBlockProtection. Error: %v", err) +
    +
    + 103 + +
    + + + cancel() +
    +
    + 104 + +
    + + + return nil, err +
    +
    + 105 + +
    + + + } +
    +
    + 106 + +
    + + + log.Info("syncBlockProtection: ", syncBlockProtection) +
    +
    + 107 + +
    +   + res := &ClientSynchronizer{ +
    +
    + 108 + +
    + + + isTrustedSequencer: isTrustedSequencer, +
    +
    + 109 + +
    + + + state: st, +
    +
    + 110 + +
    + + + etherMan: ethMan, +
    +
    + 111 + +
    + + + etherManForL1: etherManForL1, +
    +
    + 112 + +
    + + + pool: pool, +
    +
    + 113 + +
    + + + ctx: ctx, +
    +
    + 114 + +
    + + + cancelCtx: cancel, +
    +
    + 115 + +
    + + + ethTxManager: ethTxManager, +
    +
    + 116 + +
    + + + zkEVMClient: zkEVMClient, +
    +
    + 117 + +
    + + + zkEVMClientEthereumCompatible: zkEVMClientEthereumCompatible, +
    +
    + 118 + +
    + + + eventLog: eventLog, +
    +
    + 119 + +
    + + + genesis: genesis, +
    +
    + 120 + +
    + + + cfg: cfg, +
    +
    + 121 + +
    + + + proverID: "", +
    +
    + 122 + +
    + + + previousExecutorFlushID: 0, +
    +
    + 123 + +
    + + + l1SyncOrchestration: nil, +
    +
    + 124 + +
    + + + l1EventProcessors: nil, +
    +
    + 125 + +
    + + + syncBlockProtection: syncBlockProtection, +
    +
    + 126 + +
    + + + halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd +
    +
    + 127 + +
    + + + } +
    +
    + 128 + +
    + + + if cfg.L1BlockCheck.Enable { +
    +
    + 129 + +
    + + + log.Infof("L1BlockChecker enabled: %s", cfg.L1BlockCheck.String()) +
    +
    + 130 + +
    + + + l1BlockChecker := l1_check_block.NewCheckL1BlockHash(ethMan, res.state, +
    +
    + 131 + +
    + + + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset)) +
    +
    + 132 + +
    + + +
    +
    +
    + 133 + +
    + + + var preCheckAsync syncinterfaces.AsyncL1BlockChecker +
    +
    + 134 + +
    + + + if cfg.L1BlockCheck.PreCheckEnable { +
    +
    + 135 + +
    + + + log.Infof("L1BlockChecker enabled precheck from: %s/%d to: %s/%d", +
    +
    + 136 + +
    + + + cfg.L1BlockCheck.L1SafeBlockPoint, cfg.L1BlockCheck.L1SafeBlockOffset, +
    +
    + 137 + +
    + + + cfg.L1BlockCheck.L1PreSafeBlockPoint, cfg.L1BlockCheck.L1PreSafeBlockOffset) +
    +
    + 138 + +
    + + + l1BlockPreChecker := l1_check_block.NewPreCheckL1BlockHash(ethMan, res.state, +
    +
    + 139 + +
    + + + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset), +
    +
    + 140 + +
    + + + l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1PreSafeBlockPoint), cfg.L1BlockCheck.L1PreSafeBlockOffset), +
    +
    + 141 + +
    + + + ) +
    +
    + 142 + +
    + + + preCheckAsync = l1_check_block.NewAsyncCheck(l1BlockPreChecker) +
    +
    + 143 + +
    + + + } +
    +
    + 144 + +
    + + +
    +
    +
    + 145 + +
    + + + res.asyncL1BlockChecker = l1_check_block.NewL1BlockCheckerIntegration( +
    +
    + 146 + +
    + + + l1_check_block.NewAsyncCheck(l1BlockChecker), +
    +
    + 147 + +
    + + + preCheckAsync, +
    +
    + 148 + +
    + + + res.state, +
    +
    + 149 + +
    + + + res, +
    +
    + 150 + +
    + + + cfg.L1BlockCheck.ForceCheckBeforeStart, +
    +
    + 151 + +
    + + + time.Second) +
    +
    + 152 + +
    +   + } +
    +
    + 153 + +
    +   +
    +
    +
    + 154 + +
    +   + if !isTrustedSequencer { +
    +
    +
     
    +
    + 183 + +
    +   + log.Errorf("error getting last L2Block number from state. Error: %v", err) +
    +
    + 184 + +
    +   + return nil, err +
    +
    + 185 + +
    +   + } +
    +
    + 186 + +
    + + + l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) +
    +
    + 187 + +
    + + + if err != nil { +
    +
    + 188 + +
    + + + log.Error("error creating new instance of checkL2BlockHash. Error: ", err) +
    +
    + 189 + +
    + + + return nil, err +
    +
    + 190 + +
    + + + } +
    +
    + 191 + +
    +   + } else { +
    +
    + 192 + +
    +   + log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") +
    +
    + 193 + +
    +   + } +
    +
    +
     
    +
    + 207 + +
    +   + return res, nil +
    +
    + 208 + +
    +   + } +
    +
    + 209 + +
    +   +
    +
    +
    + 210 + +
    + + + func decodeSyncBlockProtection(sBP string) (rpc.BlockNumber, error) { +
    +
    + 211 + +
    + + + switch sBP { +
    +
    + 212 + +
    + + + case "latest": +
    +
    + 213 + +
    + + + return rpc.LatestBlockNumber, nil +
    +
    + 214 + +
    + + + case "finalized": +
    +
    + 215 + +
    + + + return rpc.FinalizedBlockNumber, nil +
    +
    + 216 + +
    + + + case "safe": +
    +
    + 217 + +
    + + + return rpc.SafeBlockNumber, nil +
    +
    + 218 + +
    + + + default: +
    +
    + 219 + +
    + + + return 0, fmt.Errorf("error decoding SyncBlockProtection. Unknown value") +
    +
    + 220 + +
    + + + } +
    +
    + 221 + +
    + + + } +
    +
    + 222 + +
    + + +
    +
    +
    + 223 + +
    +   + var waitDuration = time.Duration(0) +
    +
    + 224 + +
    +   +
    +
    +
    + 225 + +
    +   + func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { +
    +
    +
     
    +
    + 282 + +
    +   + // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block +
    +
    + 283 + +
    +   + // Get the latest synced block. If there is no block on db, use genesis block +
    +
    + 284 + +
    +   + log.Info("Sync started") +
    +
    + 285 + +
    + + + if s.asyncL1BlockChecker != nil { +
    +
    + 286 + +
    + + + _ = s.asyncL1BlockChecker.OnStart(s.ctx) +
    +
    + 287 + +
    + + + } +
    +
    + 288 + +
    + + +
    +
    +
    + 289 + +
    +   + dbTx, err := s.state.BeginStateTransaction(s.ctx) +
    +
    + 290 + +
    +   + if err != nil { +
    +
    + 291 + +
    +   + log.Errorf("error creating db transaction to get latest block. Error: %v", err) +
    +
    +
     
    +
    + 295 + +
    +   + if err != nil { +
    +
    + 296 + +
    +   + if errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 297 + +
    +   + log.Info("State is empty, verifying genesis block") +
    +
    + 298 + +
    + + + valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.RollupBlockNumber) +
    +
    + 299 + +
    +   + if err != nil { +
    +
    + 300 + +
    +   + log.Error("error checking genesis block number. Error: ", err) +
    +
    + 301 + +
    +   + return rollback(s.ctx, dbTx, err) +
    +
    +
     
    +
    + 303 + +
    +   + log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +
    +
    + 304 + +
    +   + return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) +
    +
    + 305 + +
    +   + } +
    +
    + 306 + +
    + + +
    +
    +
    + 307 + +
    + + + // Sync events from RollupManager that happen before rollup creation +
    +
    + 308 + +
    + + + log.Info("synchronizing events from RollupManager that happen before rollup creation") +
    +
    + 309 + +
    + + + for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize { +
    +
    + 310 + +
    + + + toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1) +
    +
    + 311 + +
    + + + blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock) +
    +
    + 312 + +
    + + + if err != nil { +
    +
    + 313 + +
    + + + log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err) +
    +
    + 314 + +
    + + + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 315 + +
    + + + if rollbackErr != nil { +
    +
    + 316 + +
    + + + log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    + 317 + +
    + + + return rollbackErr +
    +
    + 318 + +
    + + + } +
    +
    + 319 + +
    + + + return err +
    +
    + 320 + +
    + + + } +
    +
    + 321 + +
    + + + err = s.ProcessBlockRange(blocks, order) +
    +
    + 322 + +
    + + + if err != nil { +
    +
    + 323 + +
    + + + log.Error("error processing blocks before the genesis: ", err) +
    +
    + 324 + +
    + + + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 325 + +
    + + + if rollbackErr != nil { +
    +
    + 326 + +
    + + + log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    + 327 + +
    + + + return rollbackErr +
    +
    + 328 + +
    + + + } +
    +
    + 329 + +
    + + + return err +
    +
    + 330 + +
    + + + } +
    +
    + 331 + +
    + + + if toBlock == s.genesis.RollupBlockNumber-1 { +
    +
    + 332 + +
    + + + break +
    +
    + 333 + +
    + + + } +
    +
    + 334 + +
    + + + } +
    +
    + 335 + +
    + + +
    +
    +
    + 336 + +
    + + + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber)) +
    +
    + 337 + +
    +   + if err != nil { +
    +
    + 338 + +
    + + + log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err) +
    +
    + 339 + +
    +   + return rollback(s.ctx, dbTx, err) +
    +
    + 340 + +
    +   + } +
    +
    + 341 + +
    + + + log.Info("synchronizing rollup creation block") +
    +
    + 342 + +
    +   + lastEthBlockSynced = &state.Block{ +
    +
    + 343 + +
    +   + BlockNumber: header.Number.Uint64(), +
    +
    + 344 + +
    +   + BlockHash: header.Hash(), +
    +
    +
     
    +
    + 437 + +
    +   + continue +
    +
    + 438 + +
    +   + } +
    +
    + 439 + +
    +   + log.Infof("latestSequencedBatchNumber: %d, latestSyncedBatch: %d, lastVerifiedBatchNumber: %d", latestSequencedBatchNumber, latestSyncedBatch, lastVerifiedBatchNumber) +
    +
    + 440 + +
    + + + resetDone := false +
    +
    + 441 + +
    +   + // Sync trusted state +
    +
    + 442 + +
    +   + // latestSyncedBatch -> Last batch on DB +
    +
    + 443 + +
    +   + // latestSequencedBatchNumber -> last batch on SMC +
    +
    +
     
    +
    + 445 + +
    +   + startTrusted := time.Now() +
    +
    + 446 + +
    +   + if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { +
    +
    + 447 + +
    +   + log.Info("Syncing trusted state (permissionless)") +
    +
    + 448 + +
    + + + //Sync Trusted State +
    +
    + 449 + +
    + + + log.Debug("Doing reorg check before L2 sync") +
    +
    + 450 + +
    + + + resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) +
    +
    + 451 + +
    + + + if resetDone || err != nil { +
    +
    + 452 + +
    + + + log.Infof("Reset done before L2 sync") +
    +
    + 453 + +
    + + + continue +
    +
    + 454 + +
    + + + } +
    +
    + 455 + +
    +   + err = s.syncTrustedState(latestSyncedBatch) +
    +
    + 456 + +
    +   + metrics.FullTrustedSyncTime(time.Since(startTrusted)) +
    +
    + 457 + +
    +   + if err != nil { +
    +
    +
     
    +
    + 460 + +
    +   + if errors.Is(err, syncinterfaces.ErrFatalDesyncFromL1) { +
    +
    + 461 + +
    +   + l1BlockNumber := err.(*l2_shared.DeSyncPermissionlessAndTrustedNodeError).L1BlockNumber +
    +
    + 462 + +
    +   + log.Error("Trusted and permissionless desync! reseting to last common point: L1Block (%d-1)", l1BlockNumber) +
    +
    + 463 + +
    + + + for { +
    +
    + 464 + +
    + + + resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) +
    +
    + 465 + +
    + + + if resetDone { +
    +
    + 466 + +
    + + + break +
    +
    + 467 + +
    + + + } else { +
    +
    + 468 + +
    + + + log.Error("reorg isn't done, retrying...") +
    +
    + 469 + +
    + + + time.Sleep(time.Second) +
    +
    + 470 + +
    + + + } +
    +
    + 471 + +
    +   + } +
    +
    + 472 + +
    +   + } else if errors.Is(err, syncinterfaces.ErrMissingSyncFromL1) { +
    +
    + 473 + +
    +   + log.Info("Syncing from trusted node need data from L1") +
    +
    +
     
    +
    + 484 + +
    +   + waitDuration = s.cfg.SyncInterval.Duration +
    +
    + 485 + +
    +   + } +
    +
    + 486 + +
    +   + //Sync L1Blocks +
    +
    + 487 + +
    + + + resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) +
    +
    + 488 + +
    + + + if resetDone || err != nil { +
    +
    + 489 + +
    + + + continue +
    +
    + 490 + +
    + + + } +
    +
    + 491 + +
    + + +
    +
    +
    + 492 + +
    +   + startL1 := time.Now() +
    +
    + 493 + +
    +   + if s.l1SyncOrchestration != nil && (latestSyncedBatch < latestSequencedBatchNumber || !s.cfg.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized) { +
    +
    + 494 + +
    +   + log.Infof("Syncing L1 blocks in parallel lastEthBlockSynced=%d", lastEthBlockSynced.BlockNumber) +
    +
    +
     
    +
    + 503 + +
    +   + lastEthBlockSynced, err = s.syncBlocksSequential(lastEthBlockSynced) +
    +
    + 504 + +
    +   + } +
    +
    + 505 + +
    +   + metrics.FullL1SyncTime(time.Since(startL1)) +
    +
    + 506 + +
    + + + if syncCommon.IsReorgError(err) { +
    +
    + 507 + +
    + + + log.Warnf("error syncing blocks: %s", err.Error()) +
    +
    + 508 + +
    + + + for { +
    +
    + 509 + +
    + + + resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) +
    +
    + 510 + +
    + + + if resetDone { +
    +
    + 511 + +
    + + + break +
    +
    + 512 + +
    + + + } else { +
    +
    + 513 + +
    + + + log.Error("reorg isn't done, retrying...") +
    +
    + 514 + +
    + + + time.Sleep(time.Second) +
    +
    + 515 + +
    + + + } +
    +
    + 516 + +
    + + + } +
    +
    + 517 + +
    + + + continue +
    +
    + 518 + +
    + + + } +
    +
    + 519 + +
    +   + if err != nil { +
    +
    + 520 + +
    +   + log.Warn("error syncing blocks: ", err) +
    +
    + 521 + +
    +   + s.CleanTrustedState() +
    +
    +
     
    +
    + 586 + +
    +   + // This function syncs the node from a specific block to the latest +
    +
    + 587 + +
    +   + // lastEthBlockSynced -> last block synced in the db +
    +
    + 588 + +
    +   + func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 589 + +
    +   + log.Infof("Starting L1 sync orchestrator in parallel block: %d", lastEthBlockSynced.BlockNumber) +
    +
    + 590 + +
    +   + return s.l1SyncOrchestration.Start(lastEthBlockSynced) +
    +
    + 591 + +
    +   + } +
    +
    + 592 + +
    +   +
    +
    +
    + 593 + +
    +   + // This function syncs the node from a specific block to the latest +
    +
    + 594 + +
    +   + func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 595 + +
    +   + // Call the blockchain to retrieve data +
    +
    + 596 + +
    + + + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(s.syncBlockProtection.Int64())) +
    +
    + 597 + +
    +   + if err != nil { +
    +
    + 598 + +
    + + + log.Error("error getting header of the latest block in L1. Error: ", err) +
    +
    + 599 + +
    +   + return lastEthBlockSynced, err +
    +
    + 600 + +
    +   + } +
    +
    + 601 + +
    +   + lastKnownBlock := header.Number +
    +
    + 602 + +
    +   +
    +
    +
    + 603 + +
    +   + var fromBlock uint64 +
    +
    + 604 + +
    +   + if lastEthBlockSynced.BlockNumber > 0 { +
    +
    + 605 + +
    + + + fromBlock = lastEthBlockSynced.BlockNumber +
    +
    + 606 + +
    +   + } +
    +
    + 607 + +
    + + + toBlock := fromBlock + s.cfg.SyncChunkSize +
    +
    + 608 + +
    +   +
    +
    +
    + 609 + +
    +   + for { +
    +
    + 610 + +
    + + + if toBlock > lastKnownBlock.Uint64() { +
    +
    + 611 + +
    + + + log.Debug("Setting toBlock to the lastKnownBlock") +
    +
    + 612 + +
    + + + toBlock = lastKnownBlock.Uint64() +
    +
    + 613 + +
    + + + } +
    +
    + 614 + +
    + + + if fromBlock > toBlock { +
    +
    + 615 + +
    + + + log.Debug("FromBlock is higher than toBlock. Skipping...") +
    +
    + 616 + +
    + + + return lastEthBlockSynced, nil +
    +
    + 617 + +
    + + + } +
    +
    + 618 + +
    +   + log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) +
    +
    + 619 + +
    +   + log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) +
    +
    + 620 + +
    +   + // This function returns the rollup information contained in the ethereum blocks and an extra param called order. +
    +
    +
     
    +
    + 628 + +
    +   + if err != nil { +
    +
    + 629 + +
    +   + return lastEthBlockSynced, err +
    +
    + 630 + +
    +   + } +
    +
    + 631 + +
    + + +
    +
    +
    + 632 + +
    + + + var initBlockReceived *etherman.Block +
    +
    + 633 + +
    + + + if len(blocks) != 0 { +
    +
    + 634 + +
    + + + initBlockReceived = &blocks[0] +
    +
    + 635 + +
    + + + // First position of the array must be deleted +
    +
    + 636 + +
    + + + blocks = removeBlockElement(blocks, 0) +
    +
    + 637 + +
    + + + } else { +
    +
    + 638 + +
    + + + // Reorg detected +
    +
    + 639 + +
    + + + log.Infof("Reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", fromBlock) +
    +
    + 640 + +
    + + + prevBlock, err := s.state.GetPreviousBlock(s.ctx, 1, nil) +
    +
    + 641 + +
    + + + if errors.Is(err, state.ErrNotFound) { +
    +
    + 642 + +
    + + + log.Warn("error checking reorg: previous block not found in db: ", err) +
    +
    + 643 + +
    + + + prevBlock = &state.Block{} +
    +
    + 644 + +
    + + + } else if err != nil { +
    +
    + 645 + +
    + + + log.Error("error getting previousBlock from db. Error: ", err) +
    +
    + 646 + +
    + + + return lastEthBlockSynced, err +
    +
    + 647 + +
    + + + } +
    +
    + 648 + +
    + + + blockReorged, err := s.checkReorg(prevBlock, nil) +
    +
    + 649 + +
    + + + if err != nil { +
    +
    + 650 + +
    + + + log.Error("error checking reorgs in previous blocks. Error: ", err) +
    +
    + 651 + +
    + + + return lastEthBlockSynced, err +
    +
    + 652 + +
    + + + } +
    +
    + 653 + +
    + + + if blockReorged == nil { +
    +
    + 654 + +
    + + + blockReorged = prevBlock +
    +
    + 655 + +
    + + + } +
    +
    + 656 + +
    + + + err = s.resetState(blockReorged.BlockNumber) +
    +
    + 657 + +
    + + + if err != nil { +
    +
    + 658 + +
    + + + log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    + 659 + +
    + + + return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    + 660 + +
    + + + } +
    +
    + 661 + +
    + + + return blockReorged, nil +
    +
    + 662 + +
    + + + } +
    +
    + 663 + +
    + + + // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange +
    +
    + 664 + +
    + + + block, err := s.checkReorg(lastEthBlockSynced, initBlockReceived) +
    +
    + 665 + +
    + + + if err != nil { +
    +
    + 666 + +
    + + + log.Errorf("error checking reorgs. Retrying... Err: %v", err) +
    +
    + 667 + +
    + + + return lastEthBlockSynced, fmt.Errorf("error checking reorgs") +
    +
    + 668 + +
    + + + } +
    +
    + 669 + +
    + + + if block != nil { +
    +
    + 670 + +
    + + + err = s.resetState(block.BlockNumber) +
    +
    + 671 + +
    + + + if err != nil { +
    +
    + 672 + +
    + + + log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    + 673 + +
    + + + return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    + 674 + +
    + + + } +
    +
    + 675 + +
    + + + return block, nil +
    +
    + 676 + +
    + + + } +
    +
    + 677 + +
    + + +
    +
    +
    + 678 + +
    +   + start = time.Now() +
    +
    + 679 + +
    +   + err = s.ProcessBlockRange(blocks, order) +
    +
    + 680 + +
    +   + metrics.ProcessL1DataTime(time.Since(start)) +
    +
    +
     
    +
    + 689 + +
    +   + ReceivedAt: blocks[len(blocks)-1].ReceivedAt, +
    +
    + 690 + +
    +   + } +
    +
    + 691 + +
    +   + for i := range blocks { +
    +
    + 692 + +
    + + + log.Info("Position: ", i, ". New block. BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) +
    +
    + 693 + +
    +   + } +
    +
    + 694 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + 695 + +
    +   +
    +
    +
    + 696 + +
    +   + if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 { +
    +
    + 697 + +
    +   + waitDuration = s.cfg.SyncInterval.Duration +
    +
    + 698 + +
    +   + break +
    +
    + 699 + +
    +   + } +
    +
    + 700 + +
    + + +
    +
    +
    + 701 + +
    + + + fromBlock = lastEthBlockSynced.BlockNumber +
    +
    + 702 + +
    + + + toBlock = toBlock + s.cfg.SyncChunkSize +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 703 + +
    +   + } +
    +
    + 704 + +
    +   +
    +
    +
    + 705 + +
    +   + return lastEthBlockSynced, nil +
    +
    + 706 + +
    +   + } +
    +
    + 707 + +
    +   +
    +
    +
    + 708 + +
    + + + func removeBlockElement(slice []etherman.Block, s int) []etherman.Block { +
    +
    + 709 + +
    + + + ret := make([]etherman.Block, 0) +
    +
    + 710 + +
    + + + ret = append(ret, slice[:s]...) +
    +
    + 711 + +
    + + + return append(ret, slice[s+1:]...) +
    +
    + 712 + +
    + + + } +
    +
    + 713 + +
    + + +
    +
    +
    + 714 + +
    +   + // ProcessBlockRange process the L1 events and stores the information in the db +
    +
    + 715 + +
    +   + func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { +
    +
    + 716 + +
    + + + // Check the latest finalized block in L1 +
    +
    + 717 + +
    + + + finalizedBlockNumber, err := s.etherMan.GetFinalizedBlockNumber(s.ctx) +
    +
    + 718 + +
    + + + if err != nil { +
    +
    + 719 + +
    + + + log.Errorf("error getting finalized block number in L1. Error: %v", err) +
    +
    + 720 + +
    + + + return err +
    +
    + 721 + +
    + + + } +
    +
    + 722 + +
    +   + // New info has to be included into the db using the state +
    +
    + 723 + +
    +   + for i := range blocks { +
    +
    + 724 + +
    +   + // Begin db transaction +
    +
    +
     
    +
    + 733 + +
    +   + ParentHash: blocks[i].ParentHash, +
    +
    + 734 + +
    +   + ReceivedAt: blocks[i].ReceivedAt, +
    +
    + 735 + +
    +   + } +
    +
    + 736 + +
    + + + if blocks[i].BlockNumber <= finalizedBlockNumber { +
    +
    + 737 + +
    + + + b.Checked = true +
    +
    + 738 + +
    + + + } +
    +
    + 739 + +
    +   + // Add block information +
    +
    + 740 + +
    +   + err = s.state.AddBlock(s.ctx, &b, dbTx) +
    +
    + 741 + +
    +   + if err != nil { +
    +
    + 742 + +
    + + + // If any goes wrong we ensure that the state is rollbacked +
    +
    + 743 + +
    +   + log.Errorf("error storing block. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err) +
    +
    + 744 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 745 + +
    +   + if rollbackErr != nil { +
    +
    +
     
    +
    + 757 + +
    +   + log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) +
    +
    + 758 + +
    +   + } else { +
    +
    + 759 + +
    +   + forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) +
    +
    + 760 + +
    + + + log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, ". forkId: ", forkId) +
    +
    + 761 + +
    +   + } +
    +
    + 762 + +
    +   + forkIdTyped := actions.ForkIdType(forkId) +
    +
    + 763 + +
    +   + // Process event received from l1 +
    +
    +
     
    +
    + 776 + +
    +   + log.Debug("Checking FlushID to commit L1 data to db") +
    +
    + 777 + +
    +   + err = s.checkFlushID(dbTx) +
    +
    + 778 + +
    +   + if err != nil { +
    +
    + 779 + +
    + + + // If any goes wrong we ensure that the state is rollbacked +
    +
    + 780 + +
    +   + log.Errorf("error checking flushID. Error: %v", err) +
    +
    + 781 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 782 + +
    +   + if rollbackErr != nil { +
    +
    +
     
    +
    + 787 + +
    +   + } +
    +
    + 788 + +
    +   + err = dbTx.Commit(s.ctx) +
    +
    + 789 + +
    +   + if err != nil { +
    +
    + 790 + +
    + + + // If any goes wrong we ensure that the state is rollbacked +
    +
    + 791 + +
    +   + log.Errorf("error committing state to store block. BlockNumber: %d, err: %v", blocks[i].BlockNumber, err) +
    +
    + 792 + +
    +   + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 793 + +
    +   + if rollbackErr != nil { +
    +
    +
     
    +
    + 846 + +
    +   + log.Error("error committing the resetted state. Error: ", err) +
    +
    + 847 + +
    +   + return err +
    +
    + 848 + +
    +   + } +
    +
    + 849 + +
    + + + if s.asyncL1BlockChecker != nil { +
    +
    + 850 + +
    + + + s.asyncL1BlockChecker.OnResetState(s.ctx) +
    +
    + 851 + +
    + + + } +
    +
    + 852 + +
    +   + if s.l1SyncOrchestration != nil { +
    +
    + 853 + +
    + + + lastBlock, err := s.state.GetLastBlock(s.ctx, nil) +
    +
    + 854 + +
    + + + if err != nil { +
    +
    + 855 + +
    + + + log.Errorf("error getting last block synced from db. Error: %v", err) +
    +
    + 856 + +
    + + + s.l1SyncOrchestration.Reset(blockNumber) +
    +
    + 857 + +
    + + + } else { +
    +
    + 858 + +
    + + + s.l1SyncOrchestration.Reset(lastBlock.BlockNumber) +
    +
    + 859 + +
    + + + } +
    +
    + 860 + +
    +   + } +
    +
    + 861 + +
    +   + return nil +
    +
    + 862 + +
    +   + } +
    +
    + 863 + +
    +   +
    +
    +
    + 864 + +
    + + + // OnDetectedMismatchL1BlockReorg function will be called when a reorg is detected (asynchronous call) +
    +
    + 865 + +
    + + + func (s *ClientSynchronizer) OnDetectedMismatchL1BlockReorg() { +
    +
    + 866 + +
    + + + log.Infof("Detected Reorg in background at block (mismatch)") +
    +
    + 867 + +
    + + + if s.l1SyncOrchestration != nil && s.l1SyncOrchestration.IsProducerRunning() { +
    +
    + 868 + +
    + + + log.Errorf("Stop synchronizer: because L1 sync parallel aborting background process") +
    +
    + 869 + +
    + + + s.l1SyncOrchestration.Abort() +
    +
    + 870 + +
    + + + } +
    +
    + 871 + +
    + + + } +
    +
    + 872 + +
    + + +
    +
    +
    + 873 + +
    + + + // ExecuteReorgFromMismatchBlock function will reset the state to the block before the bad block +
    +
    + 874 + +
    + + + func (s *ClientSynchronizer) ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error { +
    +
    + 875 + +
    + + + log.Info("Detected reorg at block (mismatch): ", blockNumber, " reason: ", reason, " resetting the state to block:", blockNumber-1) +
    +
    + 876 + +
    + + + s.CleanTrustedState() +
    +
    + 877 + +
    + + + return s.resetState(blockNumber - 1) +
    +
    + 878 + +
    + + + } +
    +
    + 879 + +
    + + + func (s *ClientSynchronizer) detectedReorgBadBlockExecuteReset(lastEthBlockSynced *state.Block, badBlockNumber uint64) (bool, *state.Block, error) { +
    +
    + 880 + +
    + + + firstBlockOK, err := s.checkReorg(lastEthBlockSynced, nil) +
    +
    + 881 + +
    + + + if err != nil { +
    +
    + 882 + +
    + + + log.Warnf("error checking reorgs. using badBlock detected: %d Err: %v", badBlockNumber, err) +
    +
    + 883 + +
    + + + firstBlockOK = nil +
    +
    + 884 + +
    + + + } +
    +
    + 885 + +
    + + + if firstBlockOK != nil && firstBlockOK.BlockNumber >= badBlockNumber { +
    +
    + 886 + +
    + + + log.Warnf("Reorg detected firstBlockOk: %d. But oldest bad block detected: %d", firstBlockOK.BlockNumber, badBlockNumber) +
    +
    + 887 + +
    + + + firstBlockOK = nil +
    +
    + 888 + +
    + + + } +
    +
    + 889 + +
    + + + // We already known a bad block, reset from there +
    +
    + 890 + +
    + + + if firstBlockOK == nil { +
    +
    + 891 + +
    + + + firstBlockOK, err = s.state.GetPreviousBlockToBlockNumber(s.ctx, badBlockNumber, nil) +
    +
    + 892 + +
    + + + if err != nil { +
    +
    + 893 + +
    + + + log.Errorf("error getting previous block %d from db. Can't execute REORG. Error: %v", badBlockNumber, err) +
    +
    + 894 + +
    + + + return false, lastEthBlockSynced, err +
    +
    + 895 + +
    + + + } +
    +
    + 896 + +
    + + + } +
    +
    + 897 + +
    + + + newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, firstBlockOK) +
    +
    + 898 + +
    + + + if err != nil { +
    +
    + 899 + +
    + + + log.Errorf("error executing reorg. Retrying... Err: %v", err) +
    +
    + 900 + +
    + + + return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) +
    +
    + 901 + +
    + + + } +
    +
    + 902 + +
    + + + return true, newFirstBlock, nil +
    +
    + 903 + +
    + + + } +
    +
    + 904 + +
    + + +
    +
    +
    + 905 + +
    + + + // checkReorgAndExecuteReset function will check if there is a reorg and execute the reset +
    +
    + 906 + +
    + + + // returns true is reset have been done +
    +
    + 907 + +
    + + + func (s *ClientSynchronizer) checkReorgAndExecuteReset(lastEthBlockSynced *state.Block) (bool, *state.Block, error) { +
    +
    + 908 + +
    + + + var err error +
    +
    + 909 + +
    + + +
    +
    +
    + 910 + +
    + + + block, err := s.checkReorg(lastEthBlockSynced, nil) +
    +
    + 911 + +
    + + + if err != nil { +
    +
    + 912 + +
    + + + log.Errorf("error checking reorgs. Retrying... Err: %v", err) +
    +
    + 913 + +
    + + + return false, lastEthBlockSynced, fmt.Errorf("error checking reorgs") +
    +
    + 914 + +
    + + + } +
    +
    + 915 + +
    + + + if block != nil { +
    +
    + 916 + +
    + + + newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, block) +
    +
    + 917 + +
    + + + if err != nil { +
    +
    + 918 + +
    + + + log.Errorf("error executing reorg. Retrying... Err: %v", err) +
    +
    + 919 + +
    + + + return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) +
    +
    + 920 + +
    + + + } +
    +
    + 921 + +
    + + + return true, newFirstBlock, nil +
    +
    + 922 + +
    + + + } +
    +
    + 923 + +
    + + +
    +
    +
    + 924 + +
    + + + return false, lastEthBlockSynced, nil +
    +
    + 925 + +
    + + + } +
    +
    + 926 + +
    + + +
    +
    +
    + 927 + +
    + + + func (s *ClientSynchronizer) executeReorgFromFirstValidBlock(lastEthBlockSynced *state.Block, firstValidBlock *state.Block) (*state.Block, error) { +
    +
    + 928 + +
    + + + log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, firstValidBlock.BlockNumber) +
    +
    + 929 + +
    + + + s.CleanTrustedState() +
    +
    + 930 + +
    + + + err := s.resetState(firstValidBlock.BlockNumber) +
    +
    + 931 + +
    + + + if err != nil { +
    +
    + 932 + +
    + + + log.Errorf("error resetting the state to a previous block. Retrying... Err: %s", err.Error()) +
    +
    + 933 + +
    + + + return nil, fmt.Errorf("error resetting the state to a previous block. Err: %w", err) +
    +
    + 934 + +
    + + + } +
    +
    + 935 + +
    + + + newLastBlock, err := s.state.GetLastBlock(s.ctx, nil) +
    +
    + 936 + +
    + + + if err != nil { +
    +
    + 937 + +
    + + + log.Warnf("error getting last block synced from db, returning expected block %d. Error: %v", firstValidBlock.BlockNumber, err) +
    +
    + 938 + +
    + + + return firstValidBlock, nil +
    +
    + 939 + +
    + + + } +
    +
    + 940 + +
    + + + if newLastBlock.BlockNumber != firstValidBlock.BlockNumber { +
    +
    + 941 + +
    + + + log.Warnf("Doesnt match LastBlock on State and expecting one after a resetState. The block in state is %d and the expected block is %d", newLastBlock.BlockNumber, +
    +
    + 942 + +
    + + + firstValidBlock.BlockNumber) +
    +
    + 943 + +
    + + + return firstValidBlock, nil +
    +
    + 944 + +
    + + + } +
    +
    + 945 + +
    + + + return newLastBlock, nil +
    +
    + 946 + +
    + + + } +
    +
    + 947 + +
    + + +
    +
    +
    + 948 + +
    + + + func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { +
    +
    + 949 + +
    + + + if latestBlock == nil { +
    +
    + 950 + +
    + + + err := fmt.Errorf("lastEthBlockSynced is nil calling checkReorgAndExecuteReset") +
    +
    + 951 + +
    + + + log.Errorf("%s, it never have to happens", err.Error()) +
    +
    + 952 + +
    + + + return nil, err +
    +
    + 953 + +
    + + + } +
    +
    + 954 + +
    + + + block, errReturnedReorgFunction := s.newCheckReorg(latestBlock, syncedBlock) +
    +
    + 955 + +
    + + + if s.asyncL1BlockChecker != nil { +
    +
    + 956 + +
    + + + return s.asyncL1BlockChecker.CheckReorgWrapper(s.ctx, block, errReturnedReorgFunction) +
    +
    + 957 + +
    + + + } +
    +
    + 958 + +
    + + + return block, errReturnedReorgFunction +
    +
    + 959 + +
    + + + } +
    +
    + 960 + +
    + + +
    +
    +
    + 961 + +
    +   + /* +
    +
    + 962 + +
    +   + This function will check if there is a reorg. +
    +
    + 963 + +
    +   + As input param needs the last ethereum block synced. Retrieve the block info from the blockchain +
    +
    +
     
    +
    + 966 + +
    +   + must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check +
    +
    + 967 + +
    +   + hash and has parent. This operation has to be done until a match is found. +
    +
    + 968 + +
    +   + */ +
    +
    + 969 + +
    + + +
    +
    +
    + 970 + +
    + + + func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { +
    +
    + 971 + +
    +   + // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. +
    +
    + 972 + +
    + + + latestStoredEthBlock := *latestStoredBlock +
    +
    + 973 + +
    + + + reorgedBlock := *latestStoredBlock +
    +
    + 974 + +
    +   + var depth uint64 +
    +
    + 975 + +
    + + + block := syncedBlock +
    +
    + 976 + +
    +   + for { +
    +
    + 977 + +
    + + + if block == nil { +
    +
    + 978 + +
    + + + log.Infof("[checkReorg function] Checking Block %d in L1", reorgedBlock.BlockNumber) +
    +
    + 979 + +
    + + + b, err := s.etherMan.EthBlockByNumber(s.ctx, reorgedBlock.BlockNumber) +
    +
    + 980 + +
    + + + if err != nil { +
    +
    + 981 + +
    + + + log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", reorgedBlock.BlockNumber, err) +
    +
    + 982 + +
    + + + return nil, err +
    +
    + 983 + +
    + + + } +
    +
    + 984 + +
    + + + block = &etherman.Block{ +
    +
    + 985 + +
    + + + BlockNumber: b.Number().Uint64(), +
    +
    + 986 + +
    + + + BlockHash: b.Hash(), +
    +
    + 987 + +
    + + + ParentHash: b.ParentHash(), +
    +
    + 988 + +
    + + + } +
    +
    + 989 + +
    + + + if block.BlockNumber != reorgedBlock.BlockNumber { +
    +
    + 990 + +
    + + + err := fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", +
    +
    + 991 + +
    + + + reorgedBlock.BlockNumber, block.BlockNumber) +
    +
    + 992 + +
    + + + log.Error("error: ", err) +
    +
    + 993 + +
    + + + return nil, err +
    +
    + 994 + +
    + + + } +
    +
    + 995 + +
    + + + } else { +
    +
    + 996 + +
    + + + log.Infof("[checkReorg function] Using block %d from GetRollupInfoByBlockRange", block.BlockNumber) +
    +
    + 997 + +
    +   + } +
    +
    + 998 + +
    + + + log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.BlockNumber, block.BlockHash.String()) +
    +
    + 999 + +
    + + + log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) +
    +
    + 1000 + +
    + + +
    +
    +
    + 1001 + +
    +   + // Compare hashes +
    +
    + 1002 + +
    + + + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupBlockNumber { +
    +
    + 1003 + +
    + + + log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) +
    +
    + 1004 + +
    + + + log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) +
    +
    + 1005 + +
    + + + log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) +
    +
    + 1006 + +
    + + + log.Debug("[checkReorg function] => latestBlockHashParent: ", reorgedBlock.ParentHash) +
    +
    + 1007 + +
    + + + log.Debug("[checkReorg function] => BlockNumber: ", reorgedBlock.BlockNumber, block.BlockNumber) +
    +
    + 1008 + +
    + + + log.Debug("[checkReorg function] => BlockHash: ", block.BlockHash) +
    +
    + 1009 + +
    + + + log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash) +
    +
    + 1010 + +
    +   + depth++ +
    +
    + 1011 + +
    +   + log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) +
    +
    + 1012 + +
    +   + // Reorg detected. Getting previous block +
    +
    +
     
    +
    + 1015 + +
    +   + log.Errorf("error creating db transaction to get prevoius blocks") +
    +
    + 1016 + +
    +   + return nil, err +
    +
    + 1017 + +
    +   + } +
    +
    + 1018 + +
    + + + lb, err := s.state.GetPreviousBlock(s.ctx, depth, dbTx) +
    +
    + 1019 + +
    +   + errC := dbTx.Commit(s.ctx) +
    +
    + 1020 + +
    +   + if errC != nil { +
    +
    + 1021 + +
    +   + log.Errorf("error committing dbTx, err: %v", errC) +
    +
    +
     
    +
    + 1028 + +
    +   + return nil, errC +
    +
    + 1029 + +
    +   + } +
    +
    + 1030 + +
    +   + if errors.Is(err, state.ErrNotFound) { +
    +
    + 1031 + +
    + + + log.Warn("error checking reorg: previous block not found in db. Reorg reached the genesis block: %v.Genesis block can't be reorged, using genesis block as starting point. Error: %v", reorgedBlock, err) +
    +
    + 1032 + +
    + + + return &reorgedBlock, nil +
    +
    + 1033 + +
    +   + } else if err != nil { +
    +
    + 1034 + +
    + + + log.Error("error getting previousBlock from db. Error: ", err) +
    +
    + 1035 + +
    +   + return nil, err +
    +
    + 1036 + +
    +   + } +
    +
    + 1037 + +
    + + + reorgedBlock = *lb +
    +
    + 1038 + +
    +   + } else { +
    +
    + 1039 + +
    + + + log.Debugf("checkReorg: Block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) +
    +
    + 1040 + +
    +   + break +
    +
    + 1041 + +
    +   + } +
    +
    + 1042 + +
    + + + // This forces to get the block from L1 in the next iteration of the loop +
    +
    + 1043 + +
    + + + block = nil +
    +
    + 1044 + +
    +   + } +
    +
    + 1045 + +
    + + + if latestStoredEthBlock.BlockHash != reorgedBlock.BlockHash { +
    +
    + 1046 + +
    + + + latestStoredBlock = &reorgedBlock +
    +
    + 1047 + +
    + + + log.Info("Reorg detected in block: ", latestStoredEthBlock.BlockNumber, " last block OK: ", latestStoredBlock.BlockNumber) +
    +
    + 1048 + +
    + + + return latestStoredBlock, nil +
    +
    + 1049 + +
    +   + } +
    +
    + 1050 + +
    + + + log.Debugf("No reorg detected in block: %d. BlockHash: %s", latestStoredEthBlock.BlockNumber, latestStoredEthBlock.BlockHash.String()) +
    +
    + 1051 + +
    +   + return nil, nil +
    +
    + 1052 + +
    +   + } +
    +
    + 1053 + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -2,6 +2,7 @@
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + context "context" +
    +
    + + +
    +   +
    +
    +
    + 5 + +
    +   + "math/big" +
    +
    + 6 + +
    +   + "testing" +
    +
    + 7 + +
    +   + "time" +
    +
    +
    @@ -18,6 +19,7 @@
    +
    + 18 + +
    +   + syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" +
    +
    + 19 + +
    +   + "github.com/ethereum/go-ethereum/common" +
    +
    + 20 + +
    +   + ethTypes "github.com/ethereum/go-ethereum/core/types" +
    +
    + + +
    +   +
    +
    +
    + 21 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 22 + +
    +   + "github.com/stretchr/testify/assert" +
    +
    + 23 + +
    +   + "github.com/stretchr/testify/mock" +
    +
    +
    @@ -32,12 +34,13 @@
    +
    + 32 + +
    +   + ) +
    +
    + 33 + +
    +   +
    +
    +
    + 34 + +
    +   + type mocks struct { +
    +
    + 35 + +
    + - + Etherman *mock_syncinterfaces.EthermanFullInterface +
    +
    + 36 + +
    + - + State *mock_syncinterfaces.StateFullInterface +
    +
    + 37 + +
    + - + Pool *mock_syncinterfaces.PoolInterface +
    +
    + 38 + +
    + - + EthTxManager *mock_syncinterfaces.EthTxManager +
    +
    + 39 + +
    + - + DbTx *syncMocks.DbTxMock +
    +
    + 40 + +
    + - + ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +
    +
    + + +
    +   +
    +
    +
    + 41 + +
    +   + //EventLog *eventLogMock +
    +
    + 42 + +
    +   + } +
    +
    + 43 + +
    +   +
    +
    +
    +
    @@ -47,7 +50,7 @@
    +
    + 47 + +
    +   + func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { +
    +
    + 48 + +
    +   + genesis, cfg, m := setupGenericTest(t) +
    +
    + 49 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 50 + +
    + - + syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    + 51 + +
    +   + require.NoError(t, err) +
    +
    + 52 + +
    +   + sync, ok := syncInterface.(*ClientSynchronizer) +
    +
    + 53 + +
    +   + require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    +
    +
    @@ -87,7 +90,7 @@
    +
    + 87 + +
    +   + func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { +
    +
    + 88 + +
    +   + genesis, cfg, m := setupGenericTest(t) +
    +
    + 89 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 90 + +
    + - + syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    + 91 + +
    +   + require.NoError(t, err) +
    +
    + 92 + +
    +   + sync, ok := syncInterface.(*ClientSynchronizer) +
    +
    + 93 + +
    +   + require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    +
    +
    @@ -119,12 +122,16 @@
    +
    + 119 + +
    +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    +
    + 120 + +
    +   + func TestForcedBatchEtrog(t *testing.T) { +
    +
    + 121 + +
    +   + genesis := state.Genesis{ +
    +
    + 122 + +
    + - + BlockNumber: uint64(123456), +
    +
    + 123 + +
    +   + } +
    +
    + 124 + +
    +   + cfg := Config{ +
    +
    + 125 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 126 + +
    +   + SyncChunkSize: 10, +
    +
    + 127 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 128 + +
    +   + } +
    +
    + 129 + +
    +   +
    +
    +
    + 130 + +
    +   + m := mocks{ +
    +
    +
    @@ -135,7 +142,7 @@
    +
    + 135 + +
    +   + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 136 + +
    +   + } +
    +
    + 137 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 138 + +
    + - + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) +
    +
    + 139 + +
    +   + require.NoError(t, err) +
    +
    + 140 + +
    +   +
    +
    +
    + 141 + +
    +   + // state preparation +
    +
    +
    @@ -151,17 +158,21 @@
    +
    + 151 + +
    +   + Run(func(args mock.Arguments) { +
    +
    + 152 + +
    +   + ctx := args[0].(context.Context) +
    +
    + 153 + +
    +   + parentHash := common.HexToHash("0x111") +
    +
    + 154 + +
    + - + ethHeader := &ethTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} +
    +
    + 155 + +
    + - + ethBlock := ethTypes.NewBlockWithHeader(ethHeader) +
    +
    + 156 + +
    + - + lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 157 + +
    +   +
    +
    +
    + 158 + +
    +   + m.State. +
    +
    + 159 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 160 + +
    +   + Return(uint64(7), nil). +
    +
    + 161 + +
    +   + Maybe() +
    +
    + + +
    +   +
    +
    +
    + 162 + +
    +   + m.State. +
    +
    + 163 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 164 + +
    + - + Return(lastBlock, nil). +
    +
    + 165 + +
    +   + Once() +
    +
    + 166 + +
    +   +
    +
    +
    + 167 + +
    +   + m.State. +
    +
    +
    @@ -197,14 +208,14 @@
    +
    + 197 + +
    +   + Return(nil) +
    +
    + 198 + +
    +   +
    +
    +
    + 199 + +
    +   + m.Etherman. +
    +
    + 200 + +
    + - + On("EthBlockByNumber", ctx, lastBlock.BlockNumber). +
    +
    + 201 + +
    + - + Return(ethBlock, nil). +
    +
    + 202 + +
    + - + Once() +
    +
    + 203 + +
    +   +
    +
    +
    + 204 + +
    + - + var n *big.Int +
    +
    + 205 + +
    +   + m.Etherman. +
    +
    + 206 + +
    +   + On("HeaderByNumber", mock.Anything, n). +
    +
    + 207 + +
    + - + Return(ethHeader, nil). +
    +
    + 208 + +
    +   + Once() +
    +
    + 209 + +
    +   +
    +
    +
    + 210 + +
    +   + t := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    +
    @@ -223,7 +234,7 @@
    +
    + 223 + +
    +   + } +
    +
    + 224 + +
    +   +
    +
    +
    + 225 + +
    +   + forceb := []etherman.ForcedBatch{{ +
    +
    + 226 + +
    + - + BlockNumber: lastBlock.BlockNumber, +
    +
    + 227 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 228 + +
    +   + Sequencer: sequencedBatch.Coinbase, +
    +
    + 229 + +
    +   + GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
    @@ -231,16 +242,21 @@
    +
    + 231 + +
    +   + ForcedAt: time.Unix(int64(sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    +
    + 232 + +
    +   + }} +
    +
    + 233 + +
    +   +
    +
    +
    + 234 + +
    + - + ethermanBlock := etherman.Block{ +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 235 + +
    +   + BlockNumber: 1, +
    +
    + 236 + +
    +   + ReceivedAt: t, +
    +
    + 237 + +
    + - + BlockHash: ethBlock.Hash(), +
    +
    + 238 + +
    +   + SequencedBatches: [][]etherman.SequencedBatch{{sequencedBatch}}, +
    +
    + 239 + +
    +   + ForcedBatches: forceb, +
    +
    + 240 + +
    +   + } +
    +
    + 241 + +
    + - + blocks := []etherman.Block{ethermanBlock} +
    +
    + 242 + +
    +   + order := map[common.Hash][]etherman.Order{ +
    +
    + 243 + +
    + - + ethBlock.Hash(): { +
    +
    + 244 + +
    +   + { +
    +
    + 245 + +
    +   + Name: etherman.ForcedBatchesOrder, +
    +
    + 246 + +
    +   + Pos: 0, +
    +
    +
    @@ -252,9 +268,11 @@
    +
    + 252 + +
    +   + }, +
    +
    + 253 + +
    +   + } +
    +
    + 254 + +
    +   +
    +
    +
    + 255 + +
    + - + fromBlock := ethBlock.NumberU64() + 1 +
    +
    + 256 + +
    +   + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 257 + +
    + - +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 258 + +
    +   + m.Etherman. +
    +
    + 259 + +
    +   + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 260 + +
    +   + Return(blocks, order, nil). +
    +
    +
    @@ -270,10 +288,11 @@
    +
    + 270 + +
    +   + Once() +
    +
    + 271 + +
    +   +
    +
    +
    + 272 + +
    +   + stateBlock := &state.Block{ +
    +
    + 273 + +
    + - + BlockNumber: ethermanBlock.BlockNumber, +
    +
    + 274 + +
    + - + BlockHash: ethermanBlock.BlockHash, +
    +
    + 275 + +
    + - + ParentHash: ethermanBlock.ParentHash, +
    +
    + 276 + +
    + - + ReceivedAt: ethermanBlock.ReceivedAt, +
    +
    + + +
    +   +
    +
    +
    + 277 + +
    +   + } +
    +
    + 278 + +
    +   +
    +
    +
    + 279 + +
    +   + executionResponse := executor.ProcessBatchResponseV2{ +
    +
    +
    @@ -285,13 +304,18 @@
    +
    + 285 + +
    +   + Return(&executionResponse, nil). +
    +
    + 286 + +
    +   + Times(1) +
    +
    + 287 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 288 + +
    +   + m.State. +
    +
    + 289 + +
    +   + On("AddBlock", ctx, stateBlock, m.DbTx). +
    +
    + 290 + +
    +   + Return(nil). +
    +
    + 291 + +
    +   + Once() +
    +
    + 292 + +
    +   +
    +
    +
    + 293 + +
    +   + fb := []state.ForcedBatch{{ +
    +
    + 294 + +
    + - + BlockNumber: lastBlock.BlockNumber, +
    +
    + 295 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 296 + +
    +   + Sequencer: sequencedBatch.Coinbase, +
    +
    + 297 + +
    +   + GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
    @@ -326,7 +350,7 @@
    +
    + 326 + +
    +   + BatchNumber: sequencedBatch.BatchNumber, +
    +
    + 327 + +
    +   + TxHash: sequencedBatch.TxHash, +
    +
    + 328 + +
    +   + Coinbase: sequencedBatch.Coinbase, +
    +
    + 329 + +
    + - + BlockNumber: ethermanBlock.BlockNumber, +
    +
    + 330 + +
    +   + TimestampBatchEtrog: &t, +
    +
    + 331 + +
    +   + L1InfoRoot: &forcedGER, +
    +
    + 332 + +
    +   + } +
    +
    +
    @@ -372,12 +396,13 @@
    +
    + 372 + +
    +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    +
    + 373 + +
    +   + func TestSequenceForcedBatchIncaberry(t *testing.T) { +
    +
    + 374 + +
    +   + genesis := state.Genesis{ +
    +
    + 375 + +
    + - + BlockNumber: uint64(123456), +
    +
    + 376 + +
    +   + } +
    +
    + 377 + +
    +   + cfg := Config{ +
    +
    + 378 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 379 + +
    +   + SyncChunkSize: 10, +
    +
    + 380 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + + +
    +   +
    +
    +
    + 381 + +
    +   + } +
    +
    + 382 + +
    +   +
    +
    +
    + 383 + +
    +   + m := mocks{ +
    +
    +
    @@ -388,7 +413,7 @@
    +
    + 388 + +
    +   + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 389 + +
    +   + } +
    +
    + 390 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 391 + +
    + - + sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) +
    +
    + 392 + +
    +   + require.NoError(t, err) +
    +
    + 393 + +
    +   +
    +
    +
    + 394 + +
    +   + // state preparation +
    +
    +
    @@ -398,21 +423,20 @@
    +
    + 398 + +
    +   + Run(func(args mock.Arguments) { +
    +
    + 399 + +
    +   + ctx := args[0].(context.Context) +
    +
    + 400 + +
    +   + parentHash := common.HexToHash("0x111") +
    +
    + 401 + +
    + - + ethHeader := &ethTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} +
    +
    + 402 + +
    + - + ethBlock := ethTypes.NewBlockWithHeader(ethHeader) +
    +
    + 403 + +
    + - + lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 404 + +
    +   + m.State. +
    +
    + 405 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 406 + +
    +   + Return(uint64(1), nil). +
    +
    + 407 + +
    +   + Maybe() +
    +
    + 408 + +
    + - + m.State. +
    +
    + 409 + +
    + - + On("GetForkIDByBlockNumber", mock.Anything). +
    +
    + 410 + +
    + - + Return(uint64(1), nil). +
    +
    + 411 + +
    + - + Maybe() +
    +
    + 412 + +
    +   +
    +
    +
    + 413 + +
    +   + m.State. +
    +
    + 414 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 415 + +
    + - + Return(lastBlock, nil). +
    +
    + 416 + +
    +   + Once() +
    +
    + 417 + +
    +   +
    +
    +
    + 418 + +
    +   + m.State. +
    +
    +
    @@ -450,15 +474,15 @@
    +
    + 450 + +
    +   + Return(nil). +
    +
    + 451 + +
    +   + Once() +
    +
    + 452 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 453 + +
    +   + m.Etherman. +
    +
    + 454 + +
    + - + On("EthBlockByNumber", ctx, lastBlock.BlockNumber). +
    +
    + 455 + +
    + - + Return(ethBlock, nil). +
    +
    + 456 + +
    +   + Once() +
    +
    + 457 + +
    +   +
    +
    +
    + 458 + +
    + - + var n *big.Int +
    +
    + 459 + +
    +   + m.Etherman. +
    +
    + 460 + +
    + - + On("HeaderByNumber", ctx, n). +
    +
    + 461 + +
    + - + Return(ethHeader, nil). +
    +
    + 462 + +
    +   + Once() +
    +
    + 463 + +
    +   +
    +
    +
    + 464 + +
    +   + sequencedForceBatch := etherman.SequencedForceBatch{ +
    +
    +
    @@ -474,7 +498,7 @@
    +
    + 474 + +
    +   + } +
    +
    + 475 + +
    +   +
    +
    +
    + 476 + +
    +   + forceb := []etherman.ForcedBatch{{ +
    +
    + 477 + +
    + - + BlockNumber: lastBlock.BlockNumber, +
    +
    + 478 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 479 + +
    +   + Sequencer: sequencedForceBatch.Coinbase, +
    +
    + 480 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
    @@ -482,14 +506,21 @@
    +
    + 482 + +
    +   + ForcedAt: time.Unix(int64(sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    +
    + 483 + +
    +   + }} +
    +
    + 484 + +
    +   +
    +
    +
    + 485 + +
    + - + ethermanBlock := etherman.Block{ +
    +
    + 486 + +
    + - + BlockHash: ethBlock.Hash(), +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 487 + +
    +   + SequencedForceBatches: [][]etherman.SequencedForceBatch{{sequencedForceBatch}}, +
    +
    + 488 + +
    +   + ForcedBatches: forceb, +
    +
    + 489 + +
    +   + } +
    +
    + 490 + +
    + - + blocks := []etherman.Block{ethermanBlock} +
    +
    + 491 + +
    +   + order := map[common.Hash][]etherman.Order{ +
    +
    + 492 + +
    + - + ethBlock.Hash(): { +
    +
    + 493 + +
    +   + { +
    +
    + 494 + +
    +   + Name: etherman.ForcedBatchesOrder, +
    +
    + 495 + +
    +   + Pos: 0, +
    +
    +
    @@ -501,24 +532,32 @@
    +
    + 501 + +
    +   + }, +
    +
    + 502 + +
    +   + } +
    +
    + 503 + +
    +   +
    +
    +
    + 504 + +
    + - + fromBlock := ethBlock.NumberU64() + 1 +
    +
    + 505 + +
    +   + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 506 + +
    + - +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 507 + +
    +   + m.Etherman. +
    +
    + 508 + +
    +   + On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). +
    +
    + 509 + +
    +   + Return(blocks, order, nil). +
    +
    + 510 + +
    +   + Once() +
    +
    + 511 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 512 + +
    +   + m.State. +
    +
    + 513 + +
    +   + On("BeginStateTransaction", ctx). +
    +
    + 514 + +
    +   + Return(m.DbTx, nil). +
    +
    + 515 + +
    +   + Once() +
    +
    + 516 + +
    +   +
    +
    +
    + 517 + +
    +   + stateBlock := &state.Block{ +
    +
    + 518 + +
    + - + BlockNumber: ethermanBlock.BlockNumber, +
    +
    + 519 + +
    + - + BlockHash: ethermanBlock.BlockHash, +
    +
    + 520 + +
    + - + ParentHash: ethermanBlock.ParentHash, +
    +
    + 521 + +
    + - + ReceivedAt: ethermanBlock.ReceivedAt, +
    +
    + + +
    +   +
    +
    +
    + 522 + +
    +   + } +
    +
    + 523 + +
    +   +
    +
    +
    + 524 + +
    +   + m.State. +
    +
    +
    @@ -526,8 +565,13 @@
    +
    + 526 + +
    +   + Return(nil). +
    +
    + 527 + +
    +   + Once() +
    +
    + 528 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 529 + +
    +   + fb := []state.ForcedBatch{{ +
    +
    + 530 + +
    + - + BlockNumber: lastBlock.BlockNumber, +
    +
    + 531 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 532 + +
    +   + Sequencer: sequencedForceBatch.Coinbase, +
    +
    + 533 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
    @@ -559,7 +603,7 @@
    +
    + 559 + +
    +   + processingContext := state.ProcessingContext{ +
    +
    + 560 + +
    +   + BatchNumber: sequencedForceBatch.BatchNumber, +
    +
    + 561 + +
    +   + Coinbase: sequencedForceBatch.Coinbase, +
    +
    + 562 + +
    + - + Timestamp: ethBlock.ReceivedAt, +
    +
    + 563 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    + 564 + +
    +   + ForcedBatchNum: &f, +
    +
    + 565 + +
    +   + BatchL2Data: &sequencedForceBatch.PolygonRollupBaseEtrogBatchData.Transactions, +
    +
    +
    @@ -574,7 +618,7 @@
    +
    + 574 + +
    +   + TxHash: sequencedForceBatch.TxHash, +
    +
    + 575 + +
    +   + Coinbase: sequencedForceBatch.Coinbase, +
    +
    + 576 + +
    +   + SequencerAddr: sequencedForceBatch.Coinbase, +
    +
    + 577 + +
    + - + BlockNumber: ethermanBlock.BlockNumber, +
    +
    + 578 + +
    +   + } +
    +
    + 579 + +
    +   +
    +
    +
    + 580 + +
    +   + m.State. +
    +
    +
    @@ -598,7 +642,10 @@
    +
    + 598 + +
    +   +
    +
    +
    + 599 + +
    +   + m.DbTx. +
    +
    + 600 + +
    +   + On("Commit", ctx). +
    +
    + 601 + +
    + - + Run(func(args mock.Arguments) { sync.Stop() }). +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 602 + +
    +   + Return(nil). +
    +
    + 603 + +
    +   + Once() +
    +
    + 604 + +
    +   + }). +
    +
    +
    @@ -611,12 +658,13 @@
    +
    + 611 + +
    +   +
    +
    +
    + 612 + +
    +   + func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { +
    +
    + 613 + +
    +   + genesis := state.Genesis{ +
    +
    + 614 + +
    + - + BlockNumber: uint64(123456), +
    +
    + 615 + +
    +   + } +
    +
    + 616 + +
    +   + cfg := Config{ +
    +
    + 617 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 618 + +
    +   + SyncChunkSize: 10, +
    +
    + 619 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + + +
    +   +
    +
    +
    + 620 + +
    +   + L1ParallelSynchronization: L1ParallelSynchronizationConfig{ +
    +
    + 621 + +
    +   + MaxClients: 2, +
    +
    + 622 + +
    +   + MaxPendingNoProcessedBlocks: 2, +
    +
    +
    @@ -631,12 +679,13 @@
    +
    + 631 + +
    +   + } +
    +
    + 632 + +
    +   +
    +
    +
    + 633 + +
    +   + m := mocks{ +
    +
    + 634 + +
    + - + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 635 + +
    + - + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 636 + +
    + - + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 637 + +
    + - + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 638 + +
    + - + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 639 + +
    + - + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + + +
    +   +
    +
    +
    + 640 + +
    +   + //EventLog: newEventLogMock(t), +
    +
    + 641 + +
    +   + } +
    +
    + 642 + +
    +   + return &genesis, &cfg, &m +
    +
    +
    @@ -870,3 +919,1365 @@
    +
    + 870 + +
    +   + Return(nil). +
    +
    + 871 + +
    +   + Once() +
    +
    + 872 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + context "context" +
    +
    + 5 + +
    + + + "math" +
    +
    + 6 + +
    +   + "math/big" +
    +
    + 7 + +
    +   + "testing" +
    +
    + 8 + +
    +   + "time" +
    +
    +
     
    +
    + 19 + +
    +   + syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" +
    +
    + 20 + +
    +   + "github.com/ethereum/go-ethereum/common" +
    +
    + 21 + +
    +   + ethTypes "github.com/ethereum/go-ethereum/core/types" +
    +
    + 22 + +
    + + + "github.com/ethereum/go-ethereum/rpc" +
    +
    + 23 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 24 + +
    +   + "github.com/stretchr/testify/assert" +
    +
    + 25 + +
    +   + "github.com/stretchr/testify/mock" +
    +
    +
     
    +
    + 34 + +
    +   + ) +
    +
    + 35 + +
    +   +
    +
    +
    + 36 + +
    +   + type mocks struct { +
    +
    + 37 + +
    + + + Etherman *mock_syncinterfaces.EthermanFullInterface +
    +
    + 38 + +
    + + + State *mock_syncinterfaces.StateFullInterface +
    +
    + 39 + +
    + + + Pool *mock_syncinterfaces.PoolInterface +
    +
    + 40 + +
    + + + EthTxManager *mock_syncinterfaces.EthTxManager +
    +
    + 41 + +
    + + + DbTx *syncMocks.DbTxMock +
    +
    + 42 + +
    + + + ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +
    +
    + 43 + +
    + + + zkEVMClientEthereumCompatible *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface +
    +
    + 44 + +
    +   + //EventLog *eventLogMock +
    +
    + 45 + +
    +   + } +
    +
    + 46 + +
    +   +
    +
    +
    +
     
    +
    + 50 + +
    +   + func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { +
    +
    + 51 + +
    +   + genesis, cfg, m := setupGenericTest(t) +
    +
    + 52 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 53 + +
    + + + syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) +
    +
    + 54 + +
    +   + require.NoError(t, err) +
    +
    + 55 + +
    +   + sync, ok := syncInterface.(*ClientSynchronizer) +
    +
    + 56 + +
    +   + require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    +
    +
     
    +
    + 90 + +
    +   + func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { +
    +
    + 91 + +
    +   + genesis, cfg, m := setupGenericTest(t) +
    +
    + 92 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 93 + +
    + + + syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) +
    +
    + 94 + +
    +   + require.NoError(t, err) +
    +
    + 95 + +
    +   + sync, ok := syncInterface.(*ClientSynchronizer) +
    +
    + 96 + +
    +   + require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    +
    +
     
    +
    + 122 + +
    +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    +
    + 123 + +
    +   + func TestForcedBatchEtrog(t *testing.T) { +
    +
    + 124 + +
    +   + genesis := state.Genesis{ +
    +
    + 125 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 126 + +
    +   + } +
    +
    + 127 + +
    +   + cfg := Config{ +
    +
    + 128 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 129 + +
    +   + SyncChunkSize: 10, +
    +
    + 130 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + 131 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 132 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 133 + +
    + + + Enable: false, +
    +
    + 134 + +
    + + + }, +
    +
    + 135 + +
    +   + } +
    +
    + 136 + +
    +   +
    +
    +
    + 137 + +
    +   + m := mocks{ +
    +
    +
     
    +
    + 142 + +
    +   + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 143 + +
    +   + } +
    +
    + 144 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 145 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 146 + +
    +   + require.NoError(t, err) +
    +
    + 147 + +
    +   +
    +
    +
    + 148 + +
    +   + // state preparation +
    +
    +
     
    +
    + 158 + +
    +   + Run(func(args mock.Arguments) { +
    +
    + 159 + +
    +   + ctx := args[0].(context.Context) +
    +
    + 160 + +
    +   + parentHash := common.HexToHash("0x111") +
    +
    + 161 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 162 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 163 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 164 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 165 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 166 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 167 + +
    +   +
    +
    +
    + 168 + +
    +   + m.State. +
    +
    + 169 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 170 + +
    +   + Return(uint64(7), nil). +
    +
    + 171 + +
    +   + Maybe() +
    +
    + 172 + +
    + + +
    +
    +
    + 173 + +
    +   + m.State. +
    +
    + 174 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 175 + +
    + + + Return(lastBlock0, nil). +
    +
    + 176 + +
    +   + Once() +
    +
    + 177 + +
    +   +
    +
    +
    + 178 + +
    +   + m.State. +
    +
    +
     
    +
    + 208 + +
    +   + Return(nil) +
    +
    + 209 + +
    +   +
    +
    +
    + 210 + +
    +   + m.Etherman. +
    +
    + 211 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 212 + +
    + + + Return(ethBlock0, nil). +
    +
    + 213 + +
    + + + Times(2) +
    +
    + 214 + +
    +   +
    +
    +
    + 215 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 216 + +
    +   + m.Etherman. +
    +
    + 217 + +
    +   + On("HeaderByNumber", mock.Anything, n). +
    +
    + 218 + +
    + + + Return(ethHeader1, nil). +
    +
    + 219 + +
    +   + Once() +
    +
    + 220 + +
    +   +
    +
    +
    + 221 + +
    +   + t := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    +
     
    +
    + 234 + +
    +   + } +
    +
    + 235 + +
    +   +
    +
    +
    + 236 + +
    +   + forceb := []etherman.ForcedBatch{{ +
    +
    + 237 + +
    + + + BlockNumber: lastBlock1.BlockNumber, +
    +
    + 238 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 239 + +
    +   + Sequencer: sequencedBatch.Coinbase, +
    +
    + 240 + +
    +   + GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
     
    +
    + 242 + +
    +   + ForcedAt: time.Unix(int64(sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    +
    + 243 + +
    +   + }} +
    +
    + 244 + +
    +   +
    +
    +
    + 245 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 246 + +
    + + + BlockNumber: 0, +
    +
    + 247 + +
    + + + ReceivedAt: t, +
    +
    + 248 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 249 + +
    + + + } +
    +
    + 250 + +
    + + + ethermanBlock1 := etherman.Block{ +
    +
    + 251 + +
    +   + BlockNumber: 1, +
    +
    + 252 + +
    +   + ReceivedAt: t, +
    +
    + 253 + +
    + + + BlockHash: ethBlock1.Hash(), +
    +
    + 254 + +
    +   + SequencedBatches: [][]etherman.SequencedBatch{{sequencedBatch}}, +
    +
    + 255 + +
    +   + ForcedBatches: forceb, +
    +
    + 256 + +
    +   + } +
    +
    + 257 + +
    + + + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} +
    +
    + 258 + +
    +   + order := map[common.Hash][]etherman.Order{ +
    +
    + 259 + +
    + + + ethBlock1.Hash(): { +
    +
    + 260 + +
    +   + { +
    +
    + 261 + +
    +   + Name: etherman.ForcedBatchesOrder, +
    +
    + 262 + +
    +   + Pos: 0, +
    +
    +
     
    +
    + 268 + +
    +   + }, +
    +
    + 269 + +
    +   + } +
    +
    + 270 + +
    +   +
    +
    +
    + 271 + +
    + + + fromBlock := ethBlock0.NumberU64() +
    +
    + 272 + +
    +   + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 273 + +
    + + + if toBlock > ethBlock1.NumberU64() { +
    +
    + 274 + +
    + + + toBlock = ethBlock1.NumberU64() +
    +
    + 275 + +
    + + + } +
    +
    + 276 + +
    +   + m.Etherman. +
    +
    + 277 + +
    +   + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 278 + +
    +   + Return(blocks, order, nil). +
    +
    +
     
    +
    + 288 + +
    +   + Once() +
    +
    + 289 + +
    +   +
    +
    +
    + 290 + +
    +   + stateBlock := &state.Block{ +
    +
    + 291 + +
    + + + BlockNumber: ethermanBlock1.BlockNumber, +
    +
    + 292 + +
    + + + BlockHash: ethermanBlock1.BlockHash, +
    +
    + 293 + +
    + + + ParentHash: ethermanBlock1.ParentHash, +
    +
    + 294 + +
    + + + ReceivedAt: ethermanBlock1.ReceivedAt, +
    +
    + 295 + +
    + + + Checked: true, +
    +
    + 296 + +
    +   + } +
    +
    + 297 + +
    +   +
    +
    +
    + 298 + +
    +   + executionResponse := executor.ProcessBatchResponseV2{ +
    +
    +
     
    +
    + 304 + +
    +   + Return(&executionResponse, nil). +
    +
    + 305 + +
    +   + Times(1) +
    +
    + 306 + +
    +   +
    +
    +
    + 307 + +
    + + + m.Etherman. +
    +
    + 308 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 309 + +
    + + + Return(ethBlock1.NumberU64(), nil). +
    +
    + 310 + +
    + + + Once() +
    +
    + 311 + +
    + + +
    +
    +
    + 312 + +
    +   + m.State. +
    +
    + 313 + +
    +   + On("AddBlock", ctx, stateBlock, m.DbTx). +
    +
    + 314 + +
    +   + Return(nil). +
    +
    + 315 + +
    +   + Once() +
    +
    + 316 + +
    +   +
    +
    +
    + 317 + +
    +   + fb := []state.ForcedBatch{{ +
    +
    + 318 + +
    + + + BlockNumber: lastBlock1.BlockNumber, +
    +
    + 319 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 320 + +
    +   + Sequencer: sequencedBatch.Coinbase, +
    +
    + 321 + +
    +   + GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
     
    +
    + 350 + +
    +   + BatchNumber: sequencedBatch.BatchNumber, +
    +
    + 351 + +
    +   + TxHash: sequencedBatch.TxHash, +
    +
    + 352 + +
    +   + Coinbase: sequencedBatch.Coinbase, +
    +
    + 353 + +
    + + + BlockNumber: ethermanBlock1.BlockNumber, +
    +
    + 354 + +
    +   + TimestampBatchEtrog: &t, +
    +
    + 355 + +
    +   + L1InfoRoot: &forcedGER, +
    +
    + 356 + +
    +   + } +
    +
    +
     
    +
    + 396 + +
    +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    +
    + 397 + +
    +   + func TestSequenceForcedBatchIncaberry(t *testing.T) { +
    +
    + 398 + +
    +   + genesis := state.Genesis{ +
    +
    + 399 + +
    + + + RollupBlockNumber: uint64(123456), +
    +
    + 400 + +
    +   + } +
    +
    + 401 + +
    +   + cfg := Config{ +
    +
    + 402 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 403 + +
    +   + SyncChunkSize: 10, +
    +
    + 404 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + 405 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 406 + +
    +   + } +
    +
    + 407 + +
    +   +
    +
    +
    + 408 + +
    +   + m := mocks{ +
    +
    +
     
    +
    + 413 + +
    +   + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 414 + +
    +   + } +
    +
    + 415 + +
    +   + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 416 + +
    + + + sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 417 + +
    +   + require.NoError(t, err) +
    +
    + 418 + +
    +   +
    +
    +
    + 419 + +
    +   + // state preparation +
    +
    +
     
    +
    + 423 + +
    +   + Run(func(args mock.Arguments) { +
    +
    + 424 + +
    +   + ctx := args[0].(context.Context) +
    +
    + 425 + +
    +   + parentHash := common.HexToHash("0x111") +
    +
    + 426 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 427 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 428 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 429 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 430 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 431 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 432 + +
    +   + m.State. +
    +
    + 433 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 434 + +
    +   + Return(uint64(1), nil). +
    +
    + 435 + +
    +   + Maybe() +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 436 + +
    +   +
    +
    +
    + 437 + +
    +   + m.State. +
    +
    + 438 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 439 + +
    + + + Return(lastBlock0, nil). +
    +
    + 440 + +
    +   + Once() +
    +
    + 441 + +
    +   +
    +
    +
    + 442 + +
    +   + m.State. +
    +
    +
     
    +
    + 474 + +
    +   + Return(nil). +
    +
    + 475 + +
    +   + Once() +
    +
    + 476 + +
    +   +
    +
    +
    + 477 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 478 + +
    +   + m.Etherman. +
    +
    + 479 + +
    + + + On("HeaderByNumber", ctx, n). +
    +
    + 480 + +
    + + + Return(ethHeader1, nil). +
    +
    + 481 + +
    +   + Once() +
    +
    + 482 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 483 + +
    +   + m.Etherman. +
    +
    + 484 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 485 + +
    + + + Return(ethBlock0, nil). +
    +
    + 486 + +
    +   + Once() +
    +
    + 487 + +
    +   +
    +
    +
    + 488 + +
    +   + sequencedForceBatch := etherman.SequencedForceBatch{ +
    +
    +
     
    +
    + 498 + +
    +   + } +
    +
    + 499 + +
    +   +
    +
    +
    + 500 + +
    +   + forceb := []etherman.ForcedBatch{{ +
    +
    + 501 + +
    + + + BlockNumber: lastBlock1.BlockNumber, +
    +
    + 502 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 503 + +
    +   + Sequencer: sequencedForceBatch.Coinbase, +
    +
    + 504 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
     
    +
    + 506 + +
    +   + ForcedAt: time.Unix(int64(sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    +
    + 507 + +
    +   + }} +
    +
    + 508 + +
    +   +
    +
    +
    + 509 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 510 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 511 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 512 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 513 + +
    + + + } +
    +
    + 514 + +
    + + + ethermanBlock1 := etherman.Block{ +
    +
    + 515 + +
    + + + BlockNumber: ethBlock1.NumberU64(), +
    +
    + 516 + +
    + + + BlockHash: ethBlock1.Hash(), +
    +
    + 517 + +
    + + + ParentHash: ethBlock1.ParentHash(), +
    +
    + 518 + +
    +   + SequencedForceBatches: [][]etherman.SequencedForceBatch{{sequencedForceBatch}}, +
    +
    + 519 + +
    +   + ForcedBatches: forceb, +
    +
    + 520 + +
    +   + } +
    +
    + 521 + +
    + + + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} +
    +
    + 522 + +
    +   + order := map[common.Hash][]etherman.Order{ +
    +
    + 523 + +
    + + + ethBlock1.Hash(): { +
    +
    + 524 + +
    +   + { +
    +
    + 525 + +
    +   + Name: etherman.ForcedBatchesOrder, +
    +
    + 526 + +
    +   + Pos: 0, +
    +
    +
     
    +
    + 532 + +
    +   + }, +
    +
    + 533 + +
    +   + } +
    +
    + 534 + +
    +   +
    +
    +
    + 535 + +
    + + + fromBlock := ethBlock0.NumberU64() +
    +
    + 536 + +
    +   + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 537 + +
    + + + if toBlock > ethBlock1.NumberU64() { +
    +
    + 538 + +
    + + + toBlock = ethBlock1.NumberU64() +
    +
    + 539 + +
    + + + } +
    +
    + 540 + +
    +   + m.Etherman. +
    +
    + 541 + +
    +   + On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). +
    +
    + 542 + +
    +   + Return(blocks, order, nil). +
    +
    + 543 + +
    +   + Once() +
    +
    + 544 + +
    +   +
    +
    +
    + 545 + +
    + + + m.Etherman. +
    +
    + 546 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 547 + +
    + + + Return(ethBlock1.NumberU64(), nil). +
    +
    + 548 + +
    + + + Once() +
    +
    + 549 + +
    + + +
    +
    +
    + 550 + +
    +   + m.State. +
    +
    + 551 + +
    +   + On("BeginStateTransaction", ctx). +
    +
    + 552 + +
    +   + Return(m.DbTx, nil). +
    +
    + 553 + +
    +   + Once() +
    +
    + 554 + +
    +   +
    +
    +
    + 555 + +
    +   + stateBlock := &state.Block{ +
    +
    + 556 + +
    + + + BlockNumber: ethermanBlock1.BlockNumber, +
    +
    + 557 + +
    + + + BlockHash: ethermanBlock1.BlockHash, +
    +
    + 558 + +
    + + + ParentHash: ethermanBlock1.ParentHash, +
    +
    + 559 + +
    + + + ReceivedAt: ethermanBlock1.ReceivedAt, +
    +
    + 560 + +
    + + + Checked: true, +
    +
    + 561 + +
    +   + } +
    +
    + 562 + +
    +   +
    +
    +
    + 563 + +
    +   + m.State. +
    +
    +
     
    +
    + 565 + +
    +   + Return(nil). +
    +
    + 566 + +
    +   + Once() +
    +
    + 567 + +
    +   +
    +
    +
    + 568 + +
    + + + m.State. +
    +
    + 569 + +
    + + + On("GetForkIDByBlockNumber", stateBlock.BlockNumber). +
    +
    + 570 + +
    + + + Return(uint64(9), nil). +
    +
    + 571 + +
    + + + Once() +
    +
    + 572 + +
    + + +
    +
    +
    + 573 + +
    +   + fb := []state.ForcedBatch{{ +
    +
    + 574 + +
    + + + BlockNumber: lastBlock1.BlockNumber, +
    +
    + 575 + +
    +   + ForcedBatchNumber: 1, +
    +
    + 576 + +
    +   + Sequencer: sequencedForceBatch.Coinbase, +
    +
    + 577 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    +
     
    +
    + 603 + +
    +   + processingContext := state.ProcessingContext{ +
    +
    + 604 + +
    +   + BatchNumber: sequencedForceBatch.BatchNumber, +
    +
    + 605 + +
    +   + Coinbase: sequencedForceBatch.Coinbase, +
    +
    + 606 + +
    + + + Timestamp: ethBlock1.ReceivedAt, +
    +
    + 607 + +
    +   + GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    +
    + 608 + +
    +   + ForcedBatchNum: &f, +
    +
    + 609 + +
    +   + BatchL2Data: &sequencedForceBatch.PolygonRollupBaseEtrogBatchData.Transactions, +
    +
    +
     
    +
    + 618 + +
    +   + TxHash: sequencedForceBatch.TxHash, +
    +
    + 619 + +
    +   + Coinbase: sequencedForceBatch.Coinbase, +
    +
    + 620 + +
    +   + SequencerAddr: sequencedForceBatch.Coinbase, +
    +
    + 621 + +
    + + + BlockNumber: ethermanBlock1.BlockNumber, +
    +
    + 622 + +
    +   + } +
    +
    + 623 + +
    +   +
    +
    +
    + 624 + +
    +   + m.State. +
    +
    +
     
    +
    + 642 + +
    +   +
    +
    +
    + 643 + +
    +   + m.DbTx. +
    +
    + 644 + +
    +   + On("Commit", ctx). +
    +
    + 645 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 646 + +
    + + + sync.Stop() +
    +
    + 647 + +
    + + + ctx.Done() +
    +
    + 648 + +
    + + + }). +
    +
    + 649 + +
    +   + Return(nil). +
    +
    + 650 + +
    +   + Once() +
    +
    + 651 + +
    +   + }). +
    +
    +
     
    +
    + 658 + +
    +   +
    +
    +
    + 659 + +
    +   + func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { +
    +
    + 660 + +
    +   + genesis := state.Genesis{ +
    +
    + 661 + +
    + + + RollupBlockNumber: uint64(123456), +
    +
    + 662 + +
    +   + } +
    +
    + 663 + +
    +   + cfg := Config{ +
    +
    + 664 + +
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 665 + +
    +   + SyncChunkSize: 10, +
    +
    + 666 + +
    +   + L1SynchronizationMode: SequentialMode, +
    +
    + 667 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 668 + +
    +   + L1ParallelSynchronization: L1ParallelSynchronizationConfig{ +
    +
    + 669 + +
    +   + MaxClients: 2, +
    +
    + 670 + +
    +   + MaxPendingNoProcessedBlocks: 2, +
    +
    +
     
    +
    + 679 + +
    +   + } +
    +
    + 680 + +
    +   +
    +
    +
    + 681 + +
    +   + m := mocks{ +
    +
    + 682 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 683 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 684 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 685 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 686 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 687 + +
    + + + zkEVMClientEthereumCompatible: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t), +
    +
    + 688 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 689 + +
    +   + //EventLog: newEventLogMock(t), +
    +
    + 690 + +
    +   + } +
    +
    + 691 + +
    +   + return &genesis, &cfg, &m +
    +
    +
     
    +
    + 919 + +
    +   + Return(nil). +
    +
    + 920 + +
    +   + Once() +
    +
    + 921 + +
    +   + } +
    +
    + 922 + +
    + + +
    +
    +
    + 923 + +
    + + + func TestReorg(t *testing.T) { +
    +
    + 924 + +
    + + + genesis := state.Genesis{ +
    +
    + 925 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 926 + +
    + + + } +
    +
    + 927 + +
    + + + cfg := Config{ +
    +
    + 928 + +
    + + + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 929 + +
    + + + SyncChunkSize: 3, +
    +
    + 930 + +
    + + + L1SynchronizationMode: SequentialMode, +
    +
    + 931 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 932 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 933 + +
    + + + Enable: false, +
    +
    + 934 + +
    + + + }, +
    +
    + 935 + +
    + + + } +
    +
    + 936 + +
    + + +
    +
    +
    + 937 + +
    + + + m := mocks{ +
    +
    + 938 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 939 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 940 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 941 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 942 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 943 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 944 + +
    + + + } +
    +
    + 945 + +
    + + + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 946 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 947 + +
    + + + require.NoError(t, err) +
    +
    + 948 + +
    + + +
    +
    +
    + 949 + +
    + + + // state preparation +
    +
    + 950 + +
    + + + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    + 951 + +
    + + + forkIdInterval := state.ForkIDInterval{ +
    +
    + 952 + +
    + + + ForkId: 9, +
    +
    + 953 + +
    + + + FromBatchNumber: 0, +
    +
    + 954 + +
    + + + ToBatchNumber: math.MaxUint64, +
    +
    + 955 + +
    + + + } +
    +
    + 956 + +
    + + + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    + 957 + +
    + + +
    +
    +
    + 958 + +
    + + + m.State. +
    +
    + 959 + +
    + + + On("BeginStateTransaction", ctxMatchBy). +
    +
    + 960 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 961 + +
    + + + ctx := args[0].(context.Context) +
    +
    + 962 + +
    + + + parentHash := common.HexToHash("0x111") +
    +
    + 963 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 964 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 965 + +
    + + + ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} +
    +
    + 966 + +
    + + + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    + 967 + +
    + + + ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} +
    +
    + 968 + +
    + + + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) +
    +
    + 969 + +
    + + + ethHeader3bis := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2bis.Hash()} +
    +
    + 970 + +
    + + + ethBlock3bis := ethTypes.NewBlockWithHeader(ethHeader3bis) +
    +
    + 971 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 972 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 973 + +
    + + + ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    + 974 + +
    + + + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    + 975 + +
    + + + ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    + 976 + +
    + + + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    + 977 + +
    + + +
    +
    +
    + 978 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 979 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 980 + +
    + + +
    +
    +
    + 981 + +
    + + + m.State. +
    +
    + 982 + +
    + + + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 983 + +
    + + + Return(uint64(9), nil). +
    +
    + 984 + +
    + + + Maybe() +
    +
    + 985 + +
    + + + m.State. +
    +
    + 986 + +
    + + + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 987 + +
    + + + Return(lastBlock1, nil). +
    +
    + 988 + +
    + + + Once() +
    +
    + 989 + +
    + + +
    +
    +
    + 990 + +
    + + + m.State. +
    +
    + 991 + +
    + + + On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    + 992 + +
    + + + Return(uint64(10), nil). +
    +
    + 993 + +
    + + + Once() +
    +
    + 994 + +
    + + +
    +
    +
    + 995 + +
    + + + m.State. +
    +
    + 996 + +
    + + + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    + 997 + +
    + + + Return(nil). +
    +
    + 998 + +
    + + + Once() +
    +
    + 999 + +
    + + +
    +
    +
    + 1000 + +
    + + + m.DbTx. +
    +
    + 1001 + +
    + + + On("Commit", ctx). +
    +
    + 1002 + +
    + + + Return(nil). +
    +
    + 1003 + +
    + + + Once() +
    +
    + 1004 + +
    + + +
    +
    +
    + 1005 + +
    + + + m.Etherman. +
    +
    + 1006 + +
    + + + On("GetLatestBatchNumber"). +
    +
    + 1007 + +
    + + + Return(uint64(10), nil) +
    +
    + 1008 + +
    + + +
    +
    +
    + 1009 + +
    + + + var nilDbTx pgx.Tx +
    +
    + 1010 + +
    + + + m.State. +
    +
    + 1011 + +
    + + + On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    + 1012 + +
    + + + Return(uint64(10), nil) +
    +
    + 1013 + +
    + + +
    +
    +
    + 1014 + +
    + + + m.Etherman. +
    +
    + 1015 + +
    + + + On("GetLatestVerifiedBatchNum"). +
    +
    + 1016 + +
    + + + Return(uint64(10), nil) +
    +
    + 1017 + +
    + + +
    +
    +
    + 1018 + +
    + + + m.State. +
    +
    + 1019 + +
    + + + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    + 1020 + +
    + + + Return(nil) +
    +
    + 1021 + +
    + + +
    +
    +
    + 1022 + +
    + + + m.Etherman. +
    +
    + 1023 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1024 + +
    + + + Return(ethBlock1, nil). +
    +
    + 1025 + +
    + + + Once() +
    +
    + 1026 + +
    + + +
    +
    +
    + 1027 + +
    + + + m.ZKEVMClient. +
    +
    + 1028 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1029 + +
    + + + Return(uint64(1), nil). +
    +
    + 1030 + +
    + + + Once() +
    +
    + 1031 + +
    + + +
    +
    +
    + 1032 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 1033 + +
    + + + m.Etherman. +
    +
    + 1034 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1035 + +
    + + + Return(ethHeader3bis, nil). +
    +
    + 1036 + +
    + + + Once() +
    +
    + 1037 + +
    + + +
    +
    +
    + 1038 + +
    + + + m.Etherman. +
    +
    + 1039 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1040 + +
    + + + Return(ethBlock1, nil). +
    +
    + 1041 + +
    + + + Once() +
    +
    + 1042 + +
    + + +
    +
    +
    + 1043 + +
    + + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    + 1044 + +
    + + +
    +
    +
    + 1045 + +
    + + + ethermanBlock1bis := etherman.Block{ +
    +
    + 1046 + +
    + + + BlockNumber: 1, +
    +
    + 1047 + +
    + + + ReceivedAt: ti, +
    +
    + 1048 + +
    + + + BlockHash: ethBlock1bis.Hash(), +
    +
    + 1049 + +
    + + + ParentHash: ethBlock1bis.ParentHash(), +
    +
    + 1050 + +
    + + + } +
    +
    + 1051 + +
    + + + ethermanBlock2bis := etherman.Block{ +
    +
    + 1052 + +
    + + + BlockNumber: 2, +
    +
    + 1053 + +
    + + + ReceivedAt: ti, +
    +
    + 1054 + +
    + + + BlockHash: ethBlock2bis.Hash(), +
    +
    + 1055 + +
    + + + ParentHash: ethBlock2bis.ParentHash(), +
    +
    + 1056 + +
    + + + } +
    +
    + 1057 + +
    + + + blocks := []etherman.Block{ethermanBlock1bis, ethermanBlock2bis} +
    +
    + 1058 + +
    + + + order := map[common.Hash][]etherman.Order{} +
    +
    + 1059 + +
    + + +
    +
    +
    + 1060 + +
    + + + fromBlock := ethBlock1.NumberU64() +
    +
    + 1061 + +
    + + + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 1062 + +
    + + + if toBlock > ethBlock3.NumberU64() { +
    +
    + 1063 + +
    + + + toBlock = ethBlock3.NumberU64() +
    +
    + 1064 + +
    + + + } +
    +
    + 1065 + +
    + + + m.Etherman. +
    +
    + 1066 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1067 + +
    + + + Return(blocks, order, nil). +
    +
    + 1068 + +
    + + + Once() +
    +
    + 1069 + +
    + + +
    +
    +
    + 1070 + +
    + + + m.State. +
    +
    + 1071 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1072 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1073 + +
    + + + Once() +
    +
    + 1074 + +
    + + +
    +
    +
    + 1075 + +
    + + + var depth uint64 = 1 +
    +
    + 1076 + +
    + + + stateBlock0 := &state.Block{ +
    +
    + 1077 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 1078 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1079 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1080 + +
    + + + ReceivedAt: ti, +
    +
    + 1081 + +
    + + + } +
    +
    + 1082 + +
    + + + m.State. +
    +
    + 1083 + +
    + + + On("GetPreviousBlock", ctx, depth, m.DbTx). +
    +
    + 1084 + +
    + + + Return(stateBlock0, nil). +
    +
    + 1085 + +
    + + + Once() +
    +
    + 1086 + +
    + + +
    +
    +
    + 1087 + +
    + + + m.DbTx. +
    +
    + 1088 + +
    + + + On("Commit", ctx). +
    +
    + 1089 + +
    + + + Return(nil). +
    +
    + 1090 + +
    + + + Once() +
    +
    + 1091 + +
    + + +
    +
    +
    + 1092 + +
    + + + m.Etherman. +
    +
    + 1093 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1094 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1095 + +
    + + + Once() +
    +
    + 1096 + +
    + + +
    +
    +
    + 1097 + +
    + + + m.State. +
    +
    + 1098 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1099 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1100 + +
    + + + Once() +
    +
    + 1101 + +
    + + +
    +
    +
    + 1102 + +
    + + + m.State. +
    +
    + 1103 + +
    + + + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    + 1104 + +
    + + + Return(nil). +
    +
    + 1105 + +
    + + + Once() +
    +
    + 1106 + +
    + + +
    +
    +
    + 1107 + +
    + + + m.EthTxManager. +
    +
    + 1108 + +
    + + + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    + 1109 + +
    + + + Return(nil). +
    +
    + 1110 + +
    + + + Once() +
    +
    + 1111 + +
    + + +
    +
    +
    + 1112 + +
    + + + m.DbTx. +
    +
    + 1113 + +
    + + + On("Commit", ctx). +
    +
    + 1114 + +
    + + + Return(nil). +
    +
    + 1115 + +
    + + + Once() +
    +
    + 1116 + +
    + + +
    +
    +
    + 1117 + +
    + + + m.Etherman. +
    +
    + 1118 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1119 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1120 + +
    + + + Once() +
    +
    + 1121 + +
    + + +
    +
    +
    + 1122 + +
    + + + m.ZKEVMClient. +
    +
    + 1123 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1124 + +
    + + + Return(uint64(1), nil). +
    +
    + 1125 + +
    + + + Once() +
    +
    + 1126 + +
    + + +
    +
    +
    + 1127 + +
    + + + m.Etherman. +
    +
    + 1128 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1129 + +
    + + + Return(ethHeader3bis, nil). +
    +
    + 1130 + +
    + + + Once() +
    +
    + 1131 + +
    + + +
    +
    +
    + 1132 + +
    + + + m.Etherman. +
    +
    + 1133 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1134 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1135 + +
    + + + Once() +
    +
    + 1136 + +
    + + +
    +
    +
    + 1137 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 1138 + +
    + + + BlockNumber: 0, +
    +
    + 1139 + +
    + + + ReceivedAt: ti, +
    +
    + 1140 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1141 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1142 + +
    + + + } +
    +
    + 1143 + +
    + + + ethermanBlock3bis := etherman.Block{ +
    +
    + 1144 + +
    + + + BlockNumber: 3, +
    +
    + 1145 + +
    + + + ReceivedAt: ti, +
    +
    + 1146 + +
    + + + BlockHash: ethBlock3bis.Hash(), +
    +
    + 1147 + +
    + + + ParentHash: ethBlock3bis.ParentHash(), +
    +
    + 1148 + +
    + + + } +
    +
    + 1149 + +
    + + + fromBlock = 0 +
    +
    + 1150 + +
    + + + blocks2 := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis, ethermanBlock3bis} +
    +
    + 1151 + +
    + + + m.Etherman. +
    +
    + 1152 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1153 + +
    + + + Return(blocks2, order, nil). +
    +
    + 1154 + +
    + + + Once() +
    +
    + 1155 + +
    + + +
    +
    +
    + 1156 + +
    + + + m.Etherman. +
    +
    + 1157 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 1158 + +
    + + + Return(ethBlock2bis.NumberU64(), nil). +
    +
    + 1159 + +
    + + + Once() +
    +
    + 1160 + +
    + + +
    +
    +
    + 1161 + +
    + + + m.State. +
    +
    + 1162 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1163 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1164 + +
    + + + Once() +
    +
    + 1165 + +
    + + +
    +
    +
    + 1166 + +
    + + + stateBlock1bis := &state.Block{ +
    +
    + 1167 + +
    + + + BlockNumber: ethermanBlock1bis.BlockNumber, +
    +
    + 1168 + +
    + + + BlockHash: ethermanBlock1bis.BlockHash, +
    +
    + 1169 + +
    + + + ParentHash: ethermanBlock1bis.ParentHash, +
    +
    + 1170 + +
    + + + ReceivedAt: ethermanBlock1bis.ReceivedAt, +
    +
    + 1171 + +
    + + + Checked: true, +
    +
    + 1172 + +
    + + + } +
    +
    + 1173 + +
    + + + m.State. +
    +
    + 1174 + +
    + + + On("AddBlock", ctx, stateBlock1bis, m.DbTx). +
    +
    + 1175 + +
    + + + Return(nil). +
    +
    + 1176 + +
    + + + Once() +
    +
    + 1177 + +
    + + +
    +
    +
    + 1178 + +
    + + + m.State. +
    +
    + 1179 + +
    + + + On("GetStoredFlushID", ctx). +
    +
    + 1180 + +
    + + + Return(uint64(1), cProverIDExecution, nil). +
    +
    + 1181 + +
    + + + Once() +
    +
    + 1182 + +
    + + +
    +
    +
    + 1183 + +
    + + + m.DbTx. +
    +
    + 1184 + +
    + + + On("Commit", ctx). +
    +
    + 1185 + +
    + + + Return(nil). +
    +
    + 1186 + +
    + + + Once() +
    +
    + 1187 + +
    + + +
    +
    +
    + 1188 + +
    + + + m.State. +
    +
    + 1189 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1190 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1191 + +
    + + + Once() +
    +
    + 1192 + +
    + + +
    +
    +
    + 1193 + +
    + + + stateBlock2bis := &state.Block{ +
    +
    + 1194 + +
    + + + BlockNumber: ethermanBlock2bis.BlockNumber, +
    +
    + 1195 + +
    + + + BlockHash: ethermanBlock2bis.BlockHash, +
    +
    + 1196 + +
    + + + ParentHash: ethermanBlock2bis.ParentHash, +
    +
    + 1197 + +
    + + + ReceivedAt: ethermanBlock2bis.ReceivedAt, +
    +
    + 1198 + +
    + + + Checked: true, +
    +
    + 1199 + +
    + + + } +
    +
    + 1200 + +
    + + + m.State. +
    +
    + 1201 + +
    + + + On("AddBlock", ctx, stateBlock2bis, m.DbTx). +
    +
    + 1202 + +
    + + + Return(nil). +
    +
    + 1203 + +
    + + + Once() +
    +
    + 1204 + +
    + + +
    +
    +
    + 1205 + +
    + + + m.DbTx. +
    +
    + 1206 + +
    + + + On("Commit", ctx). +
    +
    + 1207 + +
    + + + Return(nil). +
    +
    + 1208 + +
    + + + Once() +
    +
    + 1209 + +
    + + +
    +
    +
    + 1210 + +
    + + + m.State. +
    +
    + 1211 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1212 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1213 + +
    + + + Once() +
    +
    + 1214 + +
    + + +
    +
    +
    + 1215 + +
    + + + stateBlock3bis := &state.Block{ +
    +
    + 1216 + +
    + + + BlockNumber: ethermanBlock3bis.BlockNumber, +
    +
    + 1217 + +
    + + + BlockHash: ethermanBlock3bis.BlockHash, +
    +
    + 1218 + +
    + + + ParentHash: ethermanBlock3bis.ParentHash, +
    +
    + 1219 + +
    + + + ReceivedAt: ethermanBlock3bis.ReceivedAt, +
    +
    + 1220 + +
    + + + Checked: false, +
    +
    + 1221 + +
    + + + } +
    +
    + 1222 + +
    + + + m.State. +
    +
    + 1223 + +
    + + + On("AddBlock", ctx, stateBlock3bis, m.DbTx). +
    +
    + 1224 + +
    + + + Return(nil). +
    +
    + 1225 + +
    + + + Once() +
    +
    + 1226 + +
    + + +
    +
    +
    + 1227 + +
    + + + m.DbTx. +
    +
    + 1228 + +
    + + + On("Commit", ctx). +
    +
    + 1229 + +
    + + + Return(nil). +
    +
    + 1230 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1231 + +
    + + + sync.Stop() +
    +
    + 1232 + +
    + + + ctx.Done() +
    +
    + 1233 + +
    + + + }). +
    +
    + 1234 + +
    + + + Once() +
    +
    + 1235 + +
    + + + }). +
    +
    + 1236 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1237 + +
    + + + Once() +
    +
    + 1238 + +
    + + +
    +
    +
    + 1239 + +
    + + + err = sync.Sync() +
    +
    + 1240 + +
    + + + require.NoError(t, err) +
    +
    + 1241 + +
    + + + } +
    +
    + 1242 + +
    + + +
    +
    +
    + 1243 + +
    + + + func TestLatestSyncedBlockEmpty(t *testing.T) { +
    +
    + 1244 + +
    + + + genesis := state.Genesis{ +
    +
    + 1245 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 1246 + +
    + + + } +
    +
    + 1247 + +
    + + + cfg := Config{ +
    +
    + 1248 + +
    + + + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 1249 + +
    + + + SyncChunkSize: 3, +
    +
    + 1250 + +
    + + + L1SynchronizationMode: SequentialMode, +
    +
    + 1251 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 1252 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 1253 + +
    + + + Enable: false, +
    +
    + 1254 + +
    + + + }, +
    +
    + 1255 + +
    + + + } +
    +
    + 1256 + +
    + + +
    +
    +
    + 1257 + +
    + + + m := mocks{ +
    +
    + 1258 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 1259 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 1260 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 1261 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 1262 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 1263 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 1264 + +
    + + + } +
    +
    + 1265 + +
    + + + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 1266 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 1267 + +
    + + + require.NoError(t, err) +
    +
    + 1268 + +
    + + +
    +
    +
    + 1269 + +
    + + + // state preparation +
    +
    + 1270 + +
    + + + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    + 1271 + +
    + + + forkIdInterval := state.ForkIDInterval{ +
    +
    + 1272 + +
    + + + ForkId: 9, +
    +
    + 1273 + +
    + + + FromBatchNumber: 0, +
    +
    + 1274 + +
    + + + ToBatchNumber: math.MaxUint64, +
    +
    + 1275 + +
    + + + } +
    +
    + 1276 + +
    + + + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    + 1277 + +
    + + +
    +
    +
    + 1278 + +
    + + + m.State. +
    +
    + 1279 + +
    + + + On("BeginStateTransaction", ctxMatchBy). +
    +
    + 1280 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1281 + +
    + + + ctx := args[0].(context.Context) +
    +
    + 1282 + +
    + + + parentHash := common.HexToHash("0x111") +
    +
    + 1283 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 1284 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 1285 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 1286 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 1287 + +
    + + + ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    + 1288 + +
    + + + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    + 1289 + +
    + + + ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    + 1290 + +
    + + + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    + 1291 + +
    + + +
    +
    +
    + 1292 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 1293 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 1294 + +
    + + +
    +
    +
    + 1295 + +
    + + + m.State. +
    +
    + 1296 + +
    + + + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 1297 + +
    + + + Return(uint64(9), nil). +
    +
    + 1298 + +
    + + + Maybe() +
    +
    + 1299 + +
    + + + m.State. +
    +
    + 1300 + +
    + + + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 1301 + +
    + + + Return(lastBlock1, nil). +
    +
    + 1302 + +
    + + + Once() +
    +
    + 1303 + +
    + + +
    +
    +
    + 1304 + +
    + + + m.State. +
    +
    + 1305 + +
    + + + On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    + 1306 + +
    + + + Return(uint64(10), nil). +
    +
    + 1307 + +
    + + + Once() +
    +
    + 1308 + +
    + + +
    +
    +
    + 1309 + +
    + + + m.State. +
    +
    + 1310 + +
    + + + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    + 1311 + +
    + + + Return(nil). +
    +
    + 1312 + +
    + + + Once() +
    +
    + 1313 + +
    + + +
    +
    +
    + 1314 + +
    + + + m.DbTx. +
    +
    + 1315 + +
    + + + On("Commit", ctx). +
    +
    + 1316 + +
    + + + Return(nil). +
    +
    + 1317 + +
    + + + Once() +
    +
    + 1318 + +
    + + +
    +
    +
    + 1319 + +
    + + + m.Etherman. +
    +
    + 1320 + +
    + + + On("GetLatestBatchNumber"). +
    +
    + 1321 + +
    + + + Return(uint64(10), nil) +
    +
    + 1322 + +
    + + +
    +
    +
    + 1323 + +
    + + + var nilDbTx pgx.Tx +
    +
    + 1324 + +
    + + + m.State. +
    +
    + 1325 + +
    + + + On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    + 1326 + +
    + + + Return(uint64(10), nil) +
    +
    + 1327 + +
    + + +
    +
    +
    + 1328 + +
    + + + m.Etherman. +
    +
    + 1329 + +
    + + + On("GetLatestVerifiedBatchNum"). +
    +
    + 1330 + +
    + + + Return(uint64(10), nil) +
    +
    + 1331 + +
    + + +
    +
    +
    + 1332 + +
    + + + m.State. +
    +
    + 1333 + +
    + + + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    + 1334 + +
    + + + Return(nil) +
    +
    + 1335 + +
    + + +
    +
    +
    + 1336 + +
    + + + m.Etherman. +
    +
    + 1337 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1338 + +
    + + + Return(ethBlock1, nil). +
    +
    + 1339 + +
    + + + Once() +
    +
    + 1340 + +
    + + +
    +
    +
    + 1341 + +
    + + + m.ZKEVMClient. +
    +
    + 1342 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1343 + +
    + + + Return(uint64(1), nil). +
    +
    + 1344 + +
    + + + Once() +
    +
    + 1345 + +
    + + +
    +
    +
    + 1346 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 1347 + +
    + + + m.Etherman. +
    +
    + 1348 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1349 + +
    + + + Return(ethHeader3, nil). +
    +
    + 1350 + +
    + + + Once() +
    +
    + 1351 + +
    + + +
    +
    +
    + 1352 + +
    + + + m.Etherman. +
    +
    + 1353 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1354 + +
    + + + Return(ethBlock1, nil). +
    +
    + 1355 + +
    + + + Once() +
    +
    + 1356 + +
    + + +
    +
    +
    + 1357 + +
    + + + blocks := []etherman.Block{} +
    +
    + 1358 + +
    + + + order := map[common.Hash][]etherman.Order{} +
    +
    + 1359 + +
    + + +
    +
    +
    + 1360 + +
    + + + fromBlock := ethBlock1.NumberU64() +
    +
    + 1361 + +
    + + + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 1362 + +
    + + + if toBlock > ethBlock3.NumberU64() { +
    +
    + 1363 + +
    + + + toBlock = ethBlock3.NumberU64() +
    +
    + 1364 + +
    + + + } +
    +
    + 1365 + +
    + + + m.Etherman. +
    +
    + 1366 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1367 + +
    + + + Return(blocks, order, nil). +
    +
    + 1368 + +
    + + + Once() +
    +
    + 1369 + +
    + + +
    +
    +
    + 1370 + +
    + + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    + 1371 + +
    + + + var depth uint64 = 1 +
    +
    + 1372 + +
    + + + stateBlock0 := &state.Block{ +
    +
    + 1373 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 1374 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1375 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1376 + +
    + + + ReceivedAt: ti, +
    +
    + 1377 + +
    + + + } +
    +
    + 1378 + +
    + + + m.State. +
    +
    + 1379 + +
    + + + On("GetPreviousBlock", ctx, depth, nil). +
    +
    + 1380 + +
    + + + Return(stateBlock0, nil). +
    +
    + 1381 + +
    + + + Once() +
    +
    + 1382 + +
    + + +
    +
    +
    + 1383 + +
    + + + m.Etherman. +
    +
    + 1384 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1385 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1386 + +
    + + + Once() +
    +
    + 1387 + +
    + + +
    +
    +
    + 1388 + +
    + + + m.State. +
    +
    + 1389 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1390 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1391 + +
    + + + Once() +
    +
    + 1392 + +
    + + +
    +
    +
    + 1393 + +
    + + + m.State. +
    +
    + 1394 + +
    + + + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    + 1395 + +
    + + + Return(nil). +
    +
    + 1396 + +
    + + + Once() +
    +
    + 1397 + +
    + + +
    +
    +
    + 1398 + +
    + + + m.EthTxManager. +
    +
    + 1399 + +
    + + + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    + 1400 + +
    + + + Return(nil). +
    +
    + 1401 + +
    + + + Once() +
    +
    + 1402 + +
    + + +
    +
    +
    + 1403 + +
    + + + m.DbTx. +
    +
    + 1404 + +
    + + + On("Commit", ctx). +
    +
    + 1405 + +
    + + + Return(nil). +
    +
    + 1406 + +
    + + + Once() +
    +
    + 1407 + +
    + + +
    +
    +
    + 1408 + +
    + + + m.Etherman. +
    +
    + 1409 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1410 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1411 + +
    + + + Once() +
    +
    + 1412 + +
    + + +
    +
    +
    + 1413 + +
    + + + m.ZKEVMClient. +
    +
    + 1414 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1415 + +
    + + + Return(uint64(1), nil). +
    +
    + 1416 + +
    + + + Once() +
    +
    + 1417 + +
    + + +
    +
    +
    + 1418 + +
    + + + m.Etherman. +
    +
    + 1419 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1420 + +
    + + + Return(ethHeader3, nil). +
    +
    + 1421 + +
    + + + Once() +
    +
    + 1422 + +
    + + +
    +
    +
    + 1423 + +
    + + + m.Etherman. +
    +
    + 1424 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1425 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1426 + +
    + + + Once() +
    +
    + 1427 + +
    + + +
    +
    +
    + 1428 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 1429 + +
    + + + BlockNumber: 0, +
    +
    + 1430 + +
    + + + ReceivedAt: ti, +
    +
    + 1431 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1432 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1433 + +
    + + + } +
    +
    + 1434 + +
    + + + blocks = []etherman.Block{ethermanBlock0} +
    +
    + 1435 + +
    + + + fromBlock = 0 +
    +
    + 1436 + +
    + + + m.Etherman. +
    +
    + 1437 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1438 + +
    + + + Return(blocks, order, nil). +
    +
    + 1439 + +
    + + + Once() +
    +
    + 1440 + +
    + + +
    +
    +
    + 1441 + +
    + + + m.Etherman. +
    +
    + 1442 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 1443 + +
    + + + Return(ethBlock3.NumberU64(), nil). +
    +
    + 1444 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1445 + +
    + + + sync.Stop() +
    +
    + 1446 + +
    + + + ctx.Done() +
    +
    + 1447 + +
    + + + }). +
    +
    + 1448 + +
    + + + Once() +
    +
    + 1449 + +
    + + + }). +
    +
    + 1450 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1451 + +
    + + + Once() +
    +
    + 1452 + +
    + + +
    +
    +
    + 1453 + +
    + + + err = sync.Sync() +
    +
    + 1454 + +
    + + + require.NoError(t, err) +
    +
    + 1455 + +
    + + + } +
    +
    + 1456 + +
    + + +
    +
    +
    + 1457 + +
    + + + func TestRegularReorg(t *testing.T) { +
    +
    + 1458 + +
    + + + genesis := state.Genesis{ +
    +
    + 1459 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 1460 + +
    + + + } +
    +
    + 1461 + +
    + + + cfg := Config{ +
    +
    + 1462 + +
    + + + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 1463 + +
    + + + SyncChunkSize: 3, +
    +
    + 1464 + +
    + + + L1SynchronizationMode: SequentialMode, +
    +
    + 1465 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 1466 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 1467 + +
    + + + Enable: false, +
    +
    + 1468 + +
    + + + }, +
    +
    + 1469 + +
    + + + } +
    +
    + 1470 + +
    + + +
    +
    +
    + 1471 + +
    + + + m := mocks{ +
    +
    + 1472 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 1473 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 1474 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 1475 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 1476 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 1477 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 1478 + +
    + + + } +
    +
    + 1479 + +
    + + + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 1480 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 1481 + +
    + + + require.NoError(t, err) +
    +
    + 1482 + +
    + + +
    +
    +
    + 1483 + +
    + + + // state preparation +
    +
    + 1484 + +
    + + + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    + 1485 + +
    + + + forkIdInterval := state.ForkIDInterval{ +
    +
    + 1486 + +
    + + + ForkId: 9, +
    +
    + 1487 + +
    + + + FromBatchNumber: 0, +
    +
    + 1488 + +
    + + + ToBatchNumber: math.MaxUint64, +
    +
    + 1489 + +
    + + + } +
    +
    + 1490 + +
    + + + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    + 1491 + +
    + + +
    +
    +
    + 1492 + +
    + + + m.State. +
    +
    + 1493 + +
    + + + On("BeginStateTransaction", ctxMatchBy). +
    +
    + 1494 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1495 + +
    + + + ctx := args[0].(context.Context) +
    +
    + 1496 + +
    + + + parentHash := common.HexToHash("0x111") +
    +
    + 1497 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 1498 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 1499 + +
    + + + ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} +
    +
    + 1500 + +
    + + + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    + 1501 + +
    + + + ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} +
    +
    + 1502 + +
    + + + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) +
    +
    + 1503 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 1504 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 1505 + +
    + + + ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    + 1506 + +
    + + + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    + 1507 + +
    + + +
    +
    +
    + 1508 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 1509 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 1510 + +
    + + +
    +
    +
    + 1511 + +
    + + + m.State. +
    +
    + 1512 + +
    + + + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 1513 + +
    + + + Return(uint64(9), nil). +
    +
    + 1514 + +
    + + + Maybe() +
    +
    + 1515 + +
    + + + m.State. +
    +
    + 1516 + +
    + + + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 1517 + +
    + + + Return(lastBlock1, nil). +
    +
    + 1518 + +
    + + + Once() +
    +
    + 1519 + +
    + + +
    +
    +
    + 1520 + +
    + + + // After a ResetState get lastblock that must be block 0 +
    +
    + 1521 + +
    + + + m.State. +
    +
    + 1522 + +
    + + + On("GetLastBlock", ctx, nil). +
    +
    + 1523 + +
    + + + Return(lastBlock0, nil). +
    +
    + 1524 + +
    + + + Once() +
    +
    + 1525 + +
    + + +
    +
    +
    + 1526 + +
    + + + m.State. +
    +
    + 1527 + +
    + + + On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    + 1528 + +
    + + + Return(uint64(10), nil). +
    +
    + 1529 + +
    + + + Once() +
    +
    + 1530 + +
    + + +
    +
    +
    + 1531 + +
    + + + m.State. +
    +
    + 1532 + +
    + + + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    + 1533 + +
    + + + Return(nil). +
    +
    + 1534 + +
    + + + Once() +
    +
    + 1535 + +
    + + +
    +
    +
    + 1536 + +
    + + + m.DbTx. +
    +
    + 1537 + +
    + + + On("Commit", ctx). +
    +
    + 1538 + +
    + + + Return(nil). +
    +
    + 1539 + +
    + + + Once() +
    +
    + 1540 + +
    + + +
    +
    +
    + 1541 + +
    + + + m.Etherman. +
    +
    + 1542 + +
    + + + On("GetLatestBatchNumber"). +
    +
    + 1543 + +
    + + + Return(uint64(10), nil) +
    +
    + 1544 + +
    + + +
    +
    +
    + 1545 + +
    + + + var nilDbTx pgx.Tx +
    +
    + 1546 + +
    + + + m.State. +
    +
    + 1547 + +
    + + + On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    + 1548 + +
    + + + Return(uint64(10), nil) +
    +
    + 1549 + +
    + + +
    +
    +
    + 1550 + +
    + + + m.Etherman. +
    +
    + 1551 + +
    + + + On("GetLatestVerifiedBatchNum"). +
    +
    + 1552 + +
    + + + Return(uint64(10), nil) +
    +
    + 1553 + +
    + + +
    +
    +
    + 1554 + +
    + + + m.State. +
    +
    + 1555 + +
    + + + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    + 1556 + +
    + + + Return(nil) +
    +
    + 1557 + +
    + + +
    +
    +
    + 1558 + +
    + + + m.Etherman. +
    +
    + 1559 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1560 + +
    + + + Return(ethBlock1, nil). +
    +
    + 1561 + +
    + + + Once() +
    +
    + 1562 + +
    + + +
    +
    +
    + 1563 + +
    + + + m.ZKEVMClient. +
    +
    + 1564 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1565 + +
    + + + Return(uint64(1), nil). +
    +
    + 1566 + +
    + + + Once() +
    +
    + 1567 + +
    + + +
    +
    +
    + 1568 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 1569 + +
    + + +
    +
    +
    + 1570 + +
    + + + m.Etherman. +
    +
    + 1571 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1572 + +
    + + + Return(ethBlock1bis, nil). +
    +
    + 1573 + +
    + + + Once() +
    +
    + 1574 + +
    + + +
    +
    +
    + 1575 + +
    + + + m.State. +
    +
    + 1576 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1577 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1578 + +
    + + + Once() +
    +
    + 1579 + +
    + + +
    +
    +
    + 1580 + +
    + + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    + 1581 + +
    + + + var depth uint64 = 1 +
    +
    + 1582 + +
    + + + stateBlock0 := &state.Block{ +
    +
    + 1583 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 1584 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1585 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1586 + +
    + + + ReceivedAt: ti, +
    +
    + 1587 + +
    + + + } +
    +
    + 1588 + +
    + + + m.State. +
    +
    + 1589 + +
    + + + On("GetPreviousBlock", ctx, depth, m.DbTx). +
    +
    + 1590 + +
    + + + Return(stateBlock0, nil). +
    +
    + 1591 + +
    + + + Once() +
    +
    + 1592 + +
    + + +
    +
    +
    + 1593 + +
    + + + m.DbTx. +
    +
    + 1594 + +
    + + + On("Commit", ctx). +
    +
    + 1595 + +
    + + + Return(nil). +
    +
    + 1596 + +
    + + + Once() +
    +
    + 1597 + +
    + + +
    +
    +
    + 1598 + +
    + + + m.Etherman. +
    +
    + 1599 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1600 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1601 + +
    + + + Once() +
    +
    + 1602 + +
    + + +
    +
    +
    + 1603 + +
    + + + m.State. +
    +
    + 1604 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1605 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1606 + +
    + + + Once() +
    +
    + 1607 + +
    + + +
    +
    +
    + 1608 + +
    + + + m.State. +
    +
    + 1609 + +
    + + + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    + 1610 + +
    + + + Return(nil). +
    +
    + 1611 + +
    + + + Once() +
    +
    + 1612 + +
    + + +
    +
    +
    + 1613 + +
    + + + m.EthTxManager. +
    +
    + 1614 + +
    + + + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    + 1615 + +
    + + + Return(nil). +
    +
    + 1616 + +
    + + + Once() +
    +
    + 1617 + +
    + + +
    +
    +
    + 1618 + +
    + + + m.DbTx. +
    +
    + 1619 + +
    + + + On("Commit", ctx). +
    +
    + 1620 + +
    + + + Return(nil). +
    +
    + 1621 + +
    + + + Once() +
    +
    + 1622 + +
    + + +
    +
    +
    + 1623 + +
    + + + m.Etherman. +
    +
    + 1624 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1625 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1626 + +
    + + + Once() +
    +
    + 1627 + +
    + + +
    +
    +
    + 1628 + +
    + + + m.ZKEVMClient. +
    +
    + 1629 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1630 + +
    + + + Return(uint64(1), nil). +
    +
    + 1631 + +
    + + + Once() +
    +
    + 1632 + +
    + + +
    +
    +
    + 1633 + +
    + + + m.Etherman. +
    +
    + 1634 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1635 + +
    + + + Return(ethHeader2bis, nil). +
    +
    + 1636 + +
    + + + Once() +
    +
    + 1637 + +
    + + +
    +
    +
    + 1638 + +
    + + + m.Etherman. +
    +
    + 1639 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1640 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1641 + +
    + + + Once() +
    +
    + 1642 + +
    + + +
    +
    +
    + 1643 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 1644 + +
    + + + BlockNumber: 0, +
    +
    + 1645 + +
    + + + ReceivedAt: ti, +
    +
    + 1646 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1647 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1648 + +
    + + + } +
    +
    + 1649 + +
    + + + ethermanBlock1bis := etherman.Block{ +
    +
    + 1650 + +
    + + + BlockNumber: 1, +
    +
    + 1651 + +
    + + + ReceivedAt: ti, +
    +
    + 1652 + +
    + + + BlockHash: ethBlock1bis.Hash(), +
    +
    + 1653 + +
    + + + ParentHash: ethBlock1bis.ParentHash(), +
    +
    + 1654 + +
    + + + } +
    +
    + 1655 + +
    + + + ethermanBlock2bis := etherman.Block{ +
    +
    + 1656 + +
    + + + BlockNumber: 2, +
    +
    + 1657 + +
    + + + ReceivedAt: ti, +
    +
    + 1658 + +
    + + + BlockHash: ethBlock2bis.Hash(), +
    +
    + 1659 + +
    + + + ParentHash: ethBlock2bis.ParentHash(), +
    +
    + 1660 + +
    + + + } +
    +
    + 1661 + +
    + + + blocks := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis} +
    +
    + 1662 + +
    + + + order := map[common.Hash][]etherman.Order{} +
    +
    + 1663 + +
    + + +
    +
    +
    + 1664 + +
    + + + fromBlock := ethBlock0.NumberU64() +
    +
    + 1665 + +
    + + + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 1666 + +
    + + + if toBlock > ethBlock2.NumberU64() { +
    +
    + 1667 + +
    + + + toBlock = ethBlock2.NumberU64() +
    +
    + 1668 + +
    + + + } +
    +
    + 1669 + +
    + + + m.Etherman. +
    +
    + 1670 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1671 + +
    + + + Return(blocks, order, nil). +
    +
    + 1672 + +
    + + + Once() +
    +
    + 1673 + +
    + + +
    +
    +
    + 1674 + +
    + + + m.Etherman. +
    +
    + 1675 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 1676 + +
    + + + Return(ethBlock2bis.NumberU64(), nil). +
    +
    + 1677 + +
    + + + Once() +
    +
    + 1678 + +
    + + +
    +
    +
    + 1679 + +
    + + + m.State. +
    +
    + 1680 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1681 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1682 + +
    + + + Once() +
    +
    + 1683 + +
    + + +
    +
    +
    + 1684 + +
    + + + stateBlock1bis := &state.Block{ +
    +
    + 1685 + +
    + + + BlockNumber: ethermanBlock1bis.BlockNumber, +
    +
    + 1686 + +
    + + + BlockHash: ethermanBlock1bis.BlockHash, +
    +
    + 1687 + +
    + + + ParentHash: ethermanBlock1bis.ParentHash, +
    +
    + 1688 + +
    + + + ReceivedAt: ethermanBlock1bis.ReceivedAt, +
    +
    + 1689 + +
    + + + Checked: true, +
    +
    + 1690 + +
    + + + } +
    +
    + 1691 + +
    + + + m.State. +
    +
    + 1692 + +
    + + + On("AddBlock", ctx, stateBlock1bis, m.DbTx). +
    +
    + 1693 + +
    + + + Return(nil). +
    +
    + 1694 + +
    + + + Once() +
    +
    + 1695 + +
    + + +
    +
    +
    + 1696 + +
    + + + m.State. +
    +
    + 1697 + +
    + + + On("GetStoredFlushID", ctx). +
    +
    + 1698 + +
    + + + Return(uint64(1), cProverIDExecution, nil). +
    +
    + 1699 + +
    + + + Once() +
    +
    + 1700 + +
    + + +
    +
    +
    + 1701 + +
    + + + m.DbTx. +
    +
    + 1702 + +
    + + + On("Commit", ctx). +
    +
    + 1703 + +
    + + + Return(nil). +
    +
    + 1704 + +
    + + + Once() +
    +
    + 1705 + +
    + + +
    +
    +
    + 1706 + +
    + + + m.State. +
    +
    + 1707 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1708 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1709 + +
    + + + Once() +
    +
    + 1710 + +
    + + +
    +
    +
    + 1711 + +
    + + + stateBlock2bis := &state.Block{ +
    +
    + 1712 + +
    + + + BlockNumber: ethermanBlock2bis.BlockNumber, +
    +
    + 1713 + +
    + + + BlockHash: ethermanBlock2bis.BlockHash, +
    +
    + 1714 + +
    + + + ParentHash: ethermanBlock2bis.ParentHash, +
    +
    + 1715 + +
    + + + ReceivedAt: ethermanBlock2bis.ReceivedAt, +
    +
    + 1716 + +
    + + + Checked: true, +
    +
    + 1717 + +
    + + + } +
    +
    + 1718 + +
    + + + m.State. +
    +
    + 1719 + +
    + + + On("AddBlock", ctx, stateBlock2bis, m.DbTx). +
    +
    + 1720 + +
    + + + Return(nil). +
    +
    + 1721 + +
    + + + Once() +
    +
    + 1722 + +
    + + +
    +
    +
    + 1723 + +
    + + + m.DbTx. +
    +
    + 1724 + +
    + + + On("Commit", ctx). +
    +
    + 1725 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1726 + +
    + + + sync.Stop() +
    +
    + 1727 + +
    + + + ctx.Done() +
    +
    + 1728 + +
    + + + }). +
    +
    + 1729 + +
    + + + Return(nil). +
    +
    + 1730 + +
    + + + Once() +
    +
    + 1731 + +
    + + + }). +
    +
    + 1732 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1733 + +
    + + + Once() +
    +
    + 1734 + +
    + + +
    +
    +
    + 1735 + +
    + + + err = sync.Sync() +
    +
    + 1736 + +
    + + + require.NoError(t, err) +
    +
    + 1737 + +
    + + + } +
    +
    + 1738 + +
    + + +
    +
    +
    + 1739 + +
    + + + func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { +
    +
    + 1740 + +
    + + + genesis := state.Genesis{ +
    +
    + 1741 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 1742 + +
    + + + } +
    +
    + 1743 + +
    + + + cfg := Config{ +
    +
    + 1744 + +
    + + + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 1745 + +
    + + + SyncChunkSize: 3, +
    +
    + 1746 + +
    + + + L1SynchronizationMode: SequentialMode, +
    +
    + 1747 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 1748 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 1749 + +
    + + + Enable: false, +
    +
    + 1750 + +
    + + + }, +
    +
    + 1751 + +
    + + + } +
    +
    + 1752 + +
    + + +
    +
    +
    + 1753 + +
    + + + m := mocks{ +
    +
    + 1754 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 1755 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 1756 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 1757 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 1758 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 1759 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 1760 + +
    + + + } +
    +
    + 1761 + +
    + + + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 1762 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 1763 + +
    + + + require.NoError(t, err) +
    +
    + 1764 + +
    + + +
    +
    +
    + 1765 + +
    + + + // state preparation +
    +
    + 1766 + +
    + + + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    + 1767 + +
    + + + forkIdInterval := state.ForkIDInterval{ +
    +
    + 1768 + +
    + + + ForkId: 9, +
    +
    + 1769 + +
    + + + FromBatchNumber: 0, +
    +
    + 1770 + +
    + + + ToBatchNumber: math.MaxUint64, +
    +
    + 1771 + +
    + + + } +
    +
    + 1772 + +
    + + + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    + 1773 + +
    + + +
    +
    +
    + 1774 + +
    + + + m.State. +
    +
    + 1775 + +
    + + + On("BeginStateTransaction", ctxMatchBy). +
    +
    + 1776 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 1777 + +
    + + + ctx := args[0].(context.Context) +
    +
    + 1778 + +
    + + + parentHash := common.HexToHash("0x111") +
    +
    + 1779 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 1780 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 1781 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 1782 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 1783 + +
    + + + ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 0, GasUsed: 10} +
    +
    + 1784 + +
    + + + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    + 1785 + +
    + + + ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    + 1786 + +
    + + + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    + 1787 + +
    + + + ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    + 1788 + +
    + + + ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    + 1789 + +
    + + +
    +
    +
    + 1790 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 1791 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 1792 + +
    + + + lastBlock2 := &state.Block{BlockHash: ethBlock2.Hash(), BlockNumber: ethBlock2.Number().Uint64(), ParentHash: ethBlock2.ParentHash()} +
    +
    + 1793 + +
    + + +
    +
    +
    + 1794 + +
    + + + m.State. +
    +
    + 1795 + +
    + + + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 1796 + +
    + + + Return(uint64(9), nil). +
    +
    + 1797 + +
    + + + Maybe() +
    +
    + 1798 + +
    + + + m.State. +
    +
    + 1799 + +
    + + + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 1800 + +
    + + + Return(lastBlock2, nil). +
    +
    + 1801 + +
    + + + Once() +
    +
    + 1802 + +
    + + +
    +
    +
    + 1803 + +
    + + + m.State. +
    +
    + 1804 + +
    + + + On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    + 1805 + +
    + + + Return(uint64(10), nil). +
    +
    + 1806 + +
    + + + Once() +
    +
    + 1807 + +
    + + +
    +
    +
    + 1808 + +
    + + + m.State. +
    +
    + 1809 + +
    + + + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    + 1810 + +
    + + + Return(nil). +
    +
    + 1811 + +
    + + + Once() +
    +
    + 1812 + +
    + + +
    +
    +
    + 1813 + +
    + + + m.DbTx. +
    +
    + 1814 + +
    + + + On("Commit", ctx). +
    +
    + 1815 + +
    + + + Return(nil). +
    +
    + 1816 + +
    + + + Once() +
    +
    + 1817 + +
    + + +
    +
    +
    + 1818 + +
    + + + m.Etherman. +
    +
    + 1819 + +
    + + + On("GetLatestBatchNumber"). +
    +
    + 1820 + +
    + + + Return(uint64(10), nil) +
    +
    + 1821 + +
    + + +
    +
    +
    + 1822 + +
    + + + var nilDbTx pgx.Tx +
    +
    + 1823 + +
    + + + m.State. +
    +
    + 1824 + +
    + + + On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    + 1825 + +
    + + + Return(uint64(10), nil) +
    +
    + 1826 + +
    + + +
    +
    +
    + 1827 + +
    + + + m.Etherman. +
    +
    + 1828 + +
    + + + On("GetLatestVerifiedBatchNum"). +
    +
    + 1829 + +
    + + + Return(uint64(10), nil) +
    +
    + 1830 + +
    + + +
    +
    +
    + 1831 + +
    + + + m.State. +
    +
    + 1832 + +
    + + + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    + 1833 + +
    + + + Return(nil) +
    +
    + 1834 + +
    + + +
    +
    +
    + 1835 + +
    + + + m.Etherman. +
    +
    + 1836 + +
    + + + On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). +
    +
    + 1837 + +
    + + + Return(ethBlock2, nil). +
    +
    + 1838 + +
    + + + Once() +
    +
    + 1839 + +
    + + +
    +
    +
    + 1840 + +
    + + + m.ZKEVMClient. +
    +
    + 1841 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1842 + +
    + + + Return(uint64(1), nil). +
    +
    + 1843 + +
    + + + Once() +
    +
    + 1844 + +
    + + +
    +
    +
    + 1845 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 1846 + +
    + + + m.Etherman. +
    +
    + 1847 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1848 + +
    + + + Return(ethHeader3, nil). +
    +
    + 1849 + +
    + + + Once() +
    +
    + 1850 + +
    + + +
    +
    +
    + 1851 + +
    + + + m.Etherman. +
    +
    + 1852 + +
    + + + On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). +
    +
    + 1853 + +
    + + + Return(ethBlock2, nil). +
    +
    + 1854 + +
    + + + Once() +
    +
    + 1855 + +
    + + +
    +
    +
    + 1856 + +
    + + + blocks := []etherman.Block{} +
    +
    + 1857 + +
    + + + order := map[common.Hash][]etherman.Order{} +
    +
    + 1858 + +
    + + +
    +
    +
    + 1859 + +
    + + + fromBlock := ethBlock2.NumberU64() +
    +
    + 1860 + +
    + + + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 1861 + +
    + + + if toBlock > ethBlock3.NumberU64() { +
    +
    + 1862 + +
    + + + toBlock = ethBlock3.NumberU64() +
    +
    + 1863 + +
    + + + } +
    +
    + 1864 + +
    + + + m.Etherman. +
    +
    + 1865 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1866 + +
    + + + Return(blocks, order, nil). +
    +
    + 1867 + +
    + + + Once() +
    +
    + 1868 + +
    + + +
    +
    +
    + 1869 + +
    + + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    + 1870 + +
    + + + var depth uint64 = 1 +
    +
    + 1871 + +
    + + + stateBlock1 := &state.Block{ +
    +
    + 1872 + +
    + + + BlockNumber: ethBlock1.NumberU64(), +
    +
    + 1873 + +
    + + + BlockHash: ethBlock1.Hash(), +
    +
    + 1874 + +
    + + + ParentHash: ethBlock1.ParentHash(), +
    +
    + 1875 + +
    + + + ReceivedAt: ti, +
    +
    + 1876 + +
    + + + } +
    +
    + 1877 + +
    + + + m.State. +
    +
    + 1878 + +
    + + + On("GetPreviousBlock", ctx, depth, nil). +
    +
    + 1879 + +
    + + + Return(stateBlock1, nil). +
    +
    + 1880 + +
    + + + Once() +
    +
    + 1881 + +
    + + +
    +
    +
    + 1882 + +
    + + + m.Etherman. +
    +
    + 1883 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 1884 + +
    + + + Return(ethBlock1bis, nil). +
    +
    + 1885 + +
    + + + Once() +
    +
    + 1886 + +
    + + +
    +
    +
    + 1887 + +
    + + + m.State. +
    +
    + 1888 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1889 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1890 + +
    + + + Once() +
    +
    + 1891 + +
    + + +
    +
    +
    + 1892 + +
    + + + stateBlock0 := &state.Block{ +
    +
    + 1893 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 1894 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1895 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1896 + +
    + + + ReceivedAt: ti, +
    +
    + 1897 + +
    + + + } +
    +
    + 1898 + +
    + + + m.State. +
    +
    + 1899 + +
    + + + On("GetPreviousBlock", ctx, depth, m.DbTx). +
    +
    + 1900 + +
    + + + Return(stateBlock0, nil). +
    +
    + 1901 + +
    + + + Once() +
    +
    + 1902 + +
    + + +
    +
    +
    + 1903 + +
    + + + m.DbTx. +
    +
    + 1904 + +
    + + + On("Commit", ctx). +
    +
    + 1905 + +
    + + + Return(nil). +
    +
    + 1906 + +
    + + + Once() +
    +
    + 1907 + +
    + + +
    +
    +
    + 1908 + +
    + + + m.Etherman. +
    +
    + 1909 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1910 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1911 + +
    + + + Once() +
    +
    + 1912 + +
    + + +
    +
    +
    + 1913 + +
    + + + m.State. +
    +
    + 1914 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1915 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1916 + +
    + + + Once() +
    +
    + 1917 + +
    + + +
    +
    +
    + 1918 + +
    + + + m.State. +
    +
    + 1919 + +
    + + + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    + 1920 + +
    + + + Return(nil). +
    +
    + 1921 + +
    + + + Once() +
    +
    + 1922 + +
    + + +
    +
    +
    + 1923 + +
    + + + m.EthTxManager. +
    +
    + 1924 + +
    + + + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    + 1925 + +
    + + + Return(nil). +
    +
    + 1926 + +
    + + + Once() +
    +
    + 1927 + +
    + + +
    +
    +
    + 1928 + +
    + + + m.DbTx. +
    +
    + 1929 + +
    + + + On("Commit", ctx). +
    +
    + 1930 + +
    + + + Return(nil). +
    +
    + 1931 + +
    + + + Once() +
    +
    + 1932 + +
    + + +
    +
    +
    + 1933 + +
    + + + m.Etherman. +
    +
    + 1934 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1935 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1936 + +
    + + + Once() +
    +
    + 1937 + +
    + + +
    +
    +
    + 1938 + +
    + + + m.ZKEVMClient. +
    +
    + 1939 + +
    + + + On("BatchNumber", ctx). +
    +
    + 1940 + +
    + + + Return(uint64(1), nil). +
    +
    + 1941 + +
    + + + Once() +
    +
    + 1942 + +
    + + +
    +
    +
    + 1943 + +
    + + + m.Etherman. +
    +
    + 1944 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 1945 + +
    + + + Return(ethHeader3, nil). +
    +
    + 1946 + +
    + + + Once() +
    +
    + 1947 + +
    + + +
    +
    +
    + 1948 + +
    + + + m.Etherman. +
    +
    + 1949 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 1950 + +
    + + + Return(ethBlock0, nil). +
    +
    + 1951 + +
    + + + Once() +
    +
    + 1952 + +
    + + +
    +
    +
    + 1953 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 1954 + +
    + + + BlockNumber: 0, +
    +
    + 1955 + +
    + + + ReceivedAt: ti, +
    +
    + 1956 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 1957 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 1958 + +
    + + + } +
    +
    + 1959 + +
    + + + ethermanBlock1bis := etherman.Block{ +
    +
    + 1960 + +
    + + + BlockNumber: 1, +
    +
    + 1961 + +
    + + + ReceivedAt: ti, +
    +
    + 1962 + +
    + + + BlockHash: ethBlock1.Hash(), +
    +
    + 1963 + +
    + + + ParentHash: ethBlock1.ParentHash(), +
    +
    + 1964 + +
    + + + } +
    +
    + 1965 + +
    + + + blocks = []etherman.Block{ethermanBlock0, ethermanBlock1bis} +
    +
    + 1966 + +
    + + + fromBlock = 0 +
    +
    + 1967 + +
    + + + m.Etherman. +
    +
    + 1968 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 1969 + +
    + + + Return(blocks, order, nil). +
    +
    + 1970 + +
    + + + Once() +
    +
    + 1971 + +
    + + +
    +
    +
    + 1972 + +
    + + + m.Etherman. +
    +
    + 1973 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 1974 + +
    + + + Return(ethBlock3.NumberU64(), nil). +
    +
    + 1975 + +
    + + + Once() +
    +
    + 1976 + +
    + + +
    +
    +
    + 1977 + +
    + + + m.State. +
    +
    + 1978 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 1979 + +
    + + + Return(m.DbTx, nil). +
    +
    + 1980 + +
    + + + Once() +
    +
    + 1981 + +
    + + +
    +
    +
    + 1982 + +
    + + + stateBlock1bis := &state.Block{ +
    +
    + 1983 + +
    + + + BlockNumber: ethermanBlock1bis.BlockNumber, +
    +
    + 1984 + +
    + + + BlockHash: ethermanBlock1bis.BlockHash, +
    +
    + 1985 + +
    + + + ParentHash: ethermanBlock1bis.ParentHash, +
    +
    + 1986 + +
    + + + ReceivedAt: ethermanBlock1bis.ReceivedAt, +
    +
    + 1987 + +
    + + + Checked: true, +
    +
    + 1988 + +
    + + + } +
    +
    + 1989 + +
    + + + m.State. +
    +
    + 1990 + +
    + + + On("AddBlock", ctx, stateBlock1bis, m.DbTx). +
    +
    + 1991 + +
    + + + Return(nil). +
    +
    + 1992 + +
    + + + Once() +
    +
    + 1993 + +
    + + +
    +
    +
    + 1994 + +
    + + + m.State. +
    +
    + 1995 + +
    + + + On("GetStoredFlushID", ctx). +
    +
    + 1996 + +
    + + + Return(uint64(1), cProverIDExecution, nil). +
    +
    + 1997 + +
    + + + Once() +
    +
    + 1998 + +
    + + +
    +
    +
    + 1999 + +
    + + + m.DbTx. +
    +
    + 2000 + +
    + + + On("Commit", ctx). +
    +
    + 2001 + +
    + + + Return(nil). +
    +
    + 2002 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 2003 + +
    + + + sync.Stop() +
    +
    + 2004 + +
    + + + ctx.Done() +
    +
    + 2005 + +
    + + + }). +
    +
    + 2006 + +
    + + + Once() +
    +
    + 2007 + +
    + + + }). +
    +
    + 2008 + +
    + + + Return(m.DbTx, nil). +
    +
    + 2009 + +
    + + + Once() +
    +
    + 2010 + +
    + + +
    +
    +
    + 2011 + +
    + + + err = sync.Sync() +
    +
    + 2012 + +
    + + + require.NoError(t, err) +
    +
    + 2013 + +
    + + + } +
    +
    + 2014 + +
    + + +
    +
    +
    + 2015 + +
    + + + func TestCallFromEmptyBlockAndReorg(t *testing.T) { +
    +
    + 2016 + +
    + + + genesis := state.Genesis{ +
    +
    + 2017 + +
    + + + RollupBlockNumber: uint64(0), +
    +
    + 2018 + +
    + + + } +
    +
    + 2019 + +
    + + + cfg := Config{ +
    +
    + 2020 + +
    + + + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    + 2021 + +
    + + + SyncChunkSize: 3, +
    +
    + 2022 + +
    + + + L1SynchronizationMode: SequentialMode, +
    +
    + 2023 + +
    + + + SyncBlockProtection: "latest", +
    +
    + 2024 + +
    + + + L1BlockCheck: L1BlockCheckConfig{ +
    +
    + 2025 + +
    + + + Enable: false, +
    +
    + 2026 + +
    + + + }, +
    +
    + 2027 + +
    + + + } +
    +
    + 2028 + +
    + + +
    +
    +
    + 2029 + +
    + + + m := mocks{ +
    +
    + 2030 + +
    + + + Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    + 2031 + +
    + + + State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    + 2032 + +
    + + + Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    + 2033 + +
    + + + DbTx: syncMocks.NewDbTxMock(t), +
    +
    + 2034 + +
    + + + ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    + 2035 + +
    + + + EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    + 2036 + +
    + + + } +
    +
    + 2037 + +
    + + + ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    + 2038 + +
    + + + sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    + 2039 + +
    + + + require.NoError(t, err) +
    +
    + 2040 + +
    + + +
    +
    +
    + 2041 + +
    + + + // state preparation +
    +
    + 2042 + +
    + + + ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    + 2043 + +
    + + + forkIdInterval := state.ForkIDInterval{ +
    +
    + 2044 + +
    + + + ForkId: 9, +
    +
    + 2045 + +
    + + + FromBatchNumber: 0, +
    +
    + 2046 + +
    + + + ToBatchNumber: math.MaxUint64, +
    +
    + 2047 + +
    + + + } +
    +
    + 2048 + +
    + + + m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    + 2049 + +
    + + +
    +
    +
    + 2050 + +
    + + + m.State. +
    +
    + 2051 + +
    + + + On("BeginStateTransaction", ctxMatchBy). +
    +
    + 2052 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 2053 + +
    + + + ctx := args[0].(context.Context) +
    +
    + 2054 + +
    + + + parentHash := common.HexToHash("0x111") +
    +
    + 2055 + +
    + + + ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    + 2056 + +
    + + + ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    + 2057 + +
    + + + ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} +
    +
    + 2058 + +
    + + + ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    + 2059 + +
    + + + ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} +
    +
    + 2060 + +
    + + + ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) +
    +
    + 2061 + +
    + + + ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    + 2062 + +
    + + + ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    + 2063 + +
    + + + ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    + 2064 + +
    + + + ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    + 2065 + +
    + + +
    +
    +
    + 2066 + +
    + + + lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    + 2067 + +
    + + + lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    + 2068 + +
    + + +
    +
    +
    + 2069 + +
    + + + m.State. +
    +
    + 2070 + +
    + + + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 2071 + +
    + + + Return(uint64(9), nil). +
    +
    + 2072 + +
    + + + Maybe() +
    +
    + 2073 + +
    + + + m.State. +
    +
    + 2074 + +
    + + + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 2075 + +
    + + + Return(lastBlock1, nil). +
    +
    + 2076 + +
    + + + Once() +
    +
    + 2077 + +
    + + +
    +
    +
    + 2078 + +
    + + + m.State. +
    +
    + 2079 + +
    + + + On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    + 2080 + +
    + + + Return(uint64(10), nil). +
    +
    + 2081 + +
    + + + Once() +
    +
    + 2082 + +
    + + +
    +
    +
    + 2083 + +
    + + + m.State. +
    +
    + 2084 + +
    + + + On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    + 2085 + +
    + + + Return(nil). +
    +
    + 2086 + +
    + + + Once() +
    +
    + 2087 + +
    + + +
    +
    +
    + 2088 + +
    + + + m.DbTx. +
    +
    + 2089 + +
    + + + On("Commit", ctx). +
    +
    + 2090 + +
    + + + Return(nil). +
    +
    + 2091 + +
    + + + Once() +
    +
    + 2092 + +
    + + +
    +
    +
    + 2093 + +
    + + + m.Etherman. +
    +
    + 2094 + +
    + + + On("GetLatestBatchNumber"). +
    +
    + 2095 + +
    + + + Return(uint64(10), nil) +
    +
    + 2096 + +
    + + +
    +
    +
    + 2097 + +
    + + + var nilDbTx pgx.Tx +
    +
    + 2098 + +
    + + + m.State. +
    +
    + 2099 + +
    + + + On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    + 2100 + +
    + + + Return(uint64(10), nil) +
    +
    + 2101 + +
    + + +
    +
    +
    + 2102 + +
    + + + m.Etherman. +
    +
    + 2103 + +
    + + + On("GetLatestVerifiedBatchNum"). +
    +
    + 2104 + +
    + + + Return(uint64(10), nil) +
    +
    + 2105 + +
    + + +
    +
    +
    + 2106 + +
    + + + m.State. +
    +
    + 2107 + +
    + + + On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    + 2108 + +
    + + + Return(nil) +
    +
    + 2109 + +
    + + +
    +
    +
    + 2110 + +
    + + + m.Etherman. +
    +
    + 2111 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 2112 + +
    + + + Return(ethBlock1, nil). +
    +
    + 2113 + +
    + + + Once() +
    +
    + 2114 + +
    + + +
    +
    +
    + 2115 + +
    + + + m.ZKEVMClient. +
    +
    + 2116 + +
    + + + On("BatchNumber", ctx). +
    +
    + 2117 + +
    + + + Return(uint64(1), nil). +
    +
    + 2118 + +
    + + + Once() +
    +
    + 2119 + +
    + + +
    +
    +
    + 2120 + +
    + + + n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    + 2121 + +
    + + +
    +
    +
    + 2122 + +
    + + + m.Etherman. +
    +
    + 2123 + +
    + + + On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 2124 + +
    + + + Return(ethBlock1, nil). +
    +
    + 2125 + +
    + + + Once() +
    +
    + 2126 + +
    + + +
    +
    +
    + 2127 + +
    + + + m.Etherman. +
    +
    + 2128 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 2129 + +
    + + + Return(ethHeader2bis, nil). +
    +
    + 2130 + +
    + + + Once() +
    +
    + 2131 + +
    + + +
    +
    +
    + 2132 + +
    + + + // m.Etherman. +
    +
    + 2133 + +
    + + + // On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    + 2134 + +
    + + + // Return(ethBlock1, nil). +
    +
    + 2135 + +
    + + + // Once() +
    +
    + 2136 + +
    + + +
    +
    +
    + 2137 + +
    + + + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    + 2138 + +
    + + +
    +
    +
    + 2139 + +
    + + + ethermanBlock0 := etherman.Block{ +
    +
    + 2140 + +
    + + + BlockNumber: 0, +
    +
    + 2141 + +
    + + + ReceivedAt: ti, +
    +
    + 2142 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 2143 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 2144 + +
    + + + } +
    +
    + 2145 + +
    + + + ethermanBlock2bis := etherman.Block{ +
    +
    + 2146 + +
    + + + BlockNumber: 2, +
    +
    + 2147 + +
    + + + ReceivedAt: ti, +
    +
    + 2148 + +
    + + + BlockHash: ethBlock2bis.Hash(), +
    +
    + 2149 + +
    + + + ParentHash: ethBlock2bis.ParentHash(), +
    +
    + 2150 + +
    + + + } +
    +
    + 2151 + +
    + + + blocks := []etherman.Block{ethermanBlock2bis} +
    +
    + 2152 + +
    + + + order := map[common.Hash][]etherman.Order{} +
    +
    + 2153 + +
    + + +
    +
    +
    + 2154 + +
    + + + fromBlock := ethBlock1.NumberU64() +
    +
    + 2155 + +
    + + + toBlock := fromBlock + cfg.SyncChunkSize +
    +
    + 2156 + +
    + + + if toBlock > ethBlock2.NumberU64() { +
    +
    + 2157 + +
    + + + toBlock = ethBlock2.NumberU64() +
    +
    + 2158 + +
    + + + } +
    +
    + 2159 + +
    + + + m.Etherman. +
    +
    + 2160 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 2161 + +
    + + + Return(blocks, order, nil). +
    +
    + 2162 + +
    + + + Once() +
    +
    + 2163 + +
    + + +
    +
    +
    + 2164 + +
    + + + m.State. +
    +
    + 2165 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 2166 + +
    + + + Return(m.DbTx, nil). +
    +
    + 2167 + +
    + + + Once() +
    +
    + 2168 + +
    + + +
    +
    +
    + 2169 + +
    + + + var depth uint64 = 1 +
    +
    + 2170 + +
    + + + stateBlock0 := &state.Block{ +
    +
    + 2171 + +
    + + + BlockNumber: ethBlock0.NumberU64(), +
    +
    + 2172 + +
    + + + BlockHash: ethBlock0.Hash(), +
    +
    + 2173 + +
    + + + ParentHash: ethBlock0.ParentHash(), +
    +
    + 2174 + +
    + + + ReceivedAt: ti, +
    +
    + 2175 + +
    + + + } +
    +
    + 2176 + +
    + + + m.State. +
    +
    + 2177 + +
    + + + On("GetPreviousBlock", ctx, depth, m.DbTx). +
    +
    + 2178 + +
    + + + Return(stateBlock0, nil). +
    +
    + 2179 + +
    + + + Once() +
    +
    + 2180 + +
    + + +
    +
    +
    + 2181 + +
    + + + m.DbTx. +
    +
    + 2182 + +
    + + + On("Commit", ctx). +
    +
    + 2183 + +
    + + + Return(nil). +
    +
    + 2184 + +
    + + + Once() +
    +
    + 2185 + +
    + + +
    +
    +
    + 2186 + +
    + + + m.Etherman. +
    +
    + 2187 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 2188 + +
    + + + Return(ethBlock0, nil). +
    +
    + 2189 + +
    + + + Once() +
    +
    + 2190 + +
    + + +
    +
    +
    + 2191 + +
    + + + m.State. +
    +
    + 2192 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 2193 + +
    + + + Return(m.DbTx, nil). +
    +
    + 2194 + +
    + + + Once() +
    +
    + 2195 + +
    + + +
    +
    +
    + 2196 + +
    + + + m.State. +
    +
    + 2197 + +
    + + + On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    + 2198 + +
    + + + Return(nil). +
    +
    + 2199 + +
    + + + Once() +
    +
    + 2200 + +
    + + +
    +
    +
    + 2201 + +
    + + + m.EthTxManager. +
    +
    + 2202 + +
    + + + On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    + 2203 + +
    + + + Return(nil). +
    +
    + 2204 + +
    + + + Once() +
    +
    + 2205 + +
    + + +
    +
    +
    + 2206 + +
    + + + m.DbTx. +
    +
    + 2207 + +
    + + + On("Commit", ctx). +
    +
    + 2208 + +
    + + + Return(nil). +
    +
    + 2209 + +
    + + + Once() +
    +
    + 2210 + +
    + + +
    +
    +
    + 2211 + +
    + + + m.Etherman. +
    +
    + 2212 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 2213 + +
    + + + Return(ethBlock0, nil). +
    +
    + 2214 + +
    + + + Once() +
    +
    + 2215 + +
    + + +
    +
    +
    + 2216 + +
    + + + m.ZKEVMClient. +
    +
    + 2217 + +
    + + + On("BatchNumber", ctx). +
    +
    + 2218 + +
    + + + Return(uint64(1), nil). +
    +
    + 2219 + +
    + + + Once() +
    +
    + 2220 + +
    + + +
    +
    +
    + 2221 + +
    + + + m.Etherman. +
    +
    + 2222 + +
    + + + On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    + 2223 + +
    + + + Return(ethBlock0, nil). +
    +
    + 2224 + +
    + + + Once() +
    +
    + 2225 + +
    + + +
    +
    +
    + 2226 + +
    + + + m.Etherman. +
    +
    + 2227 + +
    + + + On("HeaderByNumber", mock.Anything, n). +
    +
    + 2228 + +
    + + + Return(ethHeader2bis, nil). +
    +
    + 2229 + +
    + + + Once() +
    +
    + 2230 + +
    + + +
    +
    +
    + 2231 + +
    + + + blocks = []etherman.Block{ethermanBlock0, ethermanBlock2bis} +
    +
    + 2232 + +
    + + + fromBlock = ethBlock0.NumberU64() +
    +
    + 2233 + +
    + + + toBlock = fromBlock + cfg.SyncChunkSize +
    +
    + 2234 + +
    + + + if toBlock > ethBlock2.NumberU64() { +
    +
    + 2235 + +
    + + + toBlock = ethBlock2.NumberU64() +
    +
    + 2236 + +
    + + + } +
    +
    + 2237 + +
    + + + m.Etherman. +
    +
    + 2238 + +
    + + + On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    + 2239 + +
    + + + Return(blocks, order, nil). +
    +
    + 2240 + +
    + + + Once() +
    +
    + 2241 + +
    + + +
    +
    +
    + 2242 + +
    + + + m.Etherman. +
    +
    + 2243 + +
    + + + On("GetFinalizedBlockNumber", ctx). +
    +
    + 2244 + +
    + + + Return(ethBlock2bis.NumberU64(), nil). +
    +
    + 2245 + +
    + + + Once() +
    +
    + 2246 + +
    + + +
    +
    +
    + 2247 + +
    + + + m.State. +
    +
    + 2248 + +
    + + + On("BeginStateTransaction", ctx). +
    +
    + 2249 + +
    + + + Return(m.DbTx, nil). +
    +
    + 2250 + +
    + + + Once() +
    +
    + 2251 + +
    + + +
    +
    +
    + 2252 + +
    + + + stateBlock2bis := &state.Block{ +
    +
    + 2253 + +
    + + + BlockNumber: ethermanBlock2bis.BlockNumber, +
    +
    + 2254 + +
    + + + BlockHash: ethermanBlock2bis.BlockHash, +
    +
    + 2255 + +
    + + + ParentHash: ethermanBlock2bis.ParentHash, +
    +
    + 2256 + +
    + + + ReceivedAt: ethermanBlock2bis.ReceivedAt, +
    +
    + 2257 + +
    + + + Checked: true, +
    +
    + 2258 + +
    + + + } +
    +
    + 2259 + +
    + + + m.State. +
    +
    + 2260 + +
    + + + On("AddBlock", ctx, stateBlock2bis, m.DbTx). +
    +
    + 2261 + +
    + + + Return(nil). +
    +
    + 2262 + +
    + + + Once() +
    +
    + 2263 + +
    + + +
    +
    +
    + 2264 + +
    + + + m.State. +
    +
    + 2265 + +
    + + + On("GetStoredFlushID", ctx). +
    +
    + 2266 + +
    + + + Return(uint64(1), cProverIDExecution, nil). +
    +
    + 2267 + +
    + + + Once() +
    +
    + 2268 + +
    + + +
    +
    +
    + 2269 + +
    + + + m.DbTx. +
    +
    + 2270 + +
    + + + On("Commit", ctx). +
    +
    + 2271 + +
    + + + Run(func(args mock.Arguments) { +
    +
    + 2272 + +
    + + + sync.Stop() +
    +
    + 2273 + +
    + + + ctx.Done() +
    +
    + 2274 + +
    + + + }). +
    +
    + 2275 + +
    + + + Return(nil). +
    +
    + 2276 + +
    + + + Once() +
    +
    + 2277 + +
    + + + }). +
    +
    + 2278 + +
    + + + Return(m.DbTx, nil). +
    +
    + 2279 + +
    + + + Once() +
    +
    + 2280 + +
    + + +
    +
    +
    + 2281 + +
    + + + err = sync.Sync() +
    +
    + 2282 + +
    + + + require.NoError(t, err) +
    +
    + 2283 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/CounterAndBlock.sol + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,15 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + // SPDX-License-Identifier: GPL-3.0 +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + pragma solidity >=0.7.0 <0.9.0; +
    +
    + 4 + +
    + + +
    +
    +
    + 5 + +
    + + + contract CounterAndBlock { +
    +
    + 6 + +
    + + + uint public count; +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + function increment() external { +
    +
    + 9 + +
    + + + count += 1; +
    +
    + 10 + +
    + + + } +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + function getCount() public view returns (uint, uint) { +
    +
    + 13 + +
    + + + return (count, block.timestamp); +
    +
    + 14 + +
    + + + } +
    +
    + 15 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,24 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + // SPDX-License-Identifier: MIT +
    +
    + 2 + +
    + + + pragma solidity >=0.7.0 <0.9.0; +
    +
    + 3 + +
    + + +
    +
    +
    + 4 + +
    + + + contract customModExp { +
    +
    + 5 + +
    + + + bytes32 hashResult; +
    +
    + 6 + +
    + + + address retEcrecover; +
    +
    + 7 + +
    + + + bytes dataResult; +
    +
    + 8 + +
    + + + uint256 dataRes; +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + bytes32[10] arrayStorage; +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + function modExpGeneric(bytes memory input) public { +
    +
    + 13 + +
    + + + bytes32[10] memory output; +
    +
    + 14 + +
    + + +
    +
    +
    + 15 + +
    + + + assembly { +
    +
    + 16 + +
    + + + let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140) +
    +
    + 17 + +
    + + + sstore(0x00, success) +
    +
    + 18 + +
    + + + } +
    +
    + 19 + +
    + + +
    +
    +
    + 20 + +
    + + + for (uint i = 0; i < 10; i++) { +
    +
    + 21 + +
    + + + arrayStorage[i] = output[i]; +
    +
    + 22 + +
    + + + } +
    +
    + 23 + +
    + + + } +
    +
    + 24 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/CounterAndBlock/CounterAndBlock.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,287 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + // Code generated - DO NOT EDIT. +
    +
    + 2 + +
    + + + // This file is a generated binding and any manual changes will be lost. +
    +
    + 3 + +
    + + +
    +
    +
    + 4 + +
    + + + package CounterAndBlock +
    +
    + 5 + +
    + + +
    +
    +
    + 6 + +
    + + + import ( +
    +
    + 7 + +
    + + + "errors" +
    +
    + 8 + +
    + + + "math/big" +
    +
    + 9 + +
    + + + "strings" +
    +
    + 10 + +
    + + +
    +
    +
    + 11 + +
    + + + ethereum "github.com/ethereum/go-ethereum" +
    +
    + 12 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi/bind" +
    +
    + 14 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 15 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 16 + +
    + + + "github.com/ethereum/go-ethereum/event" +
    +
    + 17 + +
    + + + ) +
    +
    + 18 + +
    + + +
    +
    +
    + 19 + +
    + + + // Reference imports to suppress errors if they are not otherwise used. +
    +
    + 20 + +
    + + + var ( +
    +
    + 21 + +
    + + + _ = errors.New +
    +
    + 22 + +
    + + + _ = big.NewInt +
    +
    + 23 + +
    + + + _ = strings.NewReader +
    +
    + 24 + +
    + + + _ = ethereum.NotFound +
    +
    + 25 + +
    + + + _ = bind.Bind +
    +
    + 26 + +
    + + + _ = common.Big1 +
    +
    + 27 + +
    + + + _ = types.BloomLookup +
    +
    + 28 + +
    + + + _ = event.NewSubscription +
    +
    + 29 + +
    + + + _ = abi.ConvertType +
    +
    + 30 + +
    + + + ) +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + // CounterAndBlockMetaData contains all meta data concerning the CounterAndBlock contract. +
    +
    + 33 + +
    + + + var CounterAndBlockMetaData = &bind.MetaData{ +
    +
    + 34 + +
    + + + ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"increment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    +
    + 35 + +
    + + + Bin: "0x608060405234801561001057600080fd5b5060eb8061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c806306661abd146041578063a87d942c14605c578063d09de08a146071575b600080fd5b604960005481565b6040519081526020015b60405180910390f35b60005460408051918252426020830152016053565b60776079565b005b6001600080828254608991906090565b9091555050565b6000821982111560b057634e487b7160e01b600052601160045260246000fd5b50019056fea26469706673582212205aa9aebefdfb857d27d7bdc8475c08138617cc37e78c2e6bd98acb9a1484994964736f6c634300080c0033", +
    +
    + 36 + +
    + + + } +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + // CounterAndBlockABI is the input ABI used to generate the binding from. +
    +
    + 39 + +
    + + + // Deprecated: Use CounterAndBlockMetaData.ABI instead. +
    +
    + 40 + +
    + + + var CounterAndBlockABI = CounterAndBlockMetaData.ABI +
    +
    + 41 + +
    + + +
    +
    +
    + 42 + +
    + + + // CounterAndBlockBin is the compiled bytecode used for deploying new contracts. +
    +
    + 43 + +
    + + + // Deprecated: Use CounterAndBlockMetaData.Bin instead. +
    +
    + 44 + +
    + + + var CounterAndBlockBin = CounterAndBlockMetaData.Bin +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + // DeployCounterAndBlock deploys a new Ethereum contract, binding an instance of CounterAndBlock to it. +
    +
    + 47 + +
    + + + func DeployCounterAndBlock(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CounterAndBlock, error) { +
    +
    + 48 + +
    + + + parsed, err := CounterAndBlockMetaData.GetAbi() +
    +
    + 49 + +
    + + + if err != nil { +
    +
    + 50 + +
    + + + return common.Address{}, nil, nil, err +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + if parsed == nil { +
    +
    + 53 + +
    + + + return common.Address{}, nil, nil, errors.New("GetABI returned nil") +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CounterAndBlockBin), backend) +
    +
    + 57 + +
    + + + if err != nil { +
    +
    + 58 + +
    + + + return common.Address{}, nil, nil, err +
    +
    + 59 + +
    + + + } +
    +
    + 60 + +
    + + + return address, tx, &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + // CounterAndBlock is an auto generated Go binding around an Ethereum contract. +
    +
    + 64 + +
    + + + type CounterAndBlock struct { +
    +
    + 65 + +
    + + + CounterAndBlockCaller // Read-only binding to the contract +
    +
    + 66 + +
    + + + CounterAndBlockTransactor // Write-only binding to the contract +
    +
    + 67 + +
    + + + CounterAndBlockFilterer // Log filterer for contract events +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + +
    +
    +
    + 70 + +
    + + + // CounterAndBlockCaller is an auto generated read-only Go binding around an Ethereum contract. +
    +
    + 71 + +
    + + + type CounterAndBlockCaller struct { +
    +
    + 72 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 73 + +
    + + + } +
    +
    + 74 + +
    + + +
    +
    +
    + 75 + +
    + + + // CounterAndBlockTransactor is an auto generated write-only Go binding around an Ethereum contract. +
    +
    + 76 + +
    + + + type CounterAndBlockTransactor struct { +
    +
    + 77 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + +
    +
    +
    + 80 + +
    + + + // CounterAndBlockFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +
    +
    + 81 + +
    + + + type CounterAndBlockFilterer struct { +
    +
    + 82 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 83 + +
    + + + } +
    +
    + 84 + +
    + + +
    +
    +
    + 85 + +
    + + + // CounterAndBlockSession is an auto generated Go binding around an Ethereum contract, +
    +
    + 86 + +
    + + + // with pre-set call and transact options. +
    +
    + 87 + +
    + + + type CounterAndBlockSession struct { +
    +
    + 88 + +
    + + + Contract *CounterAndBlock // Generic contract binding to set the session for +
    +
    + 89 + +
    + + + CallOpts bind.CallOpts // Call options to use throughout this session +
    +
    + 90 + +
    + + + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + +
    +
    +
    + 93 + +
    + + + // CounterAndBlockCallerSession is an auto generated read-only Go binding around an Ethereum contract, +
    +
    + 94 + +
    + + + // with pre-set call options. +
    +
    + 95 + +
    + + + type CounterAndBlockCallerSession struct { +
    +
    + 96 + +
    + + + Contract *CounterAndBlockCaller // Generic contract caller binding to set the session for +
    +
    + 97 + +
    + + + CallOpts bind.CallOpts // Call options to use throughout this session +
    +
    + 98 + +
    + + + } +
    +
    + 99 + +
    + + +
    +
    +
    + 100 + +
    + + + // CounterAndBlockTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +
    +
    + 101 + +
    + + + // with pre-set transact options. +
    +
    + 102 + +
    + + + type CounterAndBlockTransactorSession struct { +
    +
    + 103 + +
    + + + Contract *CounterAndBlockTransactor // Generic contract transactor binding to set the session for +
    +
    + 104 + +
    + + + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +
    +
    + 105 + +
    + + + } +
    +
    + 106 + +
    + + +
    +
    +
    + 107 + +
    + + + // CounterAndBlockRaw is an auto generated low-level Go binding around an Ethereum contract. +
    +
    + 108 + +
    + + + type CounterAndBlockRaw struct { +
    +
    + 109 + +
    + + + Contract *CounterAndBlock // Generic contract binding to access the raw methods on +
    +
    + 110 + +
    + + + } +
    +
    + 111 + +
    + + +
    +
    +
    + 112 + +
    + + + // CounterAndBlockCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +
    +
    + 113 + +
    + + + type CounterAndBlockCallerRaw struct { +
    +
    + 114 + +
    + + + Contract *CounterAndBlockCaller // Generic read-only contract binding to access the raw methods on +
    +
    + 115 + +
    + + + } +
    +
    + 116 + +
    + + +
    +
    +
    + 117 + +
    + + + // CounterAndBlockTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +
    +
    + 118 + +
    + + + type CounterAndBlockTransactorRaw struct { +
    +
    + 119 + +
    + + + Contract *CounterAndBlockTransactor // Generic write-only contract binding to access the raw methods on +
    +
    + 120 + +
    + + + } +
    +
    + 121 + +
    + + +
    +
    +
    + 122 + +
    + + + // NewCounterAndBlock creates a new instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    + 123 + +
    + + + func NewCounterAndBlock(address common.Address, backend bind.ContractBackend) (*CounterAndBlock, error) { +
    +
    + 124 + +
    + + + contract, err := bindCounterAndBlock(address, backend, backend, backend) +
    +
    + 125 + +
    + + + if err != nil { +
    +
    + 126 + +
    + + + return nil, err +
    +
    + 127 + +
    + + + } +
    +
    + 128 + +
    + + + return &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil +
    +
    + 129 + +
    + + + } +
    +
    + 130 + +
    + + +
    +
    +
    + 131 + +
    + + + // NewCounterAndBlockCaller creates a new read-only instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    + 132 + +
    + + + func NewCounterAndBlockCaller(address common.Address, caller bind.ContractCaller) (*CounterAndBlockCaller, error) { +
    +
    + 133 + +
    + + + contract, err := bindCounterAndBlock(address, caller, nil, nil) +
    +
    + 134 + +
    + + + if err != nil { +
    +
    + 135 + +
    + + + return nil, err +
    +
    + 136 + +
    + + + } +
    +
    + 137 + +
    + + + return &CounterAndBlockCaller{contract: contract}, nil +
    +
    + 138 + +
    + + + } +
    +
    + 139 + +
    + + +
    +
    +
    + 140 + +
    + + + // NewCounterAndBlockTransactor creates a new write-only instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    + 141 + +
    + + + func NewCounterAndBlockTransactor(address common.Address, transactor bind.ContractTransactor) (*CounterAndBlockTransactor, error) { +
    +
    + 142 + +
    + + + contract, err := bindCounterAndBlock(address, nil, transactor, nil) +
    +
    + 143 + +
    + + + if err != nil { +
    +
    + 144 + +
    + + + return nil, err +
    +
    + 145 + +
    + + + } +
    +
    + 146 + +
    + + + return &CounterAndBlockTransactor{contract: contract}, nil +
    +
    + 147 + +
    + + + } +
    +
    + 148 + +
    + + +
    +
    +
    + 149 + +
    + + + // NewCounterAndBlockFilterer creates a new log filterer instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    + 150 + +
    + + + func NewCounterAndBlockFilterer(address common.Address, filterer bind.ContractFilterer) (*CounterAndBlockFilterer, error) { +
    +
    + 151 + +
    + + + contract, err := bindCounterAndBlock(address, nil, nil, filterer) +
    +
    + 152 + +
    + + + if err != nil { +
    +
    + 153 + +
    + + + return nil, err +
    +
    + 154 + +
    + + + } +
    +
    + 155 + +
    + + + return &CounterAndBlockFilterer{contract: contract}, nil +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + +
    +
    +
    + 158 + +
    + + + // bindCounterAndBlock binds a generic wrapper to an already deployed contract. +
    +
    + 159 + +
    + + + func bindCounterAndBlock(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { +
    +
    + 160 + +
    + + + parsed, err := CounterAndBlockMetaData.GetAbi() +
    +
    + 161 + +
    + + + if err != nil { +
    +
    + 162 + +
    + + + return nil, err +
    +
    + 163 + +
    + + + } +
    +
    + 164 + +
    + + + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +
    +
    + 165 + +
    + + + } +
    +
    + 166 + +
    + + +
    +
    +
    + 167 + +
    + + + // Call invokes the (constant) contract method with params as input values and +
    +
    + 168 + +
    + + + // sets the output to result. The result type might be a single field for simple +
    +
    + 169 + +
    + + + // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    + 170 + +
    + + + // returns. +
    +
    + 171 + +
    + + + func (_CounterAndBlock *CounterAndBlockRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    + 172 + +
    + + + return _CounterAndBlock.Contract.CounterAndBlockCaller.contract.Call(opts, result, method, params...) +
    +
    + 173 + +
    + + + } +
    +
    + 174 + +
    + + +
    +
    +
    + 175 + +
    + + + // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    + 176 + +
    + + + // its default method if one is available. +
    +
    + 177 + +
    + + + func (_CounterAndBlock *CounterAndBlockRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    + 178 + +
    + + + return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transfer(opts) +
    +
    + 179 + +
    + + + } +
    +
    + 180 + +
    + + +
    +
    +
    + 181 + +
    + + + // Transact invokes the (paid) contract method with params as input values. +
    +
    + 182 + +
    + + + func (_CounterAndBlock *CounterAndBlockRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    + 183 + +
    + + + return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transact(opts, method, params...) +
    +
    + 184 + +
    + + + } +
    +
    + 185 + +
    + + +
    +
    +
    + 186 + +
    + + + // Call invokes the (constant) contract method with params as input values and +
    +
    + 187 + +
    + + + // sets the output to result. The result type might be a single field for simple +
    +
    + 188 + +
    + + + // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    + 189 + +
    + + + // returns. +
    +
    + 190 + +
    + + + func (_CounterAndBlock *CounterAndBlockCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    + 191 + +
    + + + return _CounterAndBlock.Contract.contract.Call(opts, result, method, params...) +
    +
    + 192 + +
    + + + } +
    +
    + 193 + +
    + + +
    +
    +
    + 194 + +
    + + + // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    + 195 + +
    + + + // its default method if one is available. +
    +
    + 196 + +
    + + + func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    + 197 + +
    + + + return _CounterAndBlock.Contract.contract.Transfer(opts) +
    +
    + 198 + +
    + + + } +
    +
    + 199 + +
    + + +
    +
    +
    + 200 + +
    + + + // Transact invokes the (paid) contract method with params as input values. +
    +
    + 201 + +
    + + + func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    + 202 + +
    + + + return _CounterAndBlock.Contract.contract.Transact(opts, method, params...) +
    +
    + 203 + +
    + + + } +
    +
    + 204 + +
    + + +
    +
    +
    + 205 + +
    + + + // Count is a free data retrieval call binding the contract method 0x06661abd. +
    +
    + 206 + +
    + + + // +
    +
    + 207 + +
    + + + // Solidity: function count() view returns(uint256) +
    +
    + 208 + +
    + + + func (_CounterAndBlock *CounterAndBlockCaller) Count(opts *bind.CallOpts) (*big.Int, error) { +
    +
    + 209 + +
    + + + var out []interface{} +
    +
    + 210 + +
    + + + err := _CounterAndBlock.contract.Call(opts, &out, "count") +
    +
    + 211 + +
    + + +
    +
    +
    + 212 + +
    + + + if err != nil { +
    +
    + 213 + +
    + + + return *new(*big.Int), err +
    +
    + 214 + +
    + + + } +
    +
    + 215 + +
    + + +
    +
    +
    + 216 + +
    + + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) +
    +
    + 217 + +
    + + +
    +
    +
    + 218 + +
    + + + return out0, err +
    +
    + 219 + +
    + + +
    +
    +
    + 220 + +
    + + + } +
    +
    + 221 + +
    + + +
    +
    +
    + 222 + +
    + + + // Count is a free data retrieval call binding the contract method 0x06661abd. +
    +
    + 223 + +
    + + + // +
    +
    + 224 + +
    + + + // Solidity: function count() view returns(uint256) +
    +
    + 225 + +
    + + + func (_CounterAndBlock *CounterAndBlockSession) Count() (*big.Int, error) { +
    +
    + 226 + +
    + + + return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) +
    +
    + 227 + +
    + + + } +
    +
    + 228 + +
    + + +
    +
    +
    + 229 + +
    + + + // Count is a free data retrieval call binding the contract method 0x06661abd. +
    +
    + 230 + +
    + + + // +
    +
    + 231 + +
    + + + // Solidity: function count() view returns(uint256) +
    +
    + 232 + +
    + + + func (_CounterAndBlock *CounterAndBlockCallerSession) Count() (*big.Int, error) { +
    +
    + 233 + +
    + + + return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) +
    +
    + 234 + +
    + + + } +
    +
    + 235 + +
    + + +
    +
    +
    + 236 + +
    + + + // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +
    +
    + 237 + +
    + + + // +
    +
    + 238 + +
    + + + // Solidity: function getCount() view returns(uint256, uint256) +
    +
    + 239 + +
    + + + func (_CounterAndBlock *CounterAndBlockCaller) GetCount(opts *bind.CallOpts) (*big.Int, *big.Int, error) { +
    +
    + 240 + +
    + + + var out []interface{} +
    +
    + 241 + +
    + + + err := _CounterAndBlock.contract.Call(opts, &out, "getCount") +
    +
    + 242 + +
    + + +
    +
    +
    + 243 + +
    + + + if err != nil { +
    +
    + 244 + +
    + + + return *new(*big.Int), *new(*big.Int), err +
    +
    + 245 + +
    + + + } +
    +
    + 246 + +
    + + +
    +
    +
    + 247 + +
    + + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) +
    +
    + 248 + +
    + + + out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) +
    +
    + 249 + +
    + + +
    +
    +
    + 250 + +
    + + + return out0, out1, err +
    +
    + 251 + +
    + + +
    +
    +
    + 252 + +
    + + + } +
    +
    + 253 + +
    + + +
    +
    +
    + 254 + +
    + + + // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +
    +
    + 255 + +
    + + + // +
    +
    + 256 + +
    + + + // Solidity: function getCount() view returns(uint256, uint256) +
    +
    + 257 + +
    + + + func (_CounterAndBlock *CounterAndBlockSession) GetCount() (*big.Int, *big.Int, error) { +
    +
    + 258 + +
    + + + return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) +
    +
    + 259 + +
    + + + } +
    +
    + 260 + +
    + + +
    +
    +
    + 261 + +
    + + + // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +
    +
    + 262 + +
    + + + // +
    +
    + 263 + +
    + + + // Solidity: function getCount() view returns(uint256, uint256) +
    +
    + 264 + +
    + + + func (_CounterAndBlock *CounterAndBlockCallerSession) GetCount() (*big.Int, *big.Int, error) { +
    +
    + 265 + +
    + + + return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) +
    +
    + 266 + +
    + + + } +
    +
    + 267 + +
    + + +
    +
    +
    + 268 + +
    + + + // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +
    +
    + 269 + +
    + + + // +
    +
    + 270 + +
    + + + // Solidity: function increment() returns() +
    +
    + 271 + +
    + + + func (_CounterAndBlock *CounterAndBlockTransactor) Increment(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    + 272 + +
    + + + return _CounterAndBlock.contract.Transact(opts, "increment") +
    +
    + 273 + +
    + + + } +
    +
    + 274 + +
    + + +
    +
    +
    + 275 + +
    + + + // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +
    +
    + 276 + +
    + + + // +
    +
    + 277 + +
    + + + // Solidity: function increment() returns() +
    +
    + 278 + +
    + + + func (_CounterAndBlock *CounterAndBlockSession) Increment() (*types.Transaction, error) { +
    +
    + 279 + +
    + + + return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) +
    +
    + 280 + +
    + + + } +
    +
    + 281 + +
    + + +
    +
    +
    + 282 + +
    + + + // Increment is a paid mutator transaction binding the contract method 0xd09de08a. +
    +
    + 283 + +
    + + + // +
    +
    + 284 + +
    + + + // Solidity: function increment() returns() +
    +
    + 285 + +
    + + + func (_CounterAndBlock *CounterAndBlockTransactorSession) Increment() (*types.Transaction, error) { +
    +
    + 286 + +
    + + + return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) +
    +
    + 287 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,224 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + // Code generated - DO NOT EDIT. +
    +
    + 2 + +
    + + + // This file is a generated binding and any manual changes will be lost. +
    +
    + 3 + +
    + + +
    +
    +
    + 4 + +
    + + + package customModExp +
    +
    + 5 + +
    + + +
    +
    +
    + 6 + +
    + + + import ( +
    +
    + 7 + +
    + + + "errors" +
    +
    + 8 + +
    + + + "math/big" +
    +
    + 9 + +
    + + + "strings" +
    +
    + 10 + +
    + + +
    +
    +
    + 11 + +
    + + + ethereum "github.com/ethereum/go-ethereum" +
    +
    + 12 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi/bind" +
    +
    + 14 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 15 + +
    + + + "github.com/ethereum/go-ethereum/core/types" +
    +
    + 16 + +
    + + + "github.com/ethereum/go-ethereum/event" +
    +
    + 17 + +
    + + + ) +
    +
    + 18 + +
    + + +
    +
    +
    + 19 + +
    + + + // Reference imports to suppress errors if they are not otherwise used. +
    +
    + 20 + +
    + + + var ( +
    +
    + 21 + +
    + + + _ = errors.New +
    +
    + 22 + +
    + + + _ = big.NewInt +
    +
    + 23 + +
    + + + _ = strings.NewReader +
    +
    + 24 + +
    + + + _ = ethereum.NotFound +
    +
    + 25 + +
    + + + _ = bind.Bind +
    +
    + 26 + +
    + + + _ = common.Big1 +
    +
    + 27 + +
    + + + _ = types.BloomLookup +
    +
    + 28 + +
    + + + _ = event.NewSubscription +
    +
    + 29 + +
    + + + _ = abi.ConvertType +
    +
    + 30 + +
    + + + ) +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + // CustomModExpMetaData contains all meta data concerning the CustomModExp contract. +
    +
    + 33 + +
    + + + var CustomModExpMetaData = &bind.MetaData{ +
    +
    + 34 + +
    + + + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"modExpGeneric\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    +
    + 35 + +
    + + + Bin: "0x608060405234801561001057600080fd5b50610208806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5665d6f14610030575b600080fd5b61004361003e3660046100e2565b610045565b005b61004d6100ad565b6101408183516020850160055afa60009081555b600a8110156100a8578181600a811061007c5761007c610193565b6020020151600482600a811061009457610094610193565b0155806100a0816101a9565b915050610061565b505050565b604051806101400160405280600a906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156100f457600080fd5b813567ffffffffffffffff8082111561010c57600080fd5b818401915084601f83011261012057600080fd5b813581811115610132576101326100cc565b604051601f8201601f19908116603f0116810190838211818310171561015a5761015a6100cc565b8160405282815287602084870101111561017357600080fd5b826020860160208301376000928101602001929092525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156101cb57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212206c4940b4c9a7086754420734c8b4921cdb547ec8b31fc3bf8cd884ad9778a5b364736f6c634300080c0033", +
    +
    + 36 + +
    + + + } +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + // CustomModExpABI is the input ABI used to generate the binding from. +
    +
    + 39 + +
    + + + // Deprecated: Use CustomModExpMetaData.ABI instead. +
    +
    + 40 + +
    + + + var CustomModExpABI = CustomModExpMetaData.ABI +
    +
    + 41 + +
    + + +
    +
    +
    + 42 + +
    + + + // CustomModExpBin is the compiled bytecode used for deploying new contracts. +
    +
    + 43 + +
    + + + // Deprecated: Use CustomModExpMetaData.Bin instead. +
    +
    + 44 + +
    + + + var CustomModExpBin = CustomModExpMetaData.Bin +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + // DeployCustomModExp deploys a new Ethereum contract, binding an instance of CustomModExp to it. +
    +
    + 47 + +
    + + + func DeployCustomModExp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CustomModExp, error) { +
    +
    + 48 + +
    + + + parsed, err := CustomModExpMetaData.GetAbi() +
    +
    + 49 + +
    + + + if err != nil { +
    +
    + 50 + +
    + + + return common.Address{}, nil, nil, err +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + if parsed == nil { +
    +
    + 53 + +
    + + + return common.Address{}, nil, nil, errors.New("GetABI returned nil") +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CustomModExpBin), backend) +
    +
    + 57 + +
    + + + if err != nil { +
    +
    + 58 + +
    + + + return common.Address{}, nil, nil, err +
    +
    + 59 + +
    + + + } +
    +
    + 60 + +
    + + + return address, tx, &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + // CustomModExp is an auto generated Go binding around an Ethereum contract. +
    +
    + 64 + +
    + + + type CustomModExp struct { +
    +
    + 65 + +
    + + + CustomModExpCaller // Read-only binding to the contract +
    +
    + 66 + +
    + + + CustomModExpTransactor // Write-only binding to the contract +
    +
    + 67 + +
    + + + CustomModExpFilterer // Log filterer for contract events +
    +
    + 68 + +
    + + + } +
    +
    + 69 + +
    + + +
    +
    +
    + 70 + +
    + + + // CustomModExpCaller is an auto generated read-only Go binding around an Ethereum contract. +
    +
    + 71 + +
    + + + type CustomModExpCaller struct { +
    +
    + 72 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 73 + +
    + + + } +
    +
    + 74 + +
    + + +
    +
    +
    + 75 + +
    + + + // CustomModExpTransactor is an auto generated write-only Go binding around an Ethereum contract. +
    +
    + 76 + +
    + + + type CustomModExpTransactor struct { +
    +
    + 77 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + +
    +
    +
    + 80 + +
    + + + // CustomModExpFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +
    +
    + 81 + +
    + + + type CustomModExpFilterer struct { +
    +
    + 82 + +
    + + + contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    +
    + 83 + +
    + + + } +
    +
    + 84 + +
    + + +
    +
    +
    + 85 + +
    + + + // CustomModExpSession is an auto generated Go binding around an Ethereum contract, +
    +
    + 86 + +
    + + + // with pre-set call and transact options. +
    +
    + 87 + +
    + + + type CustomModExpSession struct { +
    +
    + 88 + +
    + + + Contract *CustomModExp // Generic contract binding to set the session for +
    +
    + 89 + +
    + + + CallOpts bind.CallOpts // Call options to use throughout this session +
    +
    + 90 + +
    + + + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +
    +
    + 91 + +
    + + + } +
    +
    + 92 + +
    + + +
    +
    +
    + 93 + +
    + + + // CustomModExpCallerSession is an auto generated read-only Go binding around an Ethereum contract, +
    +
    + 94 + +
    + + + // with pre-set call options. +
    +
    + 95 + +
    + + + type CustomModExpCallerSession struct { +
    +
    + 96 + +
    + + + Contract *CustomModExpCaller // Generic contract caller binding to set the session for +
    +
    + 97 + +
    + + + CallOpts bind.CallOpts // Call options to use throughout this session +
    +
    + 98 + +
    + + + } +
    +
    + 99 + +
    + + +
    +
    +
    + 100 + +
    + + + // CustomModExpTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +
    +
    + 101 + +
    + + + // with pre-set transact options. +
    +
    + 102 + +
    + + + type CustomModExpTransactorSession struct { +
    +
    + 103 + +
    + + + Contract *CustomModExpTransactor // Generic contract transactor binding to set the session for +
    +
    + 104 + +
    + + + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +
    +
    + 105 + +
    + + + } +
    +
    + 106 + +
    + + +
    +
    +
    + 107 + +
    + + + // CustomModExpRaw is an auto generated low-level Go binding around an Ethereum contract. +
    +
    + 108 + +
    + + + type CustomModExpRaw struct { +
    +
    + 109 + +
    + + + Contract *CustomModExp // Generic contract binding to access the raw methods on +
    +
    + 110 + +
    + + + } +
    +
    + 111 + +
    + + +
    +
    +
    + 112 + +
    + + + // CustomModExpCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +
    +
    + 113 + +
    + + + type CustomModExpCallerRaw struct { +
    +
    + 114 + +
    + + + Contract *CustomModExpCaller // Generic read-only contract binding to access the raw methods on +
    +
    + 115 + +
    + + + } +
    +
    + 116 + +
    + + +
    +
    +
    + 117 + +
    + + + // CustomModExpTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +
    +
    + 118 + +
    + + + type CustomModExpTransactorRaw struct { +
    +
    + 119 + +
    + + + Contract *CustomModExpTransactor // Generic write-only contract binding to access the raw methods on +
    +
    + 120 + +
    + + + } +
    +
    + 121 + +
    + + +
    +
    +
    + 122 + +
    + + + // NewCustomModExp creates a new instance of CustomModExp, bound to a specific deployed contract. +
    +
    + 123 + +
    + + + func NewCustomModExp(address common.Address, backend bind.ContractBackend) (*CustomModExp, error) { +
    +
    + 124 + +
    + + + contract, err := bindCustomModExp(address, backend, backend, backend) +
    +
    + 125 + +
    + + + if err != nil { +
    +
    + 126 + +
    + + + return nil, err +
    +
    + 127 + +
    + + + } +
    +
    + 128 + +
    + + + return &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil +
    +
    + 129 + +
    + + + } +
    +
    + 130 + +
    + + +
    +
    +
    + 131 + +
    + + + // NewCustomModExpCaller creates a new read-only instance of CustomModExp, bound to a specific deployed contract. +
    +
    + 132 + +
    + + + func NewCustomModExpCaller(address common.Address, caller bind.ContractCaller) (*CustomModExpCaller, error) { +
    +
    + 133 + +
    + + + contract, err := bindCustomModExp(address, caller, nil, nil) +
    +
    + 134 + +
    + + + if err != nil { +
    +
    + 135 + +
    + + + return nil, err +
    +
    + 136 + +
    + + + } +
    +
    + 137 + +
    + + + return &CustomModExpCaller{contract: contract}, nil +
    +
    + 138 + +
    + + + } +
    +
    + 139 + +
    + + +
    +
    +
    + 140 + +
    + + + // NewCustomModExpTransactor creates a new write-only instance of CustomModExp, bound to a specific deployed contract. +
    +
    + 141 + +
    + + + func NewCustomModExpTransactor(address common.Address, transactor bind.ContractTransactor) (*CustomModExpTransactor, error) { +
    +
    + 142 + +
    + + + contract, err := bindCustomModExp(address, nil, transactor, nil) +
    +
    + 143 + +
    + + + if err != nil { +
    +
    + 144 + +
    + + + return nil, err +
    +
    + 145 + +
    + + + } +
    +
    + 146 + +
    + + + return &CustomModExpTransactor{contract: contract}, nil +
    +
    + 147 + +
    + + + } +
    +
    + 148 + +
    + + +
    +
    +
    + 149 + +
    + + + // NewCustomModExpFilterer creates a new log filterer instance of CustomModExp, bound to a specific deployed contract. +
    +
    + 150 + +
    + + + func NewCustomModExpFilterer(address common.Address, filterer bind.ContractFilterer) (*CustomModExpFilterer, error) { +
    +
    + 151 + +
    + + + contract, err := bindCustomModExp(address, nil, nil, filterer) +
    +
    + 152 + +
    + + + if err != nil { +
    +
    + 153 + +
    + + + return nil, err +
    +
    + 154 + +
    + + + } +
    +
    + 155 + +
    + + + return &CustomModExpFilterer{contract: contract}, nil +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + +
    +
    +
    + 158 + +
    + + + // bindCustomModExp binds a generic wrapper to an already deployed contract. +
    +
    + 159 + +
    + + + func bindCustomModExp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { +
    +
    + 160 + +
    + + + parsed, err := CustomModExpMetaData.GetAbi() +
    +
    + 161 + +
    + + + if err != nil { +
    +
    + 162 + +
    + + + return nil, err +
    +
    + 163 + +
    + + + } +
    +
    + 164 + +
    + + + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +
    +
    + 165 + +
    + + + } +
    +
    + 166 + +
    + + +
    +
    +
    + 167 + +
    + + + // Call invokes the (constant) contract method with params as input values and +
    +
    + 168 + +
    + + + // sets the output to result. The result type might be a single field for simple +
    +
    + 169 + +
    + + + // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    + 170 + +
    + + + // returns. +
    +
    + 171 + +
    + + + func (_CustomModExp *CustomModExpRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    + 172 + +
    + + + return _CustomModExp.Contract.CustomModExpCaller.contract.Call(opts, result, method, params...) +
    +
    + 173 + +
    + + + } +
    +
    + 174 + +
    + + +
    +
    +
    + 175 + +
    + + + // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    + 176 + +
    + + + // its default method if one is available. +
    +
    + 177 + +
    + + + func (_CustomModExp *CustomModExpRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    + 178 + +
    + + + return _CustomModExp.Contract.CustomModExpTransactor.contract.Transfer(opts) +
    +
    + 179 + +
    + + + } +
    +
    + 180 + +
    + + +
    +
    +
    + 181 + +
    + + + // Transact invokes the (paid) contract method with params as input values. +
    +
    + 182 + +
    + + + func (_CustomModExp *CustomModExpRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    + 183 + +
    + + + return _CustomModExp.Contract.CustomModExpTransactor.contract.Transact(opts, method, params...) +
    +
    + 184 + +
    + + + } +
    +
    + 185 + +
    + + +
    +
    +
    + 186 + +
    + + + // Call invokes the (constant) contract method with params as input values and +
    +
    + 187 + +
    + + + // sets the output to result. The result type might be a single field for simple +
    +
    + 188 + +
    + + + // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    + 189 + +
    + + + // returns. +
    +
    + 190 + +
    + + + func (_CustomModExp *CustomModExpCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    + 191 + +
    + + + return _CustomModExp.Contract.contract.Call(opts, result, method, params...) +
    +
    + 192 + +
    + + + } +
    +
    + 193 + +
    + + +
    +
    +
    + 194 + +
    + + + // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    + 195 + +
    + + + // its default method if one is available. +
    +
    + 196 + +
    + + + func (_CustomModExp *CustomModExpTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    + 197 + +
    + + + return _CustomModExp.Contract.contract.Transfer(opts) +
    +
    + 198 + +
    + + + } +
    +
    + 199 + +
    + + +
    +
    +
    + 200 + +
    + + + // Transact invokes the (paid) contract method with params as input values. +
    +
    + 201 + +
    + + + func (_CustomModExp *CustomModExpTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    + 202 + +
    + + + return _CustomModExp.Contract.contract.Transact(opts, method, params...) +
    +
    + 203 + +
    + + + } +
    +
    + 204 + +
    + + +
    +
    +
    + 205 + +
    + + + // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    + 206 + +
    + + + // +
    +
    + 207 + +
    + + + // Solidity: function modExpGeneric(bytes input) returns() +
    +
    + 208 + +
    + + + func (_CustomModExp *CustomModExpTransactor) ModExpGeneric(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { +
    +
    + 209 + +
    + + + return _CustomModExp.contract.Transact(opts, "modExpGeneric", input) +
    +
    + 210 + +
    + + + } +
    +
    + 211 + +
    + + +
    +
    +
    + 212 + +
    + + + // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    + 213 + +
    + + + // +
    +
    + 214 + +
    + + + // Solidity: function modExpGeneric(bytes input) returns() +
    +
    + 215 + +
    + + + func (_CustomModExp *CustomModExpSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    + 216 + +
    + + + return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    + 217 + +
    + + + } +
    +
    + 218 + +
    + + +
    +
    +
    + 219 + +
    + + + // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    + 220 + +
    + + + // +
    +
    + 221 + +
    + + + // Solidity: function modExpGeneric(bytes input) returns() +
    +
    + 222 + +
    + + + func (_CustomModExp *CustomModExpTransactorSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    + 223 + +
    + + + return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    + 224 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -32,7 +32,7 @@
    +
    + 32 + +
    +   + // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. +
    +
    + 33 + +
    +   + var TriggerErrorsMetaData = &bind.MetaData{ +
    +
    + 34 + +
    +   + ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    +
    + 35 + +
    + - + Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122097beacfaa873e4896937143dfea406cc278b929a28023f7e7020b6dea6e9fc7364736f6c634300080c0033", +
    +
    + 36 + +
    +   + } +
    +
    + 37 + +
    +   +
    +
    +
    + 38 + +
    +   + // TriggerErrorsABI is the input ABI used to generate the binding from. +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 32 + +
    +   + // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. +
    +
    + 33 + +
    +   + var TriggerErrorsMetaData = &bind.MetaData{ +
    +
    + 34 + +
    +   + ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    +
    + 35 + +
    + + + Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212208f01c5dc055b1f376f5da5deb33e2c96ee776174bf48874c5ebba0f606de2ac564736f6c634300080c0033", +
    +
    + 36 + +
    +   + } +
    +
    + 37 + +
    +   +
    +
    +
    + 38 + +
    +   + // TriggerErrorsABI is the input ABI used to generate the binding from. +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -2,7 +2,7 @@
    +
    + 2 + +
    +   + networks: +
    +
    + 3 + +
    +   + default: +
    +
    + 4 + +
    +   + name: zkevm +
    +
    + 5 + +
    + - + +
    +
    + 6 + +
    +   + services: +
    +
    + 7 + +
    +   + grafana: +
    +
    + 8 + +
    +   + container_name: grafana +
    +
    +
    @@ -453,7 +453,7 @@
    +
    + 453 + +
    +   +
    +
    +
    + 454 + +
    +   + zkevm-mock-l1-network: +
    +
    + 455 + +
    +   + container_name: zkevm-mock-l1-network +
    +
    + 456 + +
    + - + image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0 +
    +
    + 457 + +
    +   + ports: +
    +
    + 458 + +
    +   + - 8545:8545 +
    +
    + 459 + +
    +   + - 8546:8546 +
    +
    +
    @@ -519,6 +519,8 @@
    +
    + 519 + +
    +   + - 50071:50071 # Executor +
    +
    + 520 + +
    +   + volumes: +
    +
    + 521 + +
    +   + - ./config/test.prover.config.json:/usr/src/app/config.json +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 522 + +
    +   + command: > +
    +
    + 523 + +
    +   + zkProver -c /usr/src/app/config.json +
    +
    + 524 + +
    +   +
    +
    +
    +
    @@ -610,6 +612,8 @@
    +
    + 610 + +
    +   + - 50078:50071 # Executor +
    +
    + 611 + +
    +   + volumes: +
    +
    + 612 + +
    +   + - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 613 + +
    +   + command: > +
    +
    + 614 + +
    +   + zkProver -c /usr/src/app/config.json +
    +
    + 615 + +
    +   +
    +
    +
    +
    @@ -628,7 +632,7 @@
    +
    + 628 + +
    +   + zkevm-sh: +
    +
    + 629 + +
    +   + container_name: zkevm-sh +
    +
    + 630 + +
    +   + image: zkevm-node +
    +
    + 631 + +
    + - + stdin_open: true +
    +
    + 632 + +
    +   + tty: true +
    +
    + 633 + +
    +   + environment: +
    +
    + 634 + +
    +   + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db +
    +
    +
    @@ -638,3 +642,51 @@
    +
    + 638 + +
    +   + - ./config/test.genesis.config.json:/app/genesis.json +
    +
    + 639 + +
    +   + command: +
    +
    + 640 + +
    +   + - "/bin/sh" +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 2 + +
    +   + networks: +
    +
    + 3 + +
    +   + default: +
    +
    + 4 + +
    +   + name: zkevm +
    +
    + 5 + +
    + + +
    +
    +
    + 6 + +
    +   + services: +
    +
    + 7 + +
    +   + grafana: +
    +
    + 8 + +
    +   + container_name: grafana +
    +
    +
     
    +
    + 453 + +
    +   +
    +
    +
    + 454 + +
    +   + zkevm-mock-l1-network: +
    +
    + 455 + +
    +   + container_name: zkevm-mock-l1-network +
    +
    + 456 + +
    + + + image: 0xpolygon/cdk-validium-contracts:forkId8 +
    +
    + 457 + +
    +   + ports: +
    +
    + 458 + +
    +   + - 8545:8545 +
    +
    + 459 + +
    +   + - 8546:8546 +
    +
    +
     
    +
    + 519 + +
    +   + - 50071:50071 # Executor +
    +
    + 520 + +
    +   + volumes: +
    +
    + 521 + +
    +   + - ./config/test.prover.config.json:/usr/src/app/config.json +
    +
    + 522 + +
    + + + environment: +
    +
    + 523 + +
    + + + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 +
    +
    + 524 + +
    +   + command: > +
    +
    + 525 + +
    +   + zkProver -c /usr/src/app/config.json +
    +
    + 526 + +
    +   +
    +
    +
    +
     
    +
    + 612 + +
    +   + - 50078:50071 # Executor +
    +
    + 613 + +
    +   + volumes: +
    +
    + 614 + +
    +   + - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json +
    +
    + 615 + +
    + + + environment: +
    +
    + 616 + +
    + + + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 +
    +
    + 617 + +
    +   + command: > +
    +
    + 618 + +
    +   + zkProver -c /usr/src/app/config.json +
    +
    + 619 + +
    +   +
    +
    +
    +
     
    +
    + 632 + +
    +   + zkevm-sh: +
    +
    + 633 + +
    +   + container_name: zkevm-sh +
    +
    + 634 + +
    +   + image: zkevm-node +
    +
    + 635 + +
    + + + stdin_open: true +
    +
    + 636 + +
    +   + tty: true +
    +
    + 637 + +
    +   + environment: +
    +
    + 638 + +
    +   + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db +
    +
    +
     
    +
    + 642 + +
    +   + - ./config/test.genesis.config.json:/app/genesis.json +
    +
    + 643 + +
    +   + command: +
    +
    + 644 + +
    +   + - "/bin/sh" +
    +
    + 645 + +
    + + +
    +
    +
    + 646 + +
    + + + zkevm-node-forced-DAC: +
    +
    + 647 + +
    + + + container_name: zkevm-node-forced-DAC +
    +
    + 648 + +
    + + + image: zkevm-node +
    +
    + 649 + +
    + + + ports: +
    +
    + 650 + +
    + + + - 8125:8125 +
    +
    + 651 + +
    + + + environment: +
    +
    + 652 + +
    + + + - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false +
    +
    + 653 + +
    + + + - ZKEVM_NODE_STATEDB_USER=test_user +
    +
    + 654 + +
    + + + - ZKEVM_NODE_STATEDB_PASSWORD=test_password +
    +
    + 655 + +
    + + + - ZKEVM_NODE_STATEDB_NAME=state_db +
    +
    + 656 + +
    + + + - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db +
    +
    + 657 + +
    + + + - ZKEVM_NODE_POOL_DB_USER=test_user +
    +
    + 658 + +
    + + + - ZKEVM_NODE_POOL_DB_PASSWORD=test_password +
    +
    + 659 + +
    + + + - ZKEVM_NODE_POOL_DB_NAME=pool_db +
    +
    + 660 + +
    + + + - ZKEVM_NODE_POOL_DB_HOST=zkevm-permissionless-db +
    +
    + 661 + +
    + + + - ZKEVM_NODE_RPC_PORT=8125 +
    +
    + 662 + +
    + + + - ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-node-json-rpc:8123 +
    +
    + 663 + +
    + + + - ZKEVM_NODE_SYNCHRONIZER_TRUSTEDSEQUENCERURL=http://you-cant-touch-this:8123 +
    +
    + 664 + +
    + + + - ZKEVM_NODE_MTCLIENT_URI=zkevm-permissionless-prover:50061 +
    +
    + 665 + +
    + + + - ZKEVM_NODE_EXECUTOR_URI=zkevm-permissionless-prover:50071 +
    +
    + 666 + +
    + + + volumes: +
    +
    + 667 + +
    + + + - ./config/test.node.config.toml:/app/config.toml +
    +
    + 668 + +
    + + + - ./config/test.genesis.config.json:/app/genesis.json +
    +
    + 669 + +
    + + + command: +
    +
    + 670 + +
    + + + - "/bin/sh" +
    +
    + 671 + +
    + + + - "-c" +
    +
    + 672 + +
    + + + - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\"" +
    +
    + 673 + +
    + + +
    +
    +
    + 674 + +
    + + + zkevm-data-node-db: +
    +
    + 675 + +
    + + + container_name: zkevm-data-node-db +
    +
    + 676 + +
    + + + restart: unless-stopped +
    +
    + 677 + +
    + + + image: postgres +
    +
    + 678 + +
    + + + healthcheck: +
    +
    + 679 + +
    + + + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] +
    +
    + 680 + +
    + + + interval: 10s +
    +
    + 681 + +
    + + + timeout: 5s +
    +
    + 682 + +
    + + + retries: 5 +
    +
    + 683 + +
    + + + ports: +
    +
    + 684 + +
    + + + - 5444:5432 +
    +
    + 685 + +
    + + + environment: +
    +
    + 686 + +
    + + + - POSTGRES_USER=committee_user +
    +
    + 687 + +
    + + + - POSTGRES_PASSWORD=committee_password +
    +
    + 688 + +
    + + + - POSTGRES_DB=committee_db +
    +
    + 689 + +
    + + + command: +
    +
    + 690 + +
    + + + - "postgres" +
    +
    + 691 + +
    + + + - "-N" +
    +
    + 692 + +
    + + + - "500" +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,270 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    @@ -142731,257 +246075,2367 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    - 1 + 1 + +
    + + + package e2e +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "crypto/ecdsa" +
    +
    + 6 + +
    + + + "encoding/json" +
    +
    + 7 + +
    + + + "fmt" +
    +
    + 8 + +
    + + + "math/big" +
    +
    + 9 + +
    + + + "os" +
    +
    + 10 + +
    + + + "os/exec" +
    +
    + 11 + +
    + + + "sort" +
    +
    + 12 + +
    + + + "strconv" +
    +
    + 13 + +
    + + + "strings" +
    +
    + 14 + +
    + + + "testing" +
    +
    + 15 + +
    + + + "time" +
    +
    + 16 + +
    + + +
    +
    +
    + 17 + +
    + + + "github.com/0xPolygon/cdk-data-availability/config" +
    +
    + 18 + +
    + + + cTypes "github.com/0xPolygon/cdk-data-availability/config/types" +
    +
    + 19 + +
    + + + "github.com/0xPolygon/cdk-data-availability/db" +
    +
    + 20 + +
    + + + "github.com/0xPolygon/cdk-data-availability/rpc" +
    +
    + 21 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +
    +
    + 22 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 23 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/test/operations" +
    +
    + 24 + +
    + + + "github.com/ethereum/go-ethereum" +
    +
    + 25 + +
    + + + eTypes "github.com/ethereum/go-ethereum/core/types" +
    +
    + 26 + +
    + + +
    +
    +
    + 27 + +
    + + + "github.com/ethereum/go-ethereum/accounts/keystore" +
    +
    + 28 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 29 + +
    + + + "github.com/ethereum/go-ethereum/crypto" +
    +
    + 30 + +
    + + + "github.com/ethereum/go-ethereum/ethclient" +
    +
    + 31 + +
    + + + "github.com/stretchr/testify/assert" +
    +
    + 32 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 33 + +
    + + + ) +
    +
    + 34 + +
    + + +
    +
    +
    + 35 + +
    + + + func TestDataCommittee(t *testing.T) { +
    +
    + 36 + +
    + + + const ( +
    +
    + 37 + +
    + + + nSignatures = 4 +
    +
    + 38 + +
    + + + mMembers = 5 +
    +
    + 39 + +
    + + + ksFile = "/tmp/pkey" +
    +
    + 40 + +
    + + + cfgFile = "/tmp/dacnodeconfigfile.json" +
    +
    + 41 + +
    + + + ksPass = "pass" +
    +
    + 42 + +
    + + + dacNodeContainer = "hermeznetwork/cdk-data-availability:v0.0.4" +
    +
    + 43 + +
    + + + ) +
    +
    + 44 + +
    + + +
    +
    +
    + 45 + +
    + + + // Setup +
    +
    + 46 + +
    + + + var err error +
    +
    + 47 + +
    + + + if testing.Short() { +
    +
    + 48 + +
    + + + t.Skip() +
    +
    + 49 + +
    + + + } +
    +
    + 50 + +
    + + + ctx := context.Background() +
    +
    + 51 + +
    + + + defer func() { +
    +
    + 52 + +
    + + + require.NoError(t, operations.Teardown()) +
    +
    + 53 + +
    + + + }() +
    +
    + 54 + +
    + + + err = operations.Teardown() +
    +
    + 55 + +
    + + + require.NoError(t, err) +
    +
    + 56 + +
    + + + opsCfg := operations.GetDefaultOperationsConfig() +
    +
    + 57 + +
    + + + opsCfg.State.MaxCumulativeGasUsed = 80000000000 +
    +
    + 58 + +
    + + + opsman, err := operations.NewManager(ctx, opsCfg) +
    +
    + 59 + +
    + + + require.NoError(t, err) +
    +
    + 60 + +
    + + + defer func() { +
    +
    + 61 + +
    + + + require.NoError(t, opsman.StopDACDB()) +
    +
    + 62 + +
    + + + }() +
    +
    + 63 + +
    + + + err = opsman.Setup() +
    +
    + 64 + +
    + + + require.NoError(t, err) +
    +
    + 65 + +
    + + + require.NoError(t, opsman.StartDACDB()) +
    +
    + 66 + +
    + + + time.Sleep(5 * time.Second) +
    +
    + 67 + +
    + + + authL2, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID) +
    +
    + 68 + +
    + + + require.NoError(t, err) +
    +
    + 69 + +
    + + + authL1, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID) +
    +
    + 70 + +
    + + + require.NoError(t, err) +
    +
    + 71 + +
    + + + clientL2, err := ethclient.Dial(operations.DefaultL2NetworkURL) +
    +
    + 72 + +
    + + + require.NoError(t, err) +
    +
    + 73 + +
    + + + clientL1, err := ethclient.Dial(operations.DefaultL1NetworkURL) +
    +
    + 74 + +
    + + + require.NoError(t, err) +
    +
    + 75 + +
    + + + dacSC, err := polygondatacommittee.NewPolygondatacommittee( +
    +
    + 76 + +
    + + + common.HexToAddress(operations.DefaultL1DataCommitteeContract), +
    +
    + 77 + +
    + + + clientL1, +
    +
    + 78 + +
    + + + ) +
    +
    + 79 + +
    + + + require.NoError(t, err) +
    +
    + 80 + +
    + + +
    +
    +
    + 81 + +
    + + + // Register committe with N / M signatures +
    +
    + 82 + +
    + + + membs := members{} +
    +
    + 83 + +
    + + + addrsBytes := []byte{} +
    +
    + 84 + +
    + + + urls := []string{} +
    +
    + 85 + +
    + + + for i := 0; i < mMembers; i++ { +
    +
    + 86 + +
    + + + pk, err := crypto.GenerateKey() +
    +
    + 87 + +
    + + + require.NoError(t, err) +
    +
    + 88 + +
    + + + membs = append(membs, member{ +
    +
    + 89 + +
    + + + addr: crypto.PubkeyToAddress(pk.PublicKey), +
    +
    + 90 + +
    + + + pk: pk, +
    +
    + 91 + +
    + + + url: fmt.Sprintf("http://cdk-data-availability-%d:420%d", i, i), +
    +
    + 92 + +
    + + + i: i, +
    +
    + 93 + +
    + + + }) +
    +
    + 94 + +
    + + + } +
    +
    + 95 + +
    + + + sort.Sort(membs) +
    +
    + 96 + +
    + + + for _, m := range membs { +
    +
    + 97 + +
    + + + addrsBytes = append(addrsBytes, m.addr.Bytes()...) +
    +
    + 98 + +
    + + + urls = append(urls, m.url) +
    +
    + 99 + +
    + + + } +
    +
    + 100 + +
    + + + tx, err := dacSC.SetupCommittee(authL1, big.NewInt(nSignatures), urls, addrsBytes) +
    +
    + 101 + +
    + + + for _, m := range membs { +
    +
    + 102 + +
    + + + fmt.Println(m.addr) +
    +
    + 103 + +
    + + + } +
    +
    + 104 + +
    + + + require.NoError(t, err) +
    +
    + 105 + +
    + + + err = operations.WaitTxToBeMined(ctx, clientL1, tx, operations.DefaultTimeoutTxToBeMined) +
    +
    + 106 + +
    + + + require.NoError(t, err) +
    +
    + 107 + +
    + + +
    +
    +
    + 108 + +
    + + + // Spin up M DAC nodes +
    +
    + 109 + +
    + + + dacNodeConfig := config.Config{ +
    +
    + 110 + +
    + + + L1: config.L1Config{ +
    +
    + 111 + +
    + + + RpcURL: "http://zkevm-mock-l1-network:8545", +
    +
    + 112 + +
    + + + WsURL: "ws://zkevm-mock-l1-network:8546", +
    +
    + 113 + +
    + + + PolygonValidiumAddress: operations.DefaultL1ZkEVMSmartContract, +
    +
    + 114 + +
    + + + DataCommitteeAddress: operations.DefaultL1DataCommitteeContract, +
    +
    + 115 + +
    + + + Timeout: cTypes.Duration{Duration: time.Second}, +
    +
    + 116 + +
    + + + RetryPeriod: cTypes.Duration{Duration: time.Second}, +
    +
    + 117 + +
    + + + }, +
    +
    + 118 + +
    + + + PrivateKey: cTypes.KeystoreFileConfig{ +
    +
    + 119 + +
    + + + Path: ksFile, +
    +
    + 120 + +
    + + + Password: ksPass, +
    +
    + 121 + +
    + + + }, +
    +
    + 122 + +
    + + + DB: db.Config{ +
    +
    + 123 + +
    + + + Name: "committee_db", +
    +
    + 124 + +
    + + + User: "committee_user", +
    +
    + 125 + +
    + + + Password: "committee_password", +
    +
    + 126 + +
    + + + Host: "zkevm-data-node-db", +
    +
    + 127 + +
    + + + Port: "5432", +
    +
    + 128 + +
    + + + EnableLog: false, +
    +
    + 129 + +
    + + + MaxConns: 10, +
    +
    + 130 + +
    + + + }, +
    +
    + 131 + +
    + + + RPC: rpc.Config{ +
    +
    + 132 + +
    + + + Host: "0.0.0.0", +
    +
    + 133 + +
    + + + MaxRequestsPerIPAndSecond: 100, +
    +
    + 134 + +
    + + + }, +
    +
    + 135 + +
    + + + } +
    +
    + 136 + +
    + + + defer func() { +
    +
    + 137 + +
    + + + // Remove tmp files +
    +
    + 138 + +
    + + + assert.NoError(t, +
    +
    + 139 + +
    + + + exec.Command("rm", cfgFile).Run(), +
    +
    + 140 + +
    + + + ) +
    +
    + 141 + +
    + + + assert.NoError(t, +
    +
    + 142 + +
    + + + exec.Command("rmdir", ksFile+"_").Run(), +
    +
    + 143 + +
    + + + ) +
    +
    + 144 + +
    + + + assert.NoError(t, +
    +
    + 145 + +
    + + + exec.Command("rm", ksFile).Run(), +
    +
    + 146 + +
    + + + ) +
    +
    + 147 + +
    + + + // Stop DAC nodes +
    +
    + 148 + +
    + + + for i := 0; i < mMembers; i++ { +
    +
    + 149 + +
    + + + assert.NoError(t, exec.Command( +
    +
    + 150 + +
    + + + "docker", "kill", "cdk-data-availability-"+strconv.Itoa(i), +
    +
    + 151 + +
    + + + ).Run()) +
    +
    + 152 + +
    + + + assert.NoError(t, exec.Command( +
    +
    + 153 + +
    + + + "docker", "rm", "cdk-data-availability-"+strconv.Itoa(i), +
    +
    + 154 + +
    + + + ).Run()) +
    +
    + 155 + +
    + + + } +
    +
    + 156 + +
    + + + // Stop permissionless node +
    +
    + 157 + +
    + + + require.NoError(t, opsman.StopPermissionlessNodeForcedToSYncThroughDAC()) +
    +
    + 158 + +
    + + + }() +
    +
    + 159 + +
    + + + // Start permissionless node +
    +
    + 160 + +
    + + + require.NoError(t, opsman.StartPermissionlessNodeForcedToSYncThroughDAC()) +
    +
    + 161 + +
    + + + // Star DAC nodes +
    +
    + 162 + +
    + + + for _, m := range membs { +
    +
    + 163 + +
    + + + // Set correct port +
    +
    + 164 + +
    + + + port := 4200 + m.i +
    +
    + 165 + +
    + + + dacNodeConfig.RPC.Port = port +
    +
    + 166 + +
    + + + // Write config file +
    +
    + 167 + +
    + + + file, err := json.MarshalIndent(dacNodeConfig, "", " ") +
    +
    + 168 + +
    + + + require.NoError(t, err) +
    +
    + 169 + +
    + + + err = os.WriteFile(cfgFile, file, 0644) +
    +
    + 170 + +
    + + + require.NoError(t, err) +
    +
    + 171 + +
    + + + // Write private key keystore file +
    +
    + 172 + +
    + + + err = createKeyStore(m.pk, ksFile, ksPass) +
    +
    + 173 + +
    + + + require.NoError(t, err) +
    +
    + 174 + +
    + + + // Run DAC node +
    +
    + 175 + +
    + + + cmd := exec.Command( +
    +
    + 176 + +
    + + + "docker", "run", "-d", +
    +
    + 177 + +
    + + + "--name", "cdk-data-availability-"+strconv.Itoa(m.i), +
    +
    + 178 + +
    + + + "-v", cfgFile+":/app/config.json", +
    +
    + 179 + +
    + + + "-v", ksFile+":"+ksFile, +
    +
    + 180 + +
    + + + "--network", "zkevm", +
    +
    + 181 + +
    + + + dacNodeContainer, +
    +
    + 182 + +
    + + + "/bin/sh", "-c", +
    +
    + 183 + +
    + + + "/app/cdk-data-availability run --cfg /app/config.json", +
    +
    + 184 + +
    + + + ) +
    +
    + 185 + +
    + + + out, err := cmd.CombinedOutput() +
    +
    + 186 + +
    + + + require.NoError(t, err, string(out)) +
    +
    + 187 + +
    + + + log.Infof("DAC node %d started", m.i) +
    +
    + 188 + +
    + + + time.Sleep(time.Second * 5) +
    +
    + 189 + +
    + + + } +
    +
    + 190 + +
    + + +
    +
    +
    + 191 + +
    + + + // Send txs +
    +
    + 192 + +
    + + + nTxs := 10 +
    +
    + 193 + +
    + + + amount := big.NewInt(10000) +
    +
    + 194 + +
    + + + toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8") +
    +
    + 195 + +
    + + + _, err = clientL2.BalanceAt(ctx, authL2.From, nil) +
    +
    + 196 + +
    + + + require.NoError(t, err) +
    +
    + 197 + +
    + + + _, err = clientL2.PendingNonceAt(ctx, authL2.From) +
    +
    + 198 + +
    + + + require.NoError(t, err) +
    +
    + 199 + +
    + + +
    +
    +
    + 200 + +
    + + + gasLimit, err := clientL2.EstimateGas(ctx, ethereum.CallMsg{From: authL2.From, To: &toAddress, Value: amount}) +
    +
    + 201 + +
    + + + require.NoError(t, err) +
    +
    + 202 + +
    + + +
    +
    +
    + 203 + +
    + + + gasPrice, err := clientL2.SuggestGasPrice(ctx) +
    +
    + 204 + +
    + + + require.NoError(t, err) +
    +
    + 205 + +
    + + +
    +
    +
    + 206 + +
    + + + nonce, err := clientL2.PendingNonceAt(ctx, authL2.From) +
    +
    + 207 + +
    + + + require.NoError(t, err) +
    +
    + 208 + +
    + + +
    +
    +
    + 209 + +
    + + + txs := make([]*eTypes.Transaction, 0, nTxs) +
    +
    + 210 + +
    + + + for i := 0; i < nTxs; i++ { +
    +
    + 211 + +
    + + + tx := eTypes.NewTransaction(nonce+uint64(i), toAddress, amount, gasLimit, gasPrice, nil) +
    +
    + 212
    + - package e2e + log.Infof("generating tx %d / %d: %s", i+1, nTxs, tx.Hash().Hex())
    - 2 + 213
    + -
    + txs = append(txs, tx)
    - 3 + 214
    + - import ( + }
    - 4 + 215
    + - "context" +
    - 5 + 216
    + - "crypto/ecdsa" + // Wait for verification
    - 6 + 217
    + - "encoding/json" + _, err = operations.ApplyL2Txs(ctx, txs, authL2, clientL2, operations.VerifiedConfirmationLevel)
    - 7 + 218
    + - "fmt" + require.NoError(t, err)
    - 8 + 219
    + - "math/big" +
    - 9 + 220
    + - "os" + // Assert that he permissionless node is fully synced (through the DAC)
    - 10 + 221
    + - "os/exec" + time.Sleep(30 * time.Second) // Give some time for the permissionless node to get synced
    - 11 + 222
    + - "sort" + clientL2Permissionless, err := ethclient.Dial(operations.PermissionlessL2NetworkURL)
    - 12 + 223
    + - "strconv" + require.NoError(t, err)
    - 13 + 224
    + - "strings" + expectedBlock, err := clientL2.BlockByNumber(ctx, nil)
    - 14 + 225
    + - "testing" + require.NoError(t, err)
    - 15 + 226
    + - "time" + actualBlock, err := clientL2Permissionless.BlockByNumber(ctx, nil)
    - 16 + 227
    + -
    + require.NoError(t, err)
    - 17 + 228
    + - "github.com/0xPolygon/cdk-data-availability/config" + // je, err := expectedBlock.Header().MarshalJSON()
    - 18 + 229
    + - cTypes "github.com/0xPolygon/cdk-data-availability/config/types" + // require.NoError(t, err)
    - 19 + 230
    + - "github.com/0xPolygon/cdk-data-availability/db" + // log.Info(string(je))
    - 20 + 231
    + - "github.com/0xPolygon/cdk-data-availability/rpc" + // ja, err := actualBlock.Header().MarshalJSON()
    - 21 + 232
    + - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" + // require.NoError(t, err)
    - 22 + 233
    + - "github.com/0xPolygonHermez/zkevm-node/log" + // log.Info(string(ja))
    - 23 + 234
    + - "github.com/0xPolygonHermez/zkevm-node/test/operations" + // require.Equal(t, string(je), string(ja))
    - 24 + 235
    + - "github.com/ethereum/go-ethereum" + require.Equal(t, expectedBlock.Root().Hex(), actualBlock.Root().Hex())
    - 25 + 236
    + - eTypes "github.com/ethereum/go-ethereum/core/types" + }
    - 26 + 237
    @@ -142991,77 +248445,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 27 + 238
    + - "github.com/ethereum/go-ethereum/accounts/keystore" + type member struct {
    - 28 + 239
    + - "github.com/ethereum/go-ethereum/common" + addr common.Address
    - 29 + 240
    + - "github.com/ethereum/go-ethereum/crypto" + pk *ecdsa.PrivateKey
    - 30 + 241
    + - "github.com/ethereum/go-ethereum/ethclient" + url string
    - 31 + 242
    + - "github.com/stretchr/testify/assert" + i int
    - 32 + 243
    + - "github.com/stretchr/testify/require" + }
    - 33 + 244
    + - ) + type members []member
    - 34 + 245
    @@ -143071,2107 +248525,2766 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 35 + 246
    + - func TestDataCommittee(t *testing.T) { + func (s members) Len() int { return len(s) }
    - 36 + 247
    + - const ( + func (s members) Less(i, j int) bool {
    - 37 + 248
    + - nSignatures = 4 + return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex())
    - 38 + 249
    + - mMembers = 5 + }
    - 39 + 250
    + - ksFile = "/tmp/pkey" + func (s members) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
    - 40 + 251
    + - cfgFile = "/tmp/dacnodeconfigfile.json" +
    - 41 + 252
    + - ksPass = "pass" + func createKeyStore(pk *ecdsa.PrivateKey, outputDir, password string) error {
    - 42 + 253
    + - dacNodeContainer = "hermeznetwork/cdk-data-availability:v0.0.4" + ks := keystore.NewKeyStore(outputDir+"_", keystore.StandardScryptN, keystore.StandardScryptP)
    - 43 + 254
    + - ) + _, err := ks.ImportECDSA(pk, password)
    - 44 + 255
    + -
    + if err != nil {
    - 45 + 256
    + - // Setup + return err
    - 46 + 257
    + - var err error + }
    - 47 + 258
    + - if testing.Short() { + fileNameB, err := exec.Command("ls", outputDir+"_/").CombinedOutput()
    - 48 + 259
    + - t.Skip() + fileName := strings.TrimSuffix(string(fileNameB), "\n")
    - 49 + 260
    + - } + if err != nil {
    - 50 + 261
    + - ctx := context.Background() + fmt.Println(fileName)
    - 51 + 262
    + - defer func() { + return err
    - 52 + 263
    + - require.NoError(t, operations.Teardown()) + }
    - 53 + 264
    + - }() + out, err := exec.Command("mv", outputDir+"_/"+fileName, outputDir).CombinedOutput()
    - 54 + 265
    + - err = operations.Teardown() + if err != nil {
    - 55 + 266
    + - require.NoError(t, err) + fmt.Println(string(out))
    - 56 + 267
    + - opsCfg := operations.GetDefaultOperationsConfig() + return err
    - 57 + 268
    + - opsCfg.State.MaxCumulativeGasUsed = 80000000000 + }
    - 58 + 269
    + - opsman, err := operations.NewManager(ctx, opsCfg) + return nil
    - 59 + 270
    + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - - - - - - - - + + + + + +
    +
    @@ -196,7 +196,7 @@
    +
    + 196 + +
    +   require.NoError(t, err)
    - 60 + + 197 +
    - + - defer func() { +   + genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr)
    - 61 + + 198 +
    - + - require.NoError(t, opsman.StopDACDB()) +   + require.NoError(t, err)
    - 62 + + 199 +
    - + - }() + - + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
    - 63 + + 200 +
    - + +   err = opsman.Setup()
    - 64 + + 201 + +
    +   + require.NoError(t, err) +
    +
    + 202 + +
    +   + time.Sleep(5 * time.Second) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + - + + + +
    +
     
    +
    + 196 + +
    +   + require.NoError(t, err) +
    +
    + 197 + +
    +   + genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr) +
    +
    + 198 + +
    +   + require.NoError(t, err) +
    +
    + 199 +
    + + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6)) +
    +
    + 200 + +
    +   + err = opsman.Setup() +
    +
    + 201 + +
    +   require.NoError(t, err)
    + + 202 + +
    +   + time.Sleep(5 * time.Second) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -63,8 +63,8 @@
    +
    + 63 + +
    +   + log.Info("# Setting Genesis #") +
    +
    + 64 + +
    +   + log.Info("###################") +
    +
    65 +
    - + - require.NoError(t, opsman.StartDACDB()) +   + genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
    + 66 +
    - + - time.Sleep(5 * time.Second) + - + require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.BlockNumber, genesisActions))
    + 67 +
    - + - authL2, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID) + - + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
    + 68 +
    - + - require.NoError(t, err) +   + actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil)
    + 69 +
    - + - authL1, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID) +   + require.NoError(t, err)
    + 70 +
    - + - require.NoError(t, err) +   + require.NoError(t, opsman.Setup())
    - 71 + +
    @@ -93,7 +93,7 @@
    +
    + 93 +
    - + - clientL2, err := ethclient.Dial(operations.DefaultL2NetworkURL) +   + }
    - 72 + + 94 +
    - + - require.NoError(t, err) +   +
    - 73 + + 95 +
    - + - clientL1, err := ethclient.Dial(operations.DefaultL1NetworkURL) +   + log.Info("#######################")
    - 74 + + 96 +
    - + - require.NoError(t, err) + - + log.Info("# Verifying new leafs #")
    - 75 + + 97 +
    - + - dacSC, err := polygondatacommittee.NewPolygondatacommittee( +   + log.Info("#######################")
    - 76 + + 98 +
    - + - common.HexToAddress(operations.DefaultL1DataCommitteeContract), +   + merkleTree := opsman.State().GetTree()
    - 77 + + 99 +
    - + - clientL1, +   + for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { +
    +
    +
    +
    +
    +
    + + + + + + + + - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 63 + +
    +   + log.Info("# Setting Genesis #")
    - 78 + + 64 + +
    +   + log.Info("###################") +
    +
    + 65 + +
    +   + genesisActions := vectors.GenerateGenesisActions(testCase.Genesis) +
    +
    + 66 +
    + - ) + require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.RollupBlockNumber, genesisActions))
    - 79 + + 67 +
    + - require.NoError(t, err) + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6))
    - 80 + + 68 + +
    +   + actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil) +
    +
    + 69 + +
    +   + require.NoError(t, err) +
    +
    + 70 + +
    +   + require.NoError(t, opsman.Setup()) +
    +
    +
     
    +
    + 93 + +
    +   + } +
    +
    + 94 + +
    +   +
    +
    +
    + 95 + +
    +   + log.Info("#######################") +
    +
    + 96 +
    + + log.Info("# Verifying new leaves #") +
    +
    + 97 + +
    +   + log.Info("#######################") +
    +
    + 98 + +
    +   + merkleTree := opsman.State().GetTree() +
    +
    + 99 + +
    +   + for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc2_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + - - - - - - + + +
    +
    @@ -456,22 +456,27 @@
    +
    + 456 + +
    +   + expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 0"}, +
    +
    + 457 + +
    +   + }, +
    +
    + 458 + +
    +   + { +
    +
    + 459 + +
    + - + name: "params has only first parameter", +
    +
    + 460 + +
    + - + params: []interface{}{map[string]interface{}{"value": "0x1"}}, +
    +
    + 461 + +
    + - + expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 1"}, +
    +
    + 462 + +
    +   + }, +
    +
    + 463 + +
    +   + } +
    +
    + 464 + +
    +  
    - 81 + + 465 + +
    +   + for _, network := range networks { +
    +
    + 466 + +
    + - + log.Infof("Network %s", network.Name) +
    +
    + 467 + +
    + - + for _, testCase := range testCases { +
    +
    + + +
    +   +
    +
    +
    + 468 + +
    +   + t.Run(network.Name+testCase.name, func(t *testing.T) { +
    +
    + 469 + +
    +   + response, err := client.JSONRPCCall(network.URL, "eth_call", testCase.params...) +
    +
    + 470 + +
    +   + require.NoError(t, err) +
    +
    + 471 + +
    + - + require.NotNil(t, response.Error) +
    +
    + 472 + +
    + - + require.Nil(t, response.Result) +
    +
    + 473 + +
    + - + require.Equal(t, testCase.expectedError.Code, response.Error.Code) +
    +
    + 474 + +
    + - + require.Equal(t, testCase.expectedError.Message, response.Error.Message) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 475 + +
    +   + }) +
    +
    + 476 + +
    +   + } +
    +
    + 477 +
    - + - // Register committe with N / M signatures +   + }
    - 82 + +
    @@ -620,24 +625,39 @@
    +
    + 620 +
    - + - membs := members{} +   + txToMsg, err := sc.Increment(auth)
    - 83 + + 621 +
    - + - addrsBytes := []byte{} +   + require.NoError(t, err)
    - 84 + + 622 +
    - + - urls := []string{} +   +
    - 85 + + 623 +
    - + - for i := 0; i < mMembers; i++ { + - + // add funds to address 0x000...001 used in the test
    - 86 + + 624 +
    - + - pk, err := crypto.GenerateKey() + - + nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil)
    - 87 + + 625 +
    - + - require.NoError(t, err) + - + require.NoError(t, err)
    - 88 + + 626 +
    - + - membs = append(membs, member{ + - + value := big.NewInt(1000)
    - 89 + + 627 +
    - + - addr: crypto.PubkeyToAddress(pk.PublicKey), + - + require.NoError(t, err)
    - 90 + + 628 +
    - + - pk: pk, + - + tx = ethTypes.NewTx(&ethTypes.LegacyTx{
    - 91 + + 629 +
    - + - url: fmt.Sprintf("http://cdk-data-availability-%d:420%d", i, i), + - + Nonce: nonce,
    - 92 + + 630 +
    - + - i: i, + - + To: state.Ptr(common.HexToAddress("0x1")),
    - 93 + + 631 +
    - + - }) + - + Value: value,
    - 94 + + 632 +
    - + - } + - + Gas: 24000,
    - 95 + + 633 +
    - + - sort.Sort(membs) + - + GasPrice: gasPrice,
    - 96 + + 634 +
    - + - for _, m := range membs { + - + })
    - 97 + + 635 +
    - + - addrsBytes = append(addrsBytes, m.addr.Bytes()...) + - + signedTx, err := auth.Signer(auth.From, tx)
    - 98 + + 636 +
    - + - urls = append(urls, m.url) + - + require.NoError(t, err)
    - 99 + + 637 +
    - + - } + - + err = ethereumClient.SendTransaction(ctx, signedTx)
    - 100 + + 638 +
    - + - tx, err := dacSC.SetupCommittee(authL1, big.NewInt(nSignatures), urls, addrsBytes) + - + require.NoError(t, err)
    - 101 + + 639 +
    - + - for _, m := range membs { + - + err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined)
    - 102 + + 640 +
    - + - fmt.Println(m.addr) + - + require.NoError(t, err)
    - 103 + + -
    - + - } +
    +
    +   +
    - 104 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 105 + + -
    - + - err = operations.WaitTxToBeMined(ctx, clientL1, tx, operations.DefaultTimeoutTxToBeMined) +
    +
    +   +
    - 106 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 107 + + -
    - + +
    +
    +  
    - 108 + + -
    - + - // Spin up M DAC nodes +
    +
    +   +
    - 109 + + -
    - + - dacNodeConfig := config.Config{ +
    +
    +   +
    - 110 + + -
    - + - L1: config.L1Config{ +
    +
    +   +
    - 111 + + -
    - + - RpcURL: "http://zkevm-mock-l1-network:8545", +
    +
    +   +
    - 112 + + -
    - + - WsURL: "ws://zkevm-mock-l1-network:8546", +
    +
    +   +
    - 113 + + -
    - + - PolygonValidiumAddress: operations.DefaultL1ZkEVMSmartContract, +
    +
    +   +
    - 114 + + -
    - + - DataCommitteeAddress: operations.DefaultL1DataCommitteeContract, +
    +
    +   +
    - 115 + + -
    - + - Timeout: cTypes.Duration{Duration: time.Second}, +
    +
    +   +
    - 116 + + -
    - + - RetryPeriod: cTypes.Duration{Duration: time.Second}, +
    +
    +   +
    - 117 + + -
    - + - }, +
    +
    +   +
    - 118 + + 641 +
    - + - PrivateKey: cTypes.KeystoreFileConfig{ +   +
    - 119 + + 642 +
    - + - Path: ksFile, +   + type testCase struct {
    - 120 + + 643 +
    - + - Password: ksPass, +   + name string
    - 121 + +
    @@ -670,19 +690,15 @@
    +
    + 670 +
    - + - }, +   + name: "with gasPrice set and without from address",
    - 122 + + 671 +
    - + - DB: db.Config{ +   + address: nil,
    - 123 + + 672 +
    - + - Name: "committee_db", +   + setGasPrice: true,
    - 124 + + 673 +
    - + - User: "committee_user", + - + expectedError: types.NewRPCError(-32000, "gas required exceeds allowance"),
    - 125 + + -
    - + - Password: "committee_password", +
    +
    +   +
    - 126 + + -
    - + - Host: "zkevm-data-node-db", +
    +
    +   +
    - 127 + + -
    - + - Port: "5432", +
    +
    +   +
    - 128 + + -
    - + - EnableLog: false, +
    +
    +   +
    - 129 + + -
    - + - MaxConns: 10, +
    +
    +   +
    - 130 + + -
    - + - }, +
    +
    +   +
    - 131 + + -
    - + - RPC: rpc.Config{ +
    +
    +   +
    - 132 + + 674 +
    - + - Host: "0.0.0.0", +   + },
    - 133 + + 675 +
    - + - MaxRequestsPerIPAndSecond: 100, + - + // TODO: This test is failing due to geth bug
    - 134 + + 676 +
    - + - }, + - + // we can uncomment it when updating geth version
    - 135 + + 677 +
    - + - } + - + // on l1 image, it's returning error code -32000 when
    - 136 + + 678 +
    - + - defer func() { + - + // it should be returning error code 3 due to execution message
    - 137 + + 679 +
    - + - // Remove tmp files + - + // {
    - 138 + + 680 +
    - + - assert.NoError(t, + - + // name: "with gasPrice and value set and address with enough balance",
    - 139 + + 681 +
    - + - exec.Command("rm", cfgFile).Run(), + - + // address: state.Ptr(auth.From),
    - 140 + + 682 +
    - + - ) + - + // value: state.Ptr(int64(1)),
    - 141 + + 683 +
    - + - assert.NoError(t, + - + // setGasPrice: true,
    - 142 + + 684 +
    - + - exec.Command("rmdir", ksFile+"_").Run(), + - + // expectedError: types.NewRPCError(3, "execution reverted"),
    - 143 + + 685 +
    - + - ) + - + // },
    - 144 + + 686 +
    - + - assert.NoError(t, +   + {
    - 145 + + 687 +
    - + - exec.Command("rm", ksFile).Run(), +   + name: "with gasPrice and value set and address without enough balance",
    - 146 + + 688 +
    - + - ) +   + address: state.Ptr(common.HexToAddress("0x1")),
    - 147 + +
    @@ -697,13 +713,21 @@
    +
    + 697 +
    - + - // Stop DAC nodes +   + setGasPrice: true,
    - 148 + + 698 +
    - + - for i := 0; i < mMembers; i++ { +   + expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"),
    - 149 + + 699 +
    - + - assert.NoError(t, exec.Command( +   + },
    - 150 + + 700 +
    - + - "docker", "kill", "cdk-data-availability-"+strconv.Itoa(i), + - + {
    - 151 + + 701 +
    - + - ).Run()) + - + name: "with gasPrice and value set and without from address",
    - 152 + + 702 +
    - + - assert.NoError(t, exec.Command( + - + address: nil,
    - 153 + + 703 +
    - + - "docker", "rm", "cdk-data-availability-"+strconv.Itoa(i), + - + value: state.Ptr(int64(-1)),
    - 154 + + 704 +
    - + - ).Run()) + - + setGasPrice: true,
    - 155 + + 705 +
    - + - } + - + expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"),
    - 156 + + 706 +
    - + - // Stop permissionless node + - + },
    - 157 + + -
    - + - require.NoError(t, opsman.StopPermissionlessNodeForcedToSYncThroughDAC()) +
    +
    +   +
    - 158 + + -
    - + - }() +
    +
    +   +
    - 159 + + -
    - + - // Start permissionless node +
    +
    +   +
    - 160 + + -
    - + - require.NoError(t, opsman.StartPermissionlessNodeForcedToSYncThroughDAC()) +
    +
    +   +
    - 161 + + -
    - + - // Star DAC nodes +
    +
    +   +
    - 162 + + -
    - + - for _, m := range membs { +
    +
    +   +
    - 163 + + -
    - + - // Set correct port +
    +
    +   +
    - 164 + + -
    - + - port := 4200 + m.i +
    +
    +   +
    - 165 + + 707 +
    - + - dacNodeConfig.RPC.Port = port +   + {
    - 166 + + 708 +
    - + - // Write config file +   + name: "without gasPrice set and address with enough balance",
    - 167 + + 709 +
    - + - file, err := json.MarshalIndent(dacNodeConfig, "", " ") +   + address: state.Ptr(auth.From),
    - 168 + +
    @@ -746,7 +770,6 @@
    +
    + 746 +
    - + - require.NoError(t, err) +   + if testCase.value != nil {
    - 169 + + 747 +
    - + - err = os.WriteFile(cfgFile, file, 0644) +   + v := *testCase.value
    - 170 + + 748 +
    - + - require.NoError(t, err) +   + if v == -1 { //set the value as acc balance + 1 to force overflow
    - 171 + + 749 +
    - + - // Write private key keystore file + - +
    - 172 + + 750 +
    - + - err = createKeyStore(m.pk, ksFile, ksPass) +   + msg.Value = common.Big0.Add(balance, common.Big1)
    - 173 + + 751 +
    - + - require.NoError(t, err) +   + } else {
    - 174 + + 752 +
    - + - // Run DAC node +   + msg.Value = big.NewInt(0).SetInt64(v)
    - 175 + +
    @@ -757,7 +780,10 @@
    +
    + 757 +
    - + - cmd := exec.Command( +   + msg.GasPrice = gasPrice
    - 176 + + 758 +
    - + - "docker", "run", "-d", +   + }
    - 177 + + 759 +
    - + - "--name", "cdk-data-availability-"+strconv.Itoa(m.i), +   +
    - 178 + + 760 +
    - + - "-v", cfgFile+":/app/config.json", + - + _, err = ethereumClient.EstimateGas(ctx, msg)
    - 179 + + -
    - + - "-v", ksFile+":"+ksFile, +
    +
    +   +
    - 180 + + -
    - + - "--network", "zkevm", +
    +
    +   +
    - 181 - -
    - + - dacNodeContainer, +
    + + +
    +   +
    - 182 + + 761 +
    - + - "/bin/sh", "-c", +   + if testCase.expectedError != nil {
    - 183 + + 762 +
    - + - "/app/cdk-data-availability run --cfg /app/config.json", +   + rpcErr := err.(rpc.Error)
    - 184 + + 763 +
    - + - ) +   + errMsg := fmt.Sprintf("[%v] expected: %v %v found: %v %v", network.Name, testCase.expectedError.ErrorCode(), testCase.expectedError.Error(), rpcErr.ErrorCode(), rpcErr.Error()) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 185 + + 456 +
    - + - out, err := cmd.CombinedOutput() +   + expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 0"},
    - 186 + + 457 +
    - + - require.NoError(t, err, string(out)) +   + },
    - 187 + + 458 +
    - + - log.Infof("DAC node %d started", m.i) +   + {
    - 188 + + 459 +
    + - time.Sleep(time.Second * 5) + name: "params has only first parameter",
    - 189 + + 460 +
    + - } + params: []interface{}{map[string]interface{}{"value": "0x1", "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92267"}},
    - 190 + + -
    - + +
    +
    +  
    - 191 + + 461 +
    - + - // Send txs +   + },
    - 192 + + 462 +
    - + - nTxs := 10 +   + }
    - 193 + + 463 +
    - + - amount := big.NewInt(10000) +   +
    - 194 + + 464 +
    - + - toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8") +   + for _, network := range networks {
    - 195 + + 465 +
    + - _, err = clientL2.BalanceAt(ctx, authL2.From, nil) + t.Logf("Network %s", network.Name)
    - 196 + + 466 +
    + - require.NoError(t, err) + for tc, testCase := range testCases {
    - 197 + 467
    + - _, err = clientL2.PendingNonceAt(ctx, authL2.From) + t.Logf("testCase %d", tc)
    - 198 + + 468 +
    - + - require.NoError(t, err) +   + t.Run(network.Name+testCase.name, func(t *testing.T) {
    - 199 + + 469 +
    - + -
    +   + response, err := client.JSONRPCCall(network.URL, "eth_call", testCase.params...)
    - 200 + + 470 +
    - + - gasLimit, err := clientL2.EstimateGas(ctx, ethereum.CallMsg{From: authL2.From, To: &toAddress, Value: amount}) +   + require.NoError(t, err)
    - 201 + + 471 +
    + - require.NoError(t, err) + if (testCase.expectedError != types.ErrorObject{}) {
    - 202 + + 472 +
    + -
    + require.NotNil(t, response.Error)
    - 203 + + 473 +
    + - gasPrice, err := clientL2.SuggestGasPrice(ctx) + require.Nil(t, response.Result)
    - 204 + + 474 +
    + - require.NoError(t, err) + require.Equal(t, testCase.expectedError.Code, response.Error.Code)
    - 205 + 475
    + -
    + require.Equal(t, testCase.expectedError.Message, response.Error.Message)
    - 206 + 476
    + - nonce, err := clientL2.PendingNonceAt(ctx, authL2.From) + } else {
    - 207 + 477
    + - require.NoError(t, err) + require.Nil(t, response.Error)
    - 208 + 478
    + -
    + require.NotNil(t, response.Result)
    - 209 + 479
    + - txs := make([]*eTypes.Transaction, 0, nTxs) + }
    - 210 + + 480 +
    - + - for i := 0; i < nTxs; i++ { +   + })
    - 211 + + 481 +
    - + - tx := eTypes.NewTransaction(nonce+uint64(i), toAddress, amount, gasLimit, gasPrice, nil) +   + }
    - 212 + + 482 +
    - + - log.Infof("generating tx %d / %d: %s", i+1, nTxs, tx.Hash().Hex()) +   + }
    - 213 - -
    - + - txs = append(txs, tx) -
    +
    +
     
    - 214 + + 625 +
    - + - } +   + txToMsg, err := sc.Increment(auth)
    - 215 + + 626 +
    - + -
    +   + require.NoError(t, err)
    - 216 + + 627 +
    - + - // Wait for verification +   +
    - 217 + + 628 +
    + - _, err = operations.ApplyL2Txs(ctx, txs, authL2, clientL2, operations.VerifiedConfirmationLevel) + // addresses the test needs to have balance
    - 218 + + 629 +
    + - require.NoError(t, err) + addressesToAddBalance := map[common.Address]*big.Int{
    - 219 + + 630 +
    + -
    + // add funds to address 0x111...111 which is the default address
    - 220 + + 631 +
    + - // Assert that he permissionless node is fully synced (through the DAC) + // when estimating TXs without specifying the sender
    - 221 + + 632 +
    + - time.Sleep(30 * time.Second) // Give some time for the permissionless node to get synced + common.HexToAddress("0x1111111111111111111111111111111111111111"): big.NewInt(3000000000000000),
    - 222 + + 633 +
    + - clientL2Permissionless, err := ethclient.Dial(operations.PermissionlessL2NetworkURL) +
    - 223 + + 634 +
    + - require.NoError(t, err) + // add funds to address 0x000...001
    - 224 + + 635 +
    + - expectedBlock, err := clientL2.BlockByNumber(ctx, nil) + common.HexToAddress("0x1"): big.NewInt(1000),
    - 225 + + 636 +
    + - require.NoError(t, err) + }
    - 226 + + 637 +
    + - actualBlock, err := clientL2Permissionless.BlockByNumber(ctx, nil) +
    - 227 + + 638 +
    + - require.NoError(t, err) + for addr, value := range addressesToAddBalance {
    - 228 + + 639 +
    + - // je, err := expectedBlock.Header().MarshalJSON() + nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil)
    - 229 + + 640 +
    + - // require.NoError(t, err) + require.NoError(t, err)
    - 230 + + 641 +
    + - // log.Info(string(je)) + value := value
    - 231 + + 642 +
    + - // ja, err := actualBlock.Header().MarshalJSON() + require.NoError(t, err)
    - 232 + + 643 +
    + - // require.NoError(t, err) + tx = ethTypes.NewTx(&ethTypes.LegacyTx{
    - 233 + + 644 +
    + - // log.Info(string(ja)) + Nonce: nonce,
    - 234 + + 645 +
    + - // require.Equal(t, string(je), string(ja)) + To: state.Ptr(addr),
    - 235 + 646
    + - require.Equal(t, expectedBlock.Root().Hex(), actualBlock.Root().Hex()) + Value: value,
    - 236 + 647
    + - } + Gas: 24000,
    - 237 + 648
    + -
    + GasPrice: gasPrice,
    - 238 + 649
    + - type member struct { + })
    - 239 + 650
    + - addr common.Address + signedTx, err := auth.Signer(auth.From, tx)
    - 240 + 651
    + - pk *ecdsa.PrivateKey + require.NoError(t, err)
    - 241 + 652
    + - url string + err = ethereumClient.SendTransaction(ctx, signedTx)
    - 242 + 653
    + - i int + require.NoError(t, err)
    - 243 + 654
    + - } + err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined)
    - 244 + 655
    + - type members []member + require.NoError(t, err)
    - 245 + 656
    @@ -145181,713 +251294,627 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 246 + 657
    + - func (s members) Len() int { return len(s) } + balance, err := ethereumClient.BalanceAt(ctx, addr, nil)
    - 247 + 658
    + - func (s members) Less(i, j int) bool { + require.NoError(t, err)
    - 248 + 659
    + - return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex()) + log.Debugf("%v balance: %v", addr.String(), balance.String())
    - 249 + 660
    + - } + }
    - 250 + + 661 +
    - + - func (s members) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +   +
    - 251 + + 662 +
    - + -
    +   + type testCase struct {
    - 252 + + 663 +
    - + - func createKeyStore(pk *ecdsa.PrivateKey, outputDir, password string) error { +   + name string
    - 253 + +
     
    +
    + 690 +
    - + - ks := keystore.NewKeyStore(outputDir+"_", keystore.StandardScryptN, keystore.StandardScryptP) +   + name: "with gasPrice set and without from address",
    - 254 + + 691 +
    - + - _, err := ks.ImportECDSA(pk, password) +   + address: nil,
    - 255 + + 692 +
    - + - if err != nil { +   + setGasPrice: true,
    - 256 + + 693 +
    + - return err + expectedError: nil,
    - 257 + 694
    + - } + },
    - 258 + 695
    + - fileNameB, err := exec.Command("ls", outputDir+"_/").CombinedOutput() + {
    - 259 + 696
    + - fileName := strings.TrimSuffix(string(fileNameB), "\n") + name: "with gasPrice and value set and address with enough balance",
    - 260 + 697
    + - if err != nil { + address: state.Ptr(auth.From),
    - 261 + 698
    + - fmt.Println(fileName) + value: state.Ptr(int64(1)),
    - 262 + 699
    + - return err + setGasPrice: true,
    - 263 + 700
    + - } + expectedError: types.NewRPCError(-32000, "execution reverted"),
    - 264 + + 701 +
    - + - out, err := exec.Command("mv", outputDir+"_/"+fileName, outputDir).CombinedOutput() +   + },
    - 265 + + -
    - + - if err != nil { +
    +
    +   +
    - 266 + + -
    - + - fmt.Println(string(out)) +
    +
    +   +
    - 267 + + -
    - + - return err +
    +
    +   +
    - 268 + + -
    - + - } +
    +
    +   +
    - 269 + + -
    - + - return nil +
    +
    +   +
    - 270 + + -
    - + - } +
    +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - -
    -
    @@ -196,7 +196,7 @@
    - 196 + + -
    +
    +
      - require.NoError(t, err) +
    - 197 + + -
    +
    +
      - genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr) +
    - 198 + + -
    +
    +
      - require.NoError(t, err) +
    - 199 + + -
    - - - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6)) +
    +
    +   +
    - 200 + 702
      - err = opsman.Setup() + {
    - 201 + 703
      - require.NoError(t, err) + name: "with gasPrice and value set and address without enough balance",
    - 202 + 704
      - time.Sleep(5 * time.Second) + address: state.Ptr(common.HexToAddress("0x1")),
    -
    -
    -
    -
    - - - + - - - - - - - - - -
     
    - 196 + 713
      - require.NoError(t, err) + setGasPrice: true,
    - 197 + 714
      - genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr) + expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"),
    - 198 + 715
      - require.NoError(t, err) + },
    - 199 + 716
    + - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6)) -
    -
    - 200 - -
    -   - err = opsman.Setup() + // TODO = Review the test below in future versions of geth.
    - 201 + + 717 +
    -   - require.NoError(t, err) + + + //
    - 202 + + 718 +
    -   - time.Sleep(5 * time.Second) -
    -
    -
    + + + // Geth is returning -32000, "insufficient funds for transfer"
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -63,8 +63,8 @@
    - 63 + + 719 +
    -   - log.Info("# Setting Genesis #") + + + // zkEVM is returning 3, "execution reverted"
    - 64 + + 720 +
    -   - log.Info("###################") + + + //
    - 65 + + 721 +
    -   - genesisActions := vectors.GenerateGenesisActions(testCase.Genesis) + + + // Since the tx has value, the method increment is not payable
    - 66 + + 722 +
    - - - require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.BlockNumber, genesisActions)) + + + // and the default account has balance, the tx should revert
    - 67 + + 723 +
    - - - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6)) + + + //
    - 68 + + 724 +
    -   - actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil) + + + // {
    - 69 + + 725 +
    -   - require.NoError(t, err) + + + // name: "with gasPrice and value set and without from address",
    - 70 + + 726 +
    -   - require.NoError(t, opsman.Setup()) + + + // address: nil,
    -
    @@ -93,7 +93,7 @@
    -
    - 93 + + 727 +
    -   - } + + + // value: state.Ptr(int64(-1)),
    - 94 + + 728 +
    -   -
    + + + // setGasPrice: true,
    - 95 + + 729 +
    -   - log.Info("#######################") + + + // expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"),
    - 96 + + 730 +
    - - - log.Info("# Verifying new leafs #") + + + // },
    - 97 + 731
      - log.Info("#######################") + {
    - 98 + 732
      - merkleTree := opsman.State().GetTree() + name: "without gasPrice set and address with enough balance",
    - 99 + 733
      - for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { + address: state.Ptr(auth.From),
    -
    -
    -
    -
    - - - + - - - - - @@ -145897,72 +251924,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + @@ -148577,92 +254634,812 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + @@ -148822,147 +255629,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - + - - - - - - @@ -148997,107 +255799,97 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - @@ -149122,123 +255914,113 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -151687,6 +259194,1039 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go + RENAMED + +
    +
    +
    +
    +
     
    - 63 + 770
      - log.Info("# Setting Genesis #") + if testCase.value != nil {
    - 64 + 771
      - log.Info("###################") + v := *testCase.value
    - 65 + 772
      - genesisActions := vectors.GenerateGenesisActions(testCase.Genesis) -
    -
    - 66 - -
    - + - require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.RollupBlockNumber, genesisActions)) + if v == -1 { //set the value as acc balance + 1 to force overflow
    - 67 + + -
    - + - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6)) +
    +
    +   +
    - 68 + 773
      - actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil) + msg.Value = common.Big0.Add(balance, common.Big1)
    - 69 + 774
      - require.NoError(t, err) + } else {
    - 70 + 775
      - require.NoError(t, opsman.Setup()) + msg.Value = big.NewInt(0).SetInt64(v)
    - 93 + 780
      - } + msg.GasPrice = gasPrice
    - 94 + 781
      -
    + }
    - 95 + 782
      - log.Info("#######################") +
    - 96 + 783
    + - log.Info("# Verifying new leaves #") + gas, err := ethereumClient.EstimateGas(ctx, msg) +
    +
    + 784 + +
    + + + t.Log("testCase: ", testCase.name) +
    +
    + 785 + +
    + + + t.Log("err: ", err) +
    +
    + 786 + +
    + + + t.Log("gas: ", gas)
    - 97 + 787
      - log.Info("#######################") + if testCase.expectedError != nil {
    - 98 + 788
      - merkleTree := opsman.State().GetTree() + rpcErr := err.(rpc.Error)
    - 99 + 789
      - for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { + errMsg := fmt.Sprintf("[%v] expected: %v %v found: %v %v", network.Name, testCase.expectedError.ErrorCode(), testCase.expectedError.Error(), rpcErr.ErrorCode(), rpcErr.Error())
    - 29 + 29 + +
    +   + DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover +
    +
    + 30 + +
    +   + DOCKERCOMPOSENODEAPPROVE := zkevm-approve +
    +
    + 31 + +
    +   + DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2 +
    +
    +
    @@ -62,6 +63,7 @@
    +
    + 62 + +
    +   +
    +
    +
    + 63 + +
    +   + RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB) +
    +
    + 64 + +
    +   + RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE) +
    +
    + + +
    +   +
    +
    +
    + 65 + +
    +   + RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) +
    +
    + 66 + +
    +   +
    +
    +
    + 67 + +
    +   + RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE) +
    +
    +
    @@ -101,6 +103,7 @@
    +
    + 101 + +
    +   +
    +
    +
    + 102 + +
    +   + STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB) +
    +
    + 103 + +
    +   + STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE) +
    +
    + + +
    +   +
    +
    +
    + 104 + +
    +   + STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) +
    +
    + 105 + +
    +   +
    +
    +
    + 106 + +
    +   + STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE) +
    +
    +
    @@ -110,6 +113,9 @@
    +
    + 110 + +
    +   +
    +
    +
    + 111 + +
    +   + STOP := $(DOCKERCOMPOSE) down --remove-orphans +
    +
    + 112 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 113 + +
    +   + .PHONY: test-full-non-e2e +
    +
    + 114 + +
    +   + test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions +
    +
    + 115 + +
    +   + $(RUNSTATEDB) +
    +
    +
    @@ -248,6 +254,17 @@
    +
    + 248 + +
    +   + docker logs $(DOCKERCOMPOSEZKPROVER) +
    +
    + 249 + +
    +   + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/... +
    +
    + 250 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 251 + +
    +   + .PHONY: benchmark-sequencer-eth-transfers +
    +
    + 252 + +
    +   + benchmark-sequencer-eth-transfers: stop +
    +
    + 253 + +
    +   + $(RUNL1NETWORK) +
    +
    +
    @@ -364,7 +381,7 @@
    +
    + 364 + +
    +   + $(STOPZKPROVER) +
    +
    + 365 + +
    +   +
    +
    +
    + 366 + +
    +   + .PHONY: run-l1-explorer +
    +
    + 367 + +
    + - + run-l1-explorer: ## Runs L1 blockscan explorer +
    +
    + 368 + +
    +   + $(RUNEXPLORERL1DB) +
    +
    + 369 + +
    +   + $(RUNEXPLORERL1) +
    +
    + 370 + +
    +   +
    +
    +
    +
    @@ -434,7 +451,7 @@
    +
    + 434 + +
    +   + .PHONY: stop-seqsender-v1tov2 +
    +
    + 435 + +
    +   + stop-seqsender-v1tov2: ## stops the sequencer sender +
    +
    + 436 + +
    +   + $(STOPV1TOV2SEQUENCESENDER) +
    +
    + 437 + +
    + - + +
    +
    + 438 + +
    +   + .PHONY: run-sync +
    +
    + 439 + +
    +   + run-sync: ## runs the synchronizer +
    +
    + 440 + +
    +   + $(RUNSYNC) +
    +
    +
    @@ -498,7 +515,7 @@
    +
    + 498 + +
    +   + .PHONY: stop-eth-tx-manager-v1tov2 +
    +
    + 499 + +
    +   + stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service +
    +
    + 500 + +
    +   + $(STOPV1TOV2ETHTXMANAGER) +
    +
    + 501 + +
    + - + +
    +
    + 502 + +
    +   + .PHONY: run-agg +
    +
    + 503 + +
    +   + run-agg: ## Runs the aggregator service +
    +
    + 504 + +
    +   + $(RUNAGGREGATOR) +
    +
    +
    @@ -540,7 +557,7 @@
    +
    + 540 + +
    +   + $(RUNPERMISSIONLESSDB) +
    +
    + 541 + +
    +   + sleep 3 +
    +
    + 542 + +
    +   + $(RUNPERMISSIONLESSZKPROVER) +
    +
    + 543 + +
    + - + +
    +
    + 544
      - DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover +
    - 30 + 545
      - DOCKERCOMPOSENODEAPPROVE := zkevm-approve + PHONY: stop-permissionless-dependencies
    - 31 + 546
      - DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2 + stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node
    -
    @@ -62,6 +63,7 @@
    +
    @@ -629,7 +646,7 @@
    - 62 + 629
      -
    + go run ./scripts/init_network/main.go .
    - 63 + 630
      - RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB) +
    - 64 + 631
      - RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE) + .PHONY: show-logs
    - + + 632 -
    -   -
    +
    +
    + - + show-logs: ## Show logs for running docker
    - 65 + 633
      - RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) + $(DOCKERCOMPOSE) logs
    - 66 + 634
    @@ -148672,132 +255449,162 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 67 + 635
      - RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE) + .PHONY: deploy-sc
    -
    @@ -101,6 +103,7 @@
    +
    @@ -669,7 +686,7 @@
    - 101 + 669
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=StateMock --filename=mock_state.go
    - 102 + 670
      - STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB) + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=txPool --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=PoolMock --filename=mock_pool.go
    - 103 + 671
      - STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE) + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../sequencer --outpkg=sequencer --structname=DbTxMock --filename=mock_dbtx.go
    - + + 672 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=etherman --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go
    - 104 + 673
      - STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) +
    - 105 + 674
      -
    + .PHONY: generate-mocks-sequencesender
    - 106 + 675
      - STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE) + generate-mocks-sequencesender: ## Generates mocks for sequencesender , using mockery tool
    -
    @@ -110,6 +113,9 @@
    +
    @@ -685,10 +702,12 @@
    - 110 + 685
      -
    + .PHONY: generate-mocks-synchronizer
    - 111 + 686
      - STOP := $(DOCKERCOMPOSE) down --remove-orphans + generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool
    - 112 + 687
      -
    + ## mocks for synchronizer
    - + + 688 -
    -   -
    +
    +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} +
    +
    + 689 + +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS} +
    +
    + 690 + +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethTxManager --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} +
    +
    + 691 + +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
    - 113 + 692
      - .PHONY: test-full-non-e2e + for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \
    - 114 + 693
      - test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions + camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \
    - 115 + 694
      - $(RUNSTATEDB) + echo $$camelcase ; \
    -
    @@ -248,6 +254,17 @@
    +
    @@ -697,7 +716,7 @@
    - 248 + 697
      - docker logs $(DOCKERCOMPOSEZKPROVER) +
    - 249 + 698
      - trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/... + rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks
    - 250 + 699
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS}
    - + + 700 -
    -   -
    +
    +
    + - +
    - + + 701 -
    +
    +
      -
    + rm -Rf ../synchronizer/l2_sync/l2_shared/mocks
    - + + 702 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS}
    - + + 703 -
    +
    +
      -
    +
    - - -
    -   -
    -
    +
    +
    @@ -707,6 +726,9 @@
    - + + 707 -
    +
    +
      -
    + rm -Rf ../synchronizer/actions/elderberry/mocks
    - + + 708 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS}
    - + + 709 -
    +
    +
      -
    +
    - 251 + 710
      - .PHONY: benchmark-sequencer-eth-transfers +
    - 252 + 711
      - benchmark-sequencer-eth-transfers: stop +
    - 253 + 712
      - $(RUNL1NETWORK) + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS}
    -
    @@ -685,10 +702,12 @@
    +
    @@ -723,7 +745,11 @@
    - 685 + 723
      - .PHONY: generate-mocks-synchronizer + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go
    - 686 + 724
      - generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
    - 687 + 725
      - ## mocks for synchronizer -
    -
    - 688 - -
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} +
    - 689 + 726
    - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS} + .PHONY: generate-mocks-aggregator
    - 690 + + -
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethTxManager --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} +
    +
    +   +
    - 691 + + -
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS} +
    +
    +   +
    - 692 + 727
      - for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \ + generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
    - 693 + 728
      - camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \ + ## mocks for the aggregator tests
    - 694 + 729
      - echo $$camelcase ; \ + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go
    -
    @@ -722,6 +741,8 @@
    +
    @@ -733,7 +759,7 @@
    - 722 + 733
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go
    - 723 + 734
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go
    - 724 + 735
    -   - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go -
    -
    - - -
     
    - + + 736 -
    -   -
    +
    +
    + - + .PHONY: generate-mocks-state
    - 725 + 737
      -
    + generate-mocks-state: ## Generates mocks for state , using mockery tool
    - 726 + 738
      - .PHONY: generate-mocks-aggregator + ## mocks for the aggregator tests
    - 727 + 739
      - generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter
    -
    @@ -745,6 +766,27 @@
    +
    @@ -745,6 +771,27 @@
    @@ -150064,6 +256846,456 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    + 381 + +
    +   + $(STOPZKPROVER) +
    +
    + 382 + +
    +   +
    +
    +
    + 383 + +
    +   + .PHONY: run-l1-explorer +
    +
    + 384 + +
    + + + run-l1-explorer: ## Runs L1 blockscan explorer +
    +
    + 385 + +
    +   + $(RUNEXPLORERL1DB) +
    +
    + 386 + +
    +   + $(RUNEXPLORERL1) +
    +
    + 387 + +
    +   +
    +
    +
    +
     
    +
    + 451 + +
    +   + .PHONY: stop-seqsender-v1tov2 +
    +
    + 452 + +
    +   + stop-seqsender-v1tov2: ## stops the sequencer sender +
    +
    + 453 + +
    +   + $(STOPV1TOV2SEQUENCESENDER) +
    +
    + 454 + +
    + + +
    +
    +
    + 455 + +
    +   + .PHONY: run-sync +
    +
    + 456 + +
    +   + run-sync: ## runs the synchronizer +
    +
    + 457 + +
    +   + $(RUNSYNC) +
    +
    +
     
    +
    + 515 + +
    +   + .PHONY: stop-eth-tx-manager-v1tov2 +
    +
    + 516 + +
    +   + stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service +
    +
    + 517 + +
    +   + $(STOPV1TOV2ETHTXMANAGER) +
    +
    + 518 + +
    + + +
    +
    +
    + 519 + +
    +   + .PHONY: run-agg +
    +
    + 520 + +
    +   + run-agg: ## Runs the aggregator service +
    +
    + 521 + +
    +   + $(RUNAGGREGATOR) +
    +
    +
     
    +
    + 557 + +
    +   + $(RUNPERMISSIONLESSDB) +
    +
    + 558 + +
    +   + sleep 3 +
    +
    + 559 + +
    +   + $(RUNPERMISSIONLESSZKPROVER) +
    +
    + 560 + +
    + + +
    +
    +
    + 561 + +
    +   +
    +
    +
    + 562 + +
    +   + PHONY: stop-permissionless-dependencies +
    +
    + 563 + +
    +   + stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node +
    +
    +
     
    +
    + 646 + +
    +   + go run ./scripts/init_network/main.go . +
    +
    + 647 + +
    +   +
    +
    +
    + 648 + +
    +   + .PHONY: show-logs +
    +
    + 649 + +
    + + + show-logs: ## Show logs for running docker +
    +
    + 650 + +
    +   + $(DOCKERCOMPOSE) logs +
    +
    + 651 + +
    +   +
    +
    +
    + 652 + +
    +   + .PHONY: deploy-sc +
    +
    +
     
    +
    + 686 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=StateMock --filename=mock_state.go +
    +
    + 687 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=txPool --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=PoolMock --filename=mock_pool.go +
    +
    + 688 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../sequencer --outpkg=sequencer --structname=DbTxMock --filename=mock_dbtx.go +
    +
    + 689 + +
    + + + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go +
    +
    + 690 + +
    +   +
    +
    +
    + 691 + +
    +   + .PHONY: generate-mocks-sequencesender +
    +
    + 692 + +
    +   + generate-mocks-sequencesender: ## Generates mocks for sequencesender , using mockery tool +
    +
    +
     
    +
    702 @@ -150191,7 +257423,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 741 + 716
    @@ -150201,47 +257433,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 742 + 717
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go + rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks
    - 743 + 718
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS} +
    +
    + 719 + +
    + + +
    +
    +
    + 720 + +
    +   + rm -Rf ../synchronizer/l2_sync/l2_shared/mocks +
    +
    + 721 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS} +
    +
    + 722 + +
    +   + +
    +
    +
     
    +
    + 726 + +
    +   + rm -Rf ../synchronizer/actions/elderberry/mocks +
    +
    + 727 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} +
    +
    + 728 + +
    +   +
    - 744 + 729
    + - + rm -Rf ../synchronizer/l1_check_block/mocks
    - 745 + 730 + +
    + + + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l1_check_block --output ../synchronizer/l1_check_block/mocks --outpkg mock_l1_check_block ${COMMON_MOCKERY_PARAMS} +
    +
    + 731
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=dataAvailabilityProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=daMock --filename=mock_da.go +
    - 746 + 732 + +
    +   + +
    +
    + 733
    @@ -150251,24 +257578,129 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 747 + 734 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} +
    +
    +
     
    +
    + 745 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go +
    +
    + 746
      - .PHONY: generate-mocks-aggregator + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
    + 747 + +
    +   +
    +
    +
    748 +
    + + + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=dataAvailabilityProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=daMock --filename=mock_da.go +
    +
    + 749 + +
    + + + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=stateMock --filename=mock_state.go +
    +
    + 750 + +
    + + +
    +
    +
    + 751 + +
    + + +
    +
    +
    + 752 + +
    + + + .PHONY: generate-mocks-aggregator +
    +
    + 753 +
      generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
    + 754 + +
    +   + ## mocks for the aggregator tests +
    +
    + 755 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go +
    +
    @@ -150276,7 +257708,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 766 + 759 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go +
    +
    + 760 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go +
    +
    + 761 + +
    +   +
    +
    +
    + 762 + +
    + + + .PHONY: generate-mocks-state +
    +
    + 763 + +
    +   + generate-mocks-state: ## Generates mocks for state , using mockery tool +
    +
    + 764 + +
    +   + ## mocks for the aggregator tests +
    +
    + 765 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter +
    +
    +
     
    +
    + 771
    @@ -150286,7 +257793,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 767 + 772
    @@ -150296,7 +257803,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 768 + 773
    @@ -150306,7 +257813,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 769 + 774
    @@ -150316,7 +257823,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 770 + 775
    @@ -150326,7 +257833,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 771 + 776
    @@ -150336,7 +257843,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 772 + 777
    @@ -150346,7 +257853,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 773 + 778
    @@ -150356,7 +257863,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 774 + 779
    @@ -150366,7 +257873,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 775 + 780
    @@ -150376,7 +257883,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 776 + 781
    @@ -150386,7 +257893,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 777 + 782
    @@ -150396,7 +257903,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 778 + 783
    @@ -150406,7 +257913,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 779 + 784
    @@ -150416,7 +257923,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 780 + 785
    @@ -150426,7 +257933,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 781 + 786
    @@ -150436,7 +257943,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 782 + 787
    @@ -150446,7 +257953,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 783 + 788
    @@ -150456,7 +257963,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 784 + 789
    @@ -150466,7 +257973,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 785 + 790
    @@ -150476,7 +257983,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 786 + 791
    @@ -150486,7 +257993,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 787 + 792
    @@ -150496,7 +258003,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 788 + 793
    @@ -150506,7 +258013,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 789 + 794
    @@ -150516,7 +258023,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 790 + 795
    @@ -150526,7 +258033,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 791 + 796
    @@ -150536,7 +258043,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 792 + 797
    @@ -151572,7 +259079,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, nil) + ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, nil, nil)
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -558,14 +558,13 @@
    +
    + 558 + +
    +   + os.Exit(1) +
    +
    + 559 + +
    +   + } +
    +
    + 560 + +
    +   +
    +
    +
    + 561 + +
    + - + client.FromEntry = cliCtx.Uint64("entry") +
    +
    + 562 + +
    + - + err = client.ExecCommand(datastreamer.CmdEntry) +
    +
    + 563 + +
    +   + if err != nil { +
    +
    + 564 + +
    +   + log.Error(err) +
    +
    + 565 + +
    +   + os.Exit(1) +
    +
    + 566 + +
    +   + } +
    +
    + 567 + +
    +   +
    +
    +
    + 568 + +
    + - + printEntry(client.Entry) +
    +
    + 569 + +
    +   + return nil +
    +
    + 570 + +
    +   + } +
    +
    + 571 + +
    +   +
    +
    +
    +
    @@ -597,35 +596,28 @@
    +
    + 597 + +
    +   + Value: l2BlockNumber, +
    +
    + 598 + +
    +   + } +
    +
    + 599 + +
    +   +
    +
    +
    + 600 + +
    + - + client.FromBookmark = bookMark.Encode() +
    +
    + 601 + +
    + - + err = client.ExecCommand(datastreamer.CmdBookmark) +
    +
    + 602 + +
    +   + if err != nil { +
    +
    + 603 + +
    +   + log.Error(err) +
    +
    + 604 + +
    +   + os.Exit(1) +
    +
    + 605 + +
    +   + } +
    +
    + 606 + +
    + - +
    +
    +
    + 607 + +
    + - + firstEntry := client.Entry +
    +
    + 608 + +
    +   + printEntry(firstEntry) +
    +
    + 609 + +
    +   +
    +
    +
    + 610 + +
    + - + client.FromEntry = firstEntry.Number + 1 +
    +
    + 611 + +
    + - + err = client.ExecCommand(datastreamer.CmdEntry) +
    +
    + 612 + +
    +   + if err != nil { +
    +
    + 613 + +
    +   + log.Error(err) +
    +
    + 614 + +
    +   + os.Exit(1) +
    +
    + 615 + +
    +   + } +
    +
    + 616 + +
    + - +
    +
    +
    + 617 + +
    + - + secondEntry := client.Entry +
    +
    + 618 + +
    +   + printEntry(secondEntry) +
    +
    + 619 + +
    +   +
    +
    +
    + 620 + +
    +   + i := uint64(2) //nolint:gomnd +
    +
    + 621 + +
    +   + for secondEntry.Type == state.EntryTypeL2Tx { +
    +
    + 622 + +
    + - + client.FromEntry = firstEntry.Number + i +
    +
    + 623 + +
    + - + err = client.ExecCommand(datastreamer.CmdEntry) +
    +
    + 624 + +
    +   + if err != nil { +
    +
    + 625 + +
    +   + log.Error(err) +
    +
    + 626 + +
    +   + os.Exit(1) +
    +
    + 627 + +
    +   + } +
    +
    + 628 + +
    + - + secondEntry = client.Entry +
    +
    + 629 + +
    +   + printEntry(secondEntry) +
    +
    + 630 + +
    +   + i++ +
    +
    + 631 + +
    +   + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 558 + +
    +   + os.Exit(1) +
    +
    + 559 + +
    +   + } +
    +
    + 560 + +
    +   +
    +
    +
    + 561 + +
    + + + entry, err := client.ExecCommandGetEntry(cliCtx.Uint64("entry")) +
    +
    + + +
    +   +
    +
    +
    + 562 + +
    +   + if err != nil { +
    +
    + 563 + +
    +   + log.Error(err) +
    +
    + 564 + +
    +   + os.Exit(1) +
    +
    + 565 + +
    +   + } +
    +
    + 566 + +
    +   +
    +
    +
    + 567 + +
    + + + printEntry(entry) +
    +
    + 568 + +
    +   + return nil +
    +
    + 569 + +
    +   + } +
    +
    + 570 + +
    +   +
    +
    +
    +
     
    +
    + 596 + +
    +   + Value: l2BlockNumber, +
    +
    + 597 + +
    +   + } +
    +
    + 598 + +
    +   +
    +
    +
    + 599 + +
    + + + firstEntry, err := client.ExecCommandGetBookmark(bookMark.Encode()) +
    +
    + + +
    +   +
    +
    +
    + 600 + +
    +   + if err != nil { +
    +
    + 601 + +
    +   + log.Error(err) +
    +
    + 602 + +
    +   + os.Exit(1) +
    +
    + 603 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 604 + +
    +   + printEntry(firstEntry) +
    +
    + 605 + +
    +   +
    +
    +
    + 606 + +
    + + + secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1) +
    +
    + + +
    +   +
    +
    +
    + 607 + +
    +   + if err != nil { +
    +
    + 608 + +
    +   + log.Error(err) +
    +
    + 609 + +
    +   + os.Exit(1) +
    +
    + 610 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 611 + +
    +   + printEntry(secondEntry) +
    +
    + 612 + +
    +   +
    +
    +
    + 613 + +
    +   + i := uint64(2) //nolint:gomnd +
    +
    + 614 + +
    +   + for secondEntry.Type == state.EntryTypeL2Tx { +
    +
    + 615 + +
    + + + entry, err := client.ExecCommandGetEntry(firstEntry.Number + i) +
    +
    + + +
    +   +
    +
    +
    + 616 + +
    +   + if err != nil { +
    +
    + 617 + +
    +   + log.Error(err) +
    +
    + 618 + +
    +   + os.Exit(1) +
    +
    + 619 + +
    +   + } +
    +
    + 620 + +
    + + + secondEntry = entry +
    +
    + 621 + +
    +   + printEntry(secondEntry) +
    +
    + 622 + +
    +   + i++ +
    +
    + 623 + +
    +   + } +
    +
    +
    +
    +
    +
    @@ -152806,7 +261346,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil) + etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil)
    From 45d64edea0025f21f05631069089c9bbb9e05680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Fri, 26 Apr 2024 08:18:50 +0200 Subject: [PATCH 16/21] Fix non-e2e tests --- synchronizer/synchronizer.go | 2 +- synchronizer/synchronizer_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 32558f4eff..f29421aad6 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -999,7 +999,7 @@ func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, synce log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) // Compare hashes - if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupManagerBlockNumber { + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupBlockNumber { log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) diff --git a/synchronizer/synchronizer_test.go b/synchronizer/synchronizer_test.go index ef1ec076af..3d9768cd07 100644 --- a/synchronizer/synchronizer_test.go +++ b/synchronizer/synchronizer_test.go @@ -921,7 +921,7 @@ func expectedCallsForsyncTrustedState(t *testing.T, m *mocks, sync *ClientSynchr func TestReorg(t *testing.T) { genesis := state.Genesis{ - BlockNumber: uint64(0), + RollupBlockNumber: uint64(0), } cfg := Config{ SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, @@ -1241,7 +1241,7 @@ func TestReorg(t *testing.T) { func TestLatestSyncedBlockEmpty(t *testing.T) { genesis := state.Genesis{ - BlockNumber: uint64(0), + RollupBlockNumber: uint64(0), } cfg := Config{ SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, @@ -1455,7 +1455,7 @@ func TestLatestSyncedBlockEmpty(t *testing.T) { func TestRegularReorg(t *testing.T) { genesis := state.Genesis{ - BlockNumber: uint64(0), + RollupBlockNumber: uint64(0), } cfg := Config{ SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, @@ -1737,7 +1737,7 @@ func TestRegularReorg(t *testing.T) { func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { genesis := state.Genesis{ - BlockNumber: uint64(0), + RollupBlockNumber: uint64(0), } cfg := Config{ SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, @@ -2013,7 +2013,7 @@ func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { func TestCallFromEmptyBlockAndReorg(t *testing.T) { genesis := state.Genesis{ - BlockNumber: uint64(0), + RollupBlockNumber: uint64(0), } cfg := Config{ SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, From d5757c058405b073da1cc967275002d8b2f6b296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Fri, 10 May 2024 16:33:19 +0200 Subject: [PATCH 17/21] Update the docker image for the mock L1 network --- test/config/test.genesis.config.json | 182 +++++++++++++-------------- test/docker-compose.yml | 2 +- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/test/config/test.genesis.config.json b/test/config/test.genesis.config.json index 1f24ff2a62..07e6ca839c 100644 --- a/test/config/test.genesis.config.json +++ b/test/config/test.genesis.config.json @@ -6,96 +6,96 @@ "polTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "polygonZkEVMGlobalExitRootAddress": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" }, - "rollupCreationBlockNumber": 83, - "rollupManagerCreationBlockNumber": 74, - "root": "0xcc9ec17819f4ac7f282949ca8c379c4d3ee1b8b7908c51b9b405b6319af67b32", + "rollupCreationBlockNumber": 45, + "rollupManagerCreationBlockNumber": 40, + "root": "0x489e44072604e671274ea693d5309e797fb37a3e0d91e5b0f04639c251c05332", "genesis": [ - { - "contractName": "PolygonZkEVMDeployer", - "balance": "0", - "nonce": "4", - "address": "0x51dbd54FCCb6b3A07738fd3E156D588e71f79973", - "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220964619cee0e0baf94c6f8763f013be157da5d54c89e5cff4a8caf4266e13f13a64736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" - } - }, - { - "contractName": "ProxyAdmin", - "balance": "0", - "nonce": "1", - "address": "0xe34Fe58DDa5b8c6D547E4857E987633aa86a5e90", - "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220c9867ffac53151bdb1305d8f5e3e883cd83e5270c7ec09cdc24e837b2e65239064736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" - } - }, - { - "contractName": "PolygonZkEVMBridge implementation", - "balance": "0", - "nonce": "1", - "address": "0x493732fB136a380920C390a85fc27d79C7b70756", - "bytecode": "0x6080604052600436106101a35760003560e01c806383f24403116100e2578063ccaa2d1111610085578063ccaa2d1114610511578063cd58657914610531578063d02103ca14610544578063dbc169761461056b578063ee25560b14610580578063f5efcd79146105ad578063f811bff7146105cd578063fb570834146105ed57600080fd5b806383f244031461040b5780638ed7e3f21461042b578063aaa13cc21461044b578063b8b284d01461046b578063bab161bf1461048b578063be5831c7146104ad578063c00f14ab146104d1578063cc461632146104f157600080fd5b80633cbc795b1161014a5780633cbc795b146102fd5780633e197043146103365780634b2f336d146103565780635ca1e165146103765780637843298b1461038b57806379e2cf97146103ab57806381b1c174146103c057806383c43a55146103f657600080fd5b806315064c96146101a85780632072f6c5146101d757806322e95f2c146101ee578063240ff3781461021b57806327aef4e81461022e5780632dfdf0b514610250578063318aee3d146102745780633c351e10146102dd575b600080fd5b3480156101b457600080fd5b506068546101c29060ff1681565b60405190151581526020015b60405180910390f35b3480156101e357600080fd5b506101ec61060d565b005b3480156101fa57600080fd5b5061020e610209366004612b65565b610642565b6040516101ce9190612b9c565b6101ec610229366004612c06565b610693565b34801561023a57600080fd5b50610243610703565b6040516101ce9190612ccf565b34801561025c57600080fd5b5061026660535481565b6040519081526020016101ce565b34801561028057600080fd5b506102b961028f366004612ce9565b606b6020526000908152604090205463ffffffff811690600160201b90046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016101ce565b3480156102e957600080fd5b50606d5461020e906001600160a01b031681565b34801561030957600080fd5b50606d5461032190600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101ce565b34801561034257600080fd5b50610266610351366004612d15565b610791565b34801561036257600080fd5b50606f5461020e906001600160a01b031681565b34801561038257600080fd5b5061026661081e565b34801561039757600080fd5b5061020e6103a6366004612d94565b6108fb565b3480156103b757600080fd5b506101ec610925565b3480156103cc57600080fd5b5061020e6103db366004612ddd565b606a602052600090815260409020546001600160a01b031681565b34801561040257600080fd5b50610243610946565b34801561041757600080fd5b50610266610426366004612e08565b610965565b34801561043757600080fd5b50606c5461020e906001600160a01b031681565b34801561045757600080fd5b5061020e610466366004612f12565b610a3b565b34801561047757600080fd5b506101ec610486366004612fad565b610b3d565b34801561049757600080fd5b5060685461032190610100900463ffffffff1681565b3480156104b957600080fd5b5060685461032190600160c81b900463ffffffff1681565b3480156104dd57600080fd5b506102436104ec366004612ce9565b610c04565b3480156104fd57600080fd5b506101c261050c36600461302f565b610c49565b34801561051d57600080fd5b506101ec61052c366004613062565b610cd2565b6101ec61053f36600461314d565b6111c7565b34801561055057600080fd5b5060685461020e90600160281b90046001600160a01b031681565b34801561057757600080fd5b506101ec611621565b34801561058c57600080fd5b5061026661059b366004612ddd565b60696020526000908152604090205481565b3480156105b957600080fd5b506101ec6105c8366004613062565b611654565b3480156105d957600080fd5b506101ec6105e83660046131e2565b6118ef565b3480156105f957600080fd5b506101c261060836600461328a565b611b62565b606c546001600160a01b0316331461063857604051631736745960e31b815260040160405180910390fd5b610640611b7a565b565b6000606a6000848460405160200161065b9291906132d2565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b60685460ff16156106b757604051630bc011ff60e21b815260040160405180910390fd5b34158015906106d05750606f546001600160a01b031615155b156106ee576040516301bd897160e61b815260040160405180910390fd5b6106fc858534868686611bd6565b5050505050565b606e8054610710906132fc565b80601f016020809104026020016040519081016040528092919081815260200182805461073c906132fc565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526001600160601b0319606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b605354600090819081805b60208110156108f2578083901c600116600103610886576033816020811061085357610853613336565b015460408051602081019290925281018590526060016040516020818303038152906040528051906020012093506108b3565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806108ea90613362565b915050610829565b50919392505050565b600061091d848461090b85611ca0565b61091486611d5f565b61046687611e17565b949350505050565b605354606854600160c81b900463ffffffff16101561064057610640611ecf565b60405180611ba00160405280611b668152602001613a7a611b66913981565b600083815b6020811015610a3257600163ffffffff8516821c811690036109d55784816020811061099857610998613336565b6020020135826040516020016109b8929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a20565b818582602081106109e8576109e8613336565b6020020135604051602001610a07929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a2a81613362565b91505061096a565b50949350505050565b6000808686604051602001610a519291906132d2565b604051602081830303815290604052805190602001209050600060ff60f81b308360405180611ba00160405280611b668152602001613a7a611b669139898989604051602001610aa39392919061337b565b60408051601f1981840301815290829052610ac192916020016133b4565b60405160208183030381529060405280519060200120604051602001610b1994939291906001600160f81b031994909416845260609290921b6001600160601b03191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610b6157604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610b8a5760405163dde3cda760e01b815260040160405180910390fd5b606f54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610bbc90339088906004016133e3565b600060405180830381600087803b158015610bd657600080fd5b505af1158015610bea573d6000803e3d6000fd5b50505050610bfc868686868686611bd6565b505050505050565b6060610c0f82611ca0565b610c1883611d5f565b610c2184611e17565b604051602001610c339392919061337b565b6040516020818303038152906040529050919050565b6068546000908190610100900463ffffffff16158015610c6f575063ffffffff83166001145b15610c81575063ffffffff8316610ca8565b610c95600160201b63ffffffff85166133fc565b610ca59063ffffffff8616613413565b90505b600881901c600090815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610cf657604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610d26576040516302caf51760e11b815260040160405180910390fd5b610d5a8c8c8c8c8c610d5560008e8e8e8e8e8e8e604051610d48929190613426565b6040518091039020610791565b611f68565b6001600160a01b038616610e9257606f546001600160a01b0316610e295760006001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610db1576020820181803683370190505b50604051610dbf9190613436565b60006040518083038185875af1925050503d8060008114610dfc576040519150601f19603f3d011682016040523d82523d6000602084013e610e01565b606091505b5050905080610e2357604051630ce8f45160e31b815260040160405180910390fd5b5061117a565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990610e5b90879087906004016133e3565b600060405180830381600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b5050505061117a565b606d546001600160a01b038781169116148015610ec05750606d5463ffffffff888116600160a01b90920416145b15610ed85760006001600160a01b0385168482610d87565b60685463ffffffff610100909104811690881603610f0957610f046001600160a01b03871685856120c7565b61117a565b60008787604051602001610f1e9291906132d2565b60408051601f1981840301815291815281516020928301206000818152606a9093529120549091506001600160a01b031680611116576000610f968386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061212292505050565b6040516340c10f1960e01b81529091506001600160a01b038216906340c10f1990610fc7908a908a906004016133e3565b600060405180830381600087803b158015610fe157600080fd5b505af1158015610ff5573d6000803e3d6000fd5b5050505080606a600085815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b6000836001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a83888860405161110895949392919061347b565b60405180910390a150611177565b6040516340c10f1960e01b81526001600160a01b038216906340c10f199061114490899089906004016133e3565b600060405180830381600087803b15801561115e57600080fd5b505af1158015611172573d6000803e3d6000fd5b505050505b50505b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8a888887876040516111b19594939291906134b4565b60405180910390a1505050505050505050505050565b60685460ff16156111eb57604051630bc011ff60e21b815260040160405180910390fd5b6111f361219e565b60685463ffffffff610100909104811690881603611224576040516302caf51760e11b815260040160405180910390fd5b6000806060876001600160a01b03881661130a578834146112585760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611285906132fc565b80601f01602080910402602001604051908101604052809291908181526020018280546112b1906132fc565b80156112fe5780601f106112d3576101008083540402835291602001916112fe565b820191906000526020600020905b8154815290600101906020018083116112e157829003601f168201915b50505050509150611596565b34156113295760405163798ee6f160e01b815260040160405180910390fd5b606f546001600160a01b03908116908916036113a457604051632770a7eb60e21b81526001600160a01b03891690639dc29fac9061136d9033908d906004016133e3565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b50505050611596565b6001600160a01b038089166000908152606b602090815260409182902082518084019093525463ffffffff81168352600160201b9004909216918101829052901561145c57604051632770a7eb60e21b81526001600160a01b038a1690639dc29fac906114179033908e906004016133e3565b600060405180830381600087803b15801561143157600080fd5b505af1158015611445573d6000803e3d6000fd5b505050508060200151945080600001519350611589565b851561146e5761146e898b89896121f7565b6040516370a0823160e01b81526000906001600160a01b038b16906370a082319061149d903090600401612b9c565b602060405180830381865afa1580156114ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114de91906134e6565b90506114f56001600160a01b038b1633308e61253d565b6040516370a0823160e01b81526000906001600160a01b038c16906370a0823190611524903090600401612b9c565b602060405180830381865afa158015611541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156591906134e6565b905061157182826134ff565b6068548c9850610100900463ffffffff169650935050505b61159289610c04565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e86886053546040516115d6989796959493929190613512565b60405180910390a16115fd6115f8600085878f8f878980519060200120610791565b612575565b861561160b5761160b611ecf565b5050505061161860018055565b50505050505050565b606c546001600160a01b0316331461164c57604051631736745960e31b815260040160405180910390fd5b610640612660565b60685460ff161561167857604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146116a8576040516302caf51760e11b815260040160405180910390fd5b6116ca8c8c8c8c8c610d5560018e8e8e8e8e8e8e604051610d48929190613426565b606f546000906001600160a01b031661178157846001600160a01b031684888a86866040516024016116ff949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b179052516117349190613436565b60006040518083038185875af1925050503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b505080915050611883565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906117b390889088906004016133e3565b600060405180830381600087803b1580156117cd57600080fd5b505af11580156117e1573d6000803e3d6000fd5b50505050846001600160a01b031687898585604051602401611806949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183b9190613436565b6000604051808303816000865af19150503d8060008114611878576040519150601f19603f3d011682016040523d82523d6000602084013e61187d565b606091505b50909150505b806118a1576040516337e391c360e01b815260040160405180910390fd5b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8b898988886040516118d89594939291906134b4565b60405180910390a150505050505050505050505050565b600054610100900460ff161580801561190f5750600054600160ff909116105b806119295750303b158015611929575060005460ff166001145b6119915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119b4576000805461ff0019166101001790555b60688054610100600160c81b03191661010063ffffffff8a160265010000000000600160c81b03191617600160281b6001600160a01b038781169190910291909117909155606c80546001600160a01b0319168583161790558616611a3d5763ffffffff851615611a3857604051630d43a60960e11b815260040160405180910390fd5b611b0c565b606d805463ffffffff8716600160a01b026001600160c01b03199091166001600160a01b03891617179055606e611a7483826135fe565b50611aeb6000801b6012604051602001611ad791906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612122565b606f80546001600160a01b0319166001600160a01b03929092169190911790555b611b146126b8565b8015611618576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b600081611b70868686610965565b1495945050505050565b60685460ff1615611b9e57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b60685463ffffffff610100909104811690871603611c07576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611c5b999897969594939291906136bd565b60405180910390a1611c926115f86001606860019054906101000a900463ffffffff16338a8a8a8989604051610d48929190613426565b8215610bfc57610bfc611ecf565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b179052905160609160009182916001600160a01b03861691611ce79190613436565b600060405180830381855afa9150503d8060008114611d22576040519150601f19603f3d011682016040523d82523d6000602084013e611d27565b606091505b509150915081611d5657604051806040016040528060078152602001664e4f5f4e414d4560c81b81525061091d565b61091d816126e7565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b179052905160609160009182916001600160a01b03861691611da69190613436565b600060405180830381855afa9150503d8060008114611de1576040519150601f19603f3d011682016040523d82523d6000602084013e611de6565b606091505b509150915081611d5657604051806040016040528060098152602001681393d7d4d6535093d360ba1b81525061091d565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b1790529051600091829182916001600160a01b03861691611e5d9190613436565b600060405180830381855afa9150503d8060008114611e98576040519150601f19603f3d011682016040523d82523d6000602084013e611e9d565b606091505b5091509150818015611eb0575080516020145b611ebb57601261091d565b8080602001905181019061091d919061372a565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b03600160281b909104166333d6247d611f1661081e565b6040518263ffffffff1660e01b8152600401611f3491815260200190565b600060405180830381600087803b158015611f4e57600080fd5b505af1158015611f62573d6000803e3d6000fd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101206312bd9b1960e11b9092526064810191909152600091600160281b90046001600160a01b03169063257b3632906084016020604051808303816000875af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906134e6565b90508060000361202857604051622f6fad60e01b815260040160405180910390fd5b600080600160401b87161561206857869150612046848a8489611b62565b612063576040516338105f3b60e21b815260040160405180910390fd5b6120b2565b602087901c612078816001613747565b915087925061209361208b868c86610965565b8a8389611b62565b6120b0576040516338105f3b60e21b815260040160405180910390fd5b505b6120bc8282612875565b505050505050505050565b61211d8363a9059cbb60e01b84846040516024016120e69291906133e3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261291d565b505050565b60008060405180611ba00160405280611b668152602001613a7a611b669139836040516020016121539291906133b4565b6040516020818303038152906040529050838151602083016000f591506001600160a01b038216612197576040516305f7d84960e51b815260040160405180910390fd5b5092915050565b6002600154036121f05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611988565b6002600155565b60006122066004828486613764565b61220f9161378e565b9050632afa533160e01b6001600160e01b03198216016123a357600080808080808061223e896004818d613764565b81019061224b91906137be565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461228b5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146122b45760405163750643af60e01b815260040160405180910390fd5b8a85146122d4576040516303fffc4b60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918e16916123529190613436565b6000604051808303816000865af19150503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b505050505050505050506106fc565b6001600160e01b031981166323f2ebc360e21b146123d457604051637141605d60e11b815260040160405180910390fd5b6000808080808080806123ea8a6004818e613764565b8101906123f79190613812565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146124395760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146124625760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f16916124e99190613436565b6000604051808303816000865af19150503d8060008114612526576040519150601f19603f3d011682016040523d82523d6000602084013e61252b565b606091505b50505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611f629085906323b872dd60e01b906084016120e6565b80600161258460206002613979565b61258e91906134ff565b605354106125af576040516377ae67b360e11b815260040160405180910390fd5b60006053600081546125c090613362565b9182905550905060005b6020811015612651578082901c6001166001036125fd5782603382602081106125f5576125f5613336565b015550505050565b6033816020811061261057612610613336565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061264990613362565b9150506125ca565b5061211d613985565b60018055565b60685460ff1661268357604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600054610100900460ff166126df5760405162461bcd60e51b81526004016119889061399b565b6106406129ef565b60606040825110612706578180602001905181019061068d91906139e6565b81516020036128425760005b602081108015612741575082818151811061272f5761272f613336565b01602001516001600160f81b03191615155b15612758578061275081613362565b915050612712565b806000036127905750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b6000816001600160401b038111156127aa576127aa612e47565b6040519080825280601f01601f1916602001820160405280156127d4576020820181803683370190505b50905060005b8281101561283a578481815181106127f4576127f4613336565b602001015160f81c60f81b82828151811061281157612811613336565b60200101906001600160f81b031916908160001a9053508061283281613362565b9150506127da565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b606854600090610100900463ffffffff16158015612899575063ffffffff82166001145b156128ab575063ffffffff82166128d2565b6128bf600160201b63ffffffff84166133fc565b6128cf9063ffffffff8516613413565b90505b600881901c60008181526069602052604081208054600160ff861690811b9182189283905592909190818316900361161857604051630c8d9eab60e31b815260040160405180910390fd5b6000612972826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a169092919063ffffffff16565b80519091501561211d57808060200190518101906129909190613a5c565b61211d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611988565b600054610100900460ff1661265a5760405162461bcd60e51b81526004016119889061399b565b606061091d848460008585600080866001600160a01b03168587604051612a3d9190613436565b60006040518083038185875af1925050503d8060008114612a7a576040519150601f19603f3d011682016040523d82523d6000602084013e612a7f565b606091505b5091509150612a9087838387612a9b565b979650505050505050565b60608315612b0a578251600003612b03576001600160a01b0385163b612b035760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611988565b508161091d565b61091d8383815115612b1f5781518083602001fd5b8060405162461bcd60e51b81526004016119889190612ccf565b803563ffffffff8116811461287057600080fd5b6001600160a01b0381168114612b6257600080fd5b50565b60008060408385031215612b7857600080fd5b612b8183612b39565b91506020830135612b9181612b4d565b809150509250929050565b6001600160a01b0391909116815260200190565b8015158114612b6257600080fd5b60008083601f840112612bd057600080fd5b5081356001600160401b03811115612be757600080fd5b602083019150836020828501011115612bff57600080fd5b9250929050565b600080600080600060808688031215612c1e57600080fd5b612c2786612b39565b94506020860135612c3781612b4d565b93506040860135612c4781612bb0565b925060608601356001600160401b03811115612c6257600080fd5b612c6e88828901612bbe565b969995985093965092949392505050565b60005b83811015612c9a578181015183820152602001612c82565b50506000910152565b60008151808452612cbb816020860160208601612c7f565b601f01601f19169290920160200192915050565b602081526000612ce26020830184612ca3565b9392505050565b600060208284031215612cfb57600080fd5b8135612ce281612b4d565b60ff81168114612b6257600080fd5b600080600080600080600060e0888a031215612d3057600080fd5b8735612d3b81612d06565b9650612d4960208901612b39565b95506040880135612d5981612b4d565b9450612d6760608901612b39565b93506080880135612d7781612b4d565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215612da957600080fd5b612db284612b39565b92506020840135612dc281612b4d565b91506040840135612dd281612b4d565b809150509250925092565b600060208284031215612def57600080fd5b5035919050565b80610400810183101561068d57600080fd5b60008060006104408486031215612e1e57600080fd5b83359250612e2f8560208601612df6565b9150612e3e6104208501612b39565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e8557612e85612e47565b604052919050565b60006001600160401b03821115612ea657612ea6612e47565b50601f01601f191660200190565b6000612ec7612ec284612e8d565b612e5d565b9050828152838383011115612edb57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612f0357600080fd5b612ce283833560208501612eb4565b600080600080600060a08688031215612f2a57600080fd5b612f3386612b39565b94506020860135612f4381612b4d565b935060408601356001600160401b0380821115612f5f57600080fd5b612f6b89838a01612ef2565b94506060880135915080821115612f8157600080fd5b50612f8e88828901612ef2565b9250506080860135612f9f81612d06565b809150509295509295909350565b60008060008060008060a08789031215612fc657600080fd5b612fcf87612b39565b95506020870135612fdf81612b4d565b9450604087013593506060870135612ff681612bb0565b925060808701356001600160401b0381111561301157600080fd5b61301d89828a01612bbe565b979a9699509497509295939492505050565b6000806040838503121561304257600080fd5b61304b83612b39565b915061305960208401612b39565b90509250929050565b6000806000806000806000806000806000806109208d8f03121561308557600080fd5b61308f8e8e612df6565b9b5061309f8e6104008f01612df6565b9a506108008d013599506108208d013598506108408d013597506130c66108608e01612b39565b96506130d66108808e0135612b4d565b6108808d013595506130eb6108a08e01612b39565b94506130fb6108c08e0135612b4d565b6108c08d013593506108e08d013592506001600160401b036109008e0135111561312457600080fd5b6131358e6109008f01358f01612bbe565b81935080925050509295989b509295989b509295989b565b600080600080600080600060c0888a03121561316857600080fd5b61317188612b39565b9650602088013561318181612b4d565b955060408801359450606088013561319881612b4d565b935060808801356131a881612bb0565b925060a08801356001600160401b038111156131c357600080fd5b6131cf8a828b01612bbe565b989b979a50959850939692959293505050565b60008060008060008060c087890312156131fb57600080fd5b61320487612b39565b9550602087013561321481612b4d565b945061322260408801612b39565b9350606087013561323281612b4d565b9250608087013561324281612b4d565b915060a08701356001600160401b0381111561325d57600080fd5b8701601f8101891361326e57600080fd5b61327d89823560208401612eb4565b9150509295509295509295565b60008060008061046085870312156132a157600080fd5b843593506132b28660208701612df6565b92506132c16104208601612b39565b939692955092936104400135925050565b60e09290921b6001600160e01b031916825260601b6001600160601b031916600482015260180190565b600181811c9082168061331057607f821691505b60208210810361333057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016133745761337461334c565b5060010190565b60608152600061338e6060830186612ca3565b82810360208401526133a08186612ca3565b91505060ff83166040830152949350505050565b600083516133c6818460208801612c7f565b8351908301906133da818360208801612c7f565b01949350505050565b6001600160a01b03929092168252602082015260400190565b808202811582820484141761068d5761068d61334c565b8082018082111561068d5761068d61334c565b8183823760009101908152919050565b60008251613448818460208701612c7f565b9190910192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03858116602083015284166040820152608060608201819052600090612a909083018486613452565b94855263ffffffff9390931660208501526001600160a01b039182166040850152166060830152608082015260a00190565b6000602082840312156134f857600080fd5b5051919050565b8181038181111561068d5761068d61334c565b60ff8916815263ffffffff88811660208301526001600160a01b03888116604084015287821660608401528616608083015260a0820185905261010060c0830181905260009161356484830187612ca3565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff841660208201526060604082018190526000906135ae9083018486613452565b9695505050505050565b601f82111561211d57600081815260208120601f850160051c810160208610156135df5750805b601f850160051c820191505b81811015610bfc578281556001016135eb565b81516001600160401b0381111561361757613617612e47565b61362b8161362584546132fc565b846135b8565b602080601f83116001811461366057600084156136485750858301515b600019600386901b1c1916600185901b178555610bfc565b600085815260208120601f198616915b8281101561368f57888601518255948401946001909101908401613670565b50858210156136ad5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60ff8a16815263ffffffff89811660208301526001600160a01b03898116604084015288821660608401528716608083015260a0820186905261010060c083018190526000916137108483018789613452565b925080851660e085015250509a9950505050505050505050565b60006020828403121561373c57600080fd5b8151612ce281612d06565b63ffffffff8181168382160190808211156121975761219761334c565b6000808585111561377457600080fd5b8386111561378157600080fd5b5050820193919092039150565b6001600160e01b031981358181169160048510156137b65780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a0312156137d957600080fd5b87356137e481612b4d565b965060208801356137f481612b4d565b955060408801359450606088013593506080880135612d7781612d06565b600080600080600080600080610100898b03121561382f57600080fd5b883561383a81612b4d565b9750602089013561384a81612b4d565b96506040890135955060608901359450608089013561386881612bb0565b935060a089013561387881612d06565b979a969950949793969295929450505060c08201359160e0013590565b600181815b808511156138d05781600019048211156138b6576138b661334c565b808516156138c357918102915b93841c939080029061389a565b509250929050565b6000826138e75750600161068d565b816138f45750600061068d565b816001811461390a576002811461391457613930565b600191505061068d565b60ff8411156139255761392561334c565b50506001821b61068d565b5060208310610133831016604e8410600b8410161715613953575081810a61068d565b61395d8383613895565b80600019048211156139715761397161334c565b029392505050565b6000612ce283836138d8565b634e487b7160e01b600052600160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156139f857600080fd5b81516001600160401b03811115613a0e57600080fd5b8201601f81018413613a1f57600080fd5b8051613a2d612ec282612e8d565b818152856020838501011115613a4257600080fd5b613a53826020830160208601612c7f565b95945050505050565b600060208284031215613a6e57600080fd5b8151612ce281612bb056fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220914f18d5b241f0d10b2ebc814aadeee338ad60bad704683e414dad415cb2e14d64736f6c63430008140033" - }, - { - "contractName": "PolygonZkEVMBridge proxy", - "balance": "340282366920938463463374607431768211455", - "nonce": "1", - "address": "0xB7098a13a48EcE087d3DA15b2D28eCE0f89819B8", - "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461086f565b610135565b61006b6100a336600461088a565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461086f565b610231565b34801561011257600080fd5b506100bd61025e565b61012361028c565b61013361012e610363565b61036d565b565b61013d610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816040518060200160405280600081525060006103d1565b50565b61017461011b565b610187610391565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103d1915050565b505050565b6101e661011b565b60006101fd610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610363565b905090565b61022e61011b565b90565b610239610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816103fc565b6000610268610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610391565b610294610391565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161045d565b3660008037600080366000845af43d6000803e80801561038c573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103da83610485565b6000825111806103e75750805b156101e6576103f683836104d2565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610425610391565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a1610174816104fe565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103b5565b61048e8161060a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606104f7838360405180606001604052806027815260200161099f602791396106d5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81166105a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161035a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b6106ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161035a565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105c4565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516106ff9190610931565b600060405180830381855af49150503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b50915091506107508683838761075a565b9695505050505050565b606083156107f05782516000036107e95773ffffffffffffffffffffffffffffffffffffffff85163b6107e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035a565b50816107fa565b6107fa8383610802565b949350505050565b8151156108125781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035a919061094d565b803573ffffffffffffffffffffffffffffffffffffffff8116811461086a57600080fd5b919050565b60006020828403121561088157600080fd5b6104f782610846565b60008060006040848603121561089f57600080fd5b6108a884610846565b9250602084013567ffffffffffffffff808211156108c557600080fd5b818601915086601f8301126108d957600080fd5b8135818111156108e857600080fd5b8760208285010111156108fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610928578181015183820152602001610910565b50506000910152565b6000825161094381846020870161090d565b9190910192915050565b602081526000825180602084015261096c81604085016020870161090d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220701a0c26bdd76686e63fc3c65e4f28a20ba3ecc8a60246733c0627e679c9804e64736f6c63430008140033", - "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000493732fb136a380920c390a85fc27d79c7b70756" - } - }, - { - "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", - "balance": "0", - "nonce": "1", - "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b881565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b8161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033" - }, - { - "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", - "balance": "0", - "nonce": "1", - "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", - "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", - "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" - } - }, - { - "contractName": "PolygonZkEVMTimelock", - "balance": "0", - "nonce": "1", - "address": "0x0165878A594ca255338adfa4d48449f69242Eb8F", - "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220c474c39da3523b28ebfa5fd66c05b42d6ddcc4a57055483bdda32888b366016164736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", - "0xaedcc9e7897c0d335bdc5d92fe3a8b4f23727fe558cd1c19f332b28716a30559": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xf5e61edb9c9cc6bfbae4463e9a2b1dd6ac3b44ddef38f18016e56ba0363910d9": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x60b9d94c75b7b3f721925089391e4644cd890cb5e6466f9596dfbd2c54e0b280": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x4b63b79f1e338a49559dcd3193ac9eecc50d0f275d24e97cc8c319e5a31a8bd0": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x800d5dfe4bba53eedee06cd4546a27da8de00f12db83f56062976d4493fda899": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - } - }, - { - "accountName": "keyless Deployer", - "balance": "0", - "nonce": "1", - "address": "0x28BB4e66addE1f042B77E04cf7D3784C1dcDBbA3" - }, - { - "accountName": "deployer", - "balance": "100000000000000000000000", - "nonce": "8", - "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - } - ] + { + "contractName": "PolygonZkEVMDeployer", + "balance": "0", + "nonce": "4", + "address": "0xFbD07134824dDEa24E4ae414c18ecbFa98169A24", + "bytecode": "0x60806040526004361061006e575f3560e01c8063715018a61161004c578063715018a6146100e25780638da5cb5b146100f6578063e11ae6cb1461011f578063f2fde38b14610132575f80fd5b80632b79805a146100725780634a94d487146100875780636d07dbf81461009a575b5f80fd5b610085610080366004610908565b610151565b005b6100856100953660046109a2565b6101c2565b3480156100a5575f80fd5b506100b96100b43660046109f5565b610203565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ed575f80fd5b50610085610215565b348015610101575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff166100b9565b61008561012d366004610a15565b610228565b34801561013d575f80fd5b5061008561014c366004610a61565b61028e565b61015961034a565b5f6101658585856103ca565b90506101718183610527565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101ca61034a565b6101d583838361056a565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b905f90a1505050565b5f61020e8383610598565b9392505050565b61021d61034a565b6102265f6105a4565b565b61023061034a565b5f61023c8484846103ca565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b61029661034a565b73ffffffffffffffffffffffffffffffffffffffff811661033e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610347816105a4565b50565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610226576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610335565b5f83471015610435576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610335565b81515f0361049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610335565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff811661020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610335565b606061020e83835f6040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610618565b6060610590848484604051806060016040528060298152602001610b0860299139610618565b949350505050565b5f61020e83833061072d565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610335565b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516106d29190610a9c565b5f6040518083038185875af1925050503d805f811461070c576040519150601f19603f3d011682016040523d82523d5f602084013e610711565b606091505b509150915061072287838387610756565b979650505050505050565b5f604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156107eb5782515f036107e45773ffffffffffffffffffffffffffffffffffffffff85163b6107e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610335565b5081610590565b61059083838151156108005781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103359190610ab7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112610870575f80fd5b813567ffffffffffffffff8082111561088b5761088b610834565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108d1576108d1610834565b816040528381528660208588010111156108e9575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f805f806080858703121561091b575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115610940575f80fd5b61094c88838901610861565b93506060870135915080821115610961575f80fd5b5061096e87828801610861565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff8116811461099d575f80fd5b919050565b5f805f606084860312156109b4575f80fd5b6109bd8461097a565b9250602084013567ffffffffffffffff8111156109d8575f80fd5b6109e486828701610861565b925050604084013590509250925092565b5f8060408385031215610a06575f80fd5b50508035926020909101359150565b5f805f60608486031215610a27575f80fd5b8335925060208401359150604084013567ffffffffffffffff811115610a4b575f80fd5b610a5786828701610861565b9150509250925092565b5f60208284031215610a71575f80fd5b61020e8261097a565b5f5b83811015610a94578181015183820152602001610a7c565b50505f910152565b5f8251610aad818460208701610a7a565b9190910192915050565b602081525f8251806020840152610ad5816040850160208701610a7a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220330b94dc698c4d290bf55c23f13b473cde6a6bae0030cb902de18af54e35839f64736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + } + }, + { + "contractName": "ProxyAdmin", + "balance": "0", + "nonce": "1", + "address": "0xfADB60b5059e31614e02083fF6C021a24C31c891", + "bytecode": "0x608060405260043610610079575f3560e01c80639623609d1161004c5780639623609d1461012357806399a88ec414610136578063f2fde38b14610155578063f3b7dead14610174575f80fd5b8063204e1c7a1461007d578063715018a6146100c55780637eff275e146100db5780638da5cb5b146100fa575b5f80fd5b348015610088575f80fd5b5061009c6100973660046105e8565b610193565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d0575f80fd5b506100d9610244565b005b3480156100e6575f80fd5b506100d96100f536600461060a565b610257565b348015610105575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff1661009c565b6100d961013136600461066e565b6102e0565b348015610141575f80fd5b506100d961015036600461060a565b610371565b348015610160575f80fd5b506100d961016f3660046105e8565b6103cd565b34801561017f575f80fd5b5061009c61018e3660046105e8565b610489565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b5f60405180830381855afa9150503d805f8114610215576040519150601f19603f3d011682016040523d82523d5f602084013e61021a565b606091505b509150915081610228575f80fd5b8080602001905181019061023c919061075b565b949350505050565b61024c6104d3565b6102555f610553565b565b61025f6104d3565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b5f604051808303815f87803b1580156102c6575f80fd5b505af11580156102d8573d5f803e3d5ffd5b505050505050565b6102e86104d3565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061033e9086908690600401610776565b5f604051808303818588803b158015610355575f80fd5b505af1158015610367573d5f803e3d5ffd5b5050505050505050565b6103796104d3565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102af565b6103d56104d3565b73ffffffffffffffffffffffffffffffffffffffff811661047d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61048681610553565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610255576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610474565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff81168114610486575f80fd5b5f602082840312156105f8575f80fd5b8135610603816105c7565b9392505050565b5f806040838503121561061b575f80fd5b8235610626816105c7565b91506020830135610636816105c7565b809150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f805f60608486031215610680575f80fd5b833561068b816105c7565b9250602084013561069b816105c7565b9150604084013567ffffffffffffffff808211156106b7575f80fd5b818601915086601f8301126106ca575f80fd5b8135818111156106dc576106dc610641565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561072257610722610641565b8160405282815289602084870101111561073a575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f6020828403121561076b575f80fd5b8151610603816105c7565b73ffffffffffffffffffffffffffffffffffffffff831681525f602060408184015283518060408501525f5b818110156107be578581018301518582016060015282016107a2565b505f6060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea26469706673582212203083a4ccc2e42eed60bd19037f2efa77ed086dc7a5403f75bebb995dcba2221c64736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" + } + }, + { + "contractName": "PolygonZkEVMBridge implementation", + "balance": "0", + "nonce": "1", + "address": "0x608484d3e94Fc775E3dCb06B0B48486c60A315e6", + "bytecode": "0x6080604052600436106101db575f3560e01c806383f24403116100fd578063ccaa2d1111610092578063ee25560b11610062578063ee25560b146105a9578063f5efcd79146105d4578063f811bff7146105f3578063fb57083414610612575f80fd5b8063ccaa2d111461053b578063cd5865791461055a578063d02103ca1461056d578063dbc1697614610595575f80fd5b8063bab161bf116100cd578063bab161bf146104b9578063be5831c7146104da578063c00f14ab146104fd578063cc4616321461051c575f80fd5b806383f244031461043d5780638ed7e3f21461045c578063aaa13cc21461047b578063b8b284d01461049a575f80fd5b80633cbc795b116101735780637843298b116101435780637843298b146103c257806379e2cf97146103e157806381b1c174146103f557806383c43a5514610429575f80fd5b80633cbc795b146103385780633e197043146103705780634b2f336d1461038f5780635ca1e165146103ae575f80fd5b806327aef4e8116101ae57806327aef4e81461026d5780632dfdf0b51461028e578063318aee3d146102b15780633c351e1014610319575f80fd5b806315064c96146101df5780632072f6c51461020d57806322e95f2c14610223578063240ff3781461025a575b5f80fd5b3480156101ea575f80fd5b506068546101f89060ff1681565b60405190151581526020015b60405180910390f35b348015610218575f80fd5b50610221610631565b005b34801561022e575f80fd5b5061024261023d366004612fb9565b610666565b6040516001600160a01b039091168152602001610204565b610221610268366004613040565b6106d0565b348015610278575f80fd5b50610281610759565b6040516102049190613102565b348015610299575f80fd5b506102a360535481565b604051908152602001610204565b3480156102bc575f80fd5b506102f56102cb36600461311b565b606b6020525f908152604090205463ffffffff81169064010000000090046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b03909116602083015201610204565b348015610324575f80fd5b50606d54610242906001600160a01b031681565b348015610343575f80fd5b50606d5461035b90600160a01b900463ffffffff1681565b60405163ffffffff9091168152602001610204565b34801561037b575f80fd5b506102a361038a366004613144565b6107e5565b34801561039a575f80fd5b50606f54610242906001600160a01b031681565b3480156103b9575f80fd5b506102a361088e565b3480156103cd575f80fd5b506102426103dc3660046131be565b61096a565b3480156103ec575f80fd5b50610221610993565b348015610400575f80fd5b5061024261040f366004613204565b606a6020525f90815260409020546001600160a01b031681565b348015610434575f80fd5b506102816109b4565b348015610448575f80fd5b506102a361045736600461322c565b6109d3565b348015610467575f80fd5b50606c54610242906001600160a01b031681565b348015610486575f80fd5b5061024261049536600461332d565b610aa8565b3480156104a5575f80fd5b506102216104b43660046133c3565b610be7565b3480156104c4575f80fd5b5060685461035b90610100900463ffffffff1681565b3480156104e5575f80fd5b5060685461035b90600160c81b900463ffffffff1681565b348015610508575f80fd5b5061028161051736600461311b565b610cc2565b348015610527575f80fd5b506101f8610536366004613441565b610d07565b348015610546575f80fd5b50610221610555366004613472565b610d8f565b610221610568366004613556565b6112c0565b348015610578575f80fd5b50606854610242906501000000000090046001600160a01b031681565b3480156105a0575f80fd5b5061022161172c565b3480156105b4575f80fd5b506102a36105c3366004613204565b60696020525f908152604090205481565b3480156105df575f80fd5b506102216105ee366004613472565b61175f565b3480156105fe575f80fd5b5061022161060d3660046135e6565b611a25565b34801561061d575f80fd5b506101f861062c366004613689565b611d40565b606c546001600160a01b0316331461065c57604051631736745960e31b815260040160405180910390fd5b610664611d57565b565b6040805160e084901b6001600160e01b031916602080830191909152606084901b6bffffffffffffffffffffffff1916602483015282516018818403018152603890920183528151918101919091205f908152606a90915220546001600160a01b03165b92915050565b60685460ff16156106f457604051630bc011ff60e21b815260040160405180910390fd5b341580159061070d5750606f546001600160a01b031615155b15610744576040517f6f625c4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610752858534868686611db2565b5050505050565b606e8054610766906136ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610792906136ce565b80156107dd5780601f106107b4576101008083540402835291602001916107dd565b820191905f5260205f20905b8154815290600101906020018083116107c057829003601f168201915b505050505081565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201526001600160e01b031960e088811b821660218401526bffffffffffffffffffffffff19606089811b821660258601529188901b909216603984015285901b16603d82015260518101839052607181018290525f90609101604051602081830303815290604052805190602001209050979650505050505050565b6053545f90819081805b6020811015610961578083901c6001166001036108f557603381602081106108c2576108c2613706565b01546040805160208101929092528101859052606001604051602081830303815290604052805190602001209350610922565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806109599061372e565b915050610898565b50919392505050565b5f61098b848461097985611e7c565b61098286611f66565b61049587612047565b949350505050565b605354606854600160c81b900463ffffffff16101561066457610664612114565b60405180611ba00160405280611b668152602001613d80611b66913981565b5f83815b6020811015610a9f57600163ffffffff8516821c81169003610a4257848160208110610a0557610a05613706565b602002013582604051602001610a25929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a8d565b81858260208110610a5557610a55613706565b6020020135604051602001610a74929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a978161372e565b9150506109d7565b50949350505050565b6040516001600160e01b031960e087901b1660208201526bffffffffffffffffffffffff19606086901b1660248201525f9081906038016040516020818303038152906040528051906020012090505f60ff60f81b308360405180611ba00160405280611b668152602001613d80611b669139898989604051602001610b3093929190613746565b60408051601f1981840301815290829052610b4e929160200161377e565b60405160208183030381529060405280519060200120604051602001610bc394939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b6bffffffffffffffffffffffff191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610c0b57604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610c4d576040517fdde3cda700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606f54604051632770a7eb60e21b8152336004820152602481018690526001600160a01b0390911690639dc29fac906044015f604051808303815f87803b158015610c96575f80fd5b505af1158015610ca8573d5f803e3d5ffd5b50505050610cba868686868686611db2565b505050505050565b6060610ccd82611e7c565b610cd683611f66565b610cdf84612047565b604051602001610cf193929190613746565b6040516020818303038152906040529050919050565b6068545f908190610100900463ffffffff16158015610d2c575063ffffffff83166001145b15610d3e575063ffffffff8316610d66565b610d5364010000000063ffffffff85166137ac565b610d639063ffffffff86166137c3565b90505b600881901c5f90815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610db357604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610de3576040516302caf51760e11b815260040160405180910390fd5b610e168c8c8c8c8c610e115f8e8e8e8e8e8e8e604051610e049291906137d6565b60405180910390206107e5565b6121c2565b6001600160a01b038616610f6057606f546001600160a01b0316610efa575f6001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610e6c576020820181803683370190505b50604051610e7a91906137e5565b5f6040518083038185875af1925050503d805f8114610eb4576040519150601f19603f3d011682016040523d82523d5f602084013e610eb9565b606091505b5050905080610ef4576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50611256565b606f546040516340c10f1960e01b81526001600160a01b03868116600483015260248201869052909116906340c10f19906044015f604051808303815f87803b158015610f45575f80fd5b505af1158015610f57573d5f803e3d5ffd5b50505050611256565b606d546001600160a01b038781169116148015610f8e5750606d5463ffffffff888116600160a01b90920416145b15610fa5575f6001600160a01b0385168482610e42565b60685463ffffffff610100909104811690881603610fd657610fd16001600160a01b0387168585612354565b611256565b6040516001600160e01b031960e089901b1660208201526bffffffffffffffffffffffff19606088901b1660248201525f9060380160408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806111f5575f6110808386868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506123d592505050565b6040516340c10f1960e01b81526001600160a01b03898116600483015260248201899052919250908216906340c10f19906044015f604051808303815f87803b1580156110cb575f80fd5b505af11580156110dd573d5f803e3d5ffd5b5050505080606a5f8581526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b5f836001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a81548163ffffffff021916908363ffffffff1602179055506020820151815f0160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a8388886040516111e7959493929190613828565b60405180910390a150611253565b6040516340c10f1960e01b81526001600160a01b038781166004830152602482018790528216906340c10f19906044015f604051808303815f87803b15801561123c575f80fd5b505af115801561124e573d5f803e3d5ffd5b505050505b50505b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a1505050505050505050505050565b60685460ff16156112e457604051630bc011ff60e21b815260040160405180910390fd5b6112ec612468565b60685463ffffffff61010090910481169088160361131d576040516302caf51760e11b815260040160405180910390fd5b5f806060876001600160a01b03881661141957883414611369576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611396906136ce565b80601f01602080910402602001604051908101604052809291908181526020018280546113c2906136ce565b801561140d5780601f106113e45761010080835404028352916020019161140d565b820191905f5260205f20905b8154815290600101906020018083116113f057829003601f168201915b505050505091506116a3565b3415611451576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606f546001600160a01b03908116908916036114c757604051632770a7eb60e21b8152336004820152602481018a90526001600160a01b03891690639dc29fac906044015f604051808303815f87803b1580156114ac575f80fd5b505af11580156114be573d5f803e3d5ffd5b505050506116a3565b6001600160a01b038089165f908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901561157957604051632770a7eb60e21b8152336004820152602481018b90526001600160a01b038a1690639dc29fac906044015f604051808303815f87803b158015611551575f80fd5b505af1158015611563573d5f803e3d5ffd5b5050505080602001519450805f01519350611696565b851561158b5761158b898b89896124c1565b6040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa1580156115cf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115f39190613860565b905061160a6001600160a01b038b1633308e612860565b6040516370a0823160e01b81523060048201525f906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561164e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116729190613860565b905061167e8282613877565b6068548c9850610100900463ffffffff169650935050505b61169f89610cc2565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b5f84868e8e86886053546040516116e298979695949392919061388a565b60405180910390a16117086117035f85878f8f8789805190602001206107e5565b6128b1565b861561171657611716612114565b5050505061172360018055565b50505050505050565b606c546001600160a01b0316331461175757604051631736745960e31b815260040160405180910390fd5b6106646129b2565b60685460ff161561178357604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146117b3576040516302caf51760e11b815260040160405180910390fd5b6117d58c8c8c8c8c610e1160018e8e8e8e8e8e8e604051610e049291906137d6565b606f545f906001600160a01b031661188857846001600160a01b031684888a868660405160240161180994939291906138f3565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183e91906137e5565b5f6040518083038185875af1925050503d805f8114611878576040519150601f19603f3d011682016040523d82523d5f602084013e61187d565b606091505b505080915050611983565b606f546040516340c10f1960e01b81526001600160a01b03878116600483015260248201879052909116906340c10f19906044015f604051808303815f87803b1580156118d3575f80fd5b505af11580156118e5573d5f803e3d5ffd5b50505050846001600160a01b03168789858560405160240161190a94939291906138f3565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161193f91906137e5565b5f604051808303815f865af19150503d805f8114611978576040519150601f19603f3d011682016040523d82523d5f602084013e61197d565b606091505b50909150505b806119ba576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080518c815263ffffffff8a1660208201526001600160a01b0389811682840152871660608201526080810186905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a150505050505050505050505050565b5f54610100900460ff1615808015611a4357505f54600160ff909116105b80611a5c5750303b158015611a5c57505f5460ff166001145b611ad35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b5f805460ff191660011790558015611af4575f805461ff0019166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8a16027fffffffffffffff0000000000000000000000000000000000000000ffffffffff1617650100000000006001600160a01b038781169190910291909117909155606c805473ffffffffffffffffffffffffffffffffffffffff19168583161790558616611bcf5763ffffffff851615611bca576040517f1a874c1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ceb565b606d805463ffffffff8716600160a01b027fffffffffffffffff0000000000000000000000000000000000000000000000009091166001600160a01b03891617179055606e611c1e8382613970565b50611cbd5f801b6012604051602001611ca991906060808252600d908201527f5772617070656420457468657200000000000000000000000000000000000000608082015260a0602082018190526004908201527f574554480000000000000000000000000000000000000000000000000000000060c082015260ff91909116604082015260e00190565b6040516020818303038152906040526123d5565b606f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03929092169190911790555b611cf3612a22565b8015611723575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b5f81611d4d8686866109d3565b1495945050505050565b60685460ff1615611d7b57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a5497905f90a1565b60685463ffffffff610100909104811690871603611de3576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611e3799989796959493929190613a2c565b60405180910390a1611e6e6117036001606860019054906101000a900463ffffffff16338a8a8a8989604051610e049291906137d6565b8215610cba57610cba612114565b60408051600481526024810182526020810180516001600160e01b03167f06fdde030000000000000000000000000000000000000000000000000000000017905290516060915f9182916001600160a01b03861691611edb91906137e5565b5f60405180830381855afa9150503d805f8114611f13576040519150601f19603f3d011682016040523d82523d5f602084013e611f18565b606091505b509150915081611f5d576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525061098b565b61098b81612a94565b60408051600481526024810182526020810180516001600160e01b03167f95d89b410000000000000000000000000000000000000000000000000000000017905290516060915f9182916001600160a01b03861691611fc591906137e5565b5f60405180830381855afa9150503d805f8114611ffd576040519150601f19603f3d011682016040523d82523d5f602084013e612002565b606091505b509150915081611f5d576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525061098b565b60408051600481526024810182526020810180516001600160e01b03167f313ce5670000000000000000000000000000000000000000000000000000000017905290515f91829182916001600160a01b038616916120a591906137e5565b5f60405180830381855afa9150503d805f81146120dd576040519150601f19603f3d011682016040523d82523d5f602084013e6120e2565b606091505b50915091508180156120f5575080516020145b61210057601261098b565b8080602001905181019061098b9190613a97565b6053546068805463ffffffff909216600160c81b027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117908190556001600160a01b0365010000000000909104166333d6247d61217561088e565b6040518263ffffffff1660e01b815260040161219391815260200190565b5f604051808303815f87803b1580156121aa575f80fd5b505af11580156121bc573d5f803e3d5ffd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101207f257b36320000000000000000000000000000000000000000000000000000000090925260648101919091525f916501000000000090046001600160a01b03169063257b3632906084016020604051808303815f875af1158015612253573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122779190613860565b9050805f036122b1576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80680100000000000000008716156122f5578691506122d3848a8489611d40565b6122f0576040516338105f3b60e21b815260040160405180910390fd5b61233f565b602087901c612305816001613ab2565b9150879250612320612318868c866109d3565b8a8389611d40565b61233d576040516338105f3b60e21b815260040160405180910390fd5b505b6123498282612c64565b505050505050505050565b6040516001600160a01b0383166024820152604481018290526123d09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d24565b505050565b5f8060405180611ba00160405280611b668152602001613d80611b6691398360405160200161240592919061377e565b6040516020818303038152906040529050838151602083015ff591506001600160a01b038216612461576040517fbefb092000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6002600154036124ba5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611aca565b6002600155565b5f6124cf6004828486613acf565b6124d891613af6565b90507f2afa5331000000000000000000000000000000000000000000000000000000006001600160e01b03198216016126b2575f80808080808061251f896004818d613acf565b81019061252c9190613b26565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461256c5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146125955760405163750643af60e01b815260040160405180910390fd5b8a85146125ce576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b03167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e169161266591906137e5565b5f604051808303815f865af19150503d805f811461269e576040519150601f19603f3d011682016040523d82523d5f602084013e6126a3565b606091505b50505050505050505050610752565b6001600160e01b031981166323f2ebc360e21b146126fc576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f808080808080806127118a6004818e613acf565b81019061271e9190613b75565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146127605760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146127895760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f169161281091906137e5565b5f604051808303815f865af19150503d805f8114612849576040519150601f19603f3d011682016040523d82523d5f602084013e61284e565b606091505b50505050505050505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526121bc9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612399565b8060016128c060206002613cd3565b6128ca9190613877565b60535410612904576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60535f81546129139061372e565b918290555090505f5b60208110156129a3578082901c60011660010361294f57826033826020811061294757612947613706565b015550505050565b6033816020811061296257612962613706565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061299b9061372e565b91505061291c565b506123d0613cde565b60018055565b60685460ff166129ee576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b3905f90a1565b5f54610100900460ff16612a8c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611aca565b610664612e08565b60606040825110612ab357818060200190518101906106ca9190613cf2565b8151602003612c26575f5b602081108015612b055750828181518110612adb57612adb613706565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b15612b1c5780612b148161372e565b915050612abe565b805f03612b5e57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b5f8167ffffffffffffffff811115612b7857612b78613268565b6040519080825280601f01601f191660200182016040528015612ba2576020820181803683370190505b5090505f5b82811015612c1e57848181518110612bc157612bc1613706565b602001015160f81c60f81b828281518110612bde57612bde613706565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a90535080612c168161372e565b915050612ba7565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b6068545f90610100900463ffffffff16158015612c87575063ffffffff82166001145b15612c99575063ffffffff8216612cc1565b612cae64010000000063ffffffff84166137ac565b612cbe9063ffffffff85166137c3565b90505b600881901c5f8181526069602052604081208054600160ff861690811b91821892839055929091908183169003611723576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f612d78826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e729092919063ffffffff16565b8051909150156123d05780806020019051810190612d969190613d64565b6123d05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611aca565b5f54610100900460ff166129ac5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611aca565b606061098b84845f85855f80866001600160a01b03168587604051612e9791906137e5565b5f6040518083038185875af1925050503d805f8114612ed1576040519150601f19603f3d011682016040523d82523d5f602084013e612ed6565b606091505b5091509150612ee787838387612ef2565b979650505050505050565b60608315612f605782515f03612f59576001600160a01b0385163b612f595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611aca565b508161098b565b61098b8383815115612f755781518083602001fd5b8060405162461bcd60e51b8152600401611aca9190613102565b803563ffffffff81168114612c5f575f80fd5b6001600160a01b0381168114612fb6575f80fd5b50565b5f8060408385031215612fca575f80fd5b612fd383612f8f565b91506020830135612fe381612fa2565b809150509250929050565b8015158114612fb6575f80fd5b5f8083601f84011261300b575f80fd5b50813567ffffffffffffffff811115613022575f80fd5b602083019150836020828501011115613039575f80fd5b9250929050565b5f805f805f60808688031215613054575f80fd5b61305d86612f8f565b9450602086013561306d81612fa2565b9350604086013561307d81612fee565b9250606086013567ffffffffffffffff811115613098575f80fd5b6130a488828901612ffb565b969995985093965092949392505050565b5f5b838110156130cf5781810151838201526020016130b7565b50505f910152565b5f81518084526130ee8160208601602086016130b5565b601f01601f19169290920160200192915050565b602081525f61311460208301846130d7565b9392505050565b5f6020828403121561312b575f80fd5b813561311481612fa2565b60ff81168114612fb6575f80fd5b5f805f805f805f60e0888a03121561315a575f80fd5b873561316581613136565b965061317360208901612f8f565b9550604088013561318381612fa2565b945061319160608901612f8f565b935060808801356131a181612fa2565b9699959850939692959460a0840135945060c09093013592915050565b5f805f606084860312156131d0575f80fd5b6131d984612f8f565b925060208401356131e981612fa2565b915060408401356131f981612fa2565b809150509250925092565b5f60208284031215613214575f80fd5b5035919050565b8061040081018310156106ca575f80fd5b5f805f610440848603121561323f575f80fd5b83359250613250856020860161321b565b915061325f6104208501612f8f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156132a5576132a5613268565b604052919050565b5f67ffffffffffffffff8211156132c6576132c6613268565b50601f01601f191660200190565b5f6132e66132e1846132ad565b61327c565b90508281528383830111156132f9575f80fd5b828260208301375f602084830101529392505050565b5f82601f83011261331e575f80fd5b613114838335602085016132d4565b5f805f805f60a08688031215613341575f80fd5b61334a86612f8f565b9450602086013561335a81612fa2565b9350604086013567ffffffffffffffff80821115613376575f80fd5b61338289838a0161330f565b94506060880135915080821115613397575f80fd5b506133a48882890161330f565b92505060808601356133b581613136565b809150509295509295909350565b5f805f805f8060a087890312156133d8575f80fd5b6133e187612f8f565b955060208701356133f181612fa2565b945060408701359350606087013561340881612fee565b9250608087013567ffffffffffffffff811115613423575f80fd5b61342f89828a01612ffb565b979a9699509497509295939492505050565b5f8060408385031215613452575f80fd5b61345b83612f8f565b915061346960208401612f8f565b90509250929050565b5f805f805f805f805f805f806109208d8f03121561348e575f80fd5b6134988e8e61321b565b9b506134a88e6104008f0161321b565b9a506108008d013599506108208d013598506108408d013597506134cf6108608e01612f8f565b96506134df6108808e0135612fa2565b6108808d013595506134f46108a08e01612f8f565b94506135046108c08e0135612fa2565b6108c08d013593506108e08d0135925067ffffffffffffffff6109008e0135111561352d575f80fd5b61353e8e6109008f01358f01612ffb565b81935080925050509295989b509295989b509295989b565b5f805f805f805f60c0888a03121561356c575f80fd5b61357588612f8f565b9650602088013561358581612fa2565b955060408801359450606088013561359c81612fa2565b935060808801356135ac81612fee565b925060a088013567ffffffffffffffff8111156135c7575f80fd5b6135d38a828b01612ffb565b989b979a50959850939692959293505050565b5f805f805f8060c087890312156135fb575f80fd5b61360487612f8f565b9550602087013561361481612fa2565b945061362260408801612f8f565b9350606087013561363281612fa2565b9250608087013561364281612fa2565b915060a087013567ffffffffffffffff81111561365d575f80fd5b8701601f8101891361366d575f80fd5b61367c898235602084016132d4565b9150509295509295509295565b5f805f80610460858703121561369d575f80fd5b843593506136ae866020870161321b565b92506136bd6104208601612f8f565b939692955092936104400135925050565b600181811c908216806136e257607f821691505b60208210810361370057634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161373f5761373f61371a565b5060010190565b606081525f61375860608301866130d7565b828103602084015261376a81866130d7565b91505060ff83166040830152949350505050565b5f835161378f8184602088016130b5565b8351908301906137a38183602088016130b5565b01949350505050565b80820281158282048414176106ca576106ca61371a565b808201808211156106ca576106ca61371a565b818382375f9101908152919050565b5f82516137f68184602087016130b5565b9190910192915050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b63ffffffff861681525f6001600160a01b03808716602084015280861660408401525060806060830152612ee7608083018486613800565b5f60208284031215613870575f80fd5b5051919050565b818103818111156106ca576106ca61371a565b5f61010060ff8b16835263ffffffff808b1660208501526001600160a01b03808b166040860152818a1660608601528089166080860152508660a08501528160c08501526138da828501876130d7565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff84166020820152606060408201525f613921606083018486613800565b9695505050505050565b601f8211156123d0575f81815260208120601f850160051c810160208610156139515750805b601f850160051c820191505b81811015610cba5782815560010161395d565b815167ffffffffffffffff81111561398a5761398a613268565b61399e8161399884546136ce565b8461392b565b602080601f8311600181146139d1575f84156139ba5750858301515b5f19600386901b1c1916600185901b178555610cba565b5f85815260208120601f198616915b828110156139ff578886015182559484019460019091019084016139e0565b5085821015613a1c57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f61010060ff8c16835263ffffffff808c1660208501526001600160a01b03808c166040860152818b166060860152808a166080860152508760a08501528160c0850152613a7d8285018789613800565b925080851660e085015250509a9950505050505050505050565b5f60208284031215613aa7575f80fd5b815161311481613136565b63ffffffff8181168382160190808211156124615761246161371a565b5f8085851115613add575f80fd5b83861115613ae9575f80fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015613b1e5780818660040360031b1b83161692505b505092915050565b5f805f805f805f60e0888a031215613b3c575f80fd5b8735613b4781612fa2565b96506020880135613b5781612fa2565b9550604088013594506060880135935060808801356131a181613136565b5f805f805f805f80610100898b031215613b8d575f80fd5b8835613b9881612fa2565b97506020890135613ba881612fa2565b965060408901359550606089013594506080890135613bc681612fee565b935060a0890135613bd681613136565b979a969950949793969295929450505060c08201359160e0013590565b600181815b80851115613c2d57815f1904821115613c1357613c1361371a565b80851615613c2057918102915b93841c9390800290613bf8565b509250929050565b5f82613c43575060016106ca565b81613c4f57505f6106ca565b8160018114613c655760028114613c6f57613c8b565b60019150506106ca565b60ff841115613c8057613c8061371a565b50506001821b6106ca565b5060208310610133831016604e8410600b8410161715613cae575081810a6106ca565b613cb88383613bf3565b805f1904821115613ccb57613ccb61371a565b029392505050565b5f6131148383613c35565b634e487b7160e01b5f52600160045260245ffd5b5f60208284031215613d02575f80fd5b815167ffffffffffffffff811115613d18575f80fd5b8201601f81018413613d28575f80fd5b8051613d366132e1826132ad565b818152856020838501011115613d4a575f80fd5b613d5b8260208301602086016130b5565b95945050505050565b5f60208284031215613d74575f80fd5b815161311481612fee56fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220432f6d6b4446edbe1f73c19fd2115454d5c35d8b03b98a74fd46724151d7672264736f6c63430008140033" + }, + { + "contractName": "PolygonZkEVMBridge proxy", + "balance": "340282366920938463463374607431768211455", + "nonce": "1", + "address": "0xFe12ABaa190Ef0c8638Ee0ba9F828BF41368Ca0E", + "bytecode": "0x60806040526004361061005d575f3560e01c80635c60da1b116100425780635c60da1b146100a65780638f283970146100e3578063f851a440146101025761006c565b80633659cfe6146100745780634f1ef286146100935761006c565b3661006c5761006a610116565b005b61006a610116565b34801561007f575f80fd5b5061006a61008e366004610854565b610130565b61006a6100a136600461086d565b610178565b3480156100b1575f80fd5b506100ba6101eb565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ee575f80fd5b5061006a6100fd366004610854565b610228565b34801561010d575f80fd5b506100ba610255565b61011e610282565b61012e610129610359565b610362565b565b610138610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d8160405180602001604052805f8152505f6103bf565b50565b61016d610116565b610180610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101e3576101de8383838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250600192506103bf915050565b505050565b6101de610116565b5f6101f4610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610359565b905090565b610225610116565b90565b610230610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d816103e9565b5f61025e610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610380565b61028a610380565b73ffffffffffffffffffffffffffffffffffffffff16330361012e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b5f61021861044a565b365f80375f80365f845af43d5f803e80801561037c573d5ff35b3d5ffd5b5f7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103c883610471565b5f825111806103d45750805b156101de576103e383836104bd565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610412610380565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161016d816104e9565b5f7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103a3565b61047a816105f5565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606104e28383604051806060016040528060278152602001610977602791396106c0565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff811661058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610350565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610350565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105af565b60605f808573ffffffffffffffffffffffffffffffffffffffff16856040516106e9919061090b565b5f60405180830381855af49150503d805f8114610721576040519150601f19603f3d011682016040523d82523d5f602084013e610726565b606091505b509150915061073786838387610741565b9695505050505050565b606083156107d65782515f036107cf5773ffffffffffffffffffffffffffffffffffffffff85163b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610350565b50816107e0565b6107e083836107e8565b949350505050565b8151156107f85781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103509190610926565b803573ffffffffffffffffffffffffffffffffffffffff8116811461084f575f80fd5b919050565b5f60208284031215610864575f80fd5b6104e28261082c565b5f805f6040848603121561087f575f80fd5b6108888461082c565b9250602084013567ffffffffffffffff808211156108a4575f80fd5b818601915086601f8301126108b7575f80fd5b8135818111156108c5575f80fd5b8760208285010111156108d6575f80fd5b6020830194508093505050509250925092565b5f5b838110156109035781810151838201526020016108eb565b50505f910152565b5f825161091c8184602087016108e9565b9190910192915050565b602081525f82518060208401526109448160408501602087016108e9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212202ac98acbfbb3d3ac1b74050e18c4e76db25a3ff2801ec69bf85d0c61414d502b64736f6c63430008140033", + "storage": { + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000608484d3e94fc775e3dcb06b0b48486c60a315e6" + } + }, + { + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", + "balance": "0", + "nonce": "1", + "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "bytecode": "0x608060405234801561000f575f80fd5b506004361061004a575f3560e01c806301fd90441461004e578063257b36321461006a57806333d6247d14610089578063a3c573eb1461009e575b5f80fd5b61005760015481565b6040519081526020015b60405180910390f35b61005761007836600461015e565b5f6020819052908152604090205481565b61009c61009736600461015e565b6100ea565b005b6100c57f000000000000000000000000fe12abaa190ef0c8638ee0ba9f828bf41368ca0e81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610061565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fe12abaa190ef0c8638ee0ba9f828bf41368ca0e1614610159576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b5f6020828403121561016e575f80fd5b503591905056fea26469706673582212205108c6c4f924146b736832a1bdf696e20d900450207b7452462368d150f2c71c64736f6c63430008140033" + }, + { + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", + "balance": "0", + "nonce": "1", + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", + "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", + "storage": { + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" + } + }, + { + "contractName": "PolygonZkEVMTimelock", + "balance": "0", + "nonce": "1", + "address": "0x0165878A594ca255338adfa4d48449f69242Eb8F", + "bytecode": "0x6080604052600436106101bd575f3560e01c806364d62353116100f2578063b1c5f42711610092578063d547741f11610062578063d547741f1461063a578063e38335e514610659578063f23a6e611461066c578063f27a0c92146106b0575f80fd5b8063b1c5f4271461058d578063bc197c81146105ac578063c4d252f5146105f0578063d45c44351461060f575f80fd5b80638f61f4f5116100cd5780638f61f4f5146104c557806391d14854146104f8578063a217fddf14610547578063b08e51c01461055a575f80fd5b806364d62353146104685780638065657f146104875780638f2a0bb0146104a6575f80fd5b8063248a9ca31161015d57806331d507501161013857806331d50750146103b357806336568abe146103d25780633a6aae72146103f1578063584b153e14610449575f80fd5b8063248a9ca3146103375780632ab0f529146103655780632f2ff15d14610394575f80fd5b80630d3cf6fc116101985780630d3cf6fc1461025e578063134008d31461029157806313bc9f20146102a4578063150b7a02146102c3575f80fd5b806301d5062a146101c857806301ffc9a7146101e957806307bd02651461021d575f80fd5b366101c457005b5f80fd5b3480156101d3575f80fd5b506101e76101e2366004611bf6565b6106c4565b005b3480156101f4575f80fd5b50610208610203366004611c65565b610757565b60405190151581526020015b60405180910390f35b348015610228575f80fd5b506102507fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610214565b348015610269575f80fd5b506102507f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e761029f366004611ca4565b6107b2565b3480156102af575f80fd5b506102086102be366004611d0b565b6108a7565b3480156102ce575f80fd5b506103066102dd366004611e28565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610214565b348015610342575f80fd5b50610250610351366004611d0b565b5f9081526020819052604090206001015490565b348015610370575f80fd5b5061020861037f366004611d0b565b5f908152600160208190526040909120541490565b34801561039f575f80fd5b506101e76103ae366004611e8c565b6108cc565b3480156103be575f80fd5b506102086103cd366004611d0b565b6108f5565b3480156103dd575f80fd5b506101e76103ec366004611e8c565b61090d565b3480156103fc575f80fd5b506104247f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610214565b348015610454575f80fd5b50610208610463366004611d0b565b6109c5565b348015610473575f80fd5b506101e7610482366004611d0b565b6109da565b348015610492575f80fd5b506102506104a1366004611ca4565b610aaa565b3480156104b1575f80fd5b506101e76104c0366004611ef7565b610ae8565b3480156104d0575f80fd5b506102507fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b348015610503575f80fd5b50610208610512366004611e8c565b5f9182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b348015610552575f80fd5b506102505f81565b348015610565575f80fd5b506102507ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b348015610598575f80fd5b506102506105a7366004611fa0565b610d18565b3480156105b7575f80fd5b506103066105c63660046120be565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105fb575f80fd5b506101e761060a366004611d0b565b610d5c565b34801561061a575f80fd5b50610250610629366004611d0b565b5f9081526001602052604090205490565b348015610645575f80fd5b506101e7610654366004611e8c565b610e56565b6101e7610667366004611fa0565b610e7a565b348015610677575f80fd5b50610306610686366004612161565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106bb575f80fd5b50610250611121565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106ee81611200565b5f6106fd898989898989610aaa565b9050610709818461120d565b5f817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161074496959493929190612208565b60405180910390a3505050505050505050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107ac57506107ac82611359565b92915050565b5f80527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661082e5761082e81336113ef565b5f61083d888888888888610aaa565b905061084981856114a6565b610855888888886115e2565b5f817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a60405161088c9493929190612252565b60405180910390a361089d816116e2565b5050505050505050565b5f818152600160205260408120546001811180156108c55750428111155b9392505050565b5f828152602081905260409020600101546108e681611200565b6108f0838361178a565b505050565b5f8181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109c18282611878565b5050565b5f818152600160208190526040822054610906565b333014610a69576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109ae565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b5f868686868686604051602001610ac696959493929190612208565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b1281611200565b888714610ba1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b888514610c30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f610c418b8b8b8b8b8b8b8b610d18565b9050610c4d818461120d565b5f5b8a811015610d0a5780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c8c57610c8c612291565b9050602002016020810190610ca191906122be565b8d8d86818110610cb357610cb3612291565b905060200201358c8c87818110610ccc57610ccc612291565b9050602002810190610cde91906122d7565b8c8b604051610cf296959493929190612208565b60405180910390a3610d0381612365565b9050610c4f565b505050505050505050505050565b5f8888888888888888604051602001610d38989796959493929190612447565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d8681611200565b610d8f826109c5565b610e1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109ae565b5f828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b5f82815260208190526040902060010154610e7081611200565b6108f08383611878565b5f80527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610ef657610ef681336113ef565b878614610f85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b878414611014576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f6110258a8a8a8a8a8a8a8a610d18565b905061103181856114a6565b5f5b8981101561110b575f8b8b8381811061104e5761104e612291565b905060200201602081019061106391906122be565b90505f8a8a8481811061107857611078612291565b905060200201359050365f8a8a8681811061109557611095612291565b90506020028101906110a791906122d7565b915091506110b7848484846115e2565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b58868686866040516110ee9493929190612252565b60405180910390a3505050508061110490612365565b9050611033565b50611115816116e2565b50505050505050505050565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16158015906111ef57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111ef919061250c565b156111f957505f90565b5060025490565b61120a81336113ef565b50565b611216826108f5565b156112a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109ae565b6112ab611121565b81101561133a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109ae565b611344814261252b565b5f928352600160205260409092209190915550565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107ac57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107ac565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109c15761142c8161192d565b61143783602061194c565b604051602001611448929190612560565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109ae916004016125e0565b6114af826108a7565b61153b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109ae565b80158061155657505f81815260016020819052604090912054145b6109c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f8473ffffffffffffffffffffffffffffffffffffffff1684848460405161160b929190612630565b5f6040518083038185875af1925050503d805f8114611645576040519150601f19603f3d011682016040523d82523d5f602084013e61164a565b606091505b50509050806116db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109ae565b5050505050565b6116eb816108a7565b611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109ae565b5f90815260016020819052604090912055565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109c1575f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561181a3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109c1575f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107ac73ffffffffffffffffffffffffffffffffffffffff831660145b60605f61195a83600261263f565b61196590600261252b565b67ffffffffffffffff81111561197d5761197d611d22565b6040519080825280601f01601f1916602001820160405280156119a7576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f815181106119dd576119dd612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a3f57611a3f612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f611a7984600261263f565b611a8490600161252b565b90505b6001811115611b20577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611ac557611ac5612291565b1a60f81b828281518110611adb57611adb612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a90535060049490941c93611b1981612656565b9050611a87565b5083156108c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109ae565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bac575f80fd5b919050565b5f8083601f840112611bc1575f80fd5b50813567ffffffffffffffff811115611bd8575f80fd5b602083019150836020828501011115611bef575f80fd5b9250929050565b5f805f805f805f60c0888a031215611c0c575f80fd5b611c1588611b89565b965060208801359550604088013567ffffffffffffffff811115611c37575f80fd5b611c438a828b01611bb1565b989b979a50986060810135976080820135975060a09091013595509350505050565b5f60208284031215611c75575f80fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c5575f80fd5b5f805f805f8060a08789031215611cb9575f80fd5b611cc287611b89565b955060208701359450604087013567ffffffffffffffff811115611ce4575f80fd5b611cf089828a01611bb1565b979a9699509760608101359660809091013595509350505050565b5f60208284031215611d1b575f80fd5b5035919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611d9657611d96611d22565b604052919050565b5f82601f830112611dad575f80fd5b813567ffffffffffffffff811115611dc757611dc7611d22565b611df860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d4f565b818152846020838601011115611e0c575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215611e3b575f80fd5b611e4485611b89565b9350611e5260208601611b89565b925060408501359150606085013567ffffffffffffffff811115611e74575f80fd5b611e8087828801611d9e565b91505092959194509250565b5f8060408385031215611e9d575f80fd5b82359150611ead60208401611b89565b90509250929050565b5f8083601f840112611ec6575f80fd5b50813567ffffffffffffffff811115611edd575f80fd5b6020830191508360208260051b8501011115611bef575f80fd5b5f805f805f805f805f60c08a8c031215611f0f575f80fd5b893567ffffffffffffffff80821115611f26575f80fd5b611f328d838e01611eb6565b909b50995060208c0135915080821115611f4a575f80fd5b611f568d838e01611eb6565b909950975060408c0135915080821115611f6e575f80fd5b50611f7b8c828d01611eb6565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b5f805f805f805f8060a0898b031215611fb7575f80fd5b883567ffffffffffffffff80821115611fce575f80fd5b611fda8c838d01611eb6565b909a50985060208b0135915080821115611ff2575f80fd5b611ffe8c838d01611eb6565b909850965060408b0135915080821115612016575f80fd5b506120238b828c01611eb6565b999c989b509699959896976060870135966080013595509350505050565b5f82601f830112612050575f80fd5b8135602067ffffffffffffffff82111561206c5761206c611d22565b8160051b61207b828201611d4f565b9283528481018201928281019087851115612094575f80fd5b83870192505b848310156120b35782358252918301919083019061209a565b979650505050505050565b5f805f805f60a086880312156120d2575f80fd5b6120db86611b89565b94506120e960208701611b89565b9350604086013567ffffffffffffffff80821115612105575f80fd5b61211189838a01612041565b94506060880135915080821115612126575f80fd5b61213289838a01612041565b93506080880135915080821115612147575f80fd5b5061215488828901611d9e565b9150509295509295909350565b5f805f805f60a08688031215612175575f80fd5b61217e86611b89565b945061218c60208701611b89565b93506040860135925060608601359150608086013567ffffffffffffffff8111156121b5575f80fd5b61215488828901611d9e565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a060408201525f61223d60a0830186886121c1565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152606060408201525f6122876060830184866121c1565b9695505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f602082840312156122ce575f80fd5b6108c582611b89565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261230a575f80fd5b83018035915067ffffffffffffffff821115612324575f80fd5b602001915036819003821315611bef575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361239557612395612338565b5060010190565b8183525f6020808501808196508560051b81019150845f5b8781101561243a57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126123f2575f80fd5b8701858101903567ffffffffffffffff81111561240d575f80fd5b80360382131561241b575f80fd5b6124268682846121c1565b9a87019a95505050908401906001016123b4565b5091979650505050505050565b60a080825281018890525f8960c08301825b8b8110156124945773ffffffffffffffffffffffffffffffffffffffff61247f84611b89565b16825260209283019290910190600101612459565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8911156124cc575f80fd5b8860051b9150818a602083013701828103602090810160408501526124f4908201878961239c565b60608401959095525050608001529695505050505050565b5f6020828403121561251c575f80fd5b815180151581146108c5575f80fd5b808201808211156107ac576107ac612338565b5f5b83811015612558578181015183820152602001612540565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f835161259781601785016020880161253e565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516125d481602884016020880161253e565b01602801949350505050565b602081525f82518060208401526125fe81604085016020870161253e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b818382375f9101908152919050565b80820281158282048414176107ac576107ac612338565b5f8161266457612664612338565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220e28ae7494480ab1c619fd775dc5ff665588c808a910d66178a982c2e7c76a1e664736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", + "0xaedcc9e7897c0d335bdc5d92fe3a8b4f23727fe558cd1c19f332b28716a30559": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xf5e61edb9c9cc6bfbae4463e9a2b1dd6ac3b44ddef38f18016e56ba0363910d9": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x60b9d94c75b7b3f721925089391e4644cd890cb5e6466f9596dfbd2c54e0b280": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x4b63b79f1e338a49559dcd3193ac9eecc50d0f275d24e97cc8c319e5a31a8bd0": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x800d5dfe4bba53eedee06cd4546a27da8de00f12db83f56062976d4493fda899": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" + } + }, + { + "accountName": "keyless Deployer", + "balance": "0", + "nonce": "1", + "address": "0x694AB5383a002a4796f95530c14Cf0C25ec3EA03" + }, + { + "accountName": "deployer", + "balance": "100000000000000000000000", + "nonce": "8", + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + } + ] } diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 4230de2abb..3094f6d509 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -453,7 +453,7 @@ services: zkevm-mock-l1-network: container_name: zkevm-mock-l1-network - image: 0xpolygon/cdk-validium-contracts:forkId8 + image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.14.3 ports: - 8545:8545 - 8546:8546 From 3e886002c618aad306a824be9ad67c3505e9ce04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 13 May 2024 12:19:11 +0200 Subject: [PATCH 18/21] Update the diff --- docs/diff/diff.html | 1340 ++++++++++++++----------------------------- 1 file changed, 430 insertions(+), 910 deletions(-) diff --git a/docs/diff/diff.html b/docs/diff/diff.html index c78fe91488..19a58310cc 100644 --- a/docs/diff/diff.html +++ b/docs/diff/diff.html @@ -1050,7 +1050,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - +476 + +439 -34
    @@ -121079,133 +121079,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 910 + + - -
    - - - } + +
    +   +
    - - 911 + + - -
    - - + +
    +  
    - - 912 + + - -
    - - - receipt := &types.Receipt{ + +
    +   +
    - - 913 + + - -
    - - - Type: tx.Type(), + +
    +   +
    - - 914 + + - -
    - - - PostState: state.ZeroHash.Bytes(), + +
    +   +
    - - 915 + + - -
    - - - CumulativeGasUsed: 0, + +
    +   +
    - - 916 + + - -
    - - - EffectiveGasPrice: big.NewInt(0), + +
    +   +
    - - 917 + + - -
    - - - BlockNumber: blockNumber, + +
    +   +
    - - 918 + + - -
    - - - GasUsed: tx.Gas(), + +
    +   +
    - - 919 + + - -
    - - - TxHash: tx.Hash(), + +
    +   +
    - - 920 + + - -
    - - - TransactionIndex: 0, + +
    +   +
    - - 921 + + - -
    - - - Status: types.ReceiptStatusSuccessful, + +
    +   +
    - - 922 + + - -
    - - - Logs: logs, + +
    +   +
    @@ -121550,7 +121550,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 923 + 910
    @@ -121560,7 +121560,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 924 + 911
    @@ -121568,6 +121568,136 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + 912 + + +
    + - + receipt := &types.Receipt{ +
    + + + + 913 + + +
    + - + Type: tx.Type(), +
    + + + + 914 + + +
    + - + PostState: state.ZeroHash.Bytes(), +
    + + + + 915 + + +
    + - + CumulativeGasUsed: 0, +
    + + + + 916 + + +
    + - + EffectiveGasPrice: big.NewInt(0), +
    + + + + 917 + + +
    + - + BlockNumber: blockNumber, +
    + + + + 918 + + +
    + - + GasUsed: tx.Gas(), +
    + + + + 919 + + +
    + - + TxHash: tx.Hash(), +
    + + + + 920 + + +
    + - + TransactionIndex: 0, +
    + + + + 921 + + +
    + - + Status: types.ReceiptStatusSuccessful, +
    + + + + 922 + + +
    + - + Logs: logs, +
    + + + + 923 + + +
    + - + } +
    + + + + 924 + + +
    + - +
    +
    + 925 @@ -122178,26 +122308,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - 1002 - - -
    -   - }) -
    - - - - 1003 - - -
    -   - } -
    - @@ -123218,6 +123328,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + 1002 + + +
    +   + }) +
    + @@ -123388,6 +123508,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + 1003 + + +
    +   + } +
    + @@ -125251,7 +125381,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -1409,5 +1757,99 @@
    +
    @@ -1409,5 +1757,62 @@
    @@ -125536,126 +125666,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - -
    @@ -125976,256 +125986,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - -
    @@ -126483,133 +126243,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 910 - +
    +
    - + 911 - +
    + - // number of transactions in a block to be created + // number of transactions in a block to be created
    - + 912 - +
    + - for t := 0; t < txsPerBlock; t++ { + for t := 0; t < txsPerBlock; t++ {
    - + 913 - +
    + - nonce++ + nonce++
    - + 914 - +
    + - txIndex := uint(t + 1) + txIndex := uint(t + 1)
    - + 915 - +
    +
    - + 916 - +
    + - tx := types.NewTx(&types.LegacyTx{ + tx := types.NewTx(&types.LegacyTx{
    - + 917 - +
    + - Nonce: nonce, + Nonce: nonce,
    - + 918 - +
    + - To: nil, + To: nil,
    - + 919 - +
    + - Value: new(big.Int), + Value: new(big.Int),
    - + 920 - +
    + - Gas: 0, + Gas: 0,
    - + 921 - +
    + - GasPrice: big.NewInt(0), + GasPrice: big.NewInt(0),
    - + 922 - +
    + - }) + })
    @@ -127005,6 +126765,136 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + +
    @@ -127583,22 +127473,22 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 1062 - +
    -   + + })
    - + 1063 - +
    -   + + }
    @@ -128603,12 +128493,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 1164 - +
    - + +   })
    @@ -128783,12 +128673,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 1182 - +
    - + +   }
    @@ -130948,12 +130838,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 1786 - +
    - + +  
    @@ -131068,12 +130958,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 1798 - +
    -   + +
    @@ -131084,7 +130974,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - func TestGetFirstUncheckedBlock(t *testing.T) { + func TestGetUncheckedBlocks(t *testing.T) {
    @@ -131104,7 +130994,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - blockNumber := uint64(51001) + blockNumber := uint64(61001)
    @@ -131171,376 +131061,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    1808 - -
    - + -
    -
    - - - - 1809 - - -
    - + - block, err := testState.GetFirstUncheckedBlock(context.Background(), blockNumber, nil) -
    - - - - 1810 - - -
    - + - require.NoError(t, err) -
    - - - - 1811 - - -
    - + - require.Equal(t, uint64(blockNumber+1), block.BlockNumber) -
    - - - - 1812 - - -
    - + - } -
    - - - - 1813 - - -
    - + -
    -
    - - - - 1814 - - -
    - + - func TestUpdateCheckedBlockByNumber(t *testing.T) { -
    - - - - 1815 - - -
    - + - var err error -
    - - - - 1816 - - -
    - + - blockNumber := uint64(54001) -
    - - - - 1817 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) -
    - - - - 1818 - - -
    - + - require.NoError(t, err) -
    - - - - 1819 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) -
    - - - - 1820 - - -
    - + - require.NoError(t, err) -
    - - - - 1821 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) -
    - - - - 1822 - - -
    - + - require.NoError(t, err) -
    - - - - 1823 - - -
    - + -
    -
    - - - - 1824 - - -
    - + - b1, err := testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) -
    - - - - 1825 - - -
    - + - require.NoError(t, err) -
    - - - - 1826 - - -
    - + - require.True(t, b1.Checked) -
    - - - - 1827 - - -
    - + -
    -
    - - - - 1828 - - -
    - + - err = testState.UpdateCheckedBlockByNumber(context.Background(), uint64(blockNumber), false, nil) -
    - - - - 1829 - - -
    - + - require.NoError(t, err) -
    - - - - 1830 - - -
    - + -
    -
    - - - - 1831 - - -
    - + - b1, err = testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) -
    - - - - 1832 - - -
    - + - require.NoError(t, err) -
    - - - - 1833 - - -
    - + - require.False(t, b1.Checked) -
    - - - - 1834 - - -
    - + - } -
    - - - - 1835 - - -
    - + -
    -
    - - - - 1836 - - -
    - + - func TestGetUncheckedBlocks(t *testing.T) { -
    - - - - 1837 - - -
    - + - var err error -
    - - - - 1838 - - -
    - + - blockNumber := uint64(61001) -
    - - - - 1839 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) -
    - - - - 1840 - - -
    - + - require.NoError(t, err) -
    - - - - 1841 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) -
    - - - - 1842 - - -
    - + - require.NoError(t, err) -
    - - - - 1843 - - -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) -
    - - - - 1844 - - -
    - + - require.NoError(t, err) -
    - - - - 1845 -
    + @@ -131549,7 +131069,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1846 + 1809
    @@ -131559,7 +131079,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1847 + 1810
    @@ -131569,7 +131089,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1848 + 1811
    @@ -131579,7 +131099,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1849 + 1812
    @@ -131589,7 +131109,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1850 + 1813
    @@ -131599,7 +131119,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1851 + 1814
    @@ -131609,7 +131129,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1852 + 1815
    @@ -131619,7 +131139,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1853 + 1816
    @@ -131629,7 +131149,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1854 + 1817
    @@ -131639,7 +131159,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1855 + 1818
    @@ -241618,7 +241138,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0 + image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0
    @@ -242537,7 +242057,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - image: 0xpolygon/cdk-validium-contracts:forkId8 + image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.14.3
    From 385bd7267750d9b92e159455d3aff804b0e551fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 21 May 2024 10:51:50 +0200 Subject: [PATCH 19/21] Fix typo in the comment --- docs/diff/diff.html | 4 ++-- test/e2e/datacommittee_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/diff/diff.html b/docs/diff/diff.html index 19a58310cc..56e35466f4 100644 --- a/docs/diff/diff.html +++ b/docs/diff/diff.html @@ -246010,7 +246010,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - dacNodeContainer = "hermeznetwork/cdk-data-availability:v0.0.4" + dacNodeContainer = "0xpolygon/cdk-data-availability:latest"
    @@ -246400,7 +246400,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - // Register committe with N / M signatures + // Register committee with N / M signatures
    diff --git a/test/e2e/datacommittee_test.go b/test/e2e/datacommittee_test.go index c33dd6179f..8b743e703c 100644 --- a/test/e2e/datacommittee_test.go +++ b/test/e2e/datacommittee_test.go @@ -78,7 +78,7 @@ func TestDataCommittee(t *testing.T) { ) require.NoError(t, err) - // Register committe with N / M signatures + // Register committee with N / M signatures membs := members{} addrsBytes := []byte{} urls := []string{} From 67b5ee10b7c2746239fd584eeb7bbaf8ca227f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 21 May 2024 14:57:06 +0200 Subject: [PATCH 20/21] Use the Geth v1.13.11 Docker image and update the genesis spec --- .../local/local.genesis.config.json | 182 +- docs/diff/diff.html | 298912 +++++++++------ test/config/test.genesis.config.json | 34 +- test/docker-compose.yml | 2 +- 4 files changed, 190580 insertions(+), 108550 deletions(-) diff --git a/config/environments/local/local.genesis.config.json b/config/environments/local/local.genesis.config.json index f0e5ecf89b..2646957eb6 100644 --- a/config/environments/local/local.genesis.config.json +++ b/config/environments/local/local.genesis.config.json @@ -6,96 +6,96 @@ "polTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "polygonZkEVMGlobalExitRootAddress": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" }, - "rollupCreationBlockNumber": 82, - "rollupManagerCreationBlockNumber": 82, + "rollupCreationBlockNumber": 46, + "rollupManagerCreationBlockNumber": 41, "root": "0xcc9ec17819f4ac7f282949ca8c379c4d3ee1b8b7908c51b9b405b6319af67b32", "genesis": [ - { - "contractName": "PolygonZkEVMDeployer", - "balance": "0", - "nonce": "4", - "address": "0xFbD07134824dDEa24E4ae414c18ecbFa98169A24", - "bytecode": "0x60806040526004361061006e575f3560e01c8063715018a61161004c578063715018a6146100e25780638da5cb5b146100f6578063e11ae6cb1461011f578063f2fde38b14610132575f80fd5b80632b79805a146100725780634a94d487146100875780636d07dbf81461009a575b5f80fd5b610085610080366004610908565b610151565b005b6100856100953660046109a2565b6101c2565b3480156100a5575f80fd5b506100b96100b43660046109f5565b610203565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ed575f80fd5b50610085610215565b348015610101575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff166100b9565b61008561012d366004610a15565b610228565b34801561013d575f80fd5b5061008561014c366004610a61565b61028e565b61015961034a565b5f6101658585856103ca565b90506101718183610527565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101ca61034a565b6101d583838361056a565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b905f90a1505050565b5f61020e8383610598565b9392505050565b61021d61034a565b6102265f6105a4565b565b61023061034a565b5f61023c8484846103ca565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b61029661034a565b73ffffffffffffffffffffffffffffffffffffffff811661033e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610347816105a4565b50565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610226576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610335565b5f83471015610435576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610335565b81515f0361049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610335565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff811661020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610335565b606061020e83835f6040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610618565b6060610590848484604051806060016040528060298152602001610b0860299139610618565b949350505050565b5f61020e83833061072d565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610335565b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516106d29190610a9c565b5f6040518083038185875af1925050503d805f811461070c576040519150601f19603f3d011682016040523d82523d5f602084013e610711565b606091505b509150915061072287838387610756565b979650505050505050565b5f604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156107eb5782515f036107e45773ffffffffffffffffffffffffffffffffffffffff85163b6107e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610335565b5081610590565b61059083838151156108005781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103359190610ab7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112610870575f80fd5b813567ffffffffffffffff8082111561088b5761088b610834565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108d1576108d1610834565b816040528381528660208588010111156108e9575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f805f806080858703121561091b575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115610940575f80fd5b61094c88838901610861565b93506060870135915080821115610961575f80fd5b5061096e87828801610861565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff8116811461099d575f80fd5b919050565b5f805f606084860312156109b4575f80fd5b6109bd8461097a565b9250602084013567ffffffffffffffff8111156109d8575f80fd5b6109e486828701610861565b925050604084013590509250925092565b5f8060408385031215610a06575f80fd5b50508035926020909101359150565b5f805f60608486031215610a27575f80fd5b8335925060208401359150604084013567ffffffffffffffff811115610a4b575f80fd5b610a5786828701610861565b9150509250925092565b5f60208284031215610a71575f80fd5b61020e8261097a565b5f5b83811015610a94578181015183820152602001610a7c565b50505f910152565b5f8251610aad818460208701610a7a565b9190910192915050565b602081525f8251806020840152610ad5816040850160208701610a7a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220330b94dc698c4d290bf55c23f13b473cde6a6bae0030cb902de18af54e35839f64736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" - } - }, - { - "contractName": "ProxyAdmin", - "balance": "0", - "nonce": "1", - "address": "0xfADB60b5059e31614e02083fF6C021a24C31c891", - "bytecode": "0x608060405260043610610079575f3560e01c80639623609d1161004c5780639623609d1461012357806399a88ec414610136578063f2fde38b14610155578063f3b7dead14610174575f80fd5b8063204e1c7a1461007d578063715018a6146100c55780637eff275e146100db5780638da5cb5b146100fa575b5f80fd5b348015610088575f80fd5b5061009c6100973660046105e8565b610193565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d0575f80fd5b506100d9610244565b005b3480156100e6575f80fd5b506100d96100f536600461060a565b610257565b348015610105575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff1661009c565b6100d961013136600461066e565b6102e0565b348015610141575f80fd5b506100d961015036600461060a565b610371565b348015610160575f80fd5b506100d961016f3660046105e8565b6103cd565b34801561017f575f80fd5b5061009c61018e3660046105e8565b610489565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b5f60405180830381855afa9150503d805f8114610215576040519150601f19603f3d011682016040523d82523d5f602084013e61021a565b606091505b509150915081610228575f80fd5b8080602001905181019061023c919061075b565b949350505050565b61024c6104d3565b6102555f610553565b565b61025f6104d3565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b5f604051808303815f87803b1580156102c6575f80fd5b505af11580156102d8573d5f803e3d5ffd5b505050505050565b6102e86104d3565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061033e9086908690600401610776565b5f604051808303818588803b158015610355575f80fd5b505af1158015610367573d5f803e3d5ffd5b5050505050505050565b6103796104d3565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102af565b6103d56104d3565b73ffffffffffffffffffffffffffffffffffffffff811661047d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61048681610553565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610255576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610474565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff81168114610486575f80fd5b5f602082840312156105f8575f80fd5b8135610603816105c7565b9392505050565b5f806040838503121561061b575f80fd5b8235610626816105c7565b91506020830135610636816105c7565b809150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f805f60608486031215610680575f80fd5b833561068b816105c7565b9250602084013561069b816105c7565b9150604084013567ffffffffffffffff808211156106b7575f80fd5b818601915086601f8301126106ca575f80fd5b8135818111156106dc576106dc610641565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561072257610722610641565b8160405282815289602084870101111561073a575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f6020828403121561076b575f80fd5b8151610603816105c7565b73ffffffffffffffffffffffffffffffffffffffff831681525f602060408184015283518060408501525f5b818110156107be578581018301518582016060015282016107a2565b505f6060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea26469706673582212203083a4ccc2e42eed60bd19037f2efa77ed086dc7a5403f75bebb995dcba2221c64736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" - } - }, - { - "contractName": "PolygonZkEVMBridge implementation", - "balance": "0", - "nonce": "1", - "address": "0x493732fB136a380920C390a85fc27d79C7b70756", - "bytecode": "0x6080604052600436106101a35760003560e01c806383f24403116100e2578063ccaa2d1111610085578063ccaa2d1114610511578063cd58657914610531578063d02103ca14610544578063dbc169761461056b578063ee25560b14610580578063f5efcd79146105ad578063f811bff7146105cd578063fb570834146105ed57600080fd5b806383f244031461040b5780638ed7e3f21461042b578063aaa13cc21461044b578063b8b284d01461046b578063bab161bf1461048b578063be5831c7146104ad578063c00f14ab146104d1578063cc461632146104f157600080fd5b80633cbc795b1161014a5780633cbc795b146102fd5780633e197043146103365780634b2f336d146103565780635ca1e165146103765780637843298b1461038b57806379e2cf97146103ab57806381b1c174146103c057806383c43a55146103f657600080fd5b806315064c96146101a85780632072f6c5146101d757806322e95f2c146101ee578063240ff3781461021b57806327aef4e81461022e5780632dfdf0b514610250578063318aee3d146102745780633c351e10146102dd575b600080fd5b3480156101b457600080fd5b506068546101c29060ff1681565b60405190151581526020015b60405180910390f35b3480156101e357600080fd5b506101ec61060d565b005b3480156101fa57600080fd5b5061020e610209366004612b65565b610642565b6040516101ce9190612b9c565b6101ec610229366004612c06565b610693565b34801561023a57600080fd5b50610243610703565b6040516101ce9190612ccf565b34801561025c57600080fd5b5061026660535481565b6040519081526020016101ce565b34801561028057600080fd5b506102b961028f366004612ce9565b606b6020526000908152604090205463ffffffff811690600160201b90046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016101ce565b3480156102e957600080fd5b50606d5461020e906001600160a01b031681565b34801561030957600080fd5b50606d5461032190600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101ce565b34801561034257600080fd5b50610266610351366004612d15565b610791565b34801561036257600080fd5b50606f5461020e906001600160a01b031681565b34801561038257600080fd5b5061026661081e565b34801561039757600080fd5b5061020e6103a6366004612d94565b6108fb565b3480156103b757600080fd5b506101ec610925565b3480156103cc57600080fd5b5061020e6103db366004612ddd565b606a602052600090815260409020546001600160a01b031681565b34801561040257600080fd5b50610243610946565b34801561041757600080fd5b50610266610426366004612e08565b610965565b34801561043757600080fd5b50606c5461020e906001600160a01b031681565b34801561045757600080fd5b5061020e610466366004612f12565b610a3b565b34801561047757600080fd5b506101ec610486366004612fad565b610b3d565b34801561049757600080fd5b5060685461032190610100900463ffffffff1681565b3480156104b957600080fd5b5060685461032190600160c81b900463ffffffff1681565b3480156104dd57600080fd5b506102436104ec366004612ce9565b610c04565b3480156104fd57600080fd5b506101c261050c36600461302f565b610c49565b34801561051d57600080fd5b506101ec61052c366004613062565b610cd2565b6101ec61053f36600461314d565b6111c7565b34801561055057600080fd5b5060685461020e90600160281b90046001600160a01b031681565b34801561057757600080fd5b506101ec611621565b34801561058c57600080fd5b5061026661059b366004612ddd565b60696020526000908152604090205481565b3480156105b957600080fd5b506101ec6105c8366004613062565b611654565b3480156105d957600080fd5b506101ec6105e83660046131e2565b6118ef565b3480156105f957600080fd5b506101c261060836600461328a565b611b62565b606c546001600160a01b0316331461063857604051631736745960e31b815260040160405180910390fd5b610640611b7a565b565b6000606a6000848460405160200161065b9291906132d2565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b60685460ff16156106b757604051630bc011ff60e21b815260040160405180910390fd5b34158015906106d05750606f546001600160a01b031615155b156106ee576040516301bd897160e61b815260040160405180910390fd5b6106fc858534868686611bd6565b5050505050565b606e8054610710906132fc565b80601f016020809104026020016040519081016040528092919081815260200182805461073c906132fc565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526001600160601b0319606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b605354600090819081805b60208110156108f2578083901c600116600103610886576033816020811061085357610853613336565b015460408051602081019290925281018590526060016040516020818303038152906040528051906020012093506108b3565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806108ea90613362565b915050610829565b50919392505050565b600061091d848461090b85611ca0565b61091486611d5f565b61046687611e17565b949350505050565b605354606854600160c81b900463ffffffff16101561064057610640611ecf565b60405180611ba00160405280611b668152602001613a7a611b66913981565b600083815b6020811015610a3257600163ffffffff8516821c811690036109d55784816020811061099857610998613336565b6020020135826040516020016109b8929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a20565b818582602081106109e8576109e8613336565b6020020135604051602001610a07929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a2a81613362565b91505061096a565b50949350505050565b6000808686604051602001610a519291906132d2565b604051602081830303815290604052805190602001209050600060ff60f81b308360405180611ba00160405280611b668152602001613a7a611b669139898989604051602001610aa39392919061337b565b60408051601f1981840301815290829052610ac192916020016133b4565b60405160208183030381529060405280519060200120604051602001610b1994939291906001600160f81b031994909416845260609290921b6001600160601b03191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610b6157604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610b8a5760405163dde3cda760e01b815260040160405180910390fd5b606f54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610bbc90339088906004016133e3565b600060405180830381600087803b158015610bd657600080fd5b505af1158015610bea573d6000803e3d6000fd5b50505050610bfc868686868686611bd6565b505050505050565b6060610c0f82611ca0565b610c1883611d5f565b610c2184611e17565b604051602001610c339392919061337b565b6040516020818303038152906040529050919050565b6068546000908190610100900463ffffffff16158015610c6f575063ffffffff83166001145b15610c81575063ffffffff8316610ca8565b610c95600160201b63ffffffff85166133fc565b610ca59063ffffffff8616613413565b90505b600881901c600090815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610cf657604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610d26576040516302caf51760e11b815260040160405180910390fd5b610d5a8c8c8c8c8c610d5560008e8e8e8e8e8e8e604051610d48929190613426565b6040518091039020610791565b611f68565b6001600160a01b038616610e9257606f546001600160a01b0316610e295760006001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610db1576020820181803683370190505b50604051610dbf9190613436565b60006040518083038185875af1925050503d8060008114610dfc576040519150601f19603f3d011682016040523d82523d6000602084013e610e01565b606091505b5050905080610e2357604051630ce8f45160e31b815260040160405180910390fd5b5061117a565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990610e5b90879087906004016133e3565b600060405180830381600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b5050505061117a565b606d546001600160a01b038781169116148015610ec05750606d5463ffffffff888116600160a01b90920416145b15610ed85760006001600160a01b0385168482610d87565b60685463ffffffff610100909104811690881603610f0957610f046001600160a01b03871685856120c7565b61117a565b60008787604051602001610f1e9291906132d2565b60408051601f1981840301815291815281516020928301206000818152606a9093529120549091506001600160a01b031680611116576000610f968386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061212292505050565b6040516340c10f1960e01b81529091506001600160a01b038216906340c10f1990610fc7908a908a906004016133e3565b600060405180830381600087803b158015610fe157600080fd5b505af1158015610ff5573d6000803e3d6000fd5b5050505080606a600085815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b6000836001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a83888860405161110895949392919061347b565b60405180910390a150611177565b6040516340c10f1960e01b81526001600160a01b038216906340c10f199061114490899089906004016133e3565b600060405180830381600087803b15801561115e57600080fd5b505af1158015611172573d6000803e3d6000fd5b505050505b50505b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8a888887876040516111b19594939291906134b4565b60405180910390a1505050505050505050505050565b60685460ff16156111eb57604051630bc011ff60e21b815260040160405180910390fd5b6111f361219e565b60685463ffffffff610100909104811690881603611224576040516302caf51760e11b815260040160405180910390fd5b6000806060876001600160a01b03881661130a578834146112585760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611285906132fc565b80601f01602080910402602001604051908101604052809291908181526020018280546112b1906132fc565b80156112fe5780601f106112d3576101008083540402835291602001916112fe565b820191906000526020600020905b8154815290600101906020018083116112e157829003601f168201915b50505050509150611596565b34156113295760405163798ee6f160e01b815260040160405180910390fd5b606f546001600160a01b03908116908916036113a457604051632770a7eb60e21b81526001600160a01b03891690639dc29fac9061136d9033908d906004016133e3565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b50505050611596565b6001600160a01b038089166000908152606b602090815260409182902082518084019093525463ffffffff81168352600160201b9004909216918101829052901561145c57604051632770a7eb60e21b81526001600160a01b038a1690639dc29fac906114179033908e906004016133e3565b600060405180830381600087803b15801561143157600080fd5b505af1158015611445573d6000803e3d6000fd5b505050508060200151945080600001519350611589565b851561146e5761146e898b89896121f7565b6040516370a0823160e01b81526000906001600160a01b038b16906370a082319061149d903090600401612b9c565b602060405180830381865afa1580156114ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114de91906134e6565b90506114f56001600160a01b038b1633308e61253d565b6040516370a0823160e01b81526000906001600160a01b038c16906370a0823190611524903090600401612b9c565b602060405180830381865afa158015611541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156591906134e6565b905061157182826134ff565b6068548c9850610100900463ffffffff169650935050505b61159289610c04565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e86886053546040516115d6989796959493929190613512565b60405180910390a16115fd6115f8600085878f8f878980519060200120610791565b612575565b861561160b5761160b611ecf565b5050505061161860018055565b50505050505050565b606c546001600160a01b0316331461164c57604051631736745960e31b815260040160405180910390fd5b610640612660565b60685460ff161561167857604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146116a8576040516302caf51760e11b815260040160405180910390fd5b6116ca8c8c8c8c8c610d5560018e8e8e8e8e8e8e604051610d48929190613426565b606f546000906001600160a01b031661178157846001600160a01b031684888a86866040516024016116ff949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b179052516117349190613436565b60006040518083038185875af1925050503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b505080915050611883565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906117b390889088906004016133e3565b600060405180830381600087803b1580156117cd57600080fd5b505af11580156117e1573d6000803e3d6000fd5b50505050846001600160a01b031687898585604051602401611806949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183b9190613436565b6000604051808303816000865af19150503d8060008114611878576040519150601f19603f3d011682016040523d82523d6000602084013e61187d565b606091505b50909150505b806118a1576040516337e391c360e01b815260040160405180910390fd5b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8b898988886040516118d89594939291906134b4565b60405180910390a150505050505050505050505050565b600054610100900460ff161580801561190f5750600054600160ff909116105b806119295750303b158015611929575060005460ff166001145b6119915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119b4576000805461ff0019166101001790555b60688054610100600160c81b03191661010063ffffffff8a160265010000000000600160c81b03191617600160281b6001600160a01b038781169190910291909117909155606c80546001600160a01b0319168583161790558616611a3d5763ffffffff851615611a3857604051630d43a60960e11b815260040160405180910390fd5b611b0c565b606d805463ffffffff8716600160a01b026001600160c01b03199091166001600160a01b03891617179055606e611a7483826135fe565b50611aeb6000801b6012604051602001611ad791906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612122565b606f80546001600160a01b0319166001600160a01b03929092169190911790555b611b146126b8565b8015611618576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b600081611b70868686610965565b1495945050505050565b60685460ff1615611b9e57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b60685463ffffffff610100909104811690871603611c07576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611c5b999897969594939291906136bd565b60405180910390a1611c926115f86001606860019054906101000a900463ffffffff16338a8a8a8989604051610d48929190613426565b8215610bfc57610bfc611ecf565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b179052905160609160009182916001600160a01b03861691611ce79190613436565b600060405180830381855afa9150503d8060008114611d22576040519150601f19603f3d011682016040523d82523d6000602084013e611d27565b606091505b509150915081611d5657604051806040016040528060078152602001664e4f5f4e414d4560c81b81525061091d565b61091d816126e7565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b179052905160609160009182916001600160a01b03861691611da69190613436565b600060405180830381855afa9150503d8060008114611de1576040519150601f19603f3d011682016040523d82523d6000602084013e611de6565b606091505b509150915081611d5657604051806040016040528060098152602001681393d7d4d6535093d360ba1b81525061091d565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b1790529051600091829182916001600160a01b03861691611e5d9190613436565b600060405180830381855afa9150503d8060008114611e98576040519150601f19603f3d011682016040523d82523d6000602084013e611e9d565b606091505b5091509150818015611eb0575080516020145b611ebb57601261091d565b8080602001905181019061091d919061372a565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b03600160281b909104166333d6247d611f1661081e565b6040518263ffffffff1660e01b8152600401611f3491815260200190565b600060405180830381600087803b158015611f4e57600080fd5b505af1158015611f62573d6000803e3d6000fd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101206312bd9b1960e11b9092526064810191909152600091600160281b90046001600160a01b03169063257b3632906084016020604051808303816000875af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906134e6565b90508060000361202857604051622f6fad60e01b815260040160405180910390fd5b600080600160401b87161561206857869150612046848a8489611b62565b612063576040516338105f3b60e21b815260040160405180910390fd5b6120b2565b602087901c612078816001613747565b915087925061209361208b868c86610965565b8a8389611b62565b6120b0576040516338105f3b60e21b815260040160405180910390fd5b505b6120bc8282612875565b505050505050505050565b61211d8363a9059cbb60e01b84846040516024016120e69291906133e3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261291d565b505050565b60008060405180611ba00160405280611b668152602001613a7a611b669139836040516020016121539291906133b4565b6040516020818303038152906040529050838151602083016000f591506001600160a01b038216612197576040516305f7d84960e51b815260040160405180910390fd5b5092915050565b6002600154036121f05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611988565b6002600155565b60006122066004828486613764565b61220f9161378e565b9050632afa533160e01b6001600160e01b03198216016123a357600080808080808061223e896004818d613764565b81019061224b91906137be565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461228b5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146122b45760405163750643af60e01b815260040160405180910390fd5b8a85146122d4576040516303fffc4b60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918e16916123529190613436565b6000604051808303816000865af19150503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b505050505050505050506106fc565b6001600160e01b031981166323f2ebc360e21b146123d457604051637141605d60e11b815260040160405180910390fd5b6000808080808080806123ea8a6004818e613764565b8101906123f79190613812565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146124395760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146124625760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f16916124e99190613436565b6000604051808303816000865af19150503d8060008114612526576040519150601f19603f3d011682016040523d82523d6000602084013e61252b565b606091505b50505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611f629085906323b872dd60e01b906084016120e6565b80600161258460206002613979565b61258e91906134ff565b605354106125af576040516377ae67b360e11b815260040160405180910390fd5b60006053600081546125c090613362565b9182905550905060005b6020811015612651578082901c6001166001036125fd5782603382602081106125f5576125f5613336565b015550505050565b6033816020811061261057612610613336565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061264990613362565b9150506125ca565b5061211d613985565b60018055565b60685460ff1661268357604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600054610100900460ff166126df5760405162461bcd60e51b81526004016119889061399b565b6106406129ef565b60606040825110612706578180602001905181019061068d91906139e6565b81516020036128425760005b602081108015612741575082818151811061272f5761272f613336565b01602001516001600160f81b03191615155b15612758578061275081613362565b915050612712565b806000036127905750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b6000816001600160401b038111156127aa576127aa612e47565b6040519080825280601f01601f1916602001820160405280156127d4576020820181803683370190505b50905060005b8281101561283a578481815181106127f4576127f4613336565b602001015160f81c60f81b82828151811061281157612811613336565b60200101906001600160f81b031916908160001a9053508061283281613362565b9150506127da565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b606854600090610100900463ffffffff16158015612899575063ffffffff82166001145b156128ab575063ffffffff82166128d2565b6128bf600160201b63ffffffff84166133fc565b6128cf9063ffffffff8516613413565b90505b600881901c60008181526069602052604081208054600160ff861690811b9182189283905592909190818316900361161857604051630c8d9eab60e31b815260040160405180910390fd5b6000612972826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a169092919063ffffffff16565b80519091501561211d57808060200190518101906129909190613a5c565b61211d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611988565b600054610100900460ff1661265a5760405162461bcd60e51b81526004016119889061399b565b606061091d848460008585600080866001600160a01b03168587604051612a3d9190613436565b60006040518083038185875af1925050503d8060008114612a7a576040519150601f19603f3d011682016040523d82523d6000602084013e612a7f565b606091505b5091509150612a9087838387612a9b565b979650505050505050565b60608315612b0a578251600003612b03576001600160a01b0385163b612b035760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611988565b508161091d565b61091d8383815115612b1f5781518083602001fd5b8060405162461bcd60e51b81526004016119889190612ccf565b803563ffffffff8116811461287057600080fd5b6001600160a01b0381168114612b6257600080fd5b50565b60008060408385031215612b7857600080fd5b612b8183612b39565b91506020830135612b9181612b4d565b809150509250929050565b6001600160a01b0391909116815260200190565b8015158114612b6257600080fd5b60008083601f840112612bd057600080fd5b5081356001600160401b03811115612be757600080fd5b602083019150836020828501011115612bff57600080fd5b9250929050565b600080600080600060808688031215612c1e57600080fd5b612c2786612b39565b94506020860135612c3781612b4d565b93506040860135612c4781612bb0565b925060608601356001600160401b03811115612c6257600080fd5b612c6e88828901612bbe565b969995985093965092949392505050565b60005b83811015612c9a578181015183820152602001612c82565b50506000910152565b60008151808452612cbb816020860160208601612c7f565b601f01601f19169290920160200192915050565b602081526000612ce26020830184612ca3565b9392505050565b600060208284031215612cfb57600080fd5b8135612ce281612b4d565b60ff81168114612b6257600080fd5b600080600080600080600060e0888a031215612d3057600080fd5b8735612d3b81612d06565b9650612d4960208901612b39565b95506040880135612d5981612b4d565b9450612d6760608901612b39565b93506080880135612d7781612b4d565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215612da957600080fd5b612db284612b39565b92506020840135612dc281612b4d565b91506040840135612dd281612b4d565b809150509250925092565b600060208284031215612def57600080fd5b5035919050565b80610400810183101561068d57600080fd5b60008060006104408486031215612e1e57600080fd5b83359250612e2f8560208601612df6565b9150612e3e6104208501612b39565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e8557612e85612e47565b604052919050565b60006001600160401b03821115612ea657612ea6612e47565b50601f01601f191660200190565b6000612ec7612ec284612e8d565b612e5d565b9050828152838383011115612edb57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612f0357600080fd5b612ce283833560208501612eb4565b600080600080600060a08688031215612f2a57600080fd5b612f3386612b39565b94506020860135612f4381612b4d565b935060408601356001600160401b0380821115612f5f57600080fd5b612f6b89838a01612ef2565b94506060880135915080821115612f8157600080fd5b50612f8e88828901612ef2565b9250506080860135612f9f81612d06565b809150509295509295909350565b60008060008060008060a08789031215612fc657600080fd5b612fcf87612b39565b95506020870135612fdf81612b4d565b9450604087013593506060870135612ff681612bb0565b925060808701356001600160401b0381111561301157600080fd5b61301d89828a01612bbe565b979a9699509497509295939492505050565b6000806040838503121561304257600080fd5b61304b83612b39565b915061305960208401612b39565b90509250929050565b6000806000806000806000806000806000806109208d8f03121561308557600080fd5b61308f8e8e612df6565b9b5061309f8e6104008f01612df6565b9a506108008d013599506108208d013598506108408d013597506130c66108608e01612b39565b96506130d66108808e0135612b4d565b6108808d013595506130eb6108a08e01612b39565b94506130fb6108c08e0135612b4d565b6108c08d013593506108e08d013592506001600160401b036109008e0135111561312457600080fd5b6131358e6109008f01358f01612bbe565b81935080925050509295989b509295989b509295989b565b600080600080600080600060c0888a03121561316857600080fd5b61317188612b39565b9650602088013561318181612b4d565b955060408801359450606088013561319881612b4d565b935060808801356131a881612bb0565b925060a08801356001600160401b038111156131c357600080fd5b6131cf8a828b01612bbe565b989b979a50959850939692959293505050565b60008060008060008060c087890312156131fb57600080fd5b61320487612b39565b9550602087013561321481612b4d565b945061322260408801612b39565b9350606087013561323281612b4d565b9250608087013561324281612b4d565b915060a08701356001600160401b0381111561325d57600080fd5b8701601f8101891361326e57600080fd5b61327d89823560208401612eb4565b9150509295509295509295565b60008060008061046085870312156132a157600080fd5b843593506132b28660208701612df6565b92506132c16104208601612b39565b939692955092936104400135925050565b60e09290921b6001600160e01b031916825260601b6001600160601b031916600482015260180190565b600181811c9082168061331057607f821691505b60208210810361333057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016133745761337461334c565b5060010190565b60608152600061338e6060830186612ca3565b82810360208401526133a08186612ca3565b91505060ff83166040830152949350505050565b600083516133c6818460208801612c7f565b8351908301906133da818360208801612c7f565b01949350505050565b6001600160a01b03929092168252602082015260400190565b808202811582820484141761068d5761068d61334c565b8082018082111561068d5761068d61334c565b8183823760009101908152919050565b60008251613448818460208701612c7f565b9190910192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03858116602083015284166040820152608060608201819052600090612a909083018486613452565b94855263ffffffff9390931660208501526001600160a01b039182166040850152166060830152608082015260a00190565b6000602082840312156134f857600080fd5b5051919050565b8181038181111561068d5761068d61334c565b60ff8916815263ffffffff88811660208301526001600160a01b03888116604084015287821660608401528616608083015260a0820185905261010060c0830181905260009161356484830187612ca3565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff841660208201526060604082018190526000906135ae9083018486613452565b9695505050505050565b601f82111561211d57600081815260208120601f850160051c810160208610156135df5750805b601f850160051c820191505b81811015610bfc578281556001016135eb565b81516001600160401b0381111561361757613617612e47565b61362b8161362584546132fc565b846135b8565b602080601f83116001811461366057600084156136485750858301515b600019600386901b1c1916600185901b178555610bfc565b600085815260208120601f198616915b8281101561368f57888601518255948401946001909101908401613670565b50858210156136ad5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60ff8a16815263ffffffff89811660208301526001600160a01b03898116604084015288821660608401528716608083015260a0820186905261010060c083018190526000916137108483018789613452565b925080851660e085015250509a9950505050505050505050565b60006020828403121561373c57600080fd5b8151612ce281612d06565b63ffffffff8181168382160190808211156121975761219761334c565b6000808585111561377457600080fd5b8386111561378157600080fd5b5050820193919092039150565b6001600160e01b031981358181169160048510156137b65780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a0312156137d957600080fd5b87356137e481612b4d565b965060208801356137f481612b4d565b955060408801359450606088013593506080880135612d7781612d06565b600080600080600080600080610100898b03121561382f57600080fd5b883561383a81612b4d565b9750602089013561384a81612b4d565b96506040890135955060608901359450608089013561386881612bb0565b935060a089013561387881612d06565b979a969950949793969295929450505060c08201359160e0013590565b600181815b808511156138d05781600019048211156138b6576138b661334c565b808516156138c357918102915b93841c939080029061389a565b509250929050565b6000826138e75750600161068d565b816138f45750600061068d565b816001811461390a576002811461391457613930565b600191505061068d565b60ff8411156139255761392561334c565b50506001821b61068d565b5060208310610133831016604e8410600b8410161715613953575081810a61068d565b61395d8383613895565b80600019048211156139715761397161334c565b029392505050565b6000612ce283836138d8565b634e487b7160e01b600052600160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156139f857600080fd5b81516001600160401b03811115613a0e57600080fd5b8201601f81018413613a1f57600080fd5b8051613a2d612ec282612e8d565b818152856020838501011115613a4257600080fd5b613a53826020830160208601612c7f565b95945050505050565b600060208284031215613a6e57600080fd5b8151612ce281612bb056fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220914f18d5b241f0d10b2ebc814aadeee338ad60bad704683e414dad415cb2e14d64736f6c63430008140033" - }, - { - "contractName": "PolygonZkEVMBridge proxy", - "balance": "340282366920938463463374607431768211455", - "nonce": "1", - "address": "0xB7098a13a48EcE087d3DA15b2D28eCE0f89819B8", - "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461086f565b610135565b61006b6100a336600461088a565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461086f565b610231565b34801561011257600080fd5b506100bd61025e565b61012361028c565b61013361012e610363565b61036d565b565b61013d610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816040518060200160405280600081525060006103d1565b50565b61017461011b565b610187610391565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103d1915050565b505050565b6101e661011b565b60006101fd610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610363565b905090565b61022e61011b565b90565b610239610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816103fc565b6000610268610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610391565b610294610391565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161045d565b3660008037600080366000845af43d6000803e80801561038c573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103da83610485565b6000825111806103e75750805b156101e6576103f683836104d2565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610425610391565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a1610174816104fe565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103b5565b61048e8161060a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606104f7838360405180606001604052806027815260200161099f602791396106d5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81166105a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161035a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b6106ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161035a565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105c4565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516106ff9190610931565b600060405180830381855af49150503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b50915091506107508683838761075a565b9695505050505050565b606083156107f05782516000036107e95773ffffffffffffffffffffffffffffffffffffffff85163b6107e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035a565b50816107fa565b6107fa8383610802565b949350505050565b8151156108125781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035a919061094d565b803573ffffffffffffffffffffffffffffffffffffffff8116811461086a57600080fd5b919050565b60006020828403121561088157600080fd5b6104f782610846565b60008060006040848603121561089f57600080fd5b6108a884610846565b9250602084013567ffffffffffffffff808211156108c557600080fd5b818601915086601f8301126108d957600080fd5b8135818111156108e857600080fd5b8760208285010111156108fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610928578181015183820152602001610910565b50506000910152565b6000825161094381846020870161090d565b9190910192915050565b602081526000825180602084015261096c81604085016020870161090d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220701a0c26bdd76686e63fc3c65e4f28a20ba3ecc8a60246733c0627e679c9804e64736f6c63430008140033", - "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000493732fb136a380920c390a85fc27d79c7b70756" - } - }, - { - "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", - "balance": "0", - "nonce": "1", - "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b881565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b8161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033" - }, - { - "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", - "balance": "0", - "nonce": "1", - "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", - "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", - "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" - } - }, - { - "contractName": "PolygonZkEVMTimelock", - "balance": "0", - "nonce": "1", - "address": "0x0165878A594ca255338adfa4d48449f69242Eb8F", - "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220c474c39da3523b28ebfa5fd66c05b42d6ddcc4a57055483bdda32888b366016164736f6c63430008140033", - "storage": { - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", - "0xaedcc9e7897c0d335bdc5d92fe3a8b4f23727fe558cd1c19f332b28716a30559": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xf5e61edb9c9cc6bfbae4463e9a2b1dd6ac3b44ddef38f18016e56ba0363910d9": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x60b9d94c75b7b3f721925089391e4644cd890cb5e6466f9596dfbd2c54e0b280": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x4b63b79f1e338a49559dcd3193ac9eecc50d0f275d24e97cc8c319e5a31a8bd0": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", - "0x800d5dfe4bba53eedee06cd4546a27da8de00f12db83f56062976d4493fda899": "0x0000000000000000000000000000000000000000000000000000000000000001", - "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" - } - }, - { - "accountName": "keyless Deployer", - "balance": "0", - "nonce": "1", - "address": "0x694AB5383a002a4796f95530c14Cf0C25ec3EA03" - }, - { - "accountName": "deployer", - "balance": "100000000000000000000000", - "nonce": "8", - "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - } - ] -} \ No newline at end of file + { + "contractName": "PolygonZkEVMDeployer", + "balance": "0", + "nonce": "4", + "address": "0x51dbd54FCCb6b3A07738fd3E156D588e71f79973", + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220964619cee0e0baf94c6f8763f013be157da5d54c89e5cff4a8caf4266e13f13a64736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + } + }, + { + "contractName": "ProxyAdmin", + "balance": "0", + "nonce": "1", + "address": "0xe34Fe58DDa5b8c6D547E4857E987633aa86a5e90", + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220c9867ffac53151bdb1305d8f5e3e883cd83e5270c7ec09cdc24e837b2e65239064736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" + } + }, + { + "contractName": "PolygonZkEVMBridge implementation", + "balance": "0", + "nonce": "1", + "address": "0x493732fB136a380920C390a85fc27d79C7b70756", + "bytecode": "0x6080604052600436106101a35760003560e01c806383f24403116100e2578063ccaa2d1111610085578063ccaa2d1114610511578063cd58657914610531578063d02103ca14610544578063dbc169761461056b578063ee25560b14610580578063f5efcd79146105ad578063f811bff7146105cd578063fb570834146105ed57600080fd5b806383f244031461040b5780638ed7e3f21461042b578063aaa13cc21461044b578063b8b284d01461046b578063bab161bf1461048b578063be5831c7146104ad578063c00f14ab146104d1578063cc461632146104f157600080fd5b80633cbc795b1161014a5780633cbc795b146102fd5780633e197043146103365780634b2f336d146103565780635ca1e165146103765780637843298b1461038b57806379e2cf97146103ab57806381b1c174146103c057806383c43a55146103f657600080fd5b806315064c96146101a85780632072f6c5146101d757806322e95f2c146101ee578063240ff3781461021b57806327aef4e81461022e5780632dfdf0b514610250578063318aee3d146102745780633c351e10146102dd575b600080fd5b3480156101b457600080fd5b506068546101c29060ff1681565b60405190151581526020015b60405180910390f35b3480156101e357600080fd5b506101ec61060d565b005b3480156101fa57600080fd5b5061020e610209366004612b65565b610642565b6040516101ce9190612b9c565b6101ec610229366004612c06565b610693565b34801561023a57600080fd5b50610243610703565b6040516101ce9190612ccf565b34801561025c57600080fd5b5061026660535481565b6040519081526020016101ce565b34801561028057600080fd5b506102b961028f366004612ce9565b606b6020526000908152604090205463ffffffff811690600160201b90046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016101ce565b3480156102e957600080fd5b50606d5461020e906001600160a01b031681565b34801561030957600080fd5b50606d5461032190600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101ce565b34801561034257600080fd5b50610266610351366004612d15565b610791565b34801561036257600080fd5b50606f5461020e906001600160a01b031681565b34801561038257600080fd5b5061026661081e565b34801561039757600080fd5b5061020e6103a6366004612d94565b6108fb565b3480156103b757600080fd5b506101ec610925565b3480156103cc57600080fd5b5061020e6103db366004612ddd565b606a602052600090815260409020546001600160a01b031681565b34801561040257600080fd5b50610243610946565b34801561041757600080fd5b50610266610426366004612e08565b610965565b34801561043757600080fd5b50606c5461020e906001600160a01b031681565b34801561045757600080fd5b5061020e610466366004612f12565b610a3b565b34801561047757600080fd5b506101ec610486366004612fad565b610b3d565b34801561049757600080fd5b5060685461032190610100900463ffffffff1681565b3480156104b957600080fd5b5060685461032190600160c81b900463ffffffff1681565b3480156104dd57600080fd5b506102436104ec366004612ce9565b610c04565b3480156104fd57600080fd5b506101c261050c36600461302f565b610c49565b34801561051d57600080fd5b506101ec61052c366004613062565b610cd2565b6101ec61053f36600461314d565b6111c7565b34801561055057600080fd5b5060685461020e90600160281b90046001600160a01b031681565b34801561057757600080fd5b506101ec611621565b34801561058c57600080fd5b5061026661059b366004612ddd565b60696020526000908152604090205481565b3480156105b957600080fd5b506101ec6105c8366004613062565b611654565b3480156105d957600080fd5b506101ec6105e83660046131e2565b6118ef565b3480156105f957600080fd5b506101c261060836600461328a565b611b62565b606c546001600160a01b0316331461063857604051631736745960e31b815260040160405180910390fd5b610640611b7a565b565b6000606a6000848460405160200161065b9291906132d2565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b60685460ff16156106b757604051630bc011ff60e21b815260040160405180910390fd5b34158015906106d05750606f546001600160a01b031615155b156106ee576040516301bd897160e61b815260040160405180910390fd5b6106fc858534868686611bd6565b5050505050565b606e8054610710906132fc565b80601f016020809104026020016040519081016040528092919081815260200182805461073c906132fc565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526001600160601b0319606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b605354600090819081805b60208110156108f2578083901c600116600103610886576033816020811061085357610853613336565b015460408051602081019290925281018590526060016040516020818303038152906040528051906020012093506108b3565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806108ea90613362565b915050610829565b50919392505050565b600061091d848461090b85611ca0565b61091486611d5f565b61046687611e17565b949350505050565b605354606854600160c81b900463ffffffff16101561064057610640611ecf565b60405180611ba00160405280611b668152602001613a7a611b66913981565b600083815b6020811015610a3257600163ffffffff8516821c811690036109d55784816020811061099857610998613336565b6020020135826040516020016109b8929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a20565b818582602081106109e8576109e8613336565b6020020135604051602001610a07929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a2a81613362565b91505061096a565b50949350505050565b6000808686604051602001610a519291906132d2565b604051602081830303815290604052805190602001209050600060ff60f81b308360405180611ba00160405280611b668152602001613a7a611b669139898989604051602001610aa39392919061337b565b60408051601f1981840301815290829052610ac192916020016133b4565b60405160208183030381529060405280519060200120604051602001610b1994939291906001600160f81b031994909416845260609290921b6001600160601b03191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610b6157604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610b8a5760405163dde3cda760e01b815260040160405180910390fd5b606f54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610bbc90339088906004016133e3565b600060405180830381600087803b158015610bd657600080fd5b505af1158015610bea573d6000803e3d6000fd5b50505050610bfc868686868686611bd6565b505050505050565b6060610c0f82611ca0565b610c1883611d5f565b610c2184611e17565b604051602001610c339392919061337b565b6040516020818303038152906040529050919050565b6068546000908190610100900463ffffffff16158015610c6f575063ffffffff83166001145b15610c81575063ffffffff8316610ca8565b610c95600160201b63ffffffff85166133fc565b610ca59063ffffffff8616613413565b90505b600881901c600090815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610cf657604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610d26576040516302caf51760e11b815260040160405180910390fd5b610d5a8c8c8c8c8c610d5560008e8e8e8e8e8e8e604051610d48929190613426565b6040518091039020610791565b611f68565b6001600160a01b038616610e9257606f546001600160a01b0316610e295760006001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610db1576020820181803683370190505b50604051610dbf9190613436565b60006040518083038185875af1925050503d8060008114610dfc576040519150601f19603f3d011682016040523d82523d6000602084013e610e01565b606091505b5050905080610e2357604051630ce8f45160e31b815260040160405180910390fd5b5061117a565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990610e5b90879087906004016133e3565b600060405180830381600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b5050505061117a565b606d546001600160a01b038781169116148015610ec05750606d5463ffffffff888116600160a01b90920416145b15610ed85760006001600160a01b0385168482610d87565b60685463ffffffff610100909104811690881603610f0957610f046001600160a01b03871685856120c7565b61117a565b60008787604051602001610f1e9291906132d2565b60408051601f1981840301815291815281516020928301206000818152606a9093529120549091506001600160a01b031680611116576000610f968386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061212292505050565b6040516340c10f1960e01b81529091506001600160a01b038216906340c10f1990610fc7908a908a906004016133e3565b600060405180830381600087803b158015610fe157600080fd5b505af1158015610ff5573d6000803e3d6000fd5b5050505080606a600085815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b6000836001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a83888860405161110895949392919061347b565b60405180910390a150611177565b6040516340c10f1960e01b81526001600160a01b038216906340c10f199061114490899089906004016133e3565b600060405180830381600087803b15801561115e57600080fd5b505af1158015611172573d6000803e3d6000fd5b505050505b50505b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8a888887876040516111b19594939291906134b4565b60405180910390a1505050505050505050505050565b60685460ff16156111eb57604051630bc011ff60e21b815260040160405180910390fd5b6111f361219e565b60685463ffffffff610100909104811690881603611224576040516302caf51760e11b815260040160405180910390fd5b6000806060876001600160a01b03881661130a578834146112585760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611285906132fc565b80601f01602080910402602001604051908101604052809291908181526020018280546112b1906132fc565b80156112fe5780601f106112d3576101008083540402835291602001916112fe565b820191906000526020600020905b8154815290600101906020018083116112e157829003601f168201915b50505050509150611596565b34156113295760405163798ee6f160e01b815260040160405180910390fd5b606f546001600160a01b03908116908916036113a457604051632770a7eb60e21b81526001600160a01b03891690639dc29fac9061136d9033908d906004016133e3565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b50505050611596565b6001600160a01b038089166000908152606b602090815260409182902082518084019093525463ffffffff81168352600160201b9004909216918101829052901561145c57604051632770a7eb60e21b81526001600160a01b038a1690639dc29fac906114179033908e906004016133e3565b600060405180830381600087803b15801561143157600080fd5b505af1158015611445573d6000803e3d6000fd5b505050508060200151945080600001519350611589565b851561146e5761146e898b89896121f7565b6040516370a0823160e01b81526000906001600160a01b038b16906370a082319061149d903090600401612b9c565b602060405180830381865afa1580156114ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114de91906134e6565b90506114f56001600160a01b038b1633308e61253d565b6040516370a0823160e01b81526000906001600160a01b038c16906370a0823190611524903090600401612b9c565b602060405180830381865afa158015611541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156591906134e6565b905061157182826134ff565b6068548c9850610100900463ffffffff169650935050505b61159289610c04565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e86886053546040516115d6989796959493929190613512565b60405180910390a16115fd6115f8600085878f8f878980519060200120610791565b612575565b861561160b5761160b611ecf565b5050505061161860018055565b50505050505050565b606c546001600160a01b0316331461164c57604051631736745960e31b815260040160405180910390fd5b610640612660565b60685460ff161561167857604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146116a8576040516302caf51760e11b815260040160405180910390fd5b6116ca8c8c8c8c8c610d5560018e8e8e8e8e8e8e604051610d48929190613426565b606f546000906001600160a01b031661178157846001600160a01b031684888a86866040516024016116ff949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b179052516117349190613436565b60006040518083038185875af1925050503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b505080915050611883565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906117b390889088906004016133e3565b600060405180830381600087803b1580156117cd57600080fd5b505af11580156117e1573d6000803e3d6000fd5b50505050846001600160a01b031687898585604051602401611806949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183b9190613436565b6000604051808303816000865af19150503d8060008114611878576040519150601f19603f3d011682016040523d82523d6000602084013e61187d565b606091505b50909150505b806118a1576040516337e391c360e01b815260040160405180910390fd5b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8b898988886040516118d89594939291906134b4565b60405180910390a150505050505050505050505050565b600054610100900460ff161580801561190f5750600054600160ff909116105b806119295750303b158015611929575060005460ff166001145b6119915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119b4576000805461ff0019166101001790555b60688054610100600160c81b03191661010063ffffffff8a160265010000000000600160c81b03191617600160281b6001600160a01b038781169190910291909117909155606c80546001600160a01b0319168583161790558616611a3d5763ffffffff851615611a3857604051630d43a60960e11b815260040160405180910390fd5b611b0c565b606d805463ffffffff8716600160a01b026001600160c01b03199091166001600160a01b03891617179055606e611a7483826135fe565b50611aeb6000801b6012604051602001611ad791906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612122565b606f80546001600160a01b0319166001600160a01b03929092169190911790555b611b146126b8565b8015611618576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b600081611b70868686610965565b1495945050505050565b60685460ff1615611b9e57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b60685463ffffffff610100909104811690871603611c07576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611c5b999897969594939291906136bd565b60405180910390a1611c926115f86001606860019054906101000a900463ffffffff16338a8a8a8989604051610d48929190613426565b8215610bfc57610bfc611ecf565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b179052905160609160009182916001600160a01b03861691611ce79190613436565b600060405180830381855afa9150503d8060008114611d22576040519150601f19603f3d011682016040523d82523d6000602084013e611d27565b606091505b509150915081611d5657604051806040016040528060078152602001664e4f5f4e414d4560c81b81525061091d565b61091d816126e7565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b179052905160609160009182916001600160a01b03861691611da69190613436565b600060405180830381855afa9150503d8060008114611de1576040519150601f19603f3d011682016040523d82523d6000602084013e611de6565b606091505b509150915081611d5657604051806040016040528060098152602001681393d7d4d6535093d360ba1b81525061091d565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b1790529051600091829182916001600160a01b03861691611e5d9190613436565b600060405180830381855afa9150503d8060008114611e98576040519150601f19603f3d011682016040523d82523d6000602084013e611e9d565b606091505b5091509150818015611eb0575080516020145b611ebb57601261091d565b8080602001905181019061091d919061372a565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b03600160281b909104166333d6247d611f1661081e565b6040518263ffffffff1660e01b8152600401611f3491815260200190565b600060405180830381600087803b158015611f4e57600080fd5b505af1158015611f62573d6000803e3d6000fd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101206312bd9b1960e11b9092526064810191909152600091600160281b90046001600160a01b03169063257b3632906084016020604051808303816000875af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906134e6565b90508060000361202857604051622f6fad60e01b815260040160405180910390fd5b600080600160401b87161561206857869150612046848a8489611b62565b612063576040516338105f3b60e21b815260040160405180910390fd5b6120b2565b602087901c612078816001613747565b915087925061209361208b868c86610965565b8a8389611b62565b6120b0576040516338105f3b60e21b815260040160405180910390fd5b505b6120bc8282612875565b505050505050505050565b61211d8363a9059cbb60e01b84846040516024016120e69291906133e3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261291d565b505050565b60008060405180611ba00160405280611b668152602001613a7a611b669139836040516020016121539291906133b4565b6040516020818303038152906040529050838151602083016000f591506001600160a01b038216612197576040516305f7d84960e51b815260040160405180910390fd5b5092915050565b6002600154036121f05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611988565b6002600155565b60006122066004828486613764565b61220f9161378e565b9050632afa533160e01b6001600160e01b03198216016123a357600080808080808061223e896004818d613764565b81019061224b91906137be565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461228b5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146122b45760405163750643af60e01b815260040160405180910390fd5b8a85146122d4576040516303fffc4b60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918e16916123529190613436565b6000604051808303816000865af19150503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b505050505050505050506106fc565b6001600160e01b031981166323f2ebc360e21b146123d457604051637141605d60e11b815260040160405180910390fd5b6000808080808080806123ea8a6004818e613764565b8101906123f79190613812565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146124395760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146124625760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f16916124e99190613436565b6000604051808303816000865af19150503d8060008114612526576040519150601f19603f3d011682016040523d82523d6000602084013e61252b565b606091505b50505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611f629085906323b872dd60e01b906084016120e6565b80600161258460206002613979565b61258e91906134ff565b605354106125af576040516377ae67b360e11b815260040160405180910390fd5b60006053600081546125c090613362565b9182905550905060005b6020811015612651578082901c6001166001036125fd5782603382602081106125f5576125f5613336565b015550505050565b6033816020811061261057612610613336565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061264990613362565b9150506125ca565b5061211d613985565b60018055565b60685460ff1661268357604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600054610100900460ff166126df5760405162461bcd60e51b81526004016119889061399b565b6106406129ef565b60606040825110612706578180602001905181019061068d91906139e6565b81516020036128425760005b602081108015612741575082818151811061272f5761272f613336565b01602001516001600160f81b03191615155b15612758578061275081613362565b915050612712565b806000036127905750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b6000816001600160401b038111156127aa576127aa612e47565b6040519080825280601f01601f1916602001820160405280156127d4576020820181803683370190505b50905060005b8281101561283a578481815181106127f4576127f4613336565b602001015160f81c60f81b82828151811061281157612811613336565b60200101906001600160f81b031916908160001a9053508061283281613362565b9150506127da565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b606854600090610100900463ffffffff16158015612899575063ffffffff82166001145b156128ab575063ffffffff82166128d2565b6128bf600160201b63ffffffff84166133fc565b6128cf9063ffffffff8516613413565b90505b600881901c60008181526069602052604081208054600160ff861690811b9182189283905592909190818316900361161857604051630c8d9eab60e31b815260040160405180910390fd5b6000612972826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a169092919063ffffffff16565b80519091501561211d57808060200190518101906129909190613a5c565b61211d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611988565b600054610100900460ff1661265a5760405162461bcd60e51b81526004016119889061399b565b606061091d848460008585600080866001600160a01b03168587604051612a3d9190613436565b60006040518083038185875af1925050503d8060008114612a7a576040519150601f19603f3d011682016040523d82523d6000602084013e612a7f565b606091505b5091509150612a9087838387612a9b565b979650505050505050565b60608315612b0a578251600003612b03576001600160a01b0385163b612b035760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611988565b508161091d565b61091d8383815115612b1f5781518083602001fd5b8060405162461bcd60e51b81526004016119889190612ccf565b803563ffffffff8116811461287057600080fd5b6001600160a01b0381168114612b6257600080fd5b50565b60008060408385031215612b7857600080fd5b612b8183612b39565b91506020830135612b9181612b4d565b809150509250929050565b6001600160a01b0391909116815260200190565b8015158114612b6257600080fd5b60008083601f840112612bd057600080fd5b5081356001600160401b03811115612be757600080fd5b602083019150836020828501011115612bff57600080fd5b9250929050565b600080600080600060808688031215612c1e57600080fd5b612c2786612b39565b94506020860135612c3781612b4d565b93506040860135612c4781612bb0565b925060608601356001600160401b03811115612c6257600080fd5b612c6e88828901612bbe565b969995985093965092949392505050565b60005b83811015612c9a578181015183820152602001612c82565b50506000910152565b60008151808452612cbb816020860160208601612c7f565b601f01601f19169290920160200192915050565b602081526000612ce26020830184612ca3565b9392505050565b600060208284031215612cfb57600080fd5b8135612ce281612b4d565b60ff81168114612b6257600080fd5b600080600080600080600060e0888a031215612d3057600080fd5b8735612d3b81612d06565b9650612d4960208901612b39565b95506040880135612d5981612b4d565b9450612d6760608901612b39565b93506080880135612d7781612b4d565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215612da957600080fd5b612db284612b39565b92506020840135612dc281612b4d565b91506040840135612dd281612b4d565b809150509250925092565b600060208284031215612def57600080fd5b5035919050565b80610400810183101561068d57600080fd5b60008060006104408486031215612e1e57600080fd5b83359250612e2f8560208601612df6565b9150612e3e6104208501612b39565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e8557612e85612e47565b604052919050565b60006001600160401b03821115612ea657612ea6612e47565b50601f01601f191660200190565b6000612ec7612ec284612e8d565b612e5d565b9050828152838383011115612edb57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612f0357600080fd5b612ce283833560208501612eb4565b600080600080600060a08688031215612f2a57600080fd5b612f3386612b39565b94506020860135612f4381612b4d565b935060408601356001600160401b0380821115612f5f57600080fd5b612f6b89838a01612ef2565b94506060880135915080821115612f8157600080fd5b50612f8e88828901612ef2565b9250506080860135612f9f81612d06565b809150509295509295909350565b60008060008060008060a08789031215612fc657600080fd5b612fcf87612b39565b95506020870135612fdf81612b4d565b9450604087013593506060870135612ff681612bb0565b925060808701356001600160401b0381111561301157600080fd5b61301d89828a01612bbe565b979a9699509497509295939492505050565b6000806040838503121561304257600080fd5b61304b83612b39565b915061305960208401612b39565b90509250929050565b6000806000806000806000806000806000806109208d8f03121561308557600080fd5b61308f8e8e612df6565b9b5061309f8e6104008f01612df6565b9a506108008d013599506108208d013598506108408d013597506130c66108608e01612b39565b96506130d66108808e0135612b4d565b6108808d013595506130eb6108a08e01612b39565b94506130fb6108c08e0135612b4d565b6108c08d013593506108e08d013592506001600160401b036109008e0135111561312457600080fd5b6131358e6109008f01358f01612bbe565b81935080925050509295989b509295989b509295989b565b600080600080600080600060c0888a03121561316857600080fd5b61317188612b39565b9650602088013561318181612b4d565b955060408801359450606088013561319881612b4d565b935060808801356131a881612bb0565b925060a08801356001600160401b038111156131c357600080fd5b6131cf8a828b01612bbe565b989b979a50959850939692959293505050565b60008060008060008060c087890312156131fb57600080fd5b61320487612b39565b9550602087013561321481612b4d565b945061322260408801612b39565b9350606087013561323281612b4d565b9250608087013561324281612b4d565b915060a08701356001600160401b0381111561325d57600080fd5b8701601f8101891361326e57600080fd5b61327d89823560208401612eb4565b9150509295509295509295565b60008060008061046085870312156132a157600080fd5b843593506132b28660208701612df6565b92506132c16104208601612b39565b939692955092936104400135925050565b60e09290921b6001600160e01b031916825260601b6001600160601b031916600482015260180190565b600181811c9082168061331057607f821691505b60208210810361333057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016133745761337461334c565b5060010190565b60608152600061338e6060830186612ca3565b82810360208401526133a08186612ca3565b91505060ff83166040830152949350505050565b600083516133c6818460208801612c7f565b8351908301906133da818360208801612c7f565b01949350505050565b6001600160a01b03929092168252602082015260400190565b808202811582820484141761068d5761068d61334c565b8082018082111561068d5761068d61334c565b8183823760009101908152919050565b60008251613448818460208701612c7f565b9190910192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03858116602083015284166040820152608060608201819052600090612a909083018486613452565b94855263ffffffff9390931660208501526001600160a01b039182166040850152166060830152608082015260a00190565b6000602082840312156134f857600080fd5b5051919050565b8181038181111561068d5761068d61334c565b60ff8916815263ffffffff88811660208301526001600160a01b03888116604084015287821660608401528616608083015260a0820185905261010060c0830181905260009161356484830187612ca3565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff841660208201526060604082018190526000906135ae9083018486613452565b9695505050505050565b601f82111561211d57600081815260208120601f850160051c810160208610156135df5750805b601f850160051c820191505b81811015610bfc578281556001016135eb565b81516001600160401b0381111561361757613617612e47565b61362b8161362584546132fc565b846135b8565b602080601f83116001811461366057600084156136485750858301515b600019600386901b1c1916600185901b178555610bfc565b600085815260208120601f198616915b8281101561368f57888601518255948401946001909101908401613670565b50858210156136ad5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60ff8a16815263ffffffff89811660208301526001600160a01b03898116604084015288821660608401528716608083015260a0820186905261010060c083018190526000916137108483018789613452565b925080851660e085015250509a9950505050505050505050565b60006020828403121561373c57600080fd5b8151612ce281612d06565b63ffffffff8181168382160190808211156121975761219761334c565b6000808585111561377457600080fd5b8386111561378157600080fd5b5050820193919092039150565b6001600160e01b031981358181169160048510156137b65780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a0312156137d957600080fd5b87356137e481612b4d565b965060208801356137f481612b4d565b955060408801359450606088013593506080880135612d7781612d06565b600080600080600080600080610100898b03121561382f57600080fd5b883561383a81612b4d565b9750602089013561384a81612b4d565b96506040890135955060608901359450608089013561386881612bb0565b935060a089013561387881612d06565b979a969950949793969295929450505060c08201359160e0013590565b600181815b808511156138d05781600019048211156138b6576138b661334c565b808516156138c357918102915b93841c939080029061389a565b509250929050565b6000826138e75750600161068d565b816138f45750600061068d565b816001811461390a576002811461391457613930565b600191505061068d565b60ff8411156139255761392561334c565b50506001821b61068d565b5060208310610133831016604e8410600b8410161715613953575081810a61068d565b61395d8383613895565b80600019048211156139715761397161334c565b029392505050565b6000612ce283836138d8565b634e487b7160e01b600052600160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156139f857600080fd5b81516001600160401b03811115613a0e57600080fd5b8201601f81018413613a1f57600080fd5b8051613a2d612ec282612e8d565b818152856020838501011115613a4257600080fd5b613a53826020830160208601612c7f565b95945050505050565b600060208284031215613a6e57600080fd5b8151612ce281612bb056fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220914f18d5b241f0d10b2ebc814aadeee338ad60bad704683e414dad415cb2e14d64736f6c63430008140033" + }, + { + "contractName": "PolygonZkEVMBridge proxy", + "balance": "340282366920938463463374607431768211455", + "nonce": "1", + "address": "0xB7098a13a48EcE087d3DA15b2D28eCE0f89819B8", + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461086f565b610135565b61006b6100a336600461088a565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461086f565b610231565b34801561011257600080fd5b506100bd61025e565b61012361028c565b61013361012e610363565b61036d565b565b61013d610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816040518060200160405280600081525060006103d1565b50565b61017461011b565b610187610391565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103d1915050565b505050565b6101e661011b565b60006101fd610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610363565b905090565b61022e61011b565b90565b610239610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816103fc565b6000610268610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610391565b610294610391565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161045d565b3660008037600080366000845af43d6000803e80801561038c573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103da83610485565b6000825111806103e75750805b156101e6576103f683836104d2565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610425610391565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a1610174816104fe565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103b5565b61048e8161060a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606104f7838360405180606001604052806027815260200161099f602791396106d5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81166105a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161035a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b6106ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161035a565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105c4565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516106ff9190610931565b600060405180830381855af49150503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b50915091506107508683838761075a565b9695505050505050565b606083156107f05782516000036107e95773ffffffffffffffffffffffffffffffffffffffff85163b6107e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035a565b50816107fa565b6107fa8383610802565b949350505050565b8151156108125781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035a919061094d565b803573ffffffffffffffffffffffffffffffffffffffff8116811461086a57600080fd5b919050565b60006020828403121561088157600080fd5b6104f782610846565b60008060006040848603121561089f57600080fd5b6108a884610846565b9250602084013567ffffffffffffffff808211156108c557600080fd5b818601915086601f8301126108d957600080fd5b8135818111156108e857600080fd5b8760208285010111156108fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610928578181015183820152602001610910565b50506000910152565b6000825161094381846020870161090d565b9190910192915050565b602081526000825180602084015261096c81604085016020870161090d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220701a0c26bdd76686e63fc3c65e4f28a20ba3ecc8a60246733c0627e679c9804e64736f6c63430008140033", + "storage": { + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000493732fb136a380920c390a85fc27d79c7b70756" + } + }, + { + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", + "balance": "0", + "nonce": "1", + "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b881565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b8161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033" + }, + { + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", + "balance": "0", + "nonce": "1", + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", + "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", + "storage": { + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" + } + }, + { + "contractName": "PolygonZkEVMTimelock", + "balance": "0", + "nonce": "1", + "address": "0x0165878A594ca255338adfa4d48449f69242Eb8F", + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220c474c39da3523b28ebfa5fd66c05b42d6ddcc4a57055483bdda32888b366016164736f6c63430008140033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", + "0xaedcc9e7897c0d335bdc5d92fe3a8b4f23727fe558cd1c19f332b28716a30559": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xf5e61edb9c9cc6bfbae4463e9a2b1dd6ac3b44ddef38f18016e56ba0363910d9": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x60b9d94c75b7b3f721925089391e4644cd890cb5e6466f9596dfbd2c54e0b280": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x4b63b79f1e338a49559dcd3193ac9eecc50d0f275d24e97cc8c319e5a31a8bd0": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + "0x800d5dfe4bba53eedee06cd4546a27da8de00f12db83f56062976d4493fda899": "0x0000000000000000000000000000000000000000000000000000000000000001", + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" + } + }, + { + "accountName": "keyless Deployer", + "balance": "0", + "nonce": "1", + "address": "0x28BB4e66addE1f042B77E04cf7D3784C1dcDBbA3" + }, + { + "accountName": "deployer", + "balance": "100000000000000000000000", + "nonce": "8", + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" + } + ] +} diff --git a/docs/diff/diff.html b/docs/diff/diff.html index 56e35466f4..c59138241b 100644 --- a/docs/diff/diff.html +++ b/docs/diff/diff.html @@ -54,7 +54,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - Files changed (137) + Files changed (209) hide show
    @@ -66,8 +66,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator.go - +135 - -21 + +807 + -27 @@ -78,8 +78,44 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go - +10 - -10 + +82 + -82 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/batch.go + + +0 + -427 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobinner.go + + +0 + -7 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobouter.go + + +0 + -11
  • @@ -95,6 +131,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/final.go + + +0 + -288 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go - +2 - -1 + +9 + -8 + +
    +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/beacon_client.go + + +0 + -68 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_beacon_blob_sidecars.go + + +0 + -92 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_beacon_genesis.go + + +0 + -60 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_config_spec.go + + +0 + -64
  • @@ -150,8 +246,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go - +158 - -18 + +140 + -29 @@ -198,8 +294,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go - +12 - -6 + +13 + -7 @@ -210,8 +306,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go - +15 - -1 + +7 + -2 @@ -352,10 +448,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0018.sql + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0013_test.go - +11 - -0 + +19 + -25 @@ -364,10 +460,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0018_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql - +69 - -0 + +19 + -75 @@ -376,10 +472,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go - +25 - -0 + +107 + -81 @@ -388,10 +484,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0021.sql - +145 - -0 + +0 + -25 @@ -400,10 +496,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020.sql + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0021_test.go - +28 - -0 + +0 + -145 @@ -412,10 +508,46 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022.sql - +99 - -0 + +0 + -12 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022_test.go + + +0 + -106 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0023.sql + + +0 + -57 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/utils_test.go + + +0 + -159
  • @@ -443,6 +575,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/docker-compose.yml + + +1 + -1 + + +
  • zkevm-node version: v0.6.0

  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/config.go + + +0 + -2 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/eip4844/eip4844.go + + +0 + -86 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go - +292 - -136 + +407 + -332
  • @@ -486,8 +654,80 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go - +42 - -31 + +51 + -40 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/events_helper.go + + +0 + -191 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/events_helper_test.go + + +0 + -180 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_contracts.go + + +0 + -38 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_event_sequence_blobs.go + + +0 + -173 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events.go + + +0 + -76 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events_test.go + + +0 + -17
  • @@ -510,11 +750,83 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - +27 + +51 + -25 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/types.go + + +4 + -5 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/ethtxmanager.go + + +4 + -33 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/ethtxmanager_test.go + + +8 + -8 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/interfaces.go + + +0 -2
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/pgstorage.go + + +0 + -44 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/pgstorage_test.go + + +0 + -66 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go - +5 + +3 -0
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/event/eventlog.go + + +25 + -1 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod - +11 - -8 + +44 + -38
  • @@ -582,8 +906,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go - +10 - -3 + +4 + -1 @@ -594,8 +918,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go - +236 - -1 + +235 + -0 @@ -678,8 +1002,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go - +20 - -1 + +0 + -5 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive.go + + +0 + -94 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive_test.go + + +0 + -113 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/client.go + + +5 + -25 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/tree.go + + +0 + -3 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/tree_test.go + + +0 + -86
  • @@ -763,7 +1147,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go +13 - -1 + -2 @@ -774,8 +1158,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go - +66 - -0 + +67 + -1 @@ -786,8 +1170,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto - +1 - -0 + +2 + -246 @@ -796,10 +1180,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/addrqueue.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/batch.go - +4 - -0 + +8 + -4 @@ -822,8 +1206,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - +103 - -26 + +8 + -6 @@ -832,10 +1216,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go - +4 - -2 + +12 + -1 @@ -844,9 +1228,9 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go - +11 + +17 -0 @@ -856,9 +1240,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go - +19 + +2 + -0 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go + + +6 -2 @@ -868,10 +1264,22 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/worker.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go + + +18 + -107 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go - +20 - -0 + +1 + -1
  • @@ -880,10 +1288,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sonar-project.properties +2 - -0 + -7 @@ -892,9 +1300,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batch_pending.go - +6 + +0 + -11 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go + + +12 + -19 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2_test.go + + +2 -2 @@ -904,10 +1336,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV3.go - +15 - -104 + +0 + -137
  • @@ -916,9 +1348,69 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_in.go - +1 + +0 + -101 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_process.go + + +0 + -18 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_request.go + + +0 + -81 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_response.go + + +0 + -114 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_sequences.go + + +0 + -69 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV2.go + + +0 -1 @@ -928,10 +1420,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV3.go - +3 - -0 + +0 + -79
  • @@ -940,9 +1432,9 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go - +1 + +2 -0 @@ -959,6 +1451,42 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/encoding_batch_v2.go + + +50 + -116 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/encoding_batch_v2_test.go + + +6 + -44 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/forkid.go + + +2 + -4 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go - +0 - -2 + +3 + -5
  • @@ -990,7 +1518,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - +8 + +12 + -24 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree_recursive.go + + +0 + -83 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree_test.go + + +4 + -11 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch.go + + +21 -1 @@ -1000,10 +1564,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch_pending.go - +18 - -7 + +0 + -1
  • @@ -1012,10 +1576,46 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_inner_in.go - +88 - -8 + +0 + -41 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_sequences.go + + +0 + -48 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_external_test.go + + +4 + -4 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_test.go + + +1 + -1
  • @@ -1026,8 +1626,20 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go - +2 - -2 + +27 + -66 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree_recursive.go + + +0 + -46
  • @@ -1038,8 +1650,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go - +87 - -3 + +84 + -0 @@ -1050,8 +1662,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go - +439 - -34 + +116 + -66 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/proof.go + + +54 + -35 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/transaction.go + + +4 + -10
  • @@ -1062,8 +1698,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - +14 - -7 + +0 + -2 @@ -1074,8 +1710,44 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go - +7 - -0 + +11 + -26 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/errors.go + + +0 + -143 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/instrumentation/tracers/native/gen_callframe_json.go + + +2 + -2 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/runtime.go + + +0 + -66
  • @@ -1086,8 +1758,44 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go - +25 - -1 + +5 + -7 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/syncinginfo_test.go + + +2 + -2 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_common/common.go + + +2 + -6 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_etrog/etrog_test.go + + +3 + -5
  • @@ -1098,8 +1806,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go - +9 - -1 + +10 + -2 @@ -1110,8 +1818,20 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go - +11 - -8 + +7 + -3 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go + + +32 + -47
  • @@ -1122,8 +1842,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - +16 - -7 + +1 + -1 @@ -1132,10 +1852,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_initial_sequence_batches.go - +34 - -22 + +3 + -3 @@ -1146,8 +1866,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go - +5 - -52 + +8 + -55 @@ -1156,7 +1876,19 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update.go + + +3 + -3 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update_test.go +1 -1 @@ -1168,10 +1900,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/reorg_error.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go - +44 - -0 + +5 + -5
  • @@ -1180,10 +1912,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/async_l1_block_checker.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches_test.go - +40 - -0 + +2 + -2 @@ -1192,10 +1924,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_update_etrog_sequence.go +3 - -1 + -3 @@ -1204,10 +1936,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_info_tree_update.go - +5 - -0 + +0 + -54 @@ -1216,10 +1948,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_ethereum_compatible_client.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs.go - +21 - -0 + +0 + -189 @@ -1228,10 +1960,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs_test.go - +34 - -0 + +0 + -102 @@ -1240,10 +1972,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go - +183 - -0 + +3 + -23 @@ -1252,10 +1984,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forced_batches.go - +138 - -0 + +3 + -3 @@ -1264,10 +1996,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go - +146 - -0 + +4 + -3 @@ -1276,10 +2008,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_global_exit_root.go - +128 - -0 + +3 + -3 @@ -1288,10 +2020,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/common.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches.go - +5 - -0 + +3 + -3 @@ -1300,10 +2032,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches_test.go - +205 - -0 + +0 + -1 @@ -1312,10 +2044,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_force_batches.go - +298 - -0 + +3 + -3 @@ -1324,10 +2056,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_verify_batch.go - +139 - -0 + +3 + -3 @@ -1336,10 +2068,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/processor_base.go - +144 - -0 + +6 + -16 @@ -1348,10 +2080,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/block_range_processor.go - +120 - -0 + +0 + -21 @@ -1360,10 +2092,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go - +113 - -0 + +0 + -6 @@ -1372,10 +2104,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/l1_event_processor_manager.go - +6 - -7 + +0 + -14 @@ -1384,10 +2116,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go - +1 - -1 + +0 + -13 @@ -1396,10 +2128,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/sync_pre_rollup_syncer.go - +7 - -1 + +0 + -10 @@ -1408,10 +2140,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go - +117 - -0 + +2 + -2 @@ -1420,10 +2152,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/default_l1processors.go - +19 - -0 + +0 + -2 @@ -1432,10 +2164,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go - +5 - -4 + +11 + -5 @@ -1444,7 +2176,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer_test.go + + +7 + -7 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go + + +1 + -1 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go +1 -0 @@ -1456,10 +2212,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - +396 - -126 + +1 + -0
  • @@ -1468,10 +2224,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_block_range_process.go - +1480 - -69 + +0 + -166 @@ -1480,10 +2236,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/CounterAndBlock.sol + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - +15 - -0 + +90 + -104 @@ -1492,10 +2248,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup.go - +24 - -0 + +0 + -122 @@ -1504,10 +2260,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/CounterAndBlock/CounterAndBlock.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup_test.go - +287 - -0 + +0 + -89 @@ -1516,10 +2272,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - +224 - -0 + +21 + -16 @@ -1528,10 +2284,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol - +1 - -1 + +24 + -0 @@ -1543,7 +2299,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml +55 - -3 + -11 @@ -1566,8 +2322,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go - +1 - -1 + +6 + -6 @@ -1578,8 +2334,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go - +3 - -3 + +2 + -2 @@ -1588,10 +2344,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc2_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc1_test.go - +74 - -48 + +13 + -14 @@ -1600,10 +2356,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/sc_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/shared.go - +103 - -0 + +2 + -2 @@ -1614,8 +2370,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go - +2 - -2 + +1 + -1 @@ -1626,8 +2382,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - +61 - -14 + +62 + -40 @@ -1638,8 +2394,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go - +21 - -1 + +22 + -6 @@ -1649,12 +2405,84 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    viewBox="0 0 14 16" width="14"> {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go + + +4 + -4 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/deploy_sc/main.go + + +6 + -0 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/hash_compare/main.go + + +0 + -124 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/hash_gen/main.go + + +0 + -188 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/http_ws_sync/main.go + + +0 + -161 + + +
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/sendForcedBatch/main.go +2 -2
  • +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/sequenceForcedBatch/main.go + + +5 + -5 + + +
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go - +6 - -14 + +1 + -156
  • @@ -1672,10 +2500,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/genesis/genesisparser/genesisparser.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/Makefile - +6 - -6 + +0 + -8 @@ -1684,10 +2512,10 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/main.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/egp/main.go - +1 - -1 + +85 + -183 @@ -1696,17 +2524,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/state/reprocess_cmd.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/executor/main.go + + +3 + -3 + + + +
  • + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/rlp/main.go +1 -1
  • - -
    -
    -
    +
    +

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -2,6 +2,7 @@
    +
    @@ -2,8 +2,11 @@
    @@ -1760,6 +2624,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + +
    +   +
    +
    + + + +
    @@ -1774,7 +2648,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "encoding/json" + "errors"
    @@ -1784,7 +2658,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "errors" + "fmt" +
    + + + + + + +
    +   +
    @@ -1794,17 +2678,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "fmt" + "net" +
    + + + + 8 + + +
    +   + "strconv" +
    + + + + 9 + + +
    +   + "strings"
    -
    @@ -67,6 +71,9 @@
    +
    @@ -64,6 +71,9 @@
    - 67 + 64
    @@ -1814,7 +2718,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 68 + 65
    @@ -1824,7 +2728,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 69 + 66
    @@ -1864,7 +2768,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 70 + 67
    @@ -1874,7 +2778,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 71 + 68
    @@ -1884,7 +2788,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 72 + 69
    @@ -1895,11 +2799,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -75,6 +82,8 @@
    +
    @@ -72,6 +82,8 @@
    - 75 + 72
    @@ -1909,7 +2813,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 76 + 73
    @@ -1919,7 +2823,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 77 + 74
    @@ -1949,7 +2853,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 78 + 75
    @@ -1959,7 +2863,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 79 + 76
    @@ -1969,7 +2873,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 80 + 77
    @@ -1980,11 +2884,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -96,6 +105,9 @@
    +
    @@ -93,6 +105,9 @@
    - 96 + 93
    @@ -1994,7 +2898,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 97 + 94
    @@ -2004,7 +2908,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 98 + 95
    @@ -2044,7 +2948,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 99 + 96
    @@ -2054,7 +2958,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 100 + 97
    @@ -2064,7 +2968,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 101 + 98
    @@ -2075,251 +2979,226 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -269,34 +281,139 @@
    +
    @@ -116,7 +131,7 @@
    - 269 + 116
      -
    + }, nil)
    - 270 + 117
      - log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot) +
    - 271 + 118
      -
    + // Delete ungenerated recursive proofs
    - 272 + 119
    - - // add batch verification to be monitored + err := a.State.DeleteUngeneratedBatchProofs(ctx, nil)
    - - 273 + + 120 - +
    - - - sender := common.HexToAddress(a.cfg.SenderAddress) +   + if err != nil {
    - - 274 + + 121 - +
    - - - to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs, sender) +   + return fmt.Errorf("failed to initialize proofs cache %w", err)
    - - 275 + + 122 - +
    - - - if err != nil { +   + }
    - - 276 - - -
    - - - log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err) -
    + + +
    @@ -214,44 +229,813 @@
    - - 277 + + 214 - +
    - - - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) +   + log.Errorf("Error checking proofs to verify: %v", err)
    - - 278 + + 215 - +
    - - - continue +   + }
    - - 279 + + 216 - +
    - - - } +   +
    - 280 + 217
    - - monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal) -
    - - - - 281 - - -
    - - - err = a.EthTxManager.Add(ctx, ethTxManagerOwner, monitoredTxID, sender, to, nil, data, a.cfg.GasOffset, nil) + proofGenerated, err := a.tryAggregateBlobOuterProofs(ctx, prover)
    - - 282 + + 218 - +
    - - +   if err != nil {
    - - 283 - - -
    - - - mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to) -
    - - - - 284 + + 219 - +
    - - mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err) + log.Errorf("Error trying to aggregate blobOuter proofs: %v", err)
    - - 285 + + 220 - +
    - - - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) +   + }
    - 286 + 221
    - - continue +
    - 287 + 222
      - } + if !proofGenerated {
    - - 288 + + 223 - +
    -   -
    + - + proofGenerated, err = a.tryGenerateBlobOuterProof(ctx, prover)
    - - 289 + + 224 - +
    - - - // process monitored batch verifications before starting a next cycle +   + if err != nil {
    - - 290 + + 225 - +
    - - a.EthTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { + log.Errorf("Error trying to generate blobOuter proofs: %v", err)
    - - 291 + + 226 - +
    - - - a.handleMonitoredTxResult(result) +   + }
    - - 292 + + 227 - +
    - - - }, nil) +   + }
    - 293 + 228
    @@ -2329,60 +3208,60 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 294 + 229
      - a.resetVerifyProofTime() + if !proofGenerated {
    - - 295 + + 230 - +
    -   - a.endProofVerification() + - + proofGenerated, err = a.tryGenerateBlobInnerProof(ctx, prover)
    - - 296 + + 231 - +
    -   - } + - + if err != nil {
    - - 297 + + 232 - +
    -   - } + - + log.Errorf("Error trying to aggregate blobInner proofs: %v", err)
    - - 298 + + 233 - +
    -   - } + - + }
    - - 299 + + - -
    + +
     
    @@ -2640,6 +3519,336 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + +
    +   +
    +
    + + + + 234 + + +
    +   + } +
    + + + + 235 + + +
    +   +
    +
    + + + + 236 + + +
    + - + if !proofGenerated { +
    + + + + 237 + + +
    + - + proofGenerated, err = a.tryAggregateBatchProofs(ctx, prover) +
    + + + + 238 + + +
    + - + if err != nil { +
    + + + + 239 + + +
    + - + log.Errorf("Error trying to aggregate batch proofs: %v", err) +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + 240 + + +
    +   + } +
    + + + + 241 + + +
    +   + } +
    + + + + 242 + + +
    +   +
    +
    + + + + 243 + + +
    + - + if !proofGenerated { +
    + + + + 244 + + +
    + - + proofGenerated, err = a.tryGenerateBatchProof(ctx, prover) +
    + + + + 245 + + +
    + - + if err != nil { +
    + + + + 246 + + +
    + - + log.Errorf("Error trying to generate batch proof: %v", err) +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + +
    @@ -3548,592 +4757,563 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 300 + + - -
    + +
      - func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) { +
    - - 301 + + - -
    + +
      - log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    - - 302 + + - -
    + +
      - proof.GeneratingSince = nil +
    - - -
    @@ -1021,7 +1138,7 @@
    - - - - 1021 + + - -
    + +
      - if err != nil { +
    - - 1022 + + - -
    + +
      - return nil, err +
    - - 1023 + + - -
    + +
      - } +
    - - 1024 + + - -
    - - - leaves, err := a.State.GetLeafsByL1InfoRoot(ctx, *l1InfoRoot, nil) + +
    +   +
    - - 1025 + + - -
    + +
      - if err != nil { +
    - - 1026 + + - -
    + +
      - return nil, err +
    - - 1027 + + - -
    + +
      - } -
    - - - - -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - @@ -4197,21 +5377,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 2 + + -
    +
    +
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "context" +
    - 5 + + -
    - + - "crypto/ecdsa" +
    +
    +   +
    - 6 + + -
    +
    +
      - "encoding/json" +
    - 7 + + -
    +
    +
      - "errors" +
    - 8 + + -
    +
    +
      - "fmt" +
    -
     
    -
    - 71 + + -
    +
    +
      - srv *grpc.Server +
    - 72 + + -
    +
    +
      - ctx context.Context +
    - 73 + + -
    +
    +
      - exit context.CancelFunc +
    - 74 + + -
    - + +
    +
    +  
    - 75 + + -
    - + - AggLayerClient client.ClientInterface +
    +
    +   +
    - 76 + + -
    - + - sequencerPrivateKey *ecdsa.PrivateKey +
    +
    +   +
    - 77 + + -
    +
    +
      - } +
    - 78 + + -
    +
    +
     
    - 79 + + -
    +
    +
      - // New creates a new aggregator. +
    -
     
    -
    - 82 + + -
    +
    +
      - stateInterface stateInterface, +
    - 83 + + -
    +
    +
      - ethTxManager ethTxManager, +
    - 84 + + -
    +
    +
      - etherman etherman, +
    - 85 + + -
    - + - agglayerClient client.ClientInterface, +
    +
    +   +
    - 86 + + -
    - + - sequencerPrivateKey *ecdsa.PrivateKey, +
    +
    +   +
    - 87 + + -
    +
    +
      - ) (Aggregator, error) { +
    - 88 + + -
    +
    +
      - var profitabilityChecker aggregatorTxProfitabilityChecker +
    - 89 + + -
    +
    +
      - switch cfg.TxProfitabilityCheckerType { +
    -
     
    -
    - 105 + + -
    +
    +
      - TimeCleanupLockedProofs: cfg.CleanupLockedProofsInterval, +
    - 106 + + -
    +
    +
     
    - 107 + + -
    +
    +
      - finalProof: make(chan finalProofMsg), +
    - 108 + + -
    - + +
    +
    +  
    - 109 + + -
    - + - AggLayerClient: agglayerClient, +
    +
    +   +
    - 110 + + -
    - + - sequencerPrivateKey: sequencerPrivateKey, +
    +
    +   +
    - 111 + + -
    +
    +
      - } +
    - 112 + + -
    +
    +
     
    - 113 + + -
    +
    +
      - return a, nil +
    -
     
    +
    + + +
    +   +
    +
    - 281 + + -
    +
    +
     
    - 282 + + -
    +
    +
      - log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot) +
    - 283 + + -
    +
    +
     
    - 284 + + -
    - + - switch a.cfg.SettlementBackend { +
    +
    +   +
    - 285 + + -
    - + - case AggLayer: +
    +
    +   +
    - 286 + + -
    - + - if success := a.settleWithAggLayer(ctx, proof, inputs); !success { +
    +
    +   +
    - 287 + + -
    - + - continue +
    +
    +   +
    - 288 + + -
    - + - } +
    +
    +   +
    - 289 + + -
    - + - default: +
    +
    +   +
    - 290 + + -
    - + - if success := a.settleDirect(ctx, proof, inputs); !success { +
    +
    +   +
    - 291 + + -
    - + - continue +
    +
    +   +
    - 292 + + -
    - + - } +
    +
    +   +
    - 293 + + -
    +
    +
      - } +
    - 294 + + -
    +
    +
     
    @@ -4267,2918 +5447,2751 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 295 + + -
    +
    +
      - a.resetVerifyProofTime() +
    - 296 + + -
    +
    +
      - a.endProofVerification() +
    - 297 + + -
    +
    +
      - } +
    - 298 + + -
    +
    +
      - } +
    - 299 + + -
    +
    +
      - } +
    - 300 + + -
    +
    +
     
    - 301 + + -
    - + - func (a *Aggregator) settleDirect( +
    +
    +   +
    - 302 + + -
    - + - ctx context.Context, +
    +
    +   +
    - 303 + + -
    - + - proof *state.Proof, +
    +
    +   +
    - 304 + + -
    - + - inputs ethmanTypes.FinalProofInputs, +
    +
    +   +
    - 305 + + -
    - + - ) (success bool) { +
    +
    +   +
    - 306 + + -
    - + - // add batch verification to be monitored +
    +
    +   +
    - 307 + + -
    - + - sender := common.HexToAddress(a.cfg.SenderAddress) +
    +
    +   +
    - 308 + + -
    - + +
    +
    +  
    - 309 + + -
    - + - to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData( +
    +
    +   +
    - 310 + + -
    - + - proof.BatchNumber-1, +
    +
    +   +
    - 311 + + -
    - + - proof.BatchNumberFinal, +
    +
    +   +
    - 312 + + -
    - + - &inputs, +
    +
    +   +
    - 313 + + -
    - + - sender, +
    +
    +   +
    - 314 + + -
    - + - ) +
    +
    +   +
    - 315 + + -
    - + - if err != nil { +
    +
    +   +
    - 316 + + -
    - + - log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err) +
    +
    +   +
    - 317 + + -
    - + - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) +
    +
    +   +
    - 318 + + -
    - + +
    +
    +  
    - 319 + + -
    - + - return false +
    +
    +   +
    - 320 + + -
    - + - } +
    +
    +   +
    - 321 + + -
    - + +
    +
    +  
    - 322 + + -
    - + - monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal) +
    +
    +   +
    - 323 + + -
    - + - err = a.EthTxManager.Add( +
    +
    +   +
    - 324 + + -
    - + - ctx, +
    +
    +   +
    - 325 + + -
    - + - ethTxManagerOwner, +
    +
    +   +
    - 326 + + -
    - + - monitoredTxID, +
    +
    +   +
    - 327 + + -
    - + - sender, +
    +
    +   +
    - 328 + + -
    - + - to, +
    +
    +   +
    - 329 + + -
    - + - nil, +
    +
    +   +
    - 330 + + -
    - + - data, +
    +
    +   +
    - 331 + + -
    - + - a.cfg.GasOffset, +
    +
    +   +
    - 332 + + -
    - + - nil, +
    +
    +   +
    - 333 + + -
    - + - ) +
    +
    +   +
    - 334 + + -
    - + - if err != nil { +
    +
    +   +
    - 335 + + -
    - + - mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to) +
    +
    +   +
    - 336 + + -
    - + - mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err) +
    +
    +   +
    - 337 + + -
    - + - a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof) +
    +
    +   +
    - 338 + + -
    - + +
    +
    +  
    - 339 + + -
    - + - return false +
    +
    +   +
    - 340 + + -
    - + - } +
    +
    +   +
    - 341 + + -
    - + +
    +
    +  
    - 342 + + -
    - + - // process monitored batch verifications before starting a next cycle +
    +
    +   +
    - 343 + + -
    - + - a.EthTxManager.ProcessPendingMonitoredTxs( +
    +
    +   +
    - 344 + + -
    - + - ctx, +
    +
    +   +
    - 345 + + -
    - + - ethTxManagerOwner, +
    +
    +   +
    - 346 + + -
    - + - func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { +
    +
    +   +
    - 347 + + -
    - + - a.handleMonitoredTxResult(result) +
    +
    +   +
    - 348 + + -
    - + - }, +
    +
    +   +
    - 349 + + -
    - + - nil, +
    +
    +   +
    - 350 + + -
    - + - ) +
    +
    +   +
    - 351 + + -
    - + +
    +
    +  
    - 352 + + -
    - + - return true +
    +
    +   +
    - 353 + + -
    - + - } +
    +
    +   +
    - 354 + + -
    - + +
    +
    +  
    - 355 + + -
    - + - func (a *Aggregator) settleWithAggLayer( +
    +
    +   +
    - 356 + + -
    - + - ctx context.Context, +
    +
    +   +
    - 357 + + -
    - + - proof *state.Proof, +
    +
    +   +
    - 358 + + 247 +
    - + - inputs ethmanTypes.FinalProofInputs, +   + }
    - 359 + + 248 +
    - + - ) (success bool) { +   + }
    - 360 + + 249 +
    - + - proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x") + - + if !proofGenerated {
    - 361 + + 250 +
    - + - proofBytes := common.Hex2Bytes(proofStrNo0x) + - + // if no proof was generated (aggregated or batch) wait some time before retry
    - 362 + + 251 +
    - + - tx := tx.Tx{ + - + time.Sleep(a.cfg.RetryTime.Duration)
    - 363 + + 252 +
    - + - LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1), + - + } // if proof was generated we retry immediately as probably we have more proofs to process
    - 364 + + -
    - + - NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal), +
    +
    +   +
    - 365 + + -
    - + - ZKP: tx.ZKP{ +
    +
    +   +
    - 366 + + -
    - + - NewStateRoot: common.BytesToHash(inputs.NewStateRoot), +
    +
    +   +
    - 367 + + -
    - + - NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot), +
    +
    +   +
    - 368 + + -
    - + - Proof: agglayerTypes.ArgBytes(proofBytes), +
    +
    +   +
    - 369 + + -
    - + - }, +
    +
    +   +
    - 370 + + -
    - + - RollupID: a.Ethman.GetRollupId(), +
    +
    +   +
    - 371 + + -
    - + - } +
    +
    +   +
    - 372 + + -
    - + - signedTx, err := tx.Sign(a.sequencerPrivateKey) +
    +
    +   +
    - 373 + + -
    - + +
    +
    +  
    - 374 + + -
    - + - if err != nil { +
    +
    +   +
    - 375 + + -
    - + - log.Errorf("failed to sign tx: %v", err) +
    +
    +   +
    - 376 + + -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) +
    +
    +   +
    - 377 + + -
    - + +
    +
    +  
    - 378 + + -
    - + - return false +
    +
    +   +
    - 379 + + -
    - + - } +
    +
    +   +
    - 380 + + -
    - + +
    +
    +  
    - 381 + + -
    - + - log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex()) +
    +
    +   +
    - 382 + + -
    - + - txHash, err := a.AggLayerClient.SendTx(*signedTx) +
    +
    +   +
    - 383 + + -
    - + - if err != nil { +
    +
    +   +
    - 384 + + -
    - + - log.Errorf("failed to send tx to the interop: %v", err) +
    +
    +   +
    - 385 + + -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) +
    +
    +   +
    - 386 + + -
    - + +
    +
    +  
    - 387 + + -
    - + - return false +
    +
    +   +
    - 388 + + -
    - + - } +
    +
    +   +
    - 389 + + -
    - + +
    +
    +  
    - 390 + + -
    - + - log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex()) +
    +
    +   +
    - 391 + + -
    - + - log.Debugf("Timeout set to %f seconds", a.cfg.AggLayerTxTimeout.Duration.Seconds()) +
    +
    +   +
    - 392 + + -
    - + - waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.AggLayerTxTimeout.Duration)) +
    +
    +   +
    - 393 + + -
    - + - defer cancelFunc() +
    +
    +   +
    - 394 + + -
    - + - if err := a.AggLayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil { +
    +
    +   +
    - 395 + + -
    - + - log.Errorf("interop didn't mine the tx: %v", err) +
    +
    +   +
    - 396 + + -
    - + - a.handleFailureToSendToAggLayer(ctx, proof) +
    +
    +   +
    - 397 + + -
    - + +
    +
    +  
    - 398 + + -
    - + - return false +
    +
    +   +
    - 399 + + -
    - + - } +
    +
    +   +
    - 400 + + -
    - + +
    +
    +  
    - 401 + + -
    - + - // TODO: wait for synchronizer to catch up +
    +
    +   +
    - 402 + + -
    - + - return true +
    +
    +   +
    - 403 + + -
    - + - } +
    +
    +   +
    - 404 + + -
    - + +
    +
    +  
    - 405 + + -
    - + - func (a *Aggregator) handleFailureToSendToAggLayer(ctx context.Context, proof *state.Proof) { +
    +
    +   +
    - 406 + + -
    - + - log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    +
    +   +
    - 407 + + -
    - + - proof.GeneratingSince = nil +
    +
    +   +
    - 408 + + -
    - + +
    +
    +  
    - 409 + + -
    - + - err := a.State.UpdateGeneratedProof(ctx, proof, nil) +
    +
    +   +
    - 410 + + -
    - + - if err != nil { +
    +
    +   +
    - 411 + + -
    - + - log.Errorf("Failed updating proof state (false): %v", err) +
    +
    +   +
    - 412 + + -
    - + - } +
    +
    +   +
    - 413 + + -
    - + +
    +
    +  
    - 414 + + -
    - + - a.endProofVerification() +
    +
    +   +
    - 415 + + -
    - + - } +
    +
    +   +
    - 416 + + -
    - + +
    +
    +  
    - 417 + + -
    +
    +
      - func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) { +
    - 418 + + -
    +
    +
      - log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    - 419 + + -
    +
    +
      - proof.GeneratingSince = nil +
    -
     
    -
    - 1138 + + -
    +
    +
      - if err != nil { +
    - 1139 + + -
    +
    +
      - return nil, err +
    - 1140 + + -
    +
    +
      - } +
    - 1141 + + -
    - + - leaves, err := a.State.GetLeavesByL1InfoRoot(ctx, *l1InfoRoot, nil) +
    +
    +   +
    - 1142 + + -
    +
    +
      - if err != nil { +
    - 1143 + + -
    +
    +
      - return nil, err +
    - 1144 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -191,7 +191,7 @@
    - 191 + + -
    +
    +
      - stateMock := mocks.NewStateMock(t) +
    - 192 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 193 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 194 + + -
    - - - a, err := New(cfg, stateMock, ethTxManager, etherman) +
    +
    +   +
    - 195 + + -
    +
    +
      - require.NoError(err) +
    - 196 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(context.Background()) +
    - 197 + + -
    +
    +
      - m := mox{ +
    -
    @@ -686,7 +686,7 @@
    -
    - 686 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 687 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 688 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 689 + + -
    - - - a, err := New(cfg, stateMock, ethTxManager, etherman) +
    +
    +   +
    - 690 + + -
    +
    +
      - require.NoError(err) +
    - 691 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 692 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
    @@ -801,7 +801,7 @@
    -
    - 801 + + -
    +
    +
      - } +
    - 802 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 803 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 804 + + -
    - - - m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 805 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 806 + + -
    +
    +
      - require.NoError(err) +
    - 807 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(nil, errBanana).Once() +
    -
    @@ -844,7 +844,7 @@
    -
    - 844 + + -
    +
    +
      - } +
    - 845 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 846 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 847 + + -
    - - - m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 848 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 849 + + -
    +
    +
      - require.NoError(err) +
    - 850 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
    @@ -888,7 +888,7 @@
    -
    - 888 + + -
    +
    +
      - } +
    - 889 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 890 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 891 + + -
    - - - m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 892 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 893 + + -
    +
    +
      - require.NoError(err) +
    - 894 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
    @@ -932,7 +932,7 @@
    -
    - 932 + + -
    +
    +
      - } +
    - 933 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 934 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 935 + + -
    - - - m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 936 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 937 + + -
    +
    +
      - require.NoError(err) +
    - 938 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
    @@ -989,7 +989,7 @@
    -
    - 989 + + -
    +
    +
      - TimestampBatchEtrog: &t, +
    - 990 + + -
    +
    +
      - } +
    - 991 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 992 + + -
    - - - m.stateMock.On("GetLeafsByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 993 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 994 + + -
    +
    +
      - require.NoError(err) +
    - 995 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
    @@ -1029,7 +1029,7 @@
    -
    - 1029 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1030 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1031 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1032 + + -
    - - - a, err := New(cfg, stateMock, ethTxManager, etherman) +
    +
    +   +
    - 1033 + + -
    +
    +
      - require.NoError(err) +
    - 1034 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1035 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
    @@ -1306,7 +1306,7 @@
    -
    - 1306 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1307 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1308 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1309 + + -
    - - - a, err := New(cfg, stateMock, ethTxManager, etherman) +
    +
    +   +
    - 1310 + + -
    +
    +
      - require.NoError(err) +
    - 1311 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1312 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
    @@ -1436,7 +1436,7 @@
    -
    - 1436 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1437 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1438 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1439 + + -
    - - - a, err := New(cfg, stateMock, ethTxManager, etherman) +
    +
    +   +
    - 1440 + + -
    +
    +
      - require.NoError(err) +
    - 1441 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1442 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 191 + + -
    +
    +
      - stateMock := mocks.NewStateMock(t) +
    - 192 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 193 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 194 + + -
    - + - a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    +
    +   +
    - 195 + + -
    +
    +
      - require.NoError(err) +
    - 196 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(context.Background()) +
    - 197 + + -
    +
    +
      - m := mox{ +
    -
     
    -
    - 686 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 687 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 688 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 689 + + -
    - + - a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    +
    +   +
    - 690 + + -
    +
    +
      - require.NoError(err) +
    - 691 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 692 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
     
    -
    - 801 + + -
    +
    +
      - } +
    - 802 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 803 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 804 + + -
    - + - m.stateMock.On("GetLeavesByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 805 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 806 + + -
    +
    +
      - require.NoError(err) +
    - 807 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(nil, errBanana).Once() +
    -
     
    -
    - 844 + + -
    +
    +
      - } +
    - 845 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 846 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 847 + + -
    - + - m.stateMock.On("GetLeavesByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 848 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 849 + + -
    +
    +
      - require.NoError(err) +
    - 850 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
     
    -
    - 888 + + -
    +
    +
      - } +
    - 889 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 890 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 891 + + -
    - + - m.stateMock.On("GetLeavesByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 892 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 893 + + -
    +
    +
      - require.NoError(err) +
    - 894 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
     
    -
    - 932 + + -
    +
    +
      - } +
    - 933 + + -
    +
    +
      - m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once() +
    - 934 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 935 + + -
    - + - m.stateMock.On("GetLeavesByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 936 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 937 + + -
    +
    +
      - require.NoError(err) +
    - 938 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
     
    -
    - 989 + + -
    +
    +
      - TimestampBatchEtrog: &t, +
    - 990 + + -
    +
    +
      - } +
    - 991 + + -
    +
    +
      - m.stateMock.On("GetVirtualBatch", mock.Anything, lastVerifiedBatchNum+1, nil).Return(&vb, nil).Twice() +
    - 992 + + -
    - + - m.stateMock.On("GetLeavesByL1InfoRoot", mock.Anything, *vb.L1InfoRoot, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil).Twice() +
    +
    +   +
    - 993 + + -
    +
    +
      - expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve) +
    - 994 + + -
    +
    +
      - require.NoError(err) +
    - 995 + + -
    +
    +
      - m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once() +
    -
     
    -
    - 1029 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1030 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1031 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1032 + + -
    - + - a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    +
    +   +
    - 1033 + + -
    +
    +
      - require.NoError(err) +
    - 1034 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1035 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
     
    -
    - 1306 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1307 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1308 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1309 + + -
    - + - a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    +
    +   +
    - 1310 + + -
    +
    +
      - require.NoError(err) +
    - 1311 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1312 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    -
     
    -
    - 1436 + + -
    +
    +
      - ethTxManager := mocks.NewEthTxManager(t) +
    - 1437 + + -
    +
    +
      - etherman := mocks.NewEtherman(t) +
    - 1438 + + -
    +
    +
      - proverMock := mocks.NewProverMock(t) +
    - 1439 + + -
    - + - a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    +
    +   +
    - 1440 + + -
    +
    +
      - require.NoError(err) +
    - 1441 + + -
    +
    +
      - aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    - 1442 + + -
    +
    +
      - a.ctx, a.exit = context.WithCancel(aggregatorCtx) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -8,6 +8,17 @@
    - 8 + 253
      - "github.com/0xPolygonHermez/zkevm-node/encoding" + }
    - 9 + + -
    +
    +
      - ) +
    - 10 + + -
    +
    +
     
    @@ -7294,66 +8307,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 11 + + -
    +
    +
      - // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int +
    - 12 + + -
    +
    +
      - type TokenAmountWithDecimals struct { +
    - 13 + + -
    +
    +
      - *big.Int `validate:"required"` +
    -
    @@ -89,6 +100,18 @@
    -
    - 89 + + -
    +
    +
      - // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog +
    - 90 + + -
    +
    +
      - UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"` +
    - 91 + + -
    +
    +
     
    @@ -7479,461 +8487,413 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 92 + + -
    +
    +
      - // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch +
    - 93 + + -
    +
    +
      - BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"` +
    - 94 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 8 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/encoding" +
    - 9 + + -
    +
    +
      - ) +
    - 10 + + -
    +
    +
     
    - 11 + + -
    - + - // SettlementBackend is the type of the settlement backend +
    +
    +   +
    - 12 + + -
    - + - type SettlementBackend string +
    +
    +   +
    - 13 + + -
    - + +
    +
    +  
    - 14 + + -
    - + - const ( +
    +
    +   +
    - 15 + + -
    - + - // AggLayer settlement backend +
    +
    +   +
    - 16 + + -
    - + - AggLayer SettlementBackend = "agglayer" +
    +
    +   +
    - 17 + + -
    - + +
    +
    +  
    - 18 + + 254 +
    - + - // L1 settlement backend +   + }
    - 19 + + -
    - + - L1 SettlementBackend = "l1" +
    +
    +   +
    - 20 + + -
    - + - ) +
    +
    +   +
    - 21 + + -
    - + +
    +
    +  
    - 22 + + -
    +
    +
      - // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int +
    - 23 + + -
    +
    +
      - type TokenAmountWithDecimals struct { +
    - 24 + + -
    +
    +
      - *big.Int `validate:"required"` +
    -
     
    -
    - 100 + + -
    +
    +
      - // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog +
    - 101 + + -
    +
    +
      - UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"` +
    - 102 + + -
    +
    +
     
    - 103 + + -
    - + - // SettlementBackend configuration defines how a final ZKP should be settled. Directly to L1 or over the Beethoven service. +
    +
    +   +
    - 104 + + -
    - + - SettlementBackend SettlementBackend `mapstructure:"SettlementBackend"` +
    +
    +   +
    - 105 + + -
    - + +
    +
    +  
    - 106 + + -
    - + - // AggLayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer +
    +
    +   +
    - 107 - -
    - + - AggLayerTxTimeout types.Duration `mapstructure:"AggLayerTxTimeout"` +
    + + +
    +   +
    - 108 + + -
    - + +
    +
    +  
    - 109 + + -
    - + - // AggLayerURL url of the agglayer service +
    +
    +   +
    - 110 + + -
    - + - AggLayerURL string `mapstructure:"AggLayerURL"` +
    +
    +   +
    - 111 + + -
    - + +
    +
    +  
    - 112 + + -
    - + - // SequencerPrivateKey Private key of the trusted sequencer +
    +
    +   +
    - 113 + + -
    - + - SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"` +
    +
    +   +
    - 114 + + -
    - + +
    +
    +  
    - 115 + + -
    +
    +
      - // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch +
    - 116 + + -
    +
    +
      - BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"` +
    - 117 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -7947,724 +8907,633 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -38,6 +38,7 @@
    - 38 + + -
    +
    +
     
    - 39 + + -
    +
    +
      - // etherman contains the methods required to interact with ethereum +
    - 40 + + -
    +
    +
      - type etherman interface { +
    - 41 + + -
    +
    +
      - GetLatestVerifiedBatchNum() (uint64, error) +
    - 42 + + -
    +
    +
      - BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error) +
    - 43 + + -
    +
    +
      - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) +
    -
    @@ -65,7 +66,7 @@
    -
    - 65 + + -
    +
    +
      - CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    - 66 + + -
    +
    +
      - CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) +
    - 67 + + -
    +
    +
      - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) +
    - 68 + + -
    - - - GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) +
    +
    +   +
    - 69 + + -
    +
    +
      - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 70 + + -
    +
    +
      - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 71 + + -
    +
    +
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 38 + + -
    +
    +
     
    - 39 + + -
    +
    +
      - // etherman contains the methods required to interact with ethereum +
    - 40 + + -
    +
    +
      - type etherman interface { +
    - 41 + + -
    - + - GetRollupId() uint32 +
    +
    +   +
    - 42 + + -
    +
    +
      - GetLatestVerifiedBatchNum() (uint64, error) +
    - 43 + + -
    +
    +
      - BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error) +
    - 44 + + -
    +
    +
      - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) +
    -
     
    -
    - 66 + + -
    +
    +
      - CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    - 67 + + -
    +
    +
      - CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) +
    - 68 + + -
    +
    +
      - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) +
    - 69 + + -
    - + - GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) +
    +
    +   +
    - 70 + + -
    +
    +
      - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 71 + + -
    +
    +
      - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 72 + + -
    +
    +
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/approve.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -51,14 +51,14 @@
    - 51 + + -
    +
    +
      - setupLog(c.Log) +
    - 52 + + -
    +
    +
     
    - 53 + + -
    +
    +
      - // Check if it is already registered +
    - 54 + + -
    - - - etherman, err := newEtherman(*c) +
    +
    +   +
    - 55 + + -
    +
    +
      - if err != nil { +
    - 56 + + -
    +
    +
      - log.Fatal(err) +
    - 57 + + -
    +
    +
      - return err +
    - 58 + + -
    +
    +
      - } +
    - 59 + + -
    +
    +
     
    - 60 + + -
    +
    +
      - // load auth from keystore file +
    - 61 + + -
    - - - auth, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    +
    +   +
    - 62 + + -
    +
    +
      - if err != nil { +
    - 63 + + -
    +
    +
      - log.Fatal(err) +
    - 64 + + -
    +
    +
      - return err -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 51 + + -
    +
    +
      - setupLog(c.Log) +
    - 52 + + -
    +
    +
     
    - 53 + + -
    +
    +
      - // Check if it is already registered +
    - 54 + + -
    - + - etherman, err := newEtherman(*c, nil) +
    +
    +   +
    - 55 + + -
    +
    +
      - if err != nil { +
    - 56 + + -
    +
    +
      - log.Fatal(err) +
    - 57 + + -
    +
    +
      - return err +
    - 58 + + -
    +
    +
      - } +
    - 59 + + -
    +
    +
     
    - 60 + + -
    +
    +
      - // load auth from keystore file +
    - 61 + + -
    - + - auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    +
    +   +
    - 62 + + -
    +
    +
      - if err != nil { +
    - 63 + + -
    +
    +
      - log.Fatal(err) +
    - 64 + + -
    +
    +
      - return err -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/main.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -8738,283 +9607,115 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -47,7 +47,7 @@
    - 47 + + -
    +
    +
      - networkFlag = cli.StringFlag{ +
    - 48 + + -
    +
    +
      - Name: config.FlagNetwork, +
    - 49 + + -
    +
    +
      - Aliases: []string{"net"}, +
    - 50 + + -
    - - - Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `cardona`, `custom`]", +
    +
    +   +
    - 51 + + -
    +
    +
      - Required: true, +
    - 52 + + -
    +
    +
      - } +
    - 53 + + -
    +
    +
      - customNetworkFlag = cli.StringFlag{ +
    -
    @@ -186,6 +186,13 @@
    +
    + + +
    +   +
    +
    - 186 + + -
    +
    +
      - Action: restore, +
    - 187 + + -
    +
    +
      - Flags: restoreFlags, +
    - 188 + + -
    +
    +
      - }, +
    - 189 + + -
    +
    +
      - } +
    - 190 + + -
    +
    +
     
    - 191 + + -
    +
    +
      - err := app.Run(os.Args) +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 47 + + -
    +
    +
      - networkFlag = cli.StringFlag{ +
    - 48 + + -
    +
    +
      - Name: config.FlagNetwork, +
    - 49 + + -
    +
    +
      - Aliases: []string{"net"}, +
    - 50 + + -
    - + - Usage: "Load default network configuration. Supported values: [`custom`]", +
    +
    +   +
    - 51 + + -
    +
    +
      - Required: true, +
    - 52 + + -
    +
    +
      - } +
    - 53 + + -
    +
    +
      - customNetworkFlag = cli.StringFlag{ +
    -
     
    -
    - 186 - -
    -   - Action: restore, -
    -
    - 187 - -
    -   - Flags: restoreFlags, -
    -
    - 188 - -
    -   - }, -
    -
    - 189 - -
    - + - { -
    -
    - 190 - -
    - + - Name: "set-data-availability-protocol", -
    -
    - 191 - -
    - + - Aliases: []string{"set-dap"}, -
    -
    - 192 - -
    - + - Usage: "Sets the new data availability protocol", -
    -
    - 193 - -
    - + - Action: setDataAvailabilityProtocol, -
    -
    - 194 - -
    - + - Flags: setDataAvailabilityProtocolFlags, -
    -
    - 195 - -
    - + - }, -
    -
    - 196 - -
    -   - } -
    -
    - 197 - -
    -   -
    -
    -
    - 198 - -
    -   - err := app.Run(os.Args) -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
    @@ -0,0 +1,308 @@
    -
    @@ -10476,793 +11177,837 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 255 -
    +
    +
      -
    + }
    - + + 256 -
    +
    +
     
    - + + 257 -
    +
    +
      -
    + // canVerifyProof returns true if we have reached the timeout to verify a proof
    - - -
    -   -
    -
    +
    +
    @@ -383,10 +1167,10 @@
    - + + 383 -
    +
    +
      -
    + }
    - + + 384 -
    +
    +
      -
    + if l1InfoRoot != nil && *l1InfoRoot != calculatedL1InfoRoot {
    - + + 385 -
    +
    +
      -
    + for i, l := range aLeaves {
    - + + 386 -
    -   -
    +
    +
    + - + log.Infof("AllLeaves[%d]: %s", i, common.Bytes2Hex(l[:]))
    - + + 387 -
    +
    +
      -
    + }
    - + + 388 -
    +
    +
      -
    + for i, s := range smtProof {
    - + + 389 -
    -   -
    +
    +
    + - + log.Infof("smtProof[%d]: %s", i, common.Bytes2Hex(s[:]))
    - + + 390 -
    +
    +
      -
    + }
    - + + 391 -
    +
    +
      -
    + return nil, fmt.Errorf("error: l1InfoRoot mismatch. L1InfoRoot: %s, calculatedL1InfoRoot: %s. l1InfoTreeIndex: %d", l1InfoRoot.String(), calculatedL1InfoRoot.String(), l2blockRaw.IndexL1InfoTree)
    - + + 392 -
    +
    +
      -
    + }
    - + +
    @@ -520,7 +1304,7 @@
    -
    +
    + 520 + +
     
    - + + 521 -
    +
    +
      -
    + // network is synced with the final proof, we can safely delete all recursive
    - + + 522 -
    +
    +
      -
    + // proofs up to the last synced batch
    - + + 523 -
    -   -
    +
    +
    + - + err = a.State.CleanupBatchProofs(a.ctx, proofBatchNumberFinal, nil)
    - + + 524 -
    +
    +
      -
    + if err != nil {
    - + + 525 -
    +
    +
      -
    + log.Errorf("Failed to store proof aggregation result: %v", err)
    - + + 526 -
    +
    +
      -
    + }
    - + +
    @@ -536,7 +1320,7 @@
    -
    +
    + 536 + +
      -
    + case <-a.ctx.Done():
    - + + 537 -
    +
    +
      -
    + return
    - + + 538 -
    +
    +
      -
    + case <-time.After(a.TimeCleanupLockedProofs.Duration):
    - + + 539 -
    -   -
    +
    +
    + - + n, err := a.State.CleanupLockedBatchProofs(a.ctx, a.cfg.GeneratingProofCleanupThreshold, nil)
    - + + 540 -
    +
    +
      -
    + if err != nil {
    - + + 541 -
    +
    +
      -
    + log.Errorf("Failed to cleanup locked proofs: %v", err)
    - + + 542 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - @@ -11276,113 +12021,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -11396,812 +12091,798 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - + + 2 -
    +
    +
     
    - + + 3 -
    +
    +
      -
    + import (
    - + + 4 -
    +
    +
      -
    + "context"
    - + + 5 -
    -   -
    +
    +
    + + + "crypto/ecdsa"
    - + + 6 -
    -   -
    +
    +
    + + + "encoding/json"
    - + + 7 -
    +
    +
      -
    + "errors"
    - + + 8 -
    +
    +
      -
    + "fmt"
    - + + 9 -
    -   -
    +
    +
    + + + "math/big"
    - + + 10 -
    +
    +
      -
    + "net"
    - + + 11 -
    +
    +
      -
    + "strconv"
    - + + 12 -
    +
    +
      -
    + "strings"
    - + +
     
    -
    +
    + 71 + +
      -
    + srv *grpc.Server
    - + + 72 -
    +
    +
      -
    + ctx context.Context
    - + + 73 -
    +
    +
      -
    + exit context.CancelFunc
    - + + 74 -
    -   +
    +
    + +
    - + + 75 -
    -   -
    +
    +
    + + + AggLayerClient client.ClientInterface
    - + + 76 -
    -   -
    +
    +
    + + + sequencerPrivateKey *ecdsa.PrivateKey
    - + + 77 -
    +
    +
      -
    + }
    - + + 78 -
    +
    +
     
    - + + 79 -
    +
    +
      -
    + // New creates a new aggregator.
    - + +
     
    -
    +
    + 82 + +
      -
    + stateInterface stateInterface,
    - + + 83 -
    +
    +
      -
    + ethTxManager ethTxManager,
    - + + 84 -
    +
    +
      -
    + etherman etherman,
    - + + 85 -
    -   -
    +
    +
    + + + agglayerClient client.ClientInterface,
    - + + 86 -
    -   -
    +
    +
    + + + sequencerPrivateKey *ecdsa.PrivateKey,
    - + + 87 -
    +
    +
      -
    + ) (Aggregator, error) {
    - + + 88 -
    +
    +
      -
    + var profitabilityChecker aggregatorTxProfitabilityChecker
    - + + 89 -
    +
    +
      -
    + switch cfg.TxProfitabilityCheckerType {
    - + +
     
    -
    +
    + 105 + +
      -
    + TimeCleanupLockedProofs: cfg.CleanupLockedProofsInterval,
    - + + 106 -
    +
    +
     
    - + + 107 -
    +
    +
      -
    + finalProof: make(chan finalProofMsg),
    - + + 108 -
    -   +
    +
    + +
    - + + 109 -
    -   -
    +
    +
    + + + AggLayerClient: agglayerClient,
    - + + 110 -
    -   -
    +
    +
    + + + sequencerPrivateKey: sequencerPrivateKey,
    - + + 111 -
    +
    +
      -
    + }
    - + + 112 -
    +
    +
     
    - + + 113 -
    +
    +
      -
    + return a, nil
    - + +
     
    -
    +
    + 131 + +
      -
    + }, nil)
    - + + 132 -
    +
    +
     
    - + + 133 -
    +
    +
      -
    + // Delete ungenerated recursive proofs
    - + + 134 -
    -   -
    +
    +
    + + + err := a.State.DeleteUngeneratedProofs(ctx, nil)
    - + + 135 -
    +
    +
      -
    + if err != nil {
    - + + 136 -
    +
    +
      -
    + return fmt.Errorf("failed to initialize proofs cache %w", err)
    - + + 137 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 229 + +
      -
    + log.Errorf("Error checking proofs to verify: %v", err)
    - + + 230 -
    +
    +
      -
    + }
    - + + 231 -
    +
    +
     
    - + + 232 -
    -   -
    +
    +
    + + + proofGenerated, err := a.tryAggregateProofs(ctx, prover)
    - + + 233 -
    +
    +
      -
    + if err != nil {
    - + + 234 -
    -   -
    +
    +
    + + + log.Errorf("Error trying to aggregate proofs: %v", err)
    - + + 235 -
    +
    +
      -
    + }
    - + + 236 -
    +
    +
      -
    + if !proofGenerated {
    - + + 237 -
    -   -
    +
    +
    + + + proofGenerated, err = a.tryGenerateBatchProof(ctx, prover)
    - + + 238 -
    +
    +
      -
    + if err != nil {
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - + + 239 -
    -   -
    +
    +
    + + + log.Errorf("Error trying to generate proof: %v", err)
    - + + 240 -
    +
    +
      -
    + }
    - + + 241 -
    +
    +
      -
    + }
    - + + 242 -
    +
    +
      -
    + if !proofGenerated {
    - + + 243 -
    -   -
    +
    +
    + + + // if no proof was generated (aggregated or batch) wait some time before retry
    - + + 244 -
    -   -
    +
    +
    + + + time.Sleep(a.cfg.RetryTime.Duration)
    - + + 245 -
    -   -
    +
    +
    + + + } // if proof was generated we retry immediately as probably we have more proofs to process
    - + + 246 -
    -   -
    +
    +
    + + + }
    - + + 247 -
    -   -
    +
    +
    + + + }
    - + + 248 -
    -   -
    +
    +
    + + + }
    - + + 249 -
    -   +
    +
    + +
    - + + 250 -
    -   -
    +
    +
    + + + // This function waits to receive a final proof from a prover. Once it receives
    - + + 251 -
    -   -
    +
    +
    + + + // the proof, it performs these steps in order:
    - + + 252 -
    -   -
    +
    +
    + + + // - send the final proof to L1
    - + + 253 -
    -   -
    +
    +
    + + + // - wait for the synchronizer to catch up
    - + + 254 -
    -   -
    +
    +
    + + + // - clean up the cache of recursive proofs
    - + + 255 -
    -   -
    +
    +
    + + + func (a *Aggregator) sendFinalProof() {
    - + + 256 -
    -   -
    +
    +
    + + + for {
    - + + 257 -
    -   -
    +
    +
    + + + select {
    - + + 258 -
    -   -
    +
    +
    + + + case <-a.ctx.Done():
    - + + 259 -
    -   -
    +
    +
    + + + return
    - + + 260 -
    -   -
    +
    +
    + + + case msg := <-a.finalProof:
    - + + 261 -
    -   -
    +
    +
    + + + ctx := a.ctx
    - + + 262 -
    -   -
    +
    +
    + + + proof := msg.recursiveProof
    - + + 263 -
    -   +
    +
    + +
    - + + 264 -
    -   -
    +
    +
    + + + log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
    - + + 265 -
    -   -
    +
    +
    + + + log.Info("Verifying final proof with ethereum smart contract")
    - + + 266 -
    -   +
    +
    + +
    - + + 267 -
    -   -
    +
    +
    + + + a.startProofVerification()
    - + + 268 -
    -   +
    +
    + +
    - + + 269 -
    -   -
    +
    +
    + + + finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil)
    - + + 270 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 271 -
    -   -
    +
    +
    + + + log.Errorf("Failed to retrieve batch with number [%d]: %v", proof.BatchNumberFinal, err)
    - + + 272 -
    -   -
    +
    +
    + + + a.endProofVerification()
    - + + 273 -
    -   -
    +
    +
    + + + continue
    - + + 274 -
    +
    +
      -
    + }
    - + + 275 -
    +
    +
     
    - + + 276 -
    -   -
    +
    +
    + + + inputs := ethmanTypes.FinalProofInputs{
    - + + 277 -
    -   -
    +
    +
    + + + FinalProof: msg.finalProof,
    - + + 278 -
    -   -
    +
    +
    + + + NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(),
    - + + 279 -
    -   -
    +
    +
    + + + NewStateRoot: finalBatch.StateRoot.Bytes(),
    - + + 280 -
    -   -
    +
    +
    + + + }
    - + + 281 -
    -   +
    +
    + +
    - + + 282 -
    -   -
    +
    +
    + + + log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot)
    - + + 283 -
    -   +
    +
    + +
    - + + 284 -
    -   -
    +
    +
    + + + switch a.cfg.SettlementBackend {
    - + + 285 -
    -   -
    +
    +
    + + + case AggLayer:
    - + + 286 -
    -   -
    +
    +
    + + + if success := a.settleWithAggLayer(ctx, proof, inputs); !success {
    - + + 287 -
    -   -
    +
    +
    + + + continue
    - + + 288 -
    -   -
    +
    +
    + + + }
    - + + 289 -
    -   -
    +
    +
    + + + default:
    - + + 290 -
    -   -
    +
    +
    + + + if success := a.settleDirect(ctx, proof, inputs); !success {
    - + + 291 -
    -   -
    +
    +
    + + + continue
    - + + 292 -
    +
    +
      -
    + }
    - + + 293 -
    +
    +
      -
    + }
    - + + 294 -
    +
    +
     
    - + + 295 -
    -   -
    +
    +
    + + + a.resetVerifyProofTime()
    - + + 296 -
    -   -
    +
    +
    + + + a.endProofVerification()
    - + + 297 -
    -   -
    +
    +
    + + + }
    - + + 298 -
    -   -
    +
    +
    + + + }
    - + + 299 -
    -   -
    +
    +
    + + + }
    - + + 300 -
    -   +
    +
    + +
    - + + 301 -
    -   -
    +
    +
    + + + func (a *Aggregator) settleDirect(
    - + + 302 -
    -   -
    +
    +
    + + + ctx context.Context,
    - + + 303 -
    -   -
    +
    +
    + + + proof *state.Proof,
    - + + 304 -
    -   -
    +
    +
    + + + inputs ethmanTypes.FinalProofInputs,
    - + + 305 -
    -   -
    +
    +
    + + + ) (success bool) {
    - + + 306 -
    -   -
    +
    +
    + + + // add batch verification to be monitored
    - + + 307 -
    -   -
    +
    +
    + + + sender := common.HexToAddress(a.cfg.SenderAddress)
    - + + 308 -
    -   +
    +
    + +
    - + + 309 -
    -   -
    +
    +
    + + + to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(
    - + + 310 -
    -   -
    +
    +
    + + + proof.BatchNumber-1,
    - - -
    -   -
    -
    +
    + 311
    -
    + +
    + + + proof.BatchNumberFinal,
    -
    -
    - - - - - + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - - -
    -
     
    - 1 + 312
    + - package main + &inputs,
    - 2 + 313
    + -
    + sender,
    - 3 + 314
    + - import ( + )
    - 4 + 315
    + - "context" + if err != nil {
    - 5 + 316
    + - "encoding/csv" + log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err)
    - 6 + 317
    + - "errors" + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - 7 + 318
    + - "fmt" +
    - 8 + 319
    + - "os" + return false
    - 9 + 320
    + - "strings" + }
    - 10 + 321
    @@ -12211,187 +12892,187 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 11 + 322
    + - "github.com/0xPolygonHermez/zkevm-node/config" + monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal)
    - 12 + 323
    + - "github.com/0xPolygonHermez/zkevm-node/pool" + err = a.EthTxManager.Add(
    - 13 + 324
    + - "github.com/0xPolygonHermez/zkevm-node/pool/pgpoolstorage" + ctx,
    - 14 + 325
    + - "github.com/ethereum/go-ethereum/common" + ethTxManagerOwner,
    - 15 + 326
    + - "github.com/urfave/cli/v2" + monitoredTxID,
    - 16 + 327
    + - ) + sender,
    - 17 + 328
    + -
    + to,
    - 18 + 329
    + - var ( + nil,
    - 19 + 330
    + - policyFlag = cli.StringFlag{ + data,
    - 20 + 331
    + - Name: "policy", + a.cfg.GasOffset,
    - 21 + 332
    + - Aliases: []string{"p"}, + nil,
    - 22 + 333
    + - Usage: "Name of policy to operate on", + )
    - 23 + 334
    + - Required: false, + if err != nil {
    - 24 + 335
    + - } + mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to)
    - 25 + 336
    + - csvFlag = cli.StringFlag{ + mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err)
    - 26 + 337
    + - Name: "csv", + a.handleFailureToAddVerifyBatchToBeMonitored(ctx, proof)
    - 27 + 338
    + - Usage: "CSV file with addresses", +
    - 28 + 339
    + - Required: false, + return false
    - 29 + 340
    @@ -12401,587 +13082,587 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 30 + 341
    + - allowFlag = cli.BoolFlag{ +
    - 31 + 342
    + - Name: "allow", + // process monitored batch verifications before starting a next cycle
    - 32 + 343
    + - Usage: "Update policy to 'allow' addresses on list", + a.EthTxManager.ProcessPendingMonitoredTxs(
    - 33 + 344
    + - Required: false, + ctx,
    - 34 + 345
    + - } + ethTxManagerOwner,
    - 35 + 346
    + - denyFlag = cli.BoolFlag{ + func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) {
    - 36 + 347
    + - Name: "deny", + a.handleMonitoredTxResult(result)
    - 37 + 348
    + - Usage: "Update policy to 'deny' addresses on list", + },
    - 38 + 349
    + - Required: false, + nil,
    - 39 + 350
    + - } + )
    - 40 + 351
    + - noHeaderFlag = cli.BoolFlag{ +
    - 41 + 352
    + - Name: "no-header", + return true
    - 42 + 353
    + - Value: false, + }
    - 43 + 354
    + - Required: false, +
    - 44 + 355
    + - } + func (a *Aggregator) settleWithAggLayer(
    - 45 + 356
    + -
    + ctx context.Context,
    - 46 + 357
    + - policyActionFlags = []cli.Flag{&policyFlag} + proof *state.Proof,
    - 47 + 358
    + - ) + inputs ethmanTypes.FinalProofInputs,
    - 48 + 359
    + -
    + ) (success bool) {
    - 49 + 360
    + - var policyCommands = cli.Command{ + proofStrNo0x := strings.TrimPrefix(inputs.FinalProof.Proof, "0x")
    - 50 + 361
    + - Name: "policy", + proofBytes := common.Hex2Bytes(proofStrNo0x)
    - 51 + 362
    + - Usage: "View, update, and apply policies", + tx := tx.Tx{
    - 52 + 363
    + - Action: describe, + LastVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumber - 1),
    - 53 + 364
    + - Flags: []cli.Flag{&configFileFlag}, + NewVerifiedBatch: agglayerTypes.ArgUint64(proof.BatchNumberFinal),
    - 54 + 365
    + - Subcommands: []*cli.Command{ + ZKP: tx.ZKP{
    - 55 + 366
    + - { + NewStateRoot: common.BytesToHash(inputs.NewStateRoot),
    - 56 + 367
    + - Name: "add", + NewLocalExitRoot: common.BytesToHash(inputs.NewLocalExitRoot),
    - 57 + 368
    + - Usage: "Add address(es) to a policy exclusion list", + Proof: agglayerTypes.ArgBytes(proofBytes),
    - 58 + 369
    + - Action: addAcl, + },
    - 59 + 370
    + - Flags: append(policyActionFlags, &csvFlag), + RollupID: a.Ethman.GetRollupId(),
    - 60 + 371
    + - }, { + }
    - 61 + 372
    + - Name: "clear", + signedTx, err := tx.Sign(a.sequencerPrivateKey)
    - 62 + 373
    + - Usage: "Clear the addresses listed as exceptions to a policy", +
    - 63 + 374
    + - Action: clearAcl, + if err != nil {
    - 64 + 375
    + - Flags: policyActionFlags, + log.Errorf("failed to sign tx: %v", err)
    - 65 + 376
    + - }, { + a.handleFailureToSendToAggLayer(ctx, proof)
    - 66 + 377
    + - Name: "describe", +
    - 67 + 378
    + - Usage: "Describe the default actions for the policies", + return false
    - 68 + 379
    + - Action: describe, + }
    - 69 + 380
    + - Flags: append(policyActionFlags, &noHeaderFlag), +
    - 70 + 381
    + - }, { + log.Debug("final proof signedTx: ", signedTx.Tx.ZKP.Proof.Hex())
    - 71 + 382
    + - Name: "remove", + txHash, err := a.AggLayerClient.SendTx(*signedTx)
    - 72 + 383
    + - Usage: "Remove address(es) from a policy exclusion list", + if err != nil {
    - 73 + 384
    + - Action: removeAcl, + log.Errorf("failed to send tx to the interop: %v", err)
    - 74 + 385
    + - Flags: append(policyActionFlags, &csvFlag), + a.handleFailureToSendToAggLayer(ctx, proof)
    - 75 + 386
    + - }, { +
    - 76 + 387
    + - Name: "update", + return false
    - 77 + 388
    + - Usage: "Update the default action for a policy", + }
    - 78 + 389
    + - Action: updatePolicy, +
    - 79 + 390
    + - Flags: append(policyActionFlags, &allowFlag, &denyFlag), + log.Infof("tx %s sent to agglayer, waiting to be mined", txHash.Hex())
    - 80 + 391
    + - }, + log.Debugf("Timeout set to %f seconds", a.cfg.AggLayerTxTimeout.Duration.Seconds())
    - 81 + 392
    + - }, + waitCtx, cancelFunc := context.WithDeadline(ctx, time.Now().Add(a.cfg.AggLayerTxTimeout.Duration))
    - 82 + 393
    + - } + defer cancelFunc()
    - 83 + 394
    + -
    + if err := a.AggLayerClient.WaitTxToBeMined(txHash, waitCtx); err != nil {
    - 84 + 395
    + - func updatePolicy(cli *cli.Context) error { + log.Errorf("interop didn't mine the tx: %v", err)
    - 85 + 396
    + - _, db, err := configAndStorage(cli) + a.handleFailureToSendToAggLayer(ctx, proof)
    - 86 + 397
    + - if err != nil { +
    - 87 + 398
    + - return err + return false
    - 88 + 399
    @@ -12991,47 +13672,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 89 + 400
    + - policy, err := resolvePolicy(cli) +
    - 90 + 401
    + - if err != nil { + // TODO: wait for synchronizer to catch up
    - 91 + 402
    + - return err + return true
    - 92 + 403
    + - } + }
    - 93 + 404
    @@ -13041,167 +13722,167 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 94 + 405
    + - allow := cli.Bool(allowFlag.Name) + func (a *Aggregator) handleFailureToSendToAggLayer(ctx context.Context, proof *state.Proof) {
    - 95 + 406
    + - deny := cli.Bool(denyFlag.Name) + log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
    - 96 + 407
    + -
    + proof.GeneratingSince = nil
    - 97 + 408
    + - // exactly one must be set +
    - 98 + 409
    + - if (allow && deny) || (!allow && !deny) { + err := a.State.UpdateGeneratedProof(ctx, proof, nil)
    - 99 + 410
    + - return errors.New("supply one policy action [--allow or --deny]") + if err != nil {
    - 100 + 411
    + - } + log.Errorf("Failed updating proof state (false): %v", err)
    - 101 + 412
    + -
    + }
    - 102 + 413
    + - var setting bool +
    - 103 + 414
    + - if allow { + a.endProofVerification()
    - 104 + 415
    + - setting = true + }
    - 105 + 416
    + - } else if deny { +
    - 106 + 417
    + - setting = false + func (a *Aggregator) handleFailureToAddVerifyBatchToBeMonitored(ctx context.Context, proof *state.Proof) {
    - 107 + 418
    + - } + log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal))
    - 108 + 419
    + -
    + proof.GeneratingSince = nil
    - 109 + 420
    + - err = db.UpdatePolicy(context.Background(), policy, setting) + err := a.State.UpdateGeneratedProof(ctx, proof, nil)
    - 110 + 421
    @@ -13211,17 +13892,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 111 + 422
    + - return err + log.Errorf("Failed updating proof state (false): %v", err)
    - 112 + 423
    @@ -13231,17 +13912,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 113 + 424
    + - return nil + a.endProofVerification()
    - 114 + 425
    @@ -13251,7 +13932,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 115 + 426
    @@ -13261,107 +13942,127 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 116 + 427
    + - func addAcl(cli *cli.Context) error { + // buildFinalProof builds and return the final proof for an aggregated/batch proof.
    - 117 + 428
    + - _, db, err := configAndStorage(cli) + func (a *Aggregator) buildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (*prover.FinalProof, error) {
    - 118 + 429
    + - if err != nil { + log := log.WithFields(
    - 119 + 430
    + - return err + "prover", prover.Name(),
    - 120 + 431
    + - } + "proverId", prover.ID(),
    - 121 + 432
    + - policy, addresses, err := requirePolicyAndAddresses(cli) + "proverAddr", prover.Addr(),
    - 122 + 433
    + - if err != nil { + "recursiveProofId", *proof.ProofID,
    - 123 + 434
    + - return err + "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal),
    - 124 + 435
    + - } + )
    - 125 + 436
    + - err = db.AddAddressesToPolicy(context.Background(), policy, addresses) + log.Info("Generating final proof")
    - 126 + 437 + +
    + + +
    +
    +
    + 438 + +
    + + + finalProofID, err := prover.FinalProof(proof.Proof, a.cfg.SenderAddress) +
    +
    + 439
    @@ -13371,17 +14072,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 127 + 440
    + - return err + return nil, fmt.Errorf("failed to get final proof id: %w", err)
    - 128 + 441
    @@ -13391,57 +14092,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 129 + 442
    + - return nil + proof.ProofID = finalProofID
    - 130 + 443
    + - } +
    - 131 + 444
    + -
    + log.Infof("Final proof ID for batches [%d-%d]: %s", proof.BatchNumber, proof.BatchNumberFinal, *proof.ProofID)
    - 132 + 445
    + - func removeAcl(cli *cli.Context) error { + log = log.WithFields("finalProofId", finalProofID)
    - 133 + 446
    + - _, db, err := configAndStorage(cli) +
    - 134 + 447 + +
    + + + finalProof, err := prover.WaitFinalProof(ctx, *proof.ProofID) +
    +
    + 448
    @@ -13451,17 +14162,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 135 + 449
    + - return err + return nil, fmt.Errorf("failed to get final proof from prover: %w", err)
    - 136 + 450
    @@ -13471,157 +14182,157 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 137 + 451
    + - policy, addresses, err := requirePolicyAndAddresses(cli) +
    - 138 + 452
    + - if err != nil { + log.Info("Final proof generated")
    - 139 + 453
    + - return err +
    - 140 + 454
    + - } + // mock prover sanity check
    - 141 + 455
    + - err = db.RemoveAddressesFromPolicy(context.Background(), policy, addresses) + if string(finalProof.Public.NewStateRoot) == mockedStateRoot && string(finalProof.Public.NewLocalExitRoot) == mockedLocalExitRoot {
    - 142 + 456
    + - if err != nil { + // This local exit root and state root come from the mock
    - 143 + 457
    + - return err + // prover, use the one captured by the executor instead
    - 144 + 458
    + - } + finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil)
    - 145 + 459
    + - return nil + if err != nil {
    - 146 + 460
    + - } + return nil, fmt.Errorf("failed to retrieve batch with number [%d]", proof.BatchNumberFinal)
    - 147 + 461
    + -
    + }
    - 148 + 462
    + - func clearAcl(cli *cli.Context) error { + log.Warnf("NewLocalExitRoot and NewStateRoot look like a mock values, using values from executor instead: LER: %v, SR: %v",
    - 149 + 463
    + - _, db, err := configAndStorage(cli) + finalBatch.LocalExitRoot.TerminalString(), finalBatch.StateRoot.TerminalString())
    - 150 + 464
    + - if err != nil { + finalProof.Public.NewStateRoot = finalBatch.StateRoot.Bytes()
    - 151 + 465
    + - return err + finalProof.Public.NewLocalExitRoot = finalBatch.LocalExitRoot.Bytes()
    - 152 + 466
    @@ -13631,187 +14342,187 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 153 + 467
    + - policy, err := resolvePolicy(cli) +
    - 154 + 468
    + - if err != nil { + return finalProof, nil
    - 155 + 469
    + - return err + }
    - 156 + 470
    + - } +
    - 157 + 471
    + - err = db.ClearPolicy(context.Background(), policy) + // tryBuildFinalProof checks if the provided proof is eligible to be used to
    - 158 + 472
    + - if err != nil { + // build the final proof. If no proof is provided it looks for a previously
    - 159 + 473
    + - return err + // generated proof. If the proof is eligible, then the final proof generation
    - 160 + 474
    + - } + // is triggered.
    - 161 + 475
    + - return nil + func (a *Aggregator) tryBuildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (bool, error) {
    - 162 + 476
    + - } + proverName := prover.Name()
    - 163 + 477
    + -
    + proverID := prover.ID()
    - 164 + 478
    + - func describe(cli *cli.Context) error { +
    - 165 + 479
    + - showHeader := !cli.Bool(noHeaderFlag.Name) + log := log.WithFields(
    - 166 + 480
    + - if cli.IsSet(policyFlag.Name) { + "prover", proverName,
    - 167 + 481
    + - return describePolicy(cli, showHeader) + "proverId", proverID,
    - 168 + 482
    + - } + "proverAddr", prover.Addr(),
    - 169 + 483
    + - return describePolicies(cli, showHeader) + )
    - 170 + 484
    + - } + log.Debug("tryBuildFinalProof start")
    - 171 + 485
    @@ -13821,47 +14532,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 172 + 486
    + - func describePolicy(cli *cli.Context, showHeader bool) error { + var err error
    - 173 + 487
    + - _, db, err := configAndStorage(cli) + if !a.canVerifyProof() {
    - 174 + 488
    + - if err != nil { + log.Debug("Time to verify proof not reached or proof verification in progress")
    - 175 + 489
    + - return err + return false, nil
    - 176 + 490
    @@ -13871,7 +14582,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 177 + 491 + +
    + + + log.Debug("Send final proof time reached") +
    +
    + 492
    @@ -13881,37 +14602,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 178 + 493
    + - policyName, err := resolvePolicy(cli) + for !a.isSynced(ctx, nil) {
    - 179 + 494
    + - if err != nil { + log.Info("Waiting for synchronizer to sync...")
    - 180 + 495
    + - return err + time.Sleep(a.cfg.RetryTime.Duration)
    - 181 + 496 + +
    + + + continue +
    +
    + 497
    @@ -13921,7 +14652,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 182 + 498
    @@ -13931,77 +14662,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 183 + 499
    + - if showHeader { + var lastVerifiedBatchNum uint64
    - 184 + 500
    + - policy, err := db.DescribePolicy(context.Background(), policyName) + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil)
    - 185 + 501
    + - if err != nil { + if err != nil && !errors.Is(err, state.ErrNotFound) {
    - 186 + 502
    + - return err + return false, fmt.Errorf("failed to get last verified batch, %w", err)
    - 187 + 503
    + - } + }
    - 188 + 504
    + - fmt.Printf("%s: %s\n", "Policy", policy.Name) + if lastVerifiedBatch != nil {
    - 189 + 505
    + - fmt.Printf("%s: %s\n", "Action", policy.Desc()) + lastVerifiedBatchNum = lastVerifiedBatch.BatchNumber
    - 190 + 506
    @@ -14011,307 +14742,357 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 191 + 507
    + - query, err := resolveAddresses(cli, false) +
    - 192 + 508
    + - if err != nil { + if proof == nil {
    - 193 + 509
    + - return nil + // we don't have a proof generating at the moment, check if we
    - 194 + 510
    + - } + // have a proof ready to verify
    - 195 + 511
    + - list, err := db.ListAcl(context.Background(), policyName, query) +
    - 196 + 512
    + - if err != nil { + proof, err = a.getAndLockProofReadyToVerify(ctx, prover, lastVerifiedBatchNum)
    - 197 + 513
    + - return err + if errors.Is(err, state.ErrNotFound) {
    - 198 + 514
    + - } + // nothing to verify, swallow the error
    - 199 + 515
    + -
    + log.Debug("No proof ready to verify")
    - 200 + 516
    + - if showHeader { + return false, nil
    - 201 + 517
    + - fmt.Println("Addresses:") + }
    - 202 + 518
    + - } + if err != nil {
    - 203 + 519
    + - for _, address := range list { + return false, err
    - 204 + 520
    + - fmt.Println(address.Hex()) + }
    - 205 + 521
    + - } +
    - 206 + 522
    + - return nil + defer func() {
    - 207 + 523
    + - } + if err != nil {
    - 208 + 524
    + -
    + // Set the generating state to false for the proof ("unlock" it)
    - 209 + 525
    + - func describePolicies(cli *cli.Context, showHeader bool) error { + proof.GeneratingSince = nil
    - 210 + 526
    + - _, db, err := configAndStorage(cli) + err2 := a.State.UpdateGeneratedProof(a.ctx, proof, nil)
    - 211 + 527
    + - if err != nil { + if err2 != nil {
    - 212 + 528
    + - return err + log.Errorf("Failed to unlock proof: %v", err2)
    - 213 + + 529 + +
    +   + } +
    +
    + 530 + +
    +   + } +
    +
    + 531 +
    + - } + }() +
    +
    + 532 + +
    + + + } else { +
    +
    + 533 + +
    + + + // we do have a proof generating at the moment, check if it is +
    +
    + 534 + +
    + + + // eligible to be verified
    - 214 + 535
    + - list, err := db.DescribePolicies(context.Background()) + eligible, err := a.validateEligibleFinalProof(ctx, proof, lastVerifiedBatchNum)
    - 215 + 536
    + - if err != nil { + if err != nil {
    - 216 + 537
    + - return err + return false, fmt.Errorf("failed to validate eligible final proof, %w", err)
    - 217 + 538
    + - } + }
    - 218 + 539
    + -
    + if !eligible {
    - 219 + 540
    + - if showHeader { + return false, nil
    - 220 + 541
    + - fmt.Printf("%7s: %s\n", "Policy", "Action") + }
    - 221 + 542
    @@ -14321,137 +15102,137 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 222 + 543
    + - for _, p := range list { +
    - 223 + 544
    + - fmt.Printf("%7s: %s\n", p.Name, p.Desc()) + log = log.WithFields(
    - 224 + 545
    + - } + "proofId", *proof.ProofID,
    - 225 + 546
    + -
    + "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal),
    - 226 + 547
    + - return nil + )
    - 227 + 548
    + - } +
    - 228 + 549
    + -
    + // at this point we have an eligible proof, build the final one using it
    - 229 + 550
    + - func configAndStorage(cli *cli.Context) (*config.Config, *pgpoolstorage.PostgresPoolStorage, error) { + finalProof, err := a.buildFinalProof(ctx, prover, proof)
    - 230 + 551
    + - c, err := config.Load(cli, false) + if err != nil {
    - 231 + 552
    + - if err != nil { + err = fmt.Errorf("failed to build final proof, %w", err)
    - 232 + 553
    + - return nil, nil, err + log.Error(FirstToUpper(err.Error()))
    - 233 + 554
    + - } + return false, err
    - 234 + 555
    + - setupLog(c.Log) + }
    - 235 + 556
    @@ -14461,67 +15242,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 236 + 557
    + - db, err := pgpoolstorage.NewPostgresPoolStorage(c.Pool.DB) + msg := finalProofMsg{
    - 237 + 558
    + - if err != nil { + proverName: proverName,
    - 238 + 559
    + - return nil, nil, err + proverID: proverID,
    - 239 + 560
    + - } + recursiveProof: proof,
    - 240 + 561
    + - return c, db, nil + finalProof: finalProof,
    - 241 + 562
    + - } + }
    - 242 + 563
    @@ -14531,47 +15312,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 243 + 564
    + - func requirePolicyAndAddresses(cli *cli.Context) (pool.PolicyName, []common.Address, error) { + select {
    - 244 + 565
    + - policy, err := resolvePolicy(cli) + case <-a.ctx.Done():
    - 245 + 566
    + - if err != nil { + return false, a.ctx.Err()
    - 246 + 567
    + - return "", nil, err + case a.finalProof <- msg:
    - 247 + 568
    @@ -14581,3940 +15362,3827 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 248 + 569
    + - addresses, err := resolveAddresses(cli, true) +
    - 249 + 570
    + - if err != nil { + log.Debug("tryBuildFinalProof end")
    - 250 + 571
    + - return "", nil, err + return true, nil
    - 251 + 572
    + - } + }
    - 252 + 573
    + - return policy, addresses, nil +
    - 253 + 574
    + - } + func (a *Aggregator) validateEligibleFinalProof(ctx context.Context, proof *state.Proof, lastVerifiedBatchNum uint64) (bool, error) {
    - 254 + 575
    + -
    + batchNumberToVerify := lastVerifiedBatchNum + 1
    - 255 + 576
    + - func resolvePolicy(cli *cli.Context) (pool.PolicyName, error) { +
    - 256 + 577
    + - policy := cli.String(policyFlag.Name) + if proof.BatchNumber != batchNumberToVerify {
    - 257 + 578
    + - if policy == "" { + if proof.BatchNumber < batchNumberToVerify && proof.BatchNumberFinal >= batchNumberToVerify {
    - 258 + 579
    + - return "", nil + // We have a proof that contains some batches below the last batch verified, anyway can be eligible as final proof
    - 259 + 580
    + - } + log.Warnf("Proof %d-%d contains some batches lower than last batch verified %d. Check anyway if it is eligible", proof.BatchNumber, proof.BatchNumberFinal, lastVerifiedBatchNum)
    - 260 + 581
    + - if !pool.IsPolicy(policy) { + } else if proof.BatchNumberFinal < batchNumberToVerify {
    - 261 + 582
    + - return "", fmt.Errorf("invalid policy name: %s", policy) + // We have a proof that contains batches below that the last batch verified, we need to delete this proof
    - 262 + 583
    + - } + log.Warnf("Proof %d-%d lower than next batch to verify %d. Deleting it", proof.BatchNumber, proof.BatchNumberFinal, batchNumberToVerify)
    - 263 + 584
    + - return pool.PolicyName(policy), nil + err := a.State.DeleteGeneratedProofs(ctx, proof.BatchNumber, proof.BatchNumberFinal, nil)
    - 264 + 585
    + - } + if err != nil {
    - 265 + 586
    + -
    + return false, fmt.Errorf("failed to delete discarded proof, err: %w", err)
    - 266 + 587
    + - func resolveAddresses(cli *cli.Context, failIfEmpty bool) ([]common.Address, error) { + }
    - 267 + 588
    + - var set = make(map[common.Address]struct{}) + return false, nil
    - 268 + 589
    + - if cli.IsSet("csv") { + } else {
    - 269 + 590
    + - file := cli.String(csvFlag.Name) + log.Debugf("Proof batch number %d is not the following to last verfied batch number %d", proof.BatchNumber, lastVerifiedBatchNum)
    - 270 + 591
    + - fd, err := os.Open(file) + return false, nil
    - 271 + 592
    + - if err != nil { + }
    - 272 + 593
    + - return nil, err + }
    - 273 + 594
    + - } +
    - 274 + 595
    + - defer func(fd *os.File) { + bComplete, err := a.State.CheckProofContainsCompleteSequences(ctx, proof, nil)
    - 275 + 596
    + - _ = fd.Close() + if err != nil {
    - 276 + 597
    + - }(fd) + return false, fmt.Errorf("failed to check if proof contains complete sequences, %w", err)
    - 277 + 598
    + -
    + }
    - 278 + 599
    + - fileReader := csv.NewReader(fd) + if !bComplete {
    - 279 + 600
    + - records, err := fileReader.ReadAll() + log.Infof("Recursive proof %d-%d not eligible to be verified: not containing complete sequences", proof.BatchNumber, proof.BatchNumberFinal)
    - 280 + 601
    + -
    + return false, nil
    - 281 + 602
    + - if err != nil { + }
    - 282 + 603
    + - return nil, err + return true, nil
    - 283 + 604
    + - } + }
    - 284 + 605
    + - for _, row := range records { +
    - 285 + 606
    + - for _, cell := range row { + func (a *Aggregator) getAndLockProofReadyToVerify(ctx context.Context, prover proverInterface, lastVerifiedBatchNum uint64) (*state.Proof, error) {
    - 286 + 607
    + - hex := strings.TrimSpace(cell) + a.StateDBMutex.Lock()
    - 287 + 608
    + - set[common.HexToAddress(hex)] = struct{}{} + defer a.StateDBMutex.Unlock()
    - 288 + 609
    + - } +
    - 289 + 610
    + - } + // Get proof ready to be verified
    - 290 + 611
    + - } + proofToVerify, err := a.State.GetProofReadyToVerify(ctx, lastVerifiedBatchNum, nil)
    - 291 + 612
    + -
    + if err != nil {
    - 292 + 613
    + - for _, a := range cli.Args().Slice() { + return nil, err
    - 293 + 614
    + - a = strings.TrimSpace(a) + }
    - 294 + 615
    + - a = strings.Trim(a, ",|") +
    - 295 + 616
    + - if !strings.HasPrefix(a, "0x") { + now := time.Now().Round(time.Microsecond)
    - 296 + 617
    + - a = "0x" + a + proofToVerify.GeneratingSince = &now
    - 297 + 618
    + - } +
    - 298 + 619
    + - set[common.HexToAddress(a)] = struct{}{} + err = a.State.UpdateGeneratedProof(ctx, proofToVerify, nil)
    - 299 + 620
    + - } + if err != nil {
    - 300 + 621
    + - var ret []common.Address + return nil, err
    - 301 + 622
    + - for a := range set { + }
    - 302 + 623
    + - ret = append(ret, a) +
    - 303 + 624
    + - } + return proofToVerify, nil
    - 304 + 625
    + - if failIfEmpty && len(ret) == 0 { + }
    - 305 + 626
    + - return nil, errors.New("no addresses given") +
    - 306 + 627
    + - } + func (a *Aggregator) unlockProofsToAggregate(ctx context.Context, proof1 *state.Proof, proof2 *state.Proof) error {
    - 307 + 628
    + - return ret, nil + // Release proofs from generating state in a single transaction
    - 308 + 629
    + - } + dbTx, err := a.State.BeginStateTransaction(ctx)
    -
    + + + 630 + + +
    + + + if err != nil {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -2,6 +2,7 @@
    - 2 + + 631 +
    -   -
    + + + log.Warnf("Failed to begin transaction to release proof aggregation state, err: %v", err)
    - 3 + + 632 +
    -   - import ( + + + return err
    - 4 + + 633 +
    -   - "context" + + + }
    - + + 634 -
    -   +
    +
    + +
    - 5 + + 635 +
    -   - "errors" + + + proof1.GeneratingSince = nil
    - 6 + + 636 +
    -   - "fmt" + + + err = a.State.UpdateGeneratedProof(ctx, proof1, dbTx)
    - 7 + + 637 +
    -   - "net" + + + if err == nil {
    -
    @@ -37,6 +42,7 @@
    -
    - 37 + + 638 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" + + + proof2.GeneratingSince = nil
    - 38 + + 639 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer" + + + err = a.State.UpdateGeneratedProof(ctx, proof2, dbTx)
    - 39 + + 640 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + + + }
    - + + 641 -
    -   +
    +
    + +
    - 40 + + 642 +
    -   - "github.com/jackc/pgx/v4/pgxpool" + + + if err != nil {
    - 41 + + 643 +
    -   - "github.com/prometheus/client_golang/prometheus/promhttp" + + + if err := dbTx.Rollback(ctx); err != nil {
    - 42 + + 644 +
    -   - "github.com/urfave/cli/v2" + + + err := fmt.Errorf("failed to rollback proof aggregation state: %w", err)
    -
    @@ -107,19 +113,27 @@
    +
    + 645 + +
    + + + log.Error(FirstToUpper(err.Error())) +
    - 107 + + 646 +
    -   - log.Fatal(err) + + + return err
    - 108 + + 647 +
    -   - } + + + }
    - 109 + + 648 +
    -   -
    + + + return fmt.Errorf("failed to release proof aggregation state: %w", err)
    - 110 + + 649 +
    - - - etherman, err := newEtherman(*c) + + + }
    - + + 650 -
    -   +
    +
    + +
    - 111 + + 651 +
    -   + + + err = dbTx.Commit(ctx) +
    +
    + 652 + +
    + + if err != nil {
    - 112 + + 653 +
    -   - log.Fatal(err) + + + return fmt.Errorf("failed to release proof aggregation state %w", err)
    - 113 + + 654 +
    -   + + }
    - 114 + + 655 +
    - - + +
    - 115 + + 656 +
    - - - // READ CHAIN ID FROM POE SC + + + return nil
    - 116 + + 657 +
    - - - l2ChainID, err := etherman.GetL2ChainID() + + + }
    - 117 + + 658 +
    -   - if err != nil { + + +
    - 118 + + 659 +
    -   - log.Fatal(err) + + + func (a *Aggregator) getAndLockProofsToAggregate(ctx context.Context, prover proverInterface) (*state.Proof, *state.Proof, error) {
    - 119 + + 660 +
    -   - } + + + log := log.WithFields(
    - 120 + + 661 +
    -   -
    + + + "prover", prover.Name(),
    - + + 662 -
    -   -
    +
    +
    + + + "proverId", prover.ID(),
    - + + 663 -
    -   -
    +
    +
    + + + "proverAddr", prover.Addr(),
    - + + 664 -
    -   -
    +
    +
    + + + )
    - + + 665 -
    -   +
    +
    + +
    - 121 + + 666 +
    -   - st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false) + + + a.StateDBMutex.Lock()
    - 122 + + 667 +
    -   -
    + + + defer a.StateDBMutex.Unlock()
    - + + 668 -
    -   +
    +
    + +
    - + + 669 -
    -   -
    +
    +
    + + + proof1, proof2, err := a.State.GetProofsToAggregate(ctx, nil)
    - + + 670 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 671 -
    -   -
    +
    +
    + + + return nil, nil, err
    - + + 672 -
    -   -
    +
    +
    + + + }
    - 123 + + 673 +
    -   - c.Aggregator.ChainID = l2ChainID + + +
    - 124 + + 674 +
    -   - c.Sequencer.StreamServer.ChainID = l2ChainID + + + // Set proofs in generating state in a single transaction
    - 125 + + 675 +
    -   - log.Infof("Chain ID read from POE SC = %v", l2ChainID) + + + dbTx, err := a.State.BeginStateTransaction(ctx)
    -
    @@ -276,8 +290,88 @@
    -
    - 276 + + 676 +
    -   - } + + + if err != nil {
    - 277 + + 677 +
    -   - } + + + log.Errorf("Failed to begin transaction to set proof aggregation state, err: %v", err)
    - 278 + + 678 +
    -   -
    + + + return nil, nil, err
    - 279 + + 679 +
    - - - func newEtherman(c config.Config) (*etherman.Client, error) { + + + }
    - 280 + + 680 +
    - - - return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config) + + +
    - + + 681 -
    -   -
    +
    +
    + + + now := time.Now().Round(time.Microsecond)
    - + + 682 -
    -   -
    +
    +
    + + + proof1.GeneratingSince = &now
    - + + 683 -
    -   -
    +
    +
    + + + err = a.State.UpdateGeneratedProof(ctx, proof1, dbTx)
    - + + 684 -
    -   -
    +
    +
    + + + if err == nil {
    - + + 685 -
    -   -
    +
    +
    + + + proof2.GeneratingSince = &now
    - + + 686 -
    -   -
    +
    +
    + + + err = a.State.UpdateGeneratedProof(ctx, proof2, dbTx)
    - + + 687 -
    -   -
    +
    +
    + + + }
    - + + 688 -
    -   +
    +
    + +
    - + + 689 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 690 -
    -   -
    +
    +
    + + + if err := dbTx.Rollback(ctx); err != nil {
    - + + 691 -
    -   -
    +
    +
    + + + err := fmt.Errorf("failed to rollback proof aggregation state %w", err)
    - + + 692 -
    -   -
    +
    +
    + + + log.Error(FirstToUpper(err.Error()))
    - + + 693 -
    -   -
    +
    +
    + + + return nil, nil, err
    - + + 694 -
    -   -
    +
    +
    + + + }
    - + + 695 -
    -   -
    +
    +
    + + + return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err)
    - + + 696 -
    -   -
    +
    +
    + + + }
    - + + 697 -
    -   +
    +
    + +
    - + + 698 -
    -   -
    +
    +
    + + + err = dbTx.Commit(ctx)
    - + + 699 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 700 -
    -   -
    +
    +
    + + + return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err)
    - + + 701 -
    -   -
    +
    +
    + + + }
    - + + 702 -
    -   +
    +
    + +
    - + + 703 -
    -   -
    +
    +
    + + + return proof1, proof2, nil
    - + + 704 -
    -   -
    +
    +
    + + + }
    - + + 705 -
    -   +
    +
    + +
    - + + 706 -
    -   -
    +
    +
    + + + func (a *Aggregator) tryAggregateProofs(ctx context.Context, prover proverInterface) (bool, error) {
    - + + 707 -
    -   -
    +
    +
    + + + proverName := prover.Name()
    - + + 708 -
    -   -
    +
    +
    + + + proverID := prover.ID()
    - + + 709 -
    -   +
    +
    + +
    - + + 710 -
    -   -
    +
    +
    + + + log := log.WithFields(
    - + + 711 -
    -   -
    +
    +
    + + + "prover", proverName,
    - + + 712 -
    -   -
    +
    +
    + + + "proverId", proverID,
    - + + 713 -
    -   -
    +
    +
    + + + "proverAddr", prover.Addr(),
    - + + 714 -
    -   -
    +
    +
    + + + )
    - + + 715 -
    -   -
    +
    +
    + + + log.Debug("tryAggregateProofs start")
    - + + 716 -
    -   +
    +
    + +
    - + + 717 -
    -   -
    +
    +
    + + + proof1, proof2, err0 := a.getAndLockProofsToAggregate(ctx, prover)
    - + + 718 -
    -   -
    +
    +
    + + + if errors.Is(err0, state.ErrNotFound) {
    - + + 719 -
    -   -
    +
    +
    + + + // nothing to aggregate, swallow the error
    - + + 720 -
    -   -
    +
    +
    + + + log.Debug("Nothing to aggregate")
    - + + 721 -
    -   -
    +
    +
    + + + return false, nil
    - + + 722 -
    -   -
    +
    +
    + + + }
    - + + 723 -
    -   -
    +
    +
    + + + if err0 != nil {
    - + + 724 -
    -   -
    +
    +
    + + + return false, err0
    - + + 725 -
    -   -
    +
    +
    + + + }
    - + + 726 -
    -   +
    +
    + +
    - + + 727 -
    -   -
    +
    +
    + + + var (
    - + + 728 -
    -   -
    +
    +
    + + + aggrProofID *string
    - + + 729 -
    -   -
    +
    +
    + + + err error
    - + + 730 -
    -   -
    +
    +
    + + + )
    - + + 731 -
    -   +
    +
    + +
    - + + 732 -
    -   -
    +
    +
    + + + defer func() {
    - + + 733 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 734 -
    -   -
    +
    +
    + + + err2 := a.unlockProofsToAggregate(a.ctx, proof1, proof2)
    - + + 735 -
    -   -
    +
    +
    + + + if err2 != nil {
    - + + 736 -
    -   -
    +
    +
    + + + log.Errorf("Failed to release aggregated proofs, err: %v", err2)
    - + + 737 -
    -   -
    +
    +
    + + + }
    - + + 738 -
    +
    +
      -
    + }
    - + + 739 -
    -   -
    +
    +
    + + + log.Debug("tryAggregateProofs end")
    - + + 740 -
    -   -
    +
    +
    + + + }()
    - + + 741 -
    -   +
    +
    + +
    - + + 742 -
    -   -
    +
    +
    + + + log.Infof("Aggregating proofs: %d-%d and %d-%d", proof1.BatchNumber, proof1.BatchNumberFinal, proof2.BatchNumber, proof2.BatchNumberFinal)
    - + + 743 -
    -   +
    +
    + +
    - + + 744 -
    -   -
    +
    +
    + + + batches := fmt.Sprintf("%d-%d", proof1.BatchNumber, proof2.BatchNumberFinal)
    - + + 745 -
    -   -
    +
    +
    + + + log = log.WithFields("batches", batches)
    - + + 746 -
    -   +
    +
    + +
    - + + 747 -
    -   -
    +
    +
    + + + inputProver := map[string]interface{}{
    - + + 748 -
    -   -
    +
    +
    + + + "recursive_proof_1": proof1.Proof,
    - + + 749 -
    -   -
    +
    +
    + + + "recursive_proof_2": proof2.Proof,
    - + + 750 -
    -   -
    +
    +
    + + + }
    - + + 751 -
    -   -
    +
    +
    + + + b, err := json.Marshal(inputProver)
    - + + 752 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 753 -
    -   -
    +
    +
    + + + err = fmt.Errorf("failed to serialize input prover, %w", err)
    - + + 754 -
    -   -
    +
    +
    + + + log.Error(FirstToUpper(err.Error()))
    - + + 755 -
    -   -
    +
    +
    + + + return false, err
    - + + 756 -
    -   -
    +
    +
    + + + }
    - + + 757 -
    -   +
    +
    + +
    - + + 758 -
    -   -
    +
    +
    + + + proof := &state.Proof{
    - + + 759 -
    -   -
    +
    +
    + + + BatchNumber: proof1.BatchNumber,
    - + + 760 -
    -   -
    +
    +
    + + + BatchNumberFinal: proof2.BatchNumberFinal,
    - 281 + + 761 +
    -   - } + + + Prover: &proverName,
    - 282 + + 762 +
    -   -
    + + + ProverID: &proverID,
    - 283 + + 763 +
    -   - func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerStorage *ethtxmanager.PostgresStorage, st *state.State, pool *pool.Pool, eventLog *event.EventLog) { + + + InputProver: string(b),
    -
    @@ -295,12 +389,23 @@
    +
    + 764 + +
    + + + } +
    - 295 + + 765 +
    -   - } + + +
    - 296 + + 766 +
    -   - log.Info("trustedSequencerURL ", trustedSequencerURL) + + + aggrProofID, err = prover.AggregatedProof(proof1.Proof, proof2.Proof)
    - 297 + + 767 +
    -   - } + + + if err != nil {
    - + + 768 -
    -   -
    +
    +
    + + + err = fmt.Errorf("failed to get aggregated proof id, %w", err)
    - + + 769 -
    -   -
    +
    +
    + + + log.Error(FirstToUpper(err.Error()))
    - + + 770 -
    -   -
    +
    +
    + + + return false, err
    - + + 771 -
    -   -
    +
    +
    + + + }
    - + + 772 -
    -   +
    +
    + +
    - + + 773 -
    -   -
    +
    +
    + + + proof.ProofID = aggrProofID
    - + + 774 -
    -   +
    +
    + +
    - + + 775 -
    -   -
    +
    +
    + + + log.Infof("Proof ID for aggregated proof: %v", *proof.ProofID)
    - + + 776 -
    -   -
    +
    +
    + + + log = log.WithFields("proofId", *proof.ProofID)
    - + + 777 -
    -   +
    +
    + +
    - + + 778 -
    -   -
    +
    +
    + + + recursiveProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID)
    - 298 + + 779 +
    -   - zkEVMClient := client.NewClient(trustedSequencerURL) + + + if err != nil {
    - 299 + + 780 +
    -   - etherManForL1 := []syncinterfaces.EthermanFullInterface{} + + + err = fmt.Errorf("failed to get aggregated proof from prover, %w", err)
    - 300 + + 781 +
    -   - // If synchronizer are using sequential mode, we only need one etherman client + + + log.Error(FirstToUpper(err.Error()))
    - 301 + + 782 +
    -   - if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode { + + + return false, err
    - 302 + 783
      - for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ { + }
    - 303 + + 784 +
    - - - eth, err := newEtherman(cfg) + + +
    - 304 + + 785 +
    -   - if err != nil { + + + log.Info("Aggregated proof generated")
    - 305 + + 786 +
    -   - log.Fatal(err) + + +
    - 306 + + 787 +
    -   - } + + + proof.Proof = recursiveProof
    -
    @@ -310,7 +415,7 @@
    -
    - 310 + + 788 +
    -   - etm := ethtxmanager.New(cfg.EthTxManager, etherman, ethTxManagerStorage, st) + + +
    - 311 + + 789 +
    -   - sy, err := synchronizer.NewSynchronizer( + + + // update the state by removing the 2 aggregated proofs and storing the
    - 312 + + 790 +
    -   - cfg.IsTrustedSequencer, etherman, etherManForL1, st, pool, etm, + + + // newly generated recursive proof
    - 313 + + 791 +
    - - - zkEVMClient, eventLog, cfg.NetworkConfig.Genesis, cfg.Synchronizer, cfg.Log.Environment == "development", + + + dbTx, err := a.State.BeginStateTransaction(ctx)
    - 314 + + 792 +
    -   - ) + + + if err != nil {
    - 315 + + 793 +
    -   - if err != nil { + + + err = fmt.Errorf("failed to begin transaction to update proof aggregation state, %w", err)
    - 316 + + 794 +
    -   - log.Fatal(err) + + + log.Error(FirstToUpper(err.Error()))
    -
    @@ -403,12 +508,12 @@
    -
    - 403 + + 795 +
    -   - } + + + return false, err
    - 404 + + 796 +
    -   -
    + + + }
    - 405 + + 797 +
    -   - func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender { + + +
    - 406 + + 798 +
    - - - etherman, err := newEtherman(cfg) + + + err = a.State.DeleteGeneratedProofs(ctx, proof1.BatchNumber, proof2.BatchNumberFinal, dbTx)
    - 407 + + 799 +
    -   + + if err != nil {
    - 408 + + 800 +
    -   - log.Fatal(err) + + + if err := dbTx.Rollback(ctx); err != nil {
    - 409 + + 801 +
    -   - } + + + err := fmt.Errorf("failed to rollback proof aggregation state, %w", err)
    - 410 + + 802 +
    -   -
    + + + log.Error(FirstToUpper(err.Error()))
    - 411 + + 803 +
    - - - auth, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password) + + + return false, err
    - 412 + + 804 +
    -   - if err != nil { + + + }
    - 413 + + 805 +
    -   - log.Fatal(err) + + + err = fmt.Errorf("failed to delete previously aggregated proofs, %w", err)
    - 414 + + 806 +
    -   - } + + + log.Error(FirstToUpper(err.Error()))
    -
    @@ -418,7 +523,12 @@
    -
    - 418 + + 807 +
    -   -
    + + + return false, err
    - 419 + + 808 +
    -   - ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st) + + + }
    - 420 + + 809 +
    -   + +
    - 421 + + 810 +
    - - - seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog) + + + now := time.Now().Round(time.Microsecond)
    - + + 811 -
    -   -
    +
    +
    + + + proof.GeneratingSince = &now
    - + + 812 -
    -   +
    +
    + +
    - + + 813 -
    -   -
    +
    +
    + + + err = a.State.AddGeneratedProof(ctx, proof, dbTx)
    - + + 814 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 815 -
    -   -
    +
    +
    + + + if err := dbTx.Rollback(ctx); err != nil {
    - 422 + + 816 +
    -   - if err != nil { + + + err := fmt.Errorf("failed to rollback proof aggregation state, %w", err)
    - 423 + + 817 +
    -   - log.Fatal(err) + + + log.Error(FirstToUpper(err.Error()))
    - 424 + + 818 +
    -   - } + + + return false, err
    -
    @@ -427,7 +537,23 @@
    +
    + 819 + +
    + + + } +
    - 427 + + 820 +
    -   - } + + + err = fmt.Errorf("failed to store the recursive proof, %w", err)
    - 428 + + 821 +
    -   -
    + + + log.Error(FirstToUpper(err.Error()))
    - 429 + + 822 +
    -   - func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) { + + + return false, err
    - 430 + + 823 +
    - - - agg, err := aggregator.New(c, st, ethTxManager, etherman) + + + }
    - + + 824 -
    -   +
    +
    + +
    - + + 825 -
    -   -
    +
    +
    + + + err = dbTx.Commit(ctx)
    - + + 826 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 827 -
    -   -
    +
    +
    + + + err = fmt.Errorf("failed to store the recursive proof, %w", err)
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - + + 828 -
    -   -
    +
    +
    + + + log.Error(FirstToUpper(err.Error()))
    - + + 829 -
    -   -
    +
    +
    + + + return false, err
    - + + 830 -
    -   -
    +
    +
    + + + }
    - + + 831 -
    -   +
    +
    + +
    - + + 832 -
    -   -
    +
    +
    + + + // NOTE(pg): the defer func is useless from now on, use a different variable
    - + + 833 -
    -   -
    +
    +
    + + + // name for errors (or shadow err in inner scopes) to not trigger it.
    - + + 834 -
    -   +
    +
    + +
    - + + 835 -
    -   -
    +
    +
    + + + // state is up to date, check if we can send the final proof using the
    - + + 836 -
    -   -
    +
    +
    + + + // one just crafted.
    - + + 837 -
    -   -
    +
    +
    + + + finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof)
    - 431 + + 838 +
    -   - if err != nil { + + + if finalProofErr != nil {
    - 432 + + 839 +
    -   - log.Fatal(err) + + + // just log the error and continue to handle the aggregated proof
    - 433 + + 840 +
    -   - } + + + log.Errorf("Failed trying to check if recursive proof can be verified: %v", finalProofErr)
    -
    @@ -497,14 +623,14 @@
    -
    - 497 + + 841 +
    -   + + }
    - 498 + + 842 +
    -   - log.Infof("Starting L1InfoRoot: %v", l1inforoot.String()) + + +
    - 499 + + 843 +
    -   -
    + + + // NOTE(pg): prover is done, use a.ctx from now on
    - 500 + + 844 +
    - - - forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.BlockNumber) + + +
    - 501 + + 845 +
    -   - if err != nil { + + + if !finalProofBuilt {
    - 502 + + 846 +
    -   - log.Fatal("error getting forkIDs. Error: ", err) + + + proof.GeneratingSince = nil
    - 503 + + 847 +
    -   - } + + +
    - 504 + + 848 +
    -   - st.UpdateForkIDIntervalsInMemory(forkIDIntervals) + + + // final proof has not been generated, update the recursive proof
    - 505 + + 849 +
    -   -
    + + + err := a.State.UpdateGeneratedProof(a.ctx, proof, nil)
    - 506 + + 850 +
    -   - currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId + + + if err != nil {
    - 507 + + 851 +
    - - - log.Infof("Fork ID read from POE SC = %v", forkIDIntervals[len(forkIDIntervals)-1].ForkId) + + + err = fmt.Errorf("failed to store batch proof result, %w", err)
    - 508 + + 852 +
    -   -
    + + + log.Error(FirstToUpper(err.Error()))
    - 509 + + 853 +
    -   - return st, currentForkID + + + return false, err
    - 510 + + 854 +
    -   - } + + + }
    -
    @@ -520,13 +646,13 @@
    -
    - 520 + + 855 +
    -   - } + + + }
    - 521 + + 856 +
    -   + +
    - 522 + + 857 +
    -   - func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client { + + + return true, nil
    - 523 + + 858 +
    - - - etherman, err := newEtherman(cfg) + + + }
    - 524 + + 859 +
    -   - if err != nil { + + +
    - 525 + + 860 +
    -   - log.Fatal(err) + + + func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverInterface) (*state.Batch, *state.Proof, error) {
    - 526 + + 861 +
    -   - } + + + proverID := prover.ID()
    - 527 + + 862 +
    -   -
    + + + proverName := prover.Name()
    - 528 + + 863 +
    -   - for _, privateKey := range cfg.EthTxManager.PrivateKeys { + + +
    - 529 + + 864 +
    - - - _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password) + + + log := log.WithFields(
    - 530 + + 865 +
    -   - if err != nil { + + + "prover", proverName,
    - 531 + + 866 +
    -   - log.Fatal(err) + + + "proverId", proverID,
    - 532 + + 867 +
    -   - } + + + "proverAddr", prover.Addr(),
    -
    @@ -658,14 +784,32 @@
    -
    - 658 + + 868 +
    -   - } + + + )
    - 659 + + 869 +
    -   - forkIDIntervals = forkIntervals + + +
    - 660 + + 870 +
    -   - } else { + + + a.StateDBMutex.Lock()
    - 661 + + 871 +
    - - - log.Debug("Getting initial forkID") + + + defer a.StateDBMutex.Unlock()
    - 662 + + 872 +
    - - - forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, genesisBlockNumber) -
    -
    - - -
    -   + +
    - + + 873 -
    -   -
    +
    +
    + + + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil)
    - + + 874 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 875 -
    -   -
    +
    +
    + + + return nil, nil, err
    - + + 876 -
    -   -
    +
    +
    + + + }
    - + + 877 -
    -   +
    +
    + +
    - + + 878 -
    -   -
    +
    +
    + + + // Get header of the last L1 block
    - + + 879 -
    -   -
    +
    +
    + + + lastL1BlockHeader, err := a.Ethman.GetLatestBlockHeader(ctx)
    - 663 + + 880 +
    -   - if err != nil { + + + if err != nil {
    - 664 + + 881 +
    -   - return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err) + + + log.Errorf("Failed to get last L1 block header, err: %v", err)
    - 665 + + 882 +
    -   - } else if len(forkIntervals) == 0 { + + + return nil, nil, err
    - 666 + + 883 +
    -   - return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...") + + + }
    - 667 + + 884 +
    -   - } + + + lastL1BlockNumber := lastL1BlockHeader.Number.Uint64()
    - 668 + + 885 +
    -   - forkIDIntervals = forkIntervals + + +
    - + + 886 -
    -   -
    +
    +
    + + + // Calculate max L1 block number for getting next virtual batch to prove
    - + + 887 -
    -   -
    +
    +
    + + + maxL1BlockNumber := uint64(0)
    - + + 888 -
    -   -
    +
    +
    + + + if a.cfg.BatchProofL1BlockConfirmations <= lastL1BlockNumber {
    - + + 889 -
    -   -
    +
    +
    + + + maxL1BlockNumber = lastL1BlockNumber - a.cfg.BatchProofL1BlockConfirmations
    - + + 890 -
    -   -
    +
    +
    + + + }
    - + + 891 -
    -   -
    +
    +
    + + + log.Debugf("Max L1 block number for getting next virtual batch to prove: %d", maxL1BlockNumber)
    - + + 892 -
    -   +
    +
    + +
    - + + 893 -
    -   -
    +
    +
    + + + // Get virtual batch pending to generate proof
    - + + 894 -
    -   -
    +
    +
    + + + batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, maxL1BlockNumber, nil)
    - + + 895 -
    -   -
    +
    +
    + + + if err != nil {
    - 669 + + 896 +
    -   - } + + + return nil, nil, err
    - 670 + + 897 +
    -   + + }
    - 671 + + 898 +
    -   - return forkIDIntervals, nil -
    -
    -
    + + +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - @@ -19599,47 +20202,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + - - - - - - - - - - - - - - + +
    -
     
    - 2 + + 899 +
    -   -
    + + + log.Infof("Found virtual batch %d pending to generate proof", batchToVerify.BatchNumber)
    - 3 + + 900 +
    -   - import ( + + + log = log.WithFields("batch", batchToVerify.BatchNumber)
    - 4 + + 901 +
    -   - "context" + + +
    - 5 + 902
    + - "crypto/ecdsa" + log.Info("Checking profitability to aggregate batch")
    - 6 + + 903 +
    -   - "errors" + + +
    - 7 + + 904 +
    -   - "fmt" + + + // pass pol collateral as zero here, bcs in smart contract fee for aggregator is not defined yet
    - 8 + + 905 +
    -   - "net" + + + isProfitable, err := a.ProfitabilityChecker.IsProfitable(ctx, big.NewInt(0))
    -
     
    -
    - 42 + + 906 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" + + + if err != nil {
    - 43 + + 907 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer" + + + log.Errorf("Failed to check aggregator profitability, err: %v", err)
    - 44 + + 908 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + + + return nil, nil, err
    - 45 + 909
    + - "github.com/ethereum/go-ethereum/ethclient" + }
    - 46 + + 910 +
    -   - "github.com/jackc/pgx/v4/pgxpool" + + +
    - 47 + + 911 +
    -   - "github.com/prometheus/client_golang/prometheus/promhttp" + + + if !isProfitable {
    - 48 + + 912 +
    -   - "github.com/urfave/cli/v2" + + + log.Infof("Batch is not profitable, pol collateral %d", big.NewInt(0))
    -
     
    -
    - 113 + + 913 +
    -   - log.Fatal(err) + + + return nil, nil, err
    - 114 + + 914 +
    -   + + }
    - 115 + + 915 +
    -   + +
    - 116 + + 916 +
    + - // READ CHAIN ID FROM POE SC + now := time.Now().Round(time.Microsecond)
    - 117 + 917
    + - tmpEthMan, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) + proof := &state.Proof{
    - 118 + + 918 +
    -   - if err != nil { + + + BatchNumber: batchToVerify.BatchNumber,
    - 119 + + 919 +
    -   - log.Fatal(err) + + + BatchNumberFinal: batchToVerify.BatchNumber,
    - 120 + + 920 +
    -   - } + + + Prover: &proverName,
    - 121 + + 921 +
    + - l2ChainID, err := tmpEthMan.GetL2ChainID() + ProverID: &proverID,
    - + + 922 -
    -   -
    +
    +
    + + + GeneratingSince: &now,
    - + + 923 -
    -   -
    +
    +
    + + + }
    - 122 + + 924 +
    -   - if err != nil { + + +
    - 123 + + 925 +
    -   - log.Fatal(err) + + + // Avoid other prover to process the same batch
    - 124 + + 926 +
    -   - } + + + err = a.State.AddGeneratedProof(ctx, proof, nil)
    - 125 + + 927 +
    -   -
    + + + if err != nil {
    - 126 + 928
    + - etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) + log.Errorf("Failed to add batch proof, err: %v", err)
    - 127 + 929
    + - if err != nil { + return nil, nil, err
    - 128 + 930
    + - log.Fatal(err) + }
    - 129 + 931
    + - } -
    -
    - 130 - -
    -   - st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false) -
    -
    - 131 - -
    -   -
    +
    - 132 + 932
    + - etherman, err = newEtherman(*c, st) + return batchToVerify, proof, nil
    - 133 + 933
    + - if err != nil { + }
    - 134 + 934
    + - log.Fatal(err) +
    - 135 + 935
    + - } + func (a *Aggregator) tryGenerateBatchProof(ctx context.Context, prover proverInterface) (bool, error) {
    - 136 + 936
    + -
    + log := log.WithFields(
    - 137 + + 937 +
    -   - c.Aggregator.ChainID = l2ChainID + + + "prover", prover.Name(),
    - 138 + + 938 +
    -   - c.Sequencer.StreamServer.ChainID = l2ChainID + + + "proverId", prover.ID(),
    - 139 + + 939 +
    -   - log.Infof("Chain ID read from POE SC = %v", l2ChainID) + + + "proverAddr", prover.Addr(),
    -
     
    -
    - 290 + + 940 +
    -   - } + + + )
    - 291 + + 941 +
    -   - } + + + log.Debug("tryGenerateBatchProof start")
    - 292 + + 942 +
    -   + +
    - 293 + + 943 +
    + - func newEtherman(c config.Config, st *state.State) (*etherman.Client, error) { + batchToProve, proof, err0 := a.getAndLockBatchToProve(ctx, prover)
    - 294 + + 944 +
    + - ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) + if errors.Is(err0, state.ErrNotFound) {
    - 295 + 945
    + - if err != nil { + // nothing to proof, swallow the error
    - 296 + 946
    + - return nil, err + log.Debug("Nothing to generate proof")
    - 297 + 947
    + - } + return false, nil
    - 298 + 948
    + - da, err := newDataAvailability(c, st, ethman, false) + }
    - 299 + 949
    + - if err != nil { + if err0 != nil {
    - 300 + 950
    + - return nil, err + return false, err0
    - 301 + 951
    @@ -18524,27 +19192,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 302 + 952
    + - return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da, st) +
    - 303 + 953
    + - } + log = log.WithFields("batch", batchToProve.BatchNumber)
    - 304 + 954
    @@ -18554,237 +19222,237 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 305 + 955
    + - func newDataAvailability(c config.Config, st *state.State, etherman *etherman.Client, isSequenceSender bool) (*dataavailability.DataAvailability, error) { + var (
    - 306 + 956
    + - var ( + genProofID *string
    - 307 + 957
    + - trustedSequencerURL string + err error
    - 308 + 958
    + - err error + )
    - 309 + 959
    + - ) +
    - 310 + 960
    + - if !c.IsTrustedSequencer { + defer func() {
    - 311 + 961
    + - if c.Synchronizer.TrustedSequencerURL != "" { + if err != nil {
    - 312 + 962
    + - trustedSequencerURL = c.Synchronizer.TrustedSequencerURL + err2 := a.State.DeleteGeneratedProofs(a.ctx, proof.BatchNumber, proof.BatchNumberFinal, nil)
    - 313 + 963
    + - } else { + if err2 != nil {
    - 314 + 964
    + - log.Debug("getting trusted sequencer URL from smc") + log.Errorf("Failed to delete proof in progress, err: %v", err2)
    - 315 + 965
    + - trustedSequencerURL, err = etherman.GetTrustedSequencerURL() + }
    - 316 + 966
    + - if err != nil { + }
    - 317 + 967
    + - return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err) + log.Debug("tryGenerateBatchProof end")
    - 318 + 968
    + - } + }()
    - 319 + 969
    + - } +
    - 320 + 970
    + - log.Debug("trustedSequencerURL ", trustedSequencerURL) + log.Info("Generating proof from batch")
    - 321 + 971
    + - } +
    - 322 + 972
    + - zkEVMClient := client.NewClient(trustedSequencerURL) + log.Infof("Sending zki + batch to the prover, batchNumber [%d]", batchToProve.BatchNumber)
    - 323 + 973
    + -
    + inputProver, err := a.buildInputProver(ctx, batchToProve)
    - 324 + 974
    + - // Backend specific config + if err != nil {
    - 325 + 975
    + - daProtocolName, err := etherman.GetDAProtocolName() + err = fmt.Errorf("failed to build input prover, %w", err)
    - 326 + 976
    + - if err != nil { + log.Error(FirstToUpper(err.Error()))
    - 327 + 977
    + - return nil, fmt.Errorf("error getting data availability protocol name: %v", err) + return false, err
    - 328 + 978
    @@ -18794,387 +19462,387 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 329 + 979
    + - var daBackend dataavailability.DABackender +
    - 330 + 980
    + - switch daProtocolName { + b, err := json.Marshal(inputProver)
    - 331 + 981
    + - case string(dataavailability.DataAvailabilityCommittee): + if err != nil {
    - 332 + 982
    + - var ( + err = fmt.Errorf("failed to serialize input prover, %w", err)
    - 333 + 983
    + - pk *ecdsa.PrivateKey + log.Error(FirstToUpper(err.Error()))
    - 334 + 984
    + - err error + return false, err
    - 335 + 985
    + - ) + }
    - 336 + 986
    + - if isSequenceSender { +
    - 337 + 987
    + - _, pk, err = etherman.LoadAuthFromKeyStore(c.SequenceSender.PrivateKey.Path, c.SequenceSender.PrivateKey.Password) + proof.InputProver = string(b)
    - 338 + 988
    + - if err != nil { +
    - 339 + 989
    + - return nil, err + log.Infof("Sending a batch to the prover. OldStateRoot [%#x], OldBatchNum [%d]",
    - 340 + 990
    + - } + inputProver.PublicInputs.OldStateRoot, inputProver.PublicInputs.OldBatchNum)
    - 341 + 991
    + - } +
    - 342 + 992
    + - dacAddr, err := etherman.GetDAProtocolAddr() + genProofID, err = prover.BatchProof(inputProver)
    - 343 + 993
    + - if err != nil { + if err != nil {
    - 344 + 994
    + - return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err) + err = fmt.Errorf("failed to get batch proof id, %w", err)
    - 345 + 995
    + - } + log.Error(FirstToUpper(err.Error()))
    - 346 + 996
    + -
    + return false, err
    - 347 + 997
    + - daBackend, err = datacommittee.New( + }
    - 348 + 998
    + - c.Etherman.URL, +
    - 349 + 999
    + - dacAddr, + proof.ProofID = genProofID
    - 350 + 1000
    + - pk, +
    - 351 + 1001
    + - dataCommitteeClient.NewFactory(), + log.Infof("Proof ID %v", *proof.ProofID)
    - 352 + 1002
    + - ) + log = log.WithFields("proofId", *proof.ProofID)
    - 353 + 1003
    + - if err != nil { +
    - 354 + 1004
    + - return nil, err + resGetProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID)
    - 355 + 1005
    + - } + if err != nil {
    - 356 + 1006
    + - default: + err = fmt.Errorf("failed to get proof from prover, %w", err)
    - 357 + 1007
    + - return nil, fmt.Errorf("unexpected / unsupported DA protocol: %s", daProtocolName) + log.Error(FirstToUpper(err.Error()))
    - 358 + 1008
    + - } + return false, err
    - 359 + 1009
    + -
    + }
    - 360 + 1010
    + - return dataavailability.New( +
    - 361 + 1011
    + - c.IsTrustedSequencer, + log.Info("Batch proof generated")
    - 362 + 1012
    + - daBackend, +
    - 363 + 1013
    + - st, + proof.Proof = resGetProof
    - 364 + 1014
    + - zkEVMClient, +
    - 365 + 1015
    + - ) + // NOTE(pg): the defer func is useless from now on, use a different variable
    - 366 + 1016
    + - } + // name for errors (or shadow err in inner scopes) to not trigger it.
    - 367 + 1017
    @@ -19184,242 +19852,187 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 368 + 1018
    + - func newL2EthClient(url string) (*ethclient.Client, error) { + finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof)
    - 369 + 1019
    + - ethClient, err := ethclient.Dial(url) + if finalProofErr != nil {
    - 370 + 1020
    + - if err != nil { + // just log the error and continue to handle the generated proof
    - 371 + 1021
    + - log.Errorf("error connecting L1 to %s: %+v", url, err) + log.Errorf("Error trying to build final proof: %v", finalProofErr)
    - 372 + 1022
    + - return nil, err + }
    - 373 + 1023
    + - } +
    - 374 + 1024
    + - return ethClient, nil -
    -
    - 375 - -
    -   - } + // NOTE(pg): prover is done, use a.ctx from now on
    - 376 + + 1025 +
    -   + +
    - 377 - -
    -   - func runSynchronizer(cfg config.Config, etherman *etherman.Client, ethTxManagerStorage *ethtxmanager.PostgresStorage, st *state.State, pool *pool.Pool, eventLog *event.EventLog) { -
    -
    -
     
    -
    - 389 - -
    -   - } -
    -
    - 390 - -
    -   - log.Info("trustedSequencerURL ", trustedSequencerURL) -
    -
    - 391 - -
    -   - } -
    -
    - 392 + 1026
    + - var ethClientForL2 *ethclient.Client + if !finalProofBuilt {
    - 393 + 1027
    + - if trustedSequencerURL != "" { + proof.GeneratingSince = nil
    - 394 + 1028
    + - log.Infof("Creating L2 ethereum client %s", trustedSequencerURL) +
    - 395 + 1029
    + - ethClientForL2, err = newL2EthClient(trustedSequencerURL) + // final proof has not been generated, update the batch proof
    - 396 + 1030
    + - if err != nil { + err := a.State.UpdateGeneratedProof(a.ctx, proof, nil)
    - 397 + 1031
    + - log.Fatalf("Can't create L2 ethereum client. Err:%w", err) + if err != nil {
    - 398 + 1032
    + - } + err = fmt.Errorf("failed to store batch proof result, %w", err)
    - 399 + 1033
    + - } else { + log.Error(FirstToUpper(err.Error()))
    - 400 + 1034
    + - ethClientForL2 = nil + return false, err
    - 401 + 1035
    + - log.Infof("skipping creating L2 ethereum client because URL is empty") + }
    - 402 + 1036
    @@ -19428,168 +20041,158 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 403 + + 1037 +
    -   - zkEVMClient := client.NewClient(trustedSequencerURL) + + +
    - 404 + + 1038 +
    -   - etherManForL1 := []syncinterfaces.EthermanFullInterface{} + + + return true, nil
    - 405 + 1039
      - // If synchronizer are using sequential mode, we only need one etherman client + }
    - 406 + 1040
      - if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode { +
    - 407 + 1041
      - for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ { + // canVerifyProof returns true if we have reached the timeout to verify a proof
    - 408 - -
    - + - eth, err := newEtherman(cfg, st) -
    +
    +
     
    - 409 + 1167
      - if err != nil { + }
    - 410 + 1168
      - log.Fatal(err) + if l1InfoRoot != nil && *l1InfoRoot != calculatedL1InfoRoot {
    - 411 + 1169
      - } + for i, l := range aLeaves {
    -
     
    -
    - 415 + + 1170 +
    -   - etm := ethtxmanager.New(cfg.EthTxManager, etherman, ethTxManagerStorage, st) + + + log.Info("AllLeaves[%d]: %s", i, common.Bytes2Hex(l[:]))
    - 416 + 1171
      - sy, err := synchronizer.NewSynchronizer( + }
    - 417 + 1172
      - cfg.IsTrustedSequencer, etherman, etherManForL1, st, pool, etm, + for i, s := range smtProof {
    - 418 + 1173
    + - zkEVMClient, ethClientForL2, eventLog, cfg.NetworkConfig.Genesis, cfg.Synchronizer, cfg.Log.Environment == "development", + log.Info("smtProof[%d]: %s", i, common.Bytes2Hex(s[:]))
    - 419 + 1174
      - ) + }
    - 420 + 1175
      - if err != nil { + return nil, fmt.Errorf("error: l1InfoRoot mismatch. L1InfoRoot: %s, calculatedL1InfoRoot: %s. l1InfoTreeIndex: %d", l1InfoRoot.String(), calculatedL1InfoRoot.String(), l2blockRaw.IndexL1InfoTree)
    - 421 + 1176
      - log.Fatal(err) + }
    - 508 + 1304
      - } +
    - 509 + 1305
      -
    + // network is synced with the final proof, we can safely delete all recursive
    - 510 + 1306
      - func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender { + // proofs up to the last synced batch
    - 511 + 1307
    + - etherman, err := newEtherman(cfg, st) + err = a.State.CleanupGeneratedProofs(a.ctx, proofBatchNumberFinal, nil)
    - 512 + 1308
    @@ -19649,17 +20252,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 513 + 1309
      - log.Fatal(err) + log.Errorf("Failed to store proof aggregation result: %v", err)
    - 514 + 1310
    @@ -19667,5778 +20270,5693 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    +
     
    +
    - 515 + 1320
      -
    -
    -
    - 516 - -
    - + - auth, _, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password) + case <-a.ctx.Done():
    - 517 + 1321
      - if err != nil { + return
    - 518 + 1322
      - log.Fatal(err) + case <-time.After(a.TimeCleanupLockedProofs.Duration):
    - 519 + + 1323 +
    -   - } + + + n, err := a.State.CleanupLockedProofs(a.ctx, a.cfg.GeneratingProofCleanupThreshold, nil)
    -
     
    -
    - 523 + 1324
      -
    + if err != nil {
    - 524 + 1325
      - ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st) + log.Errorf("Failed to cleanup locked proofs: %v", err)
    - 525 + 1326
      -
    -
    -
    - 526 - -
    - + - da, err := newDataAvailability(cfg, st, etherman, true) + }
    - 527 - -
    - + - if err != nil { +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + - - - - - - - - - - - - - - - - - + - + + - - + + + - - -
    +
    @@ -89,7 +89,7 @@
    - 528 + + 89 +
    - + - log.Fatal(err) +   + m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
    - 529 + + 90 +
    - + - } +   + assert.True(a.verifyingProof)
    - 530 + + 91 +
    - + -
    +   + }).Return(nil, nil, errBanana).Once()
    - 531 + + 92 +
    - + - seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog, da) + - + m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    - 532 + 93
      - if err != nil { + // test is done, stop the sendFinalProof method
    - 533 + 94
      - log.Fatal(err) + a.exit()
    - 534 + 95
      - } + }).Return(nil).Once()
    -
     
    +
    @@ -99,7 +99,7 @@
    - 537 + 99
      - } + },
    - 538 + 100
      -
    + },
    - 539 + 101
      - func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) { + {
    - 540 + + 102 +
    - + - var ( + - + name: "UpdateBatchProof error after BuildTrustedVerifyBatchesTxData error",
    - 541 + + 103 +
    - + - aggCli *agglayerClient.Client +   + setup: func(m mox, a *Aggregator) {
    - 542 + + 104 +
    - + - pk *ecdsa.PrivateKey +   + m.stateMock.On("GetBatchByNumber", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) {
    - 543 + + 105 +
    - + - err error +   + assert.True(a.verifyingProof)
    - 544 - -
    - + - ) -
    +
    +
    @@ -112,7 +112,7 @@
    - 545 + + 112 +
    - + -
    +   + m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
    - 546 + + 113 +
    - + - if c.SettlementBackend == aggregator.AggLayer { +   + assert.True(a.verifyingProof)
    - 547 + + 114 +
    - + - aggCli = agglayerClient.New(c.AggLayerURL) +   + }).Return(nil, nil, errBanana).Once()
    - 548 + + 115 +
    - + -
    + - + m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    - 549 + + 116 +
    - + - // Load private key +   + // test is done, stop the sendFinalProof method
    - 550 + + 117 +
    - + - pk, err = config.NewKeyFromKeystore(c.SequencerPrivateKey) +   + a.exit()
    - 551 + + 118 +
    - + - if err != nil { +   + }).Return(errBanana).Once()
    - 552 - -
    - + - log.Fatal(err) -
    +
    +
    @@ -137,7 +137,7 @@
    - 553 + + 137 +
    - + - } +   + }).Return(&to, data, nil).Once()
    - 554 + + 138 +
    - + - } +   + monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal)
    - 555 + + 139 +
    - + -
    +   + m.ethTxManager.On("Add", mock.Anything, ethTxManagerOwner, monitoredTxID, from, &to, value, data, cfg.GasOffset, nil).Return(errBanana).Once()
    - 556 + + 140 +
    - + - agg, err := aggregator.New(c, st, ethTxManager, etherman, aggCli, pk) + - + m.stateMock.On("UpdateBatchProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    - 557 + 141
      - if err != nil { + // test is done, stop the sendFinalProof method
    - 558 + 142
      - log.Fatal(err) + a.exit()
    - 559 + 143
      - } + }).Return(nil).Once()
    -
     
    +
    @@ -175,7 +175,7 @@
    - 623 + 175
      - } + }
    - 624 + 176
      - log.Infof("Starting L1InfoRoot: %v", l1inforoot.String()) + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&verifiedBatch, nil).Once()
    - 625 + 177
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNumFinal, nil).Once()
    - 626 + + 178 +
    - + - forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.RollupBlockNumber) + - + m.stateMock.On("CleanupBatchProofs", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) {
    - 627 + 179
      - if err != nil { + // test is done, stop the sendFinalProof method
    - 628 + 180
      - log.Fatal("error getting forkIDs. Error: ", err) + a.exit()
    - 629 + 181
      - } + }).Return(nil).Once()
    +
    @@ -191,7 +191,7 @@
    +
    - 630 + 191
      - st.UpdateForkIDIntervalsInMemory(forkIDIntervals) + stateMock := mocks.NewStateMock(t)
    - 631 + 192
      -
    + ethTxManager := mocks.NewEthTxManager(t)
    - 632 + 193
      - currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId + etherman := mocks.NewEtherman(t)
    - 633 + + 194 +
    - + - log.Infof("Fork ID read from POE SC = %v", currentForkID) + - + a, err := New(cfg, stateMock, ethTxManager, etherman)
    - 634 + 195
      -
    + require.NoError(err)
    - 635 + 196
      - return st, currentForkID + a.ctx, a.exit = context.WithCancel(context.Background())
    - 636 + 197
      - } + m := mox{
    -
     
    +
    @@ -251,12 +251,12 @@
    - 646 + 251
      - } + asserts func(bool, *Aggregator, error)
    - 647 + 252
      -
    + }{
    - 648 + 253
      - func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client { -
    -
    - 649 - -
    - + - etherman, err := newEtherman(cfg, st) + {
    - 650 + + 254 +
    -   - if err != nil { + - + name: "getAndLockBatchProofsToAggregate returns generic error",
    - 651 + 255
      - log.Fatal(err) + setup: func(m mox, a *Aggregator) {
    - 652 + 256
      - } + m.proverMock.On("Name").Return(proverName).Twice()
    - 653 + 257
      -
    + m.proverMock.On("ID").Return(proverID).Twice()
    - 654 + 258
      - for _, privateKey := range cfg.EthTxManager.PrivateKeys { + m.proverMock.On("Addr").Return("addr")
    - 655 + + 259 +
    - + - _, _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password) + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, errBanana).Once()
    - 656 + 260
      - if err != nil { + },
    - 657 + 261
      - log.Fatal(err) + asserts: func(result bool, a *Aggregator, err error) {
    - 658 + 262
      - } + assert.False(result)
    -
     
    +
    @@ -264,12 +264,12 @@
    - 784 + 264
      - } + },
    - 785 + 265
      - forkIDIntervals = forkIntervals + },
    - 786 + 266
      - } else { + {
    - 787 + + 267 +
    - + - log.Debug("Getting all forkIDs") + - + name: "getAndLockBatchProofsToAggregate returns ErrNotFound",
    - 788 + + 268 +
    - + -
    +   + setup: func(m mox, a *Aggregator) {
    - 789 + + 269 +
    - + - // Get last L1 block number +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 790 + + 270 +
    - + - bn, err := etherman.GetLatestBlockNumber(ctx) +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 791 + + 271 +
    - + - if err != nil { +   + m.proverMock.On("Addr").Return("addr")
    - 792 + + 272 +
    - + - return []state.ForkIDInterval{}, fmt.Errorf("error getting latest block number. Error: %v", err) + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, state.ErrNotFound).Once()
    - 793 + + 273 +
    - + - } +   + },
    - 794 + + 274 +
    - + -
    +   + asserts: func(result bool, a *Aggregator, err error) {
    - 795 + + 275 +
    - + - // Get all forkIDs since genesis +   + assert.False(result)
    - 796 + +
    @@ -277,7 +277,7 @@
    +
    + 277 +
    - + - forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, bn) +   + },
    - 797 + 278
      - if err != nil { + },
    - 798 + 279
      - return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err) + { +
    +
    + 280 + +
    + - + name: "getAndLockBatchProofsToAggregate error updating proofs",
    - 799 + 281
      - } else if len(forkIntervals) == 0 { + setup: func(m mox, a *Aggregator) {
    - 800 + 282
      - return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...") + m.proverMock.On("Name").Return(proverName).Twice()
    - 801 + 283
      - } + m.proverMock.On("ID").Return(proverID).Twice()
    +
    @@ -285,9 +285,9 @@
    +
    - 802 + 285
      - forkIDIntervals = forkIntervals + dbTx := &mocks.DbTxMock{}
    - 803 + + 286 +
    - + -
    +   + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 804 + + 287 +
    - + - log.Debugf("Retrieved %d forkIDs", len(forkIDIntervals)) +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 805 + + 288 +
    - + -
    + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 806 + + 289 +
    - + - log.Debug("Adding forkIDs to db and memory") +   + m.stateMock.
    - 807 + + 290 +
    - + - for _, forkID := range forkIDIntervals { + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 808 + + 291 +
    - + - err = st.AddForkIDInterval(ctx, forkID, nil) +   + Run(func(args mock.Arguments) {
    - 809 + + 292 +
    - + - if err != nil { +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 810 + + 293 +
    - + - log.Fatal("error adding forkID to db. Error: ", err) +   + }).
    - 811 + +
    @@ -300,7 +300,7 @@
    +
    + 300 +
    - + - } +   + },
    - 812 + + 301 +
    - + - } +   + },
    - 813 + 302
      - } + { +
    +
    + 303 + +
    + - + name: "AggregatedBatchProof prover error",
    - 814 + 304
      - } + setup: func(m mox, a *Aggregator) {
    - 815 + 305
      - return forkIDIntervals, nil + m.proverMock.On("Name").Return(proverName).Twice()
    -
    + + + 306 + + +
    +   + m.proverMock.On("ID").Return(proverID).Twice()
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/set_data_availability_protocol.go - RENAMED - -
    -
    -
    -
    - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,68 @@
    +
    @@ -308,16 +308,16 @@
    - + + 308 -
    +
    +
      -
    + dbTx := &mocks.DbTxMock{}
    - + + 309 -
    +
    +
      -
    + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - + + 310 -
    +
    +
      -
    + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - + + 311 -
    -   -
    +
    +
    + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - + + 312 -
    +
    +
      -
    + proof1GeneratingTrueCall := m.stateMock.
    - + + 313 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - + + 314 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 315 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 316 -
    +
    +
      -
    + }).
    - + + 317 -
    +
    +
      -
    + Return(nil).
    - + + 318 -
    +
    +
      -
    + Once()
    - + + 319 -
    +
    +
      -
    + proof2GeneratingTrueCall := m.stateMock.
    - + + 320 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - + + 321 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 322 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 323 -
    +
    +
      -
    + }).
    - - -
    -   -
    -
    +
    +
    @@ -326,7 +326,7 @@
    - + + 326 -
    +
    +
      -
    + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(nil, errBanana).Once()
    - + + 327 -
    +
    +
      -
    + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - + + 328 -
    +
    +
      -
    + m.stateMock.
    - + + 329 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - + + 330 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 331 -
    +
    +
      -
    + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - + + 332 -
    +
    +
      -
    + }).
    - + +
    @@ -334,7 +334,7 @@
    -
    +
    + 334 + +
      -
    + Once().
    - + + 335 -
    +
    +
      -
    + NotBefore(proof1GeneratingTrueCall)
    - + + 336 -
    +
    +
      -
    + m.stateMock.
    - + + 337 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - + + 338 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 339 -
    +
    +
      -
    + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - + + 340 -
    +
    +
      -
    + }).
    - + +
    @@ -357,16 +357,16 @@
    -
    +
    + 357 + +
      -
    + dbTx := &mocks.DbTxMock{}
    - + + 358 -
    +
    +
      -
    + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - + + 359 -
    +
    +
      -
    + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - + + 360 -
    -   -
    +
    +
    + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - + + 361 -
    +
    +
      -
    + proof1GeneratingTrueCall := m.stateMock.
    - + + 362 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - + + 363 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 364 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 365 -
    +
    +
      -
    + }).
    - + + 366 -
    +
    +
      -
    + Return(nil).
    - + + 367 -
    +
    +
      -
    + Once()
    - + + 368 -
    +
    +
      -
    + proof2GeneratingTrueCall := m.stateMock.
    - + + 369 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - + + 370 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 371 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 372 -
    +
    +
      -
    + }).
    - + +
    @@ -376,7 +376,7 @@
    -
    +
    + 376 + +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - + + 377 -
    +
    +
      -
    + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - + + 378 -
    +
    +
      -
    + m.stateMock.
    - + + 379 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - + + 380 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 381 -
    +
    +
      -
    + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - + + 382 -
    +
    +
      -
    + }).
    - + +
    @@ -384,7 +384,7 @@
    -
    +
    + 384 + +
      -
    + Once().
    - + + 385 -
    +
    +
      -
    + NotBefore(proof1GeneratingTrueCall)
    - + + 386 -
    +
    +
      -
    + m.stateMock.
    - + + 387 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - + + 388 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 389 -
    +
    +
      -
    + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - + + 390 -
    +
    +
      -
    + }).
    - + +
    @@ -399,7 +399,7 @@
    -
    +
    + 399 + +
      -
    + },
    - + + 400 -
    +
    +
      -
    + },
    - + + 401 -
    +
    +
      -
    + {
    - + + 402 -
    -   -
    +
    +
    + - + name: "unlockBatchProofsToAggregate error after WaitRecursiveProof prover error",
    - + + 403 -
    +
    +
      -
    + setup: func(m mox, a *Aggregator) {
    - + + 404 -
    +
    +
      -
    + m.proverMock.On("Name").Return(proverName).Twice()
    - + + 405 -
    +
    +
      -
    + m.proverMock.On("ID").Return(proverID).Twice()
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    -
     
    +
    @@ -407,16 +407,16 @@
    - 1 + + 407 +
    - + - package main +   + dbTx := &mocks.DbTxMock{}
    - 2 + + 408 +
    - + -
    +   + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 3 + + 409 +
    - + - import ( +   + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 4 + + 410 +
    - + - "github.com/0xPolygonHermez/zkevm-node/config" + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 5 + + 411 +
    - + - "github.com/0xPolygonHermez/zkevm-node/log" +   + proof1GeneratingTrueCall := m.stateMock.
    - 6 + + 412 +
    - + - "github.com/ethereum/go-ethereum/common" + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 7 + + 413 +
    - + - "github.com/urfave/cli/v2" +   + Run(func(args mock.Arguments) {
    - 8 + + 414 +
    - + - ) +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 9 + + 415 +
    - + -
    +   + }).
    - 10 + + 416 +
    - + - const flagDAAddress = "data-availability-address" +   + Return(nil).
    - 11 + + 417 +
    - + -
    +   + Once()
    - 12 + + 418 +
    - + - var setDataAvailabilityProtocolFlags = []cli.Flag{ +   + m.stateMock.
    - 13 + + 419 +
    - + - &cli.StringFlag{ + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 14 + + 420 +
    - + - Name: flagDAAddress, +   + Run(func(args mock.Arguments) {
    - 15 + + 421 +
    - + - Aliases: []string{"da-addr"}, +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 16 + + 422 +
    - + - Usage: "address of the new data availibility protocol", +   + }).
    - 17 - -
    - + - Required: true, -
    +
    +
    @@ -426,7 +426,7 @@
    - 18 + + 426 +
    - + - }, +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - 19 + + 427 +
    - + - &cli.StringFlag{ +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 20 + + 428 +
    - + - Name: config.FlagKeyStorePath, +   + m.stateMock.
    - 21 + + 429 +
    - + - Aliases: []string{"ksp"}, + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 22 + + 430 +
    - + - Usage: "the path of the key store file containing the private key of the account going to set new data availability protocol", +   + Run(func(args mock.Arguments) {
    - 23 + + 431 +
    - + - Required: true, +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 24 + + 432 +
    - + - }, +   + }).
    - 25 - -
    - + - &cli.StringFlag{ -
    +
    +
    @@ -441,7 +441,7 @@
    - 26 + + 441 +
    - + - Name: config.FlagPassword, +   + },
    - 27 + + 442 +
    - + - Aliases: []string{"pw"}, +   + },
    - 28 + + 443 +
    - + - Usage: "the password do decrypt the key store file", +   + {
    - 29 + + 444 +
    - + - Required: true, + - + name: "rollback after DeleteBatchProofs error in db transaction",
    - 30 + + 445 +
    - + - }, +   + setup: func(m mox, a *Aggregator) {
    - 31 + + 446 +
    - + - &configFileFlag, +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 32 + + 447 +
    - + - &networkFlag, +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 33 - -
    - + - &customNetworkFlag, -
    +
    +
    @@ -449,16 +449,16 @@
    - 34 + + 449 +
    - + - } +   + dbTx := &mocks.DbTxMock{}
    - 35 + + 450 +
    - + -
    +   + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 36 + + 451 +
    - + - func setDataAvailabilityProtocol(ctx *cli.Context) error { +   + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 37 + + 452 +
    - + - c, err := config.Load(ctx, true) + - + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 38 + + 453 +
    - + - if err != nil { +   + proof1GeneratingTrueCall := m.stateMock.
    - 39 + + 454 +
    - + - return err + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 40 + + 455 +
    - + - } +   + Run(func(args mock.Arguments) {
    - 41 + + 456 +
    - + -
    +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 42 + + 457 +
    - + - setupLog(c.Log) +   + }).
    - 43 + + 458 +
    - + -
    +   + Return(nil).
    - 44 + + 459 +
    - + - daAddress := common.HexToAddress(ctx.String(flagDAAddress)) +   + Once()
    - 45 + + 460 +
    - + - addrKeyStorePath := ctx.String(config.FlagKeyStorePath) +   + proof2GeneratingTrueCall := m.stateMock.
    - 46 + + 461 +
    - + - addrPassword := ctx.String(config.FlagPassword) + - + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 47 + + 462 +
    - + -
    +   + Run(func(args mock.Arguments) {
    - 48 + + 463 +
    - + - etherman, err := newEtherman(*c, nil) +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 49 + + 464 +
    - + - if err != nil { +   + }).
    - 50 - -
    - + - log.Fatal(err) -
    +
    +
    @@ -466,11 +466,11 @@
    - 51 + + 466 +
    - + - return err +   + Once()
    - 52 + + 467 +
    - + - } +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 53 + + 468 +
    - + -
    +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 54 + + 469 +
    - + - auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) + - + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(errBanana).Once()
    - 55 + + 470 +
    - + - if err != nil { +   + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 56 + + 471 +
    - + - log.Fatal(err) +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 57 + + 472 +
    - + - return err +   + m.stateMock.
    - 58 + + 473 +
    - + - } + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 59 + + 474 +
    - + -
    +   + Run(func(args mock.Arguments) {
    - 60 + + 475 +
    - + - tx, err := etherman.SetDataAvailabilityProtocol(auth.From, daAddress) +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 61 + + 476 +
    - + - if err != nil { +   + }).
    - 62 + +
    @@ -478,7 +478,7 @@
    +
    + 478 +
    - + - return err +   + Once().
    - 63 + + 479 +
    - + - } +   + NotBefore(proof1GeneratingTrueCall)
    - 64 + + 480 +
    - + -
    +   + m.stateMock.
    - 65 + + 481 +
    - + - log.Infof("Transaction to set new data availability protocol sent. Hash: %s", tx.Hash()) + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - 66 + + 482 +
    - + -
    +   + Run(func(args mock.Arguments) {
    - 67 + + 483 +
    - + - return nil +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 68 + + 484 +
    - + - } +   + }).
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/cardonagenesis.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,109 +0,0 @@
    +
    @@ -493,7 +493,7 @@
    - 1 + + 493 +
    - - - package config +   + },
    - 2 + + 494 +
    - - -
    +   + },
    - 3 + + 495 +
    - - - // CardonaNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup +   + {
    - 4 + + 496 +
    - - const CardonaNetworkConfigJSON = ` + name: "rollback after AddBatchProof error in db transaction",
    - 5 + + 497 +
    - - - { +   + setup: func(m mox, a *Aggregator) {
    - 6 + + 498 +
    - - - "l1Config": { +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 7 + + 499 +
    - - - "polygonZkEVMAddress": "0xA13Ddb14437A8F34897131367ad3ca78416d6bCa", +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 8 - -
    - - - "polygonZkEVMBridgeAddress": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582", -
    +
    +
    @@ -501,16 +501,16 @@
    - 9 + + 501 +
    - - - "polygonZkEVMGlobalExitRootAddress": "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF", +   + dbTx := &mocks.DbTxMock{}
    - 10 + + 502 +
    - - - "polTokenAddress": "0x6a7c3F4B0651d6DA389AD1d11D962ea458cDCA70", +   + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 11 + + 503 +
    - - - "polygonRollupManagerAddress": "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff", +   + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 12 + + 504 +
    - - "chainId": 11155111 + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 13 + + 505 +
    - - - }, +   + proof1GeneratingTrueCall := m.stateMock.
    - 14 + + 506 +
    - - "genesisBlockNumber": 4789190, + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 15 + + 507 +
    - - - "root": "0x91dfcdeb628dfdc51f3a2ee38cb17c78581e4e7ff91bcc2e327d24a9dfa46982", +   + Run(func(args mock.Arguments) {
    - 16 + + 508 +
    - - - "genesis": [ +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 17 + + 509 +
    - - - { +   + }).
    - 18 + + 510 +
    - - - "contractName": "PolygonZkEVMDeployer", +   + Return(nil).
    - 19 + + 511 +
    - - - "balance": "0", +   + Once()
    - 20 + + 512 +
    - - - "nonce": "4", +   + proof2GeneratingTrueCall := m.stateMock.
    - 21 + + 513 +
    - - "address": "0x36810012486fc134D0679c07f85fe5ba5A087D8C", + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 22 + + 514 +
    - - - "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033", +   + Run(func(args mock.Arguments) {
    - 23 + + 515 +
    - - - "storage": { +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 24 + + 516 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000ff6250d0e86a2465b0c1bf8e36409503d6a26963" +   + }).
    - 25 + +
    @@ -518,12 +518,12 @@
    +
    + 518 +
    - - - } +   + Once()
    - 26 + + 519 +
    - - - }, +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 27 + + 520 +
    - - - { +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 28 + + 521 +
    - - "contractName": "ProxyAdmin", + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - 29 + + 522 +
    - - "balance": "0", + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Return(errBanana).Once()
    - 30 + + 523 +
    - - - "nonce": "1", +   + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 31 + + 524 +
    - - - "address": "0x85cEB41028B1a5ED2b88E395145344837308b251", +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 32 + + 525 +
    - - - "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033", +   + m.stateMock.
    - 33 + + 526 +
    - - "storage": { + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 34 + + 527 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000dbc6981a11fc2b000c635bfa7c47676b25c87d39" +   + Run(func(args mock.Arguments) {
    - 35 + + 528 +
    - - - } +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 36 + + 529 +
    - - - }, +   + }).
    - 37 + +
    @@ -531,7 +531,7 @@
    +
    + 531 +
    - - - { +   + Once().
    - 38 + + 532 +
    - - - "contractName": "PolygonZkEVMBridge implementation", +   + NotBefore(proof1GeneratingTrueCall)
    - 39 + + 533 +
    - - - "balance": "0", +   + m.stateMock.
    - 40 + + 534 +
    - - "nonce": "1", + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - 41 + + 535 +
    - - - "address": "0x8BD36ca1A55e389335004872aA3C3Be0969D3aA7", +   + Run(func(args mock.Arguments) {
    - 42 + + 536 +
    - - - "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033" +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 43 + + 537 +
    - - - }, +   + }).
    - 44 + +
    @@ -554,16 +554,16 @@
    +
    + 554 +
    - - - { +   + dbTx := &mocks.DbTxMock{}
    - 45 + + 555 +
    - - - "contractName": "PolygonZkEVMBridge proxy", +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 46 + + 556 +
    - - - "balance": "200000000000000000000000000", +   + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice()
    - 47 + + 557 +
    - - "nonce": "1", + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 48 + + 558 +
    - - - "address": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582", +   + m.stateMock.
    - 49 + + 559 +
    - - "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 50 + + 560 +
    - - - "storage": { +   + Run(func(args mock.Arguments) {
    - 51 + + 561 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 52 + + 562 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + }).
    - 53 + + 563 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", +   + Return(nil).
    - 54 + + 564 +
    - - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251", +   + Once()
    - 55 + + 565 +
    - - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000008bd36ca1a55e389335004872aa3c3be0969d3aa7" +   + m.stateMock.
    - 56 + + 566 +
    - - } + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 57 + + 567 +
    - - - }, +   + Run(func(args mock.Arguments) {
    - 58 + + 568 +
    - - - { +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 59 + + 569 +
    - - - "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", +   + }).
    - 60 + +
    @@ -571,14 +571,14 @@
    +
    + 571 +
    - - - "balance": "0", +   + Once()
    - 61 + + 572 +
    - - - "nonce": "1", +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 62 + + 573 +
    - - - "address": "0x282a631D9F3Ef04Bf1A44B4C9e8bDC8EB278917f", +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 63 + + 574 +
    - - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed58281565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed582161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - 64 + + 575 +
    - - - }, +   + expectedInputProver := map[string]interface{}{
    - 65 + + 576 +
    - - - { +   + "recursive_proof_1": proof1.Proof,
    - 66 + + 577 +
    - - - "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +   + "recursive_proof_2": proof2.Proof,
    - 67 + + 578 +
    - - - "balance": "0", +   + }
    - 68 + + 579 +
    - - - "nonce": "1", +   + b, err := json.Marshal(expectedInputProver)
    - 69 + + 580 +
    - - - "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", +   + require.NoError(err)
    - 70 + + 581 +
    - - "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Run(
    - 71 + + 582 +
    - - - "storage": { +   + func(args mock.Arguments) {
    - 72 + + 583 +
    - - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251", +   + proof := args[1].(*state.Proof)
    - 73 + + 584 +
    - - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000282a631d9f3ef04bf1a44b4c9e8bdc8eb278917f" +   + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - 74 + +
    @@ -590,7 +590,7 @@
    +
    + 590 +
    - - - } +   + assert.InDelta(time.Now().Unix(), proof.GeneratingSince.Unix(), float64(time.Second))
    - 75 + + 591 +
    - - - }, +   + },
    - 76 + + 592 +
    - - - { +   + ).Return(nil).Once()
    - 77 + + 593 +
    - - "contractName": "PolygonZkEVMTimelock", + m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - 78 + + 594 +
    - - - "balance": "0", +   + func(args mock.Arguments) {
    - 79 + + 595 +
    - - - "nonce": "1", +   + proof := args[1].(*state.Proof)
    - 80 + + 596 +
    - - - "address": "0xdbC6981a11fc2B000c635bFA7C47676b25C87D39", +   + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - 81 + +
    @@ -618,16 +618,16 @@
    +
    + 618 +
    - - - "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033", +   + dbTx := &mocks.DbTxMock{}
    - 82 + + 619 +
    - - - "storage": { +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 83 + + 620 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", +   + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice()
    - 84 + + 621 +
    - - "0xf587dde6f8846415188f807710a3304f72092565918b30307d60efdc8014f20b": "0x0000000000000000000000000000000000000000000000000000000000000001", + m.stateMock.On("GetBatchProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 85 + + 622 +
    - - - "0x07020fe9de9b8274d1e6cc0668a6f6344a870f35e5a847590c8069dfa85ac78f": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + m.stateMock.
    - 86 + + 623 +
    - - "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 87 + + 624 +
    - - - "0xc8e266e0814671642b74f3807affd27009fcc23f713ea92d1743e0ee0c1e7603": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + Run(func(args mock.Arguments) {
    - 88 + + 625 +
    - - - "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 89 + + 626 +
    - - - "0x9b3efc411c5f69533db363941e091f6f3af8b7e306525413577a56d27e5dbe73": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + }).
    - 90 + + 627 +
    - - - "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +   + Return(nil).
    - 91 + + 628 +
    - - - "0xa2001bdd6a5944149e83176d089ee9a8246bd56aecf38fe4d6c66f5fbac18675": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + Once()
    - 92 + + 629 +
    - - - "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +   + m.stateMock.
    - 93 + + 630 +
    - - } + On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 94 + + 631 +
    - - - }, +   + Run(func(args mock.Arguments) {
    - 95 + + 632 +
    - - - { +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 96 + + 633 +
    - - - "accountName": "keyless Deployer", +   + }).
    - 97 + +
    @@ -635,14 +635,14 @@
    +
    + 635 +
    - - - "balance": "0", +   + Once()
    - 98 + + 636 +
    - - - "nonce": "1", +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 99 + + 637 +
    - - - "address": "0x1754175c450BEbB9B6E14dEe542649c0402A25d2" +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 100 + + 638 +
    - - }, + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - 101 + + 639 +
    - - - { +   + expectedInputProver := map[string]interface{}{
    - 102 + + 640 +
    - - - "accountName": "deployer", +   + "recursive_proof_1": proof1.Proof,
    - 103 + + 641 +
    - - - "balance": "100000000000000000000000", +   + "recursive_proof_2": proof2.Proof,
    - 104 + + 642 +
    - - - "nonce": "8", +   + }
    - 105 + + 643 +
    - - - "address": "0xff6250d0E86A2465B0C1bF8e36409503d6a26963" +   + b, err := json.Marshal(expectedInputProver)
    - 106 + + 644 +
    - - - } +   + require.NoError(err)
    - 107 + + 645 +
    - - ] + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Run(
    - 108 + + 646 +
    - - - } +   + func(args mock.Arguments) {
    - 109 + + 647 +
    - - - ` +   + proof := args[1].(*state.Proof)
    -
    + + + 648 + + +
    +   + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    -
    -
    - - - + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - -
    -
     
    +
    @@ -660,7 +660,7 @@
    - + + 660 -
    +
    +
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(uint64(42), nil).Once()
    - + + 661 -
    +
    +
      -
    + // make tryBuildFinalProof fail ASAP
    - + + 662 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, errBanana).Once().NotBefore(isSyncedCall)
    - + + 663 -
    -   -
    +
    +
    + - + m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - + + 664 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 665 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 666 -
    +
    +
      -
    + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -686,7 +686,7 @@
    - + + 686 -
    +
    +
      -
    + ethTxManager := mocks.NewEthTxManager(t)
    - + + 687 -
    +
    +
      -
    + etherman := mocks.NewEtherman(t)
    - + + 688 -
    +
    +
      -
    + proverMock := mocks.NewProverMock(t)
    - + + 689 -
    -   -
    +
    +
    + - + a, err := New(cfg, stateMock, ethTxManager, etherman)
    - + + 690 -
    +
    +
      -
    + require.NoError(err)
    - + + 691 -
    +
    +
      -
    + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - + + 692 -
    +
    +
      -
    + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    - + +
    @@ -701,7 +701,7 @@
    -
    +
    + 701 + +
      -
    + }
    - + + 702 -
    +
    +
      -
    + a.resetVerifyProofTime()
    - + + 703 -
    +
    +
     
    - + + 704 -
    -   -
    +
    +
    + - + result, err := a.tryAggregateBatchProofs(proverCtx, proverMock)
    - + + 705 -
    +
    +
     
    - + + 706 -
    +
    +
      -
    + if tc.asserts != nil {
    - + + 707 -
    +
    +
      -
    + tc.asserts(result, &a, err)
    - + +
    @@ -777,7 +777,7 @@
    -
    +
    + 777 + +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 778 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 779 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 780 -
    -   -
    +
    +
    + - + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 781 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 782 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 783 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - + +
    @@ -805,7 +805,7 @@
    -
    +
    + 805 + +
      -
    + expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
    - + + 806 -
    +
    +
      -
    + require.NoError(err)
    - + + 807 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(nil, errBanana).Once()
    - + + 808 -
    -   -
    +
    +
    + - + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(nil).Once()
    - + + 809 -
    +
    +
      -
    + },
    - + + 810 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 811 -
    +
    +
      -
    + assert.False(result)
    - + +
    @@ -820,7 +820,7 @@
    -
    +
    + 820 + +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 821 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 822 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 823 -
    -   -
    +
    +
    + - + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 824 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 825 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 826 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - + +
    @@ -849,7 +849,7 @@
    -
    +
    + 849 + +
      -
    + require.NoError(err)
    - + + 850 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
    - + + 851 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - - -
    -   -
    +
    + 852 + +
    + - + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(nil).Once()
    - + + 853 -
    +
    +
      -
    + },
    - + + 854 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 855 -
    +
    +
      -
    + assert.False(result)
    - - -
    -   -
    -
    +
    +
    @@ -857,14 +857,14 @@
    - + + 857 -
    +
    +
      -
    + },
    - + + 858 -
    +
    +
      -
    + },
    - + + 859 -
    +
    +
      -
    + {
    - + + 860 -
    -   -
    +
    +
    + - + name: "DeleteBatchProofs error after WaitRecursiveProof prover error",
    - + + 861 -
    +
    +
      -
    + setup: func(m mox, a *Aggregator) {
    - + + 862 -
    +
    +
      -
    + m.proverMock.On("Name").Return(proverName).Twice()
    - + + 863 -
    +
    +
      -
    + m.proverMock.On("ID").Return(proverID).Twice()
    - + + 864 -
    +
    +
      -
    + m.proverMock.On("Addr").Return(proverID)
    - + + 865 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 866 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 867 -
    -   -
    +
    +
    + - + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 868 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 869 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 870 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -893,7 +893,7 @@
    - + + 893 -
    +
    +
      -
    + require.NoError(err)
    - + + 894 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
    - + + 895 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - + + 896 -
    -   -
    +
    +
    + - + m.stateMock.On("DeleteBatchProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(errBanana).Once()
    - + + 897 -
    +
    +
      -
    + },
    - + + 898 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 899 -
    +
    +
      -
    + assert.False(result)
    - - -
    -   -
    -
    +
    +
    @@ -908,7 +908,7 @@
    - + + 908 -
    +
    +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 909 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 910 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 911 -
    -   -
    +
    +
    + - + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 912 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 913 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 914 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -939,7 +939,7 @@
    - + + 939 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - + + 940 -
    +
    +
      -
    + b, err := json.Marshal(expectedInputProver)
    - + + 941 -
    +
    +
      -
    + require.NoError(err)
    - + + 942 -
    -   -
    +
    +
    + - + m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - + + 943 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 944 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 945 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -966,7 +966,7 @@
    - + + 966 -
    +
    +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 967 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 968 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 969 -
    -   -
    +
    +
    + - + m.stateMock.On("AddBatchProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 970 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 971 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 972 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -1003,7 +1003,7 @@
    - + + 1003 -
    +
    +
      -
    + m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
    - + + 1004 -
    +
    +
      -
    + // make tryBuildFinalProof fail ASAP
    - + + 1005 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, errBanana).Once().NotBefore(isSyncedCall)
    - + + 1006 -
    -   -
    +
    +
    + - + m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - + + 1007 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 1008 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 1009 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -1029,7 +1029,7 @@
    - + + 1029 -
    +
    +
      -
    + ethTxManager := mocks.NewEthTxManager(t)
    - + + 1030 -
    +
    +
      -
    + etherman := mocks.NewEtherman(t)
    - + + 1031 -
    +
    +
      -
    -
    -
    -
    + proverMock := mocks.NewProverMock(t)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - + - - + - - - - + + + - - + - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
    @@ -2,6 +2,8 @@
    - 2 + + 1032 +
    -   -
    + - + a, err := New(cfg, stateMock, ethTxManager, etherman)
    - 3 + 1033
      - import ( + require.NoError(err)
    - 4 + 1034
      - "bytes" + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - + + 1035 -
    +
    +
      -
    + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    - - -
    -   -
    -
    +
    +
    @@ -1138,11 +1138,11 @@
    - 5 + 1138
      - "path/filepath" + m.proverMock.On("Addr").Return("addr").Twice()
    - 6 + 1139
      - "strings" + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 7 + 1140
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    -
    @@ -21,6 +24,7 @@
    +
    + 1141 + +
    + - + m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() +
    - 21 + + 1142 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state" + - + proofGeneratingTrueCall := m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - 22 + 1143
      - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(nil, errBanana).Once()
    - 23 + 1144
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer" + m.stateMock.
    - + + 1145 -
    -   -
    +
    +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil).
    - 24 + 1146
      - "github.com/mitchellh/mapstructure" + Return(nil).
    - 25 + 1147
      - "github.com/spf13/viper" + Once().
    - 26 + 1148
      - "github.com/urfave/cli/v2" + NotBefore(proofGeneratingTrueCall)
    -
    @@ -31,7 +35,7 @@
    +
    @@ -1160,12 +1160,12 @@
    - 31 + 1160
      - FlagYes = "yes" + m.proverMock.On("Addr").Return("addr").Twice()
    - 32 + 1161
      - // FlagCfg is the flag for cfg. + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 33 + 1162
      - FlagCfg = "cfg" + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - 34 + 1163
    - - // FlagNetwork is the flag for the network name. Valid values: ["testnet", "mainnet", "cardona", "custom"]. + m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() +
    +
    + 1164 + +
    + - + proofGeneratingTrueCall := m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - 35 + 1165
      - FlagNetwork = "network" + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once()
    - 36 + 1166
      - // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom + m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(nil, errBanana).Once()
    - 37 + 1167
      - FlagCustomNetwork = "custom-network-file" + m.stateMock.
    -
    @@ -183,3 +187,19 @@
    +
    + 1168 + +
    + - + On("UpdateBatchProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil). +
    - 183 + 1169
      - } + Return(nil).
    - 184 + 1170
      - return cfg, nil + Once().
    - 185 + 1171
      - } + NotBefore(proofGeneratingTrueCall)
    - - -
    -   -
    -
    +
    +
    @@ -1183,7 +1183,7 @@
    - + + 1183 -
    +
    +
      -
    + m.proverMock.On("Addr").Return(proverID).Once()
    - + + 1184 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - + + 1185 -
    +
    +
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - + + 1186 -
    -   -
    +
    +
    + - + m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(nil, errBanana).Once()
    - + + 1187 -
    +
    +
      -
    + },
    - + + 1188 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 1189 -
    +
    +
      -
    + assert.False(result)
    - - -
    -   -
    -
    +
    +
    @@ -1198,7 +1198,7 @@
    - + + 1198 -
    +
    +
      -
    + m.proverMock.On("Addr").Return(proverID).Once()
    - + + 1199 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - + + 1200 -
    +
    +
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - + + 1201 -
    -   -
    +
    +
    + - + m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(nil, state.ErrNotFound).Once()
    - + + 1202 -
    +
    +
      -
    + },
    - + + 1203 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 1204 -
    +
    +
      -
    + assert.False(result)
    -
    -
    -
    -
    - - - + - - - - - - - - - + + +
    -
     
    +
    @@ -1213,8 +1213,8 @@
    - 2 + 1213
      -
    + m.proverMock.On("Addr").Return(proverID).Twice()
    - 3 + 1214
      - import ( + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 4 + 1215
      - "bytes" + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - 5 + + 1216 +
    - + - "crypto/ecdsa" + - + m.stateMock.On("GetProofReadyForFinal", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once()
    - 6 + + 1217 +
    - + - "os" + - + m.stateMock.On("UpdateBatchProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - 7 + 1218
      - "path/filepath" + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once()
    - 8 + 1219
      - "strings" + m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(&finalProof, nil).Once()
    - 9 + 1220
      -
    + },
    -
     
    +
    @@ -1306,7 +1306,7 @@
    - 24 + 1306
      - "github.com/0xPolygonHermez/zkevm-node/state" + ethTxManager := mocks.NewEthTxManager(t)
    - 25 + 1307
      - "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" + etherman := mocks.NewEtherman(t)
    - 26 + 1308
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer" + proverMock := mocks.NewProverMock(t)
    - 27 + + 1309 +
    - + - "github.com/ethereum/go-ethereum/accounts/keystore" + - + a, err := New(cfg, stateMock, ethTxManager, etherman)
    - 28 + 1310
      - "github.com/mitchellh/mapstructure" + require.NoError(err)
    - 29 + 1311
      - "github.com/spf13/viper" + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - 30 + 1312
      - "github.com/urfave/cli/v2" + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    -
     
    +
    @@ -1436,7 +1436,7 @@
    - 35 + 1436
      - FlagYes = "yes" + ethTxManager := mocks.NewEthTxManager(t)
    - 36 + 1437
      - // FlagCfg is the flag for cfg. + etherman := mocks.NewEtherman(t)
    - 37 + 1438
      - FlagCfg = "cfg" + proverMock := mocks.NewProverMock(t)
    - 38 + + 1439 +
    - + - // FlagNetwork is the flag for the network name. Valid values: ["custom"]. + - + a, err := New(cfg, stateMock, ethTxManager, etherman)
    - 39 + 1440
      - FlagNetwork = "network" + require.NoError(err)
    - 40 + 1441
      - // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - 41 + 1442
      - FlagCustomNetwork = "custom-network-file" + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    +
    +
    +
    +
    + + + - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - -
     
    - 187 + 89
      - } + m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
    - 188 + 90
      - return cfg, nil + assert.True(a.verifyingProof)
    - 189 + 91
      - } + }).Return(nil, nil, errBanana).Once()
    - 190 + + 92 +
    + -
    + m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    - 191 + + 93 +
    - + - // NewKeyFromKeystore creates a private key from a keystore file +   + // test is done, stop the sendFinalProof method
    - 192 + + 94 +
    - + - func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error) { +   + a.exit()
    - 193 + + 95 +
    - + - if cfg.Path == "" && cfg.Password == "" { +   + }).Return(nil).Once()
    - 194 - -
    - + - return nil, nil -
    +
    +
     
    - 195 + + 99 +
    - + - } +   + },
    - 196 + + 100 +
    - + - keystoreEncrypted, err := os.ReadFile(filepath.Clean(cfg.Path)) +   + },
    - 197 + + 101 +
    - + - if err != nil { +   + {
    - 198 + + 102 +
    + - return nil, err + name: "UpdateGeneratedProof error after BuildTrustedVerifyBatchesTxData error",
    - 199 + + 103 +
    - + - } +   + setup: func(m mox, a *Aggregator) {
    - 200 + + 104 +
    - + - key, err := keystore.DecryptKey(keystoreEncrypted, cfg.Password) +   + m.stateMock.On("GetBatchByNumber", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) {
    - 201 + + 105 +
    - + - if err != nil { +   + assert.True(a.verifyingProof)
    - 202 + +
     
    +
    + 112 +
    - + - return nil, err +   + m.etherman.On("BuildTrustedVerifyBatchesTxData", batchNum-1, batchNumFinal, &expectedInputs, common.HexToAddress(cfg.SenderAddress)).Run(func(args mock.Arguments) {
    - 203 + + 113 +
    - + - } +   + assert.True(a.verifyingProof)
    - 204 + + 114 +
    - + - return key.PrivateKey, nil +   + }).Return(nil, nil, errBanana).Once()
    - 205 + + 115 +
    + - } + m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - + - - - - - - - - + - - - - + @@ -25457,7 +25975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -25467,17 +25985,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -25487,7 +26005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -25497,7 +26015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -25507,471 +26025,502 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + - - + - - + + + - - -
    -
    @@ -174,24 +174,28 @@
    -
    - 174 + 116
      - expectedValue: uint64(80000), + // test is done, stop the sendFinalProof method
    - 175 + 117
      - }, + a.exit()
    - 176 + 118
      - { -
    -
    - - -
    -   -
    + }).Return(errBanana).Once()
    - - -
    -   -
    -
    +
    +
     
    - + + 137 -
    +
    +
      -
    + }).Return(&to, data, nil).Once()
    - + + 138 -
    +
    +
      -
    + monitoredTxID := buildMonitoredTxID(batchNum, batchNumFinal)
    - 177 + 139
      - path: "Etherman.URL", + m.ethTxManager.On("Add", mock.Anything, ethTxManagerOwner, monitoredTxID, from, &to, value, data, cfg.GasOffset, nil).Return(errBanana).Once()
    - 178 + + 140 +
    -   - expectedValue: "http://localhost:8545", + + + m.stateMock.On("UpdateGeneratedProof", mock.Anything, recursiveProof, nil).Run(func(args mock.Arguments) {
    - 179 + 141
      - }, + // test is done, stop the sendFinalProof method
    - 180 + 142
      - { + a.exit()
    - 181 + 143
      - path: "NetworkConfig.L1Config.L1ChainID", + }).Return(nil).Once()
    - 182 - -
    - - - expectedValue: uint64(5), -
    +
    +
     
    - 183 + 175
      - }, + }
    - 184 + 176
      - { + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&verifiedBatch, nil).Once()
    - 185 + 177
      - path: "NetworkConfig.L1Config.ZkEVMAddr", + m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNumFinal, nil).Once()
    - 186 + + 178 +
    - - - expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"), + + + m.stateMock.On("CleanupGeneratedProofs", mock.Anything, batchNumFinal, nil).Run(func(args mock.Arguments) {
    - 187 + 179
      - }, + // test is done, stop the sendFinalProof method
    - 188 + 180
      - { + a.exit()
    - 189 + 181
      - path: "NetworkConfig.L1Config.PolAddr", + }).Return(nil).Once()
    - 190 - -
    - - - expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"), -
    +
    +
     
    @@ -25447,7 +25965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - }, + stateMock := mocks.NewStateMock(t)
      - { + ethTxManager := mocks.NewEthTxManager(t)
      - path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", + etherman := mocks.NewEtherman(t)
    + 194 +
    - - - expectedValue: common.HexToAddress("0x4d9427DCA0406358445bC0a8F88C26b704004f74"), + + + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
      - }, + require.NoError(err)
      - { + a.ctx, a.exit = context.WithCancel(context.Background())
      - path: "Etherman.MultiGasProvider", + m := mox{
    -
    @@ -547,7 +551,8 @@
    +
     
    - 547 + 251
      - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) + asserts func(bool, *Aggregator, error)
    - 548 + 252
      -
    + }{
    - 549 + 253
      - flagSet := flag.NewFlagSet("", flag.PanicOnError) + {
    - 550 + + 254 +
    - - - flagSet.String(config.FlagNetwork, "testnet", "") + + + name: "getAndLockProofsToAggregate returns generic error",
    - + + 255 -
    +
    +
      -
    + setup: func(m mox, a *Aggregator) {
    - 551 + 256
      - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) + m.proverMock.On("Name").Return(proverName).Twice()
    - 552 + 257
      - cfg, err := config.Load(ctx, true) + m.proverMock.On("ID").Return(proverID).Twice()
    - 553 + 258
      - if err != nil { + m.proverMock.On("Addr").Return("addr")
    -
    @@ -585,7 +590,8 @@
    +
    + 259 + +
    + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, errBanana).Once() +
    - 585 + 260
      - }() + },
    - 586 + 261
      - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) + asserts: func(result bool, a *Aggregator, err error) {
    - 587 + 262
      - flagSet := flag.NewFlagSet("", flag.PanicOnError) + assert.False(result)
    - 588 - -
    - - - flagSet.String(config.FlagNetwork, "testnet", "") -
    +
    +
     
    - + + 264 -
    +
    +
      -
    + },
    - 589 + 265
      - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) + },
    - 590 + 266
      -
    + { +
    +
    + 267 + +
    + + + name: "getAndLockProofsToAggregate returns ErrNotFound",
    - 591 + 268
      - os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c") -
    -
    -
    + setup: func(m mox, a *Aggregator) {
    -
    -
    - - - - - - - - - - - - - + + + + + + - - + + + + + + - - + + + @@ -25981,3861 +26530,3942 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - - - - -
    -
     
    - 174 + 269
      - expectedValue: uint64(80000), + m.proverMock.On("Name").Return(proverName).Twice()
    - 175 + 270
      - }, + m.proverMock.On("ID").Return(proverID).Twice()
    - 176 + 271
      - { + m.proverMock.On("Addr").Return("addr")
    - 177 + + 272 +
    + - path: "SequenceSender.MaxBatchesForL1", + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, nil, state.ErrNotFound).Once()
    - 178 + + 273 +
    - + - expectedValue: uint64(300), +   + },
    - 179 + + 274 +
    - + - }, +   + asserts: func(result bool, a *Aggregator, err error) {
    - 180 + + 275 +
    - + - { +   + assert.False(result)
    +
     
    +
    - 181 + 277
      - path: "Etherman.URL", + },
    - 182 + 278
      - expectedValue: "http://localhost:8545", + },
    - 183 + 279
      - }, + { +
    +
    + 280 + +
    + + + name: "getAndLockProofsToAggregate error updating proofs",
    - 184 + 281
      - { + setup: func(m mox, a *Aggregator) {
    - 185 + 282
      - path: "NetworkConfig.L1Config.L1ChainID", + m.proverMock.On("Name").Return(proverName).Twice()
    - 186 + + 283 +
    - + - expectedValue: uint64(1337), +   + m.proverMock.On("ID").Return(proverID).Twice()
    +
     
    +
    - 187 + 285
      - }, + dbTx := &mocks.DbTxMock{}
    - 188 + 286
      - { + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 189 + 287
      - path: "NetworkConfig.L1Config.ZkEVMAddr", + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 190 + 288
    + - expectedValue: common.HexToAddress("0x8dAF17A20c9DBA35f005b6324F493785D239719d"), + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 191 + 289
      - }, + m.stateMock. +
    +
    + 290 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 192 + 291
      - { + Run(func(args mock.Arguments) {
    - 193 + 292
      - path: "NetworkConfig.L1Config.PolAddr", + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 194 + + 293 +
    - + - expectedValue: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"), +   + }).
    +
     
    +
    - 195 + 300
      - }, + },
    - 196 + 301
      - { + },
    - 197 + 302
      - path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", + {
    - 198 + 303
    + - expectedValue: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + name: "AggregatedProof prover error",
    - 199 + 304
      - }, + setup: func(m mox, a *Aggregator) {
    - 200 + 305
      - { + m.proverMock.On("Name").Return(proverName).Twice()
    - 201 + 306
      - path: "Etherman.MultiGasProvider", + m.proverMock.On("ID").Return(proverID).Twice()
    - 551 + 308
      - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) + dbTx := &mocks.DbTxMock{}
    - 552 + 309
      -
    + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 553 + 310
      - flagSet := flag.NewFlagSet("", flag.PanicOnError) + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 554 + 311
    + - flagSet.String(config.FlagNetwork, "custom", "") + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 555 + + 312 + +
    +   + proof1GeneratingTrueCall := m.stateMock. +
    +
    + 313 +
    + - flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 556 + 314
      - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) + Run(func(args mock.Arguments) {
    - 557 + 315
      - cfg, err := config.Load(ctx, true) + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 558 + 316
      - if err != nil { + }).
    -
     
    -
    - 590 + 317
      - }() + Return(nil).
    - 591 + 318
      - require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) + Once()
    - 592 + 319
      - flagSet := flag.NewFlagSet("", flag.PanicOnError) + proof2GeneratingTrueCall := m.stateMock.
    - 593 + 320
    + - flagSet.String(config.FlagNetwork, "custom", "") -
    -
    - 594 - -
    - + - flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 595 + 321
      - ctx := cli.NewContext(cli.NewApp(), flagSet, nil) + Run(func(args mock.Arguments) {
    - 596 + 322
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 597 + 323
      - os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c") + }).
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - + - - - - - - - - - - - - - - + + + - - + + + + - - - - + - + - + + - - - - - - - - -
    -
    @@ -102,9 +102,18 @@
    +
     
    - 102 + 326
      - SyncInterval = "1s" + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(nil, errBanana).Once()
    - 103 + 327
      - SyncChunkSize = 100 + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 104 + 328
      - TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc + m.stateMock.
    - + + 329 -
    -   -
    +
    +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 105 + 330
      - L1SynchronizationMode = "sequential" + Run(func(args mock.Arguments) {
    - 106 + 331
      - L1SyncCheckL2BlockHash = true + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 107 + + 332 +
    - - - L1SyncCheckL2BlockNumberhModulus = 30 +   + }).
    - - -
    -   -
    -
    +
    +
     
    - + + 334 -
    +
    +
      -
    + Once().
    - + + 335 -
    +
    +
      -
    + NotBefore(proof1GeneratingTrueCall)
    - + + 336 -
    +
    +
      -
    + m.stateMock.
    - + + 337 -
    -   -
    +
    +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - + + 338 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 339 -
    +
    +
      -
    + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - + + 340 -
    +
    +
      -
    + }).
    +
     
    +
    - 108 + 357
      - [Synchronizer.L1ParallelSynchronization] + dbTx := &mocks.DbTxMock{}
    - 109 + 358
      - MaxClients = 10 + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 110 + 359
      - MaxPendingNoProcessedBlocks = 25 + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    -
    @@ -160,6 +169,7 @@
    +
    + 360 + +
    + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() +
    - 160 + 361
      - L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" + proof1GeneratingTrueCall := m.stateMock. +
    +
    + 362 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 161 + 363
      - PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} + Run(func(args mock.Arguments) {
    - 162 + 364
      - GasOffset = 80000 + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 365 -
    +
    +
      -
    + }).
    - 163 + 366
      -
    + Return(nil).
    - 164 + 367
      - [Aggregator] + Once()
    - 165 + 368
      - Host = "0.0.0.0" + proof2GeneratingTrueCall := m.stateMock.
    -
    @@ -174,6 +184,10 @@
    +
    + 369 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). +
    - 174 + 370
      - GasOffset = 0 + Run(func(args mock.Arguments) {
    - 175 + 371
      - UpgradeEtrogBatchNumber = 0 + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 176 + 372
      - BatchProofL1BlockConfirmations = 2 + }).
    - + +
     
    -
    +
    + 376 + +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - + + 377 -
    +
    +
      -
    + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - + + 378 -
    +
    +
      -
    + m.stateMock.
    - + + 379 -
    -   -
    +
    +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 177 + 380
      -
    + Run(func(args mock.Arguments) {
    - 178 + 381
      - [L2GasPriceSuggester] + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 179 + 382
      - Type = "follower" + }).
    -
    -
    -
    -
    - - - + - - - - - + - + + - - - - - - - - - - - - - - + - - + + + + - - - - + - + - + + - - - - - - - - -
     
    - 102 + 384
      - SyncInterval = "1s" + Once().
    - 103 + 385
      - SyncChunkSize = 100 + NotBefore(proof1GeneratingTrueCall)
    - 104 + 386
      - TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc + m.stateMock.
    - 105 + + 387 +
    + - SyncBlockProtection = "safe" # latest, finalized, safe + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - 106 + 388
      - L1SynchronizationMode = "sequential" + Run(func(args mock.Arguments) {
    - 107 + 389
      - L1SyncCheckL2BlockHash = true + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 108 + + 390 +
    - + - L1SyncCheckL2BlockNumberhModulus = 600 +   + }).
    - 109 + +
     
    +
    + 399 +
    - + - [Synchronizer.L1BlockCheck] +   + },
    - 110 + + 400 +
    - + - Enable = true +   + },
    - 111 + + 401 +
    - + - L1SafeBlockPoint = "finalized" +   + {
    - 112 + + 402 +
    + - L1SafeBlockOffset = 0 + name: "unlockProofsToAggregate error after WaitRecursiveProof prover error",
    - 113 + + 403 +
    - + - ForceCheckBeforeStart = true +   + setup: func(m mox, a *Aggregator) {
    - 114 + + 404 +
    - + - PreCheckEnable = true +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 115 + + 405 +
    - + - L1PreSafeBlockPoint = "safe" +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 116 - -
    - + - L1PreSafeBlockOffset = 0 -
    +
    +
     
    - 117 + 407
      - [Synchronizer.L1ParallelSynchronization] + dbTx := &mocks.DbTxMock{}
    - 118 + 408
      - MaxClients = 10 + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Once()
    - 119 + 409
      - MaxPendingNoProcessedBlocks = 25 + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    -
     
    +
    + 410 + +
    + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once() +
    - 169 + 411
      - L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" + proof1GeneratingTrueCall := m.stateMock. +
    +
    + 412 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 170 + 413
      - PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} + Run(func(args mock.Arguments) {
    - 171 + 414
      - GasOffset = 80000 + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 172 + + 415 +
    - + - MaxBatchesForL1 = 300 +   + }).
    - 173 + 416
      -
    + Return(nil).
    - 174 + 417
      - [Aggregator] + Once()
    - 175 + 418
      - Host = "0.0.0.0" + m.stateMock.
    -
     
    +
    + 419 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx). +
    - 184 + 420
      - GasOffset = 0 + Run(func(args mock.Arguments) {
    - 185 + 421
      - UpgradeEtrogBatchNumber = 0 + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 186 + 422
      - BatchProofL1BlockConfirmations = 2 + }).
    - 187 + +
     
    +
    + 426 +
    - + - SettlementBackend = "agglayer" +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - 188 + + 427 +
    - + - AggLayerTxTimeout = "5m" +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 189 + + 428 +
    - + - AggLayerURL = "http://zkevm-agglayer" +   + m.stateMock.
    - 190 + + 429 +
    + - SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 191 + 430
      -
    + Run(func(args mock.Arguments) {
    - 192 + 431
      - [L2GasPriceSuggester] + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 193 + 432
      - Type = "follower" + }).
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/mainnetgenesis.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - -
    -
    @@ -1,108 +0,0 @@
    +
     
    - 1 + + 441 +
    - - - package config +   + },
    - 2 + + 442 +
    - - -
    +   + },
    - 3 + + 443 +
    - - - // MainnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup +   + {
    - 4 + + 444 +
    - - - const MainnetNetworkConfigJSON = ` + + + name: "rollback after DeleteGeneratedProofs error in db transaction",
    - 5 + + 445 +
    - - - { +   + setup: func(m mox, a *Aggregator) {
    - 6 + + 446 +
    - - - "l1Config" : { +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 7 + + 447 +
    - - - "chainId": 1, +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 8 + +
     
    +
    + 449 +
    - - - "polygonZkEVMAddress": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987", +   + dbTx := &mocks.DbTxMock{}
    - 9 + + 450 +
    - - - "polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2", +   + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 10 + + 451 +
    - - - "polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6", +   + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 11 + + 452 +
    - - - "polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb" + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 12 + + 453 +
    - - - }, +   + proof1GeneratingTrueCall := m.stateMock.
    - 13 + + 454 +
    - - - "root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 14 + + 455 +
    - - - "genesisBlockNumber": 16896721, +   + Run(func(args mock.Arguments) {
    - 15 + + 456 +
    - - - "genesis": [ +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 16 + + 457 +
    - - - { +   + }).
    - 17 + + 458 +
    - - - "contractName": "PolygonZkEVMDeployer", +   + Return(nil).
    - 18 + + 459 +
    - - - "balance": "0", +   + Once()
    - 19 + + 460 +
    - - - "nonce": "4", +   + proof2GeneratingTrueCall := m.stateMock.
    - 20 + + 461 +
    - - - "address": "0xCB19eDdE626906eB1EE52357a27F62dd519608C2", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 21 + + 462 +
    - - - "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033", +   + Run(func(args mock.Arguments) {
    - 22 + + 463 +
    - - - "storage": { +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 23 + + 464 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000004c1665d6651ecefa59b9b3041951608468b18891" +   + }).
    - 24 + +
     
    +
    + 466 +
    - - - } +   + Once()
    - 25 + + 467 +
    - - - }, +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 26 + + 468 +
    - - - { +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 27 + + 469 +
    - - - "contractName": "ProxyAdmin", + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(errBanana).Once()
    - 28 + + 470 +
    - - - "balance": "0", +   + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 29 + + 471 +
    - - - "nonce": "1", +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 30 + + 472 +
    - - - "address": "0x0F99738B2Fc14D77308337f3e2596b63aE7BCC4A", +   + m.stateMock.
    - 31 + + 473 +
    - - - "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 32 + + 474 +
    - - - "storage": { +   + Run(func(args mock.Arguments) {
    - 33 + + 475 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000bba0935fa93eb23de7990b47f0d96a8f75766d13" +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 34 + + 476 +
    - - - } +   + }).
    - 35 + +
     
    +
    + 478 +
    - - - }, +   + Once().
    - 36 + + 479 +
    - - - { +   + NotBefore(proof1GeneratingTrueCall)
    - 37 + + 480 +
    - - - "contractName": "PolygonZkEVMBridge implementation", +   + m.stateMock.
    - 38 + + 481 +
    - - - "balance": "0", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - 39 + + 482 +
    - - - "nonce": "1", +   + Run(func(args mock.Arguments) {
    - 40 + + 483 +
    - - - "address": "0x5ac4182A1dd41AeEf465E40B82fd326BF66AB82C", +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 41 + + 484 +
    - - - "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033" +   + }).
    - 42 + +
     
    +
    + 493 +
    - - - }, +   + },
    - 43 + + 494 +
    - - - { +   + },
    - 44 + + 495 +
    - - - "contractName": "PolygonZkEVMBridge proxy", +   + {
    - 45 + + 496 +
    - - - "balance": "200000000000000000000000000", + + + name: "rollback after AddGeneratedProof error in db transaction",
    - 46 + + 497 +
    - - - "nonce": "1", +   + setup: func(m mox, a *Aggregator) {
    - 47 + + 498 +
    - - - "address": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe", +   + m.proverMock.On("Name").Return(proverName).Twice()
    - 48 + + 499 +
    - - - "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", +   + m.proverMock.On("ID").Return(proverID).Twice()
    - 49 + +
     
    +
    + 501 +
    - - - "storage": { +   + dbTx := &mocks.DbTxMock{}
    - 50 + + 502 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + lockProofsTxBegin := m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 51 + + 503 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + lockProofsTxCommit := dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 52 + + 504 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 53 + + 505 +
    - - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a", +   + proof1GeneratingTrueCall := m.stateMock.
    - 54 + + 506 +
    - - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000005ac4182a1dd41aeef465e40b82fd326bf66ab82c" + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 55 + + 507 +
    - - - } +   + Run(func(args mock.Arguments) {
    - 56 + + 508 +
    - - - }, +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 57 + + 509 +
    - - - { +   + }).
    - 58 + + 510 +
    - - - "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", +   + Return(nil).
    - 59 + + 511 +
    - - - "balance": "0", +   + Once()
    - 60 + + 512 +
    - - - "nonce": "1", +   + proof2GeneratingTrueCall := m.stateMock.
    - 61 + + 513 +
    - - - "address": "0x0200143Fa295EE4dffEF22eE2616c2E008D81688", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 62 + + 514 +
    - - - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" +   + Run(func(args mock.Arguments) {
    - 63 + + 515 +
    - - - }, +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 64 + + 516 +
    - - - { +   + }).
    - 65 + +
     
    +
    + 518 +
    - - - "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +   + Once()
    - 66 + + 519 +
    - - - "balance": "0", +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 67 + + 520 +
    - - - "nonce": "1", +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 68 + + 521 +
    - - - "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - 69 + + 522 +
    - - - "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033", + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Return(errBanana).Once()
    - 70 + + 523 +
    - - - "storage": { +   + dbTx.On("Rollback", mock.MatchedBy(matchProverCtxFn)).Return(nil).Once()
    - 71 + + 524 +
    - - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a", +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchAggregatorCtxFn)).Return(dbTx, nil).Once().NotBefore(lockProofsTxBegin)
    - 72 + + 525 +
    - - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000000200143fa295ee4dffef22ee2616c2e008d81688" +   + m.stateMock.
    - 73 + + 526 +
    - - - } + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof1, dbTx).
    - 74 + + 527 +
    - - - }, +   + Run(func(args mock.Arguments) {
    - 75 + + 528 +
    - - - { +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 76 + + 529 +
    - - - "contractName": "PolygonZkEVMTimelock", +   + }).
    - 77 + +
     
    +
    + 531 +
    - - - "balance": "0", +   + Once().
    - 78 + + 532 +
    - - - "nonce": "1", +   + NotBefore(proof1GeneratingTrueCall)
    - 79 + + 533 +
    - - - "address": "0xBBa0935Fa93Eb23de7990b47F0D96a8f75766d13", +   + m.stateMock.
    - 80 + + 534 +
    - - - "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proof2, dbTx).
    - 81 + + 535 +
    - - - "storage": { +   + Run(func(args mock.Arguments) {
    - 82 + + 536 +
    - - - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x00000000000000000000000000000000000000000000000000000000000d2f00", +   + assert.Nil(args[1].(*state.Proof).GeneratingSince)
    - 83 + + 537 +
    - - - "0x33d4aa03df3f12c4f615b40676f67fdafecd3edb5a9c0ca2a47a923dae33a023": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + }).
    - 84 + +
     
    +
    + 554 +
    - - - "0x9fa2d8034dbcb437bee38d61fbd100910e1342ffc07f128aa1b8e6790b7f3f68": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + dbTx := &mocks.DbTxMock{}
    - 85 + + 555 +
    - - - "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +   + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - 86 + + 556 +
    - - - "0x531a7c25761aa4b0f2310edca9bb25e1e3ceb49ad4b0422aec866b3ce7567c87": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice()
    - 87 + + 557 +
    - - - "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - 88 + + 558 +
    - - - "0xedbedc78c4240c7613622a35de050b48bd6c6d9a31b3d485b68fbbed54a4802d": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + m.stateMock.
    - 89 + + 559 +
    - - - "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - 90 + + 560 +
    - - - "0x76616448da8d124a07383c26a6b2433b3259de946aa40f51524ec96ee05e871a": "0x0000000000000000000000000000000000000000000000000000000000000001", +   + Run(func(args mock.Arguments) {
    - 91 + + 561 +
    - - - "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 92 + + 562 +
    - - - } +   + }).
    - 93 + + 563 +
    - - - }, +   + Return(nil).
    - 94 + + 564 +
    - - - { +   + Once()
    - 95 + + 565 +
    - - - "accountName": "keyless Deployer", +   + m.stateMock.
    - 96 + + 566 +
    - - - "balance": "0", + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - 97 + + 567 +
    - - - "nonce": "1", +   + Run(func(args mock.Arguments) {
    - 98 + + 568 +
    - - - "address": "0x9d90066e7478496e2284E54c3548106bb4F90E50" +   + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - 99 + + 569 +
    - - - }, +   + }).
    - 100 + +
     
    +
    + 571 +
    - - - { +   + Once()
    - 101 + + 572 +
    - - - "accountName": "deployer", +   + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - 102 + + 573 +
    - - - "balance": "0", +   + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 103 + + 574 +
    - - - "nonce": "8", + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - 104 + + 575 +
    - - - "address": "0x4c1665d6651ecEfa59B9B3041951608468b18891" +   + expectedInputProver := map[string]interface{}{
    - 105 + + 576 +
    - - - } +   + "recursive_proof_1": proof1.Proof,
    - 106 + + 577 +
    - - - ] +   + "recursive_proof_2": proof2.Proof,
    - 107 + + 578 +
    - - - } +   + }
    - 108 + + 579 +
    - - - ` +   + b, err := json.Marshal(expectedInputProver)
    -
    + + + 580 + + +
    +   + require.NoError(err)
    -
    -
    - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - -
    -
     
    - + + 581 -
    -   -
    +
    +
    + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Run(
    - + + 582 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 583 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 584 -
    +
    +
      -
    + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 590 + +
      -
    + assert.InDelta(time.Now().Unix(), proof.GeneratingSince.Unix(), float64(time.Second))
    - + + 591 -
    +
    +
      -
    + },
    - + + 592 -
    +
    +
      -
    + ).Return(nil).Once()
    - + + 593 -
    -   -
    +
    +
    + + + m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - + + 594 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 595 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 596 -
    +
    +
      -
    + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 618 + +
      -
    + dbTx := &mocks.DbTxMock{}
    - + + 619 -
    +
    +
      -
    + m.stateMock.On("BeginStateTransaction", mock.MatchedBy(matchProverCtxFn)).Return(dbTx, nil).Twice()
    - + + 620 -
    +
    +
      -
    + dbTx.On("Commit", mock.MatchedBy(matchProverCtxFn)).Return(nil).Twice()
    - + + 621 -
    -   -
    +
    +
    + + + m.stateMock.On("GetProofsToAggregate", mock.MatchedBy(matchProverCtxFn), nil).Return(&proof1, &proof2, nil).Once()
    - + + 622 -
    +
    +
      -
    + m.stateMock.
    - + + 623 -
    -   -
    +
    +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof1, dbTx).
    - + + 624 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 625 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 626 -
    +
    +
      -
    + }).
    - + + 627 -
    +
    +
      -
    + Return(nil).
    - + + 628 -
    +
    +
      -
    + Once()
    - + + 629 -
    +
    +
      -
    + m.stateMock.
    - + + 630 -
    -   -
    +
    +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proof2, dbTx).
    - + + 631 -
    +
    +
      -
    + Run(func(args mock.Arguments) {
    - + + 632 -
    +
    +
      -
    + assert.NotNil(args[1].(*state.Proof).GeneratingSince)
    - + + 633 -
    +
    +
      -
    + }).
    - + +
     
    -
    +
    + 635 + +
      -
    + Once()
    - + + 636 -
    +
    +
      -
    + m.proverMock.On("AggregatedProof", proof1.Proof, proof2.Proof).Return(&proofID, nil).Once()
    - + + 637 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - + + 638 -
    -   -
    +
    +
    + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchProverCtxFn), proof1.BatchNumber, proof2.BatchNumberFinal, dbTx).Return(nil).Once()
    - + + 639 -
    +
    +
      -
    + expectedInputProver := map[string]interface{}{
    - + + 640 -
    +
    +
      -
    + "recursive_proof_1": proof1.Proof,
    - + + 641 -
    +
    +
      -
    + "recursive_proof_2": proof2.Proof,
    - + + 642 -
    +
    +
      -
    + }
    - + + 643 -
    +
    +
      -
    + b, err := json.Marshal(expectedInputProver)
    - + + 644 -
    +
    +
      -
    + require.NoError(err)
    - + + 645 -
    -   -
    +
    +
    + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, dbTx).Run(
    - + + 646 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 647 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 648 -
    +
    +
      -
    + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 660 + +
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(uint64(42), nil).Once()
    - + + 661 -
    +
    +
      -
    + // make tryBuildFinalProof fail ASAP
    - + + 662 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, errBanana).Once().NotBefore(isSyncedCall)
    - + + 663 -
    -   -
    +
    +
    + + + m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - + + 664 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 665 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 666 -
    +
    +
      -
    + assert.Equal(proof1.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 686 + +
      -
    + ethTxManager := mocks.NewEthTxManager(t)
    - + + 687 -
    +
    +
      -
    + etherman := mocks.NewEtherman(t)
    - + + 688 -
    +
    +
      -
    + proverMock := mocks.NewProverMock(t)
    - + + 689 -
    -   -
    +
    +
    + + + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
    - + + 690 -
    +
    +
      -
    + require.NoError(err)
    - + + 691 -
    +
    +
      -
    + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - + + 692 -
    +
    +
      -
    + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    - + +
     
    -
    +
    + 701 + +
      -
    + }
    - + + 702 -
    +
    +
      -
    + a.resetVerifyProofTime()
    - + + 703 -
    +
    +
     
    - + + 704 -
    -   -
    +
    +
    + + + result, err := a.tryAggregateProofs(proverCtx, proverMock)
    - + + 705 -
    +
    +
     
    - + + 706 -
    +
    +
      -
    + if tc.asserts != nil {
    - + + 707 -
    +
    +
      -
    + tc.asserts(result, &a, err)
    - + +
     
    -
    +
    + 777 + +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 778 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 779 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 780 -
    -   -
    +
    +
    + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 781 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 782 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 783 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 805 + +
      -
    + expectedInputProver, err := a.buildInputProver(context.Background(), &batchToProve)
    - + + 806 -
    +
    +
      -
    + require.NoError(err)
    - + + 807 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(nil, errBanana).Once()
    - + + 808 -
    -   -
    +
    +
    + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(nil).Once()
    - + + 809 -
    +
    +
      -
    + },
    - + + 810 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 811 -
    +
    +
      -
    + assert.False(result)
    - + +
     
    -
    +
    + 820 + +
      -
    + m.proverMock.On("Addr").Return("addr")
    - + + 821 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 822 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 823 -
    -   -
    +
    +
    + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 824 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 825 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 826 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 849 + +
      -
    + require.NoError(err)
    - + + 850 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
    - + + 851 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - + + 852 -
    -   -
    +
    +
    + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(nil).Once()
    - + + 853 -
    +
    +
      -
    + },
    - + + 854 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 855 -
    +
    +
      -
    + assert.False(result)
    - + +
     
    -
    +
    + 857 + +
      -
    + },
    - + + 858 -
    +
    +
      -
    + },
    - + + 859 -
    +
    +
      -
    + {
    - + + 860 -
    -   -
    +
    +
    + + + name: "DeleteGeneratedProofs error after WaitRecursiveProof prover error",
    - + + 861 -
    +
    +
      -
    + setup: func(m mox, a *Aggregator) {
    - + + 862 -
    +
    +
      -
    + m.proverMock.On("Name").Return(proverName).Twice()
    - + + 863 -
    +
    +
      -
    + m.proverMock.On("ID").Return(proverID).Twice()
    - + + 864 -
    +
    +
      -
    + m.proverMock.On("Addr").Return(proverID)
    - + + 865 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - + + 866 -
    +
    +
      -
    + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - + + 867 -
    -   -
    +
    +
    + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - + + 868 -
    +
    +
      -
    + func(args mock.Arguments) {
    - + + 869 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 870 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - + +
     
    -
    +
    + 893 + +
      -
    + require.NoError(err)
    - + + 894 -
    +
    +
      -
    + m.proverMock.On("BatchProof", expectedInputProver).Return(&proofID, nil).Once()
    - + + 895 -
    +
    +
      -
    + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return("", errBanana).Once()
    - + + 896 -
    -   -
    +
    +
    + + + m.stateMock.On("DeleteGeneratedProofs", mock.MatchedBy(matchAggregatorCtxFn), batchToProve.BatchNumber, batchToProve.BatchNumber, nil).Return(errBanana).Once()
    -
    + + + 897 + + +
    +   + },
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network.go - RENAMED - -
    -
    -
    -
    - - - - - + + + - - - - - - + + + - - - - - - - - + + + - - - - - - - - - + - - - - - - - - - - - - - - - - - - + + + - - -
    -
    @@ -25,17 +25,16 @@
    - 25 + 898
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - 26 + 899
      - type network string + assert.False(result)
    +
     
    +
    - 27 + 908
      -
    + m.proverMock.On("Addr").Return("addr")
    - 28 + + 909 +
    - - - const mainnet network = "mainnet" +   + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - 29 + + 910 +
    - - - const testnet network = "testnet" +   + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    - 30 + + 911 +
    - - - const cardona network = "cardona" + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - 31 + 912
      - const custom network = "custom" + func(args mock.Arguments) {
    - 32 + 913
      -
    + proof := args[1].(*state.Proof)
    - 33 + 914
      - // GenesisFromJSON is the config file for network_custom + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    +
     
    +
    - 34 + 939
      - type GenesisFromJSON struct { + m.proverMock.On("WaitRecursiveProof", mock.MatchedBy(matchProverCtxFn), proofID).Return(recursiveProof, nil).Once()
    - 35 + 940
      - // L1: root hash of the genesis block + b, err := json.Marshal(expectedInputProver)
    - 36 + 941
      - Root string `json:"root"` + require.NoError(err)
    - 37 + + 942 +
    - - - // L1: block number of the genesis block + + + m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - 38 + + 943 +
    - - - GenesisBlockNum uint64 `json:"genesisBlockNumber"` +   + func(args mock.Arguments) {
    - + + 944 -
    +
    +
      -
    + proof := args[1].(*state.Proof)
    - + + 945 -
    +
    +
      -
    + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    +
     
    +
    - 39 + 966
      - // L2: List of states contracts used to populate merkle tree at initial state + m.proverMock.On("Addr").Return("addr")
    - 40 + 967
      - Genesis []genesisAccountFromJSON `json:"genesis"` + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&lastVerifiedBatch, nil).Once()
    - 41 + 968
      - // L1: configuration of the network + m.stateMock.On("GetVirtualBatchToProve", mock.MatchedBy(matchProverCtxFn), lastVerifiedBatchNum, mock.Anything, nil).Return(&batchToProve, nil).Once()
    -
    @@ -60,12 +59,6 @@
    -
    - 60 + + 969 +
    -   - func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { + + + m.stateMock.On("AddGeneratedProof", mock.MatchedBy(matchProverCtxFn), mock.Anything, nil).Run(
    - 61 + 970
      - var networkJSON string + func(args mock.Arguments) {
    - 62 + 971
      - switch ctx.String(FlagNetwork) { + proof := args[1].(*state.Proof)
    - 63 + + 972 +
    - - - case string(mainnet): +   + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    - 64 - -
    - - - networkJSON = MainnetNetworkConfigJSON -
    +
    +
     
    - 65 + + 1003 +
    - - - case string(testnet): +   + m.etherman.On("GetLatestBlockHeader", mock.Anything).Return(&types.Header{Number: new(big.Int).SetUint64(1)}, nil).Once()
    - 66 + + 1004 +
    - - - networkJSON = TestnetNetworkConfigJSON +   + // make tryBuildFinalProof fail ASAP
    - 67 + + 1005 +
    - - - case string(cardona): +   + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(nil, errBanana).Once().NotBefore(isSyncedCall)
    - 68 + + 1006 +
    - - - networkJSON = CardonaNetworkConfigJSON + + + m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), mock.Anything, nil).Run(
    - 69 + 1007
      - case string(custom): + func(args mock.Arguments) {
    - 70 + 1008
      - var err error + proof := args[1].(*state.Proof)
    - 71 + 1009
      - cfgPath := ctx.String(FlagCustomNetwork) + assert.Equal(batchToProve.BatchNumber, proof.BatchNumber)
    -
    @@ -74,7 +67,7 @@
    +
     
    - 74 + 1029
      - panic(err.Error()) + ethTxManager := mocks.NewEthTxManager(t)
    - 75 + 1030
      - } + etherman := mocks.NewEtherman(t)
    - 76 + 1031
      - default: + proverMock := mocks.NewProverMock(t)
    - 77 + + 1032 +
    - - - log.Fatalf("unsupported --network value. Must be one of: [%s, %s, %s]", mainnet, testnet, cardona, custom) + + + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
    - 78 + 1033
      - } + require.NoError(err)
    - 79 + 1034
      - config, err := LoadGenesisFromJSONString(networkJSON) + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - 80 + 1035
      - if err != nil { + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    -
    @@ -122,9 +115,10 @@
    +
     
    - 122 + 1138
      -
    + m.proverMock.On("Addr").Return("addr").Twice()
    - 123 + 1139
      - cfg.L1Config = cfgJSON.L1Config + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 124 + 1140
      - cfg.Genesis = state.Genesis{ + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - 125 + + 1141 +
    - - - BlockNumber: cfgJSON.GenesisBlockNum, + + + m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once()
    - 126 + + 1142 +
    - - - Root: common.HexToHash(cfgJSON.Root), + + + proofGeneratingTrueCall := m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - 127 + + 1143 +
    - - - Actions: []*state.GenesisAction{}, +   + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(nil, errBanana).Once()
    - + + 1144 -
    +
    +
      -
    + m.stateMock. +
    +
    + 1145 + +
    + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil).
    - 128 + 1146
      - } + Return(nil).
    - 129 + 1147
      -
    + Once().
    - 130 + 1148
      - for _, account := range cfgJSON.Genesis { + NotBefore(proofGeneratingTrueCall)
    -
    -
    -
    -
    - - - + - - - - - - - - - + - + + - - - - - - @@ -29845,122 +30475,157 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - + - + + - - - - + + + + + + @@ -29970,72 +30635,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -30045,102 +30710,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - @@ -30150,12 +30785,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/batch.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - -
     
    - 25 + 1160
      -
    + m.proverMock.On("Addr").Return("addr").Twice()
    - 26 + 1161
      - type network string + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 27 + 1162
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - + + 1163 -
    -   -
    +
    +
    + + + m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once()
    - + + 1164 -
    -   -
    +
    +
    + + + proofGeneratingTrueCall := m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - + + 1165 -
    +
    +
      -
    + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once()
    - 28 + 1166
      - const custom network = "custom" + m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(nil, errBanana).Once()
    - 29 + 1167
      -
    + m.stateMock.
    - 30 + + 1168 +
    -   - // GenesisFromJSON is the config file for network_custom + + + On("UpdateGeneratedProof", mock.MatchedBy(matchAggregatorCtxFn), &proofToVerify, nil).
    - 31 + 1169
      - type GenesisFromJSON struct { + Return(nil).
    - 32 + 1170
      - // L1: root hash of the genesis block + Once().
    - 33 + 1171
      - Root string `json:"root"` + NotBefore(proofGeneratingTrueCall)
    - 34 + +
     
    +
    + 1183 +
    - + - // L1: block number in which the rollup was created +   + m.proverMock.On("Addr").Return(proverID).Once()
    - 35 + + 1184 +
    - + - RollupCreationBlockNum uint64 `json:"rollupCreationBlockNumber"` +   + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 36 + + 1185 +
    - + - // L1: block number in which the rollup manager was created +   + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - 37 + + 1186 +
    + - RollupManagerCreationBlockNum uint64 `json:"rollupManagerCreationBlockNumber"` + m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(nil, errBanana).Once()
    - 38 + 1187
      - // L2: List of states contracts used to populate merkle tree at initial state + },
    - 39 + 1188
      - Genesis []genesisAccountFromJSON `json:"genesis"` + asserts: func(result bool, a *Aggregator, err error) {
    - 40 + 1189
      - // L1: configuration of the network + assert.False(result)
    - 59 + 1198
      - func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { + m.proverMock.On("Addr").Return(proverID).Once()
    - 60 + 1199
      - var networkJSON string + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - 61 + 1200
      - switch ctx.String(FlagNetwork) { + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once()
    - + + 1201 -
    +
    +
    + + + m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(nil, state.ErrNotFound).Once() +
    +
    + 1202 + +
      -
    + },
    - + + 1203 -
    +
    +
      -
    + asserts: func(result bool, a *Aggregator, err error) {
    - + + 1204 -
    +
    +
      -
    + assert.False(result)
    - + +
     
    -
    +
    + 1213 + +
      -
    + m.proverMock.On("Addr").Return(proverID).Twice()
    - + + 1214 -
    +
    +
      -
    + m.stateMock.On("GetLastVerifiedBatch", mock.MatchedBy(matchProverCtxFn), nil).Return(&verifiedBatch, nil).Twice()
    - + + 1215 -
    +
    +
      -
    + m.etherman.On("GetLatestVerifiedBatchNum").Return(latestVerifiedBatchNum, nil).Once() +
    +
    + 1216 + +
    + + + m.stateMock.On("GetProofReadyToVerify", mock.MatchedBy(matchProverCtxFn), latestVerifiedBatchNum, nil).Return(&proofToVerify, nil).Once() +
    +
    + 1217 + +
    + + + m.stateMock.On("UpdateGeneratedProof", mock.MatchedBy(matchProverCtxFn), &proofToVerify, nil).Return(nil).Once()
    - 62 + 1218
      - case string(custom): + m.proverMock.On("FinalProof", proofToVerify.Proof, from.String()).Return(&finalProofID, nil).Once()
    - 63 + 1219
      - var err error + m.proverMock.On("WaitFinalProof", mock.MatchedBy(matchProverCtxFn), finalProofID).Return(&finalProof, nil).Once()
    - 64 + 1220
      - cfgPath := ctx.String(FlagCustomNetwork) + },
    - 67 + 1306
      - panic(err.Error()) + ethTxManager := mocks.NewEthTxManager(t)
    - 68 + 1307
      - } + etherman := mocks.NewEtherman(t)
    - 69 + 1308
      - default: + proverMock := mocks.NewProverMock(t)
    - 70 + 1309
    + - log.Fatalf("unsupported --network value. Must be %s", custom) + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
    - 71 + 1310
      - } + require.NoError(err)
    - 72 + 1311
      - config, err := LoadGenesisFromJSONString(networkJSON) + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - 73 + 1312
      - if err != nil { + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    - 115 + 1436
      -
    + ethTxManager := mocks.NewEthTxManager(t)
    - 116 + 1437
      - cfg.L1Config = cfgJSON.L1Config + etherman := mocks.NewEtherman(t)
    - 117 + 1438
      - cfg.Genesis = state.Genesis{ -
    -
    - 118 - -
    - + - RollupBlockNumber: cfgJSON.RollupCreationBlockNum, -
    -
    - 119 - -
    - + - RollupManagerBlockNumber: cfgJSON.RollupManagerCreationBlockNum, + proverMock := mocks.NewProverMock(t)
    - 120 + 1439
    + - Root: common.HexToHash(cfgJSON.Root), -
    -
    - 121 - -
    - + - Actions: []*state.GenesisAction{}, + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil)
    - 122 + 1440
      - } + require.NoError(err)
    - 123 + 1441
      -
    + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck
    - 124 + 1442
      - for _, account := range cfgJSON.Genesis { + a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    -
    @@ -14,18 +13,6 @@
    -
    - 14 - -
    -   - "github.com/urfave/cli/v2" -
    +
    @@ -1,427 +0,0 @@
    - 15 + + 1 +
    -   - ) + - + package aggregator
    - 16 + + 2 +
    -   + -
    - 17 + 3
    - - func TestCardona(t *testing.T) { + import (
    - 18 + 4
    - - cfg := Config{} + "context"
    - 19 + 5
    - - fs := flag.NewFlagSet("", flag.ExitOnError) + "encoding/json"
    - 20 + 6
    - - fs.String(FlagNetwork, string(cardona), string(cardona)) + "errors"
    - 21 + 7
    - - err := fs.Set(FlagNetwork, string(cardona)) + "fmt"
    - 22 + 8
    - - require.NoError(t, err) + "math/big"
    - 23 + 9
    - - app := cli.NewApp() + "time"
    - 24 + 10
    - - ctx := cli.NewContext(app, fs, nil) +
    - 25 + 11
    - -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - 26 + 12
    - - log.Info("flag=", ctx.String(FlagNetwork)) + "github.com/0xPolygonHermez/zkevm-node/state"
    - 27 + 13
    - - cfg.loadNetworkConfig(ctx) + )
    - 28 + 14
    - - } +
    - 29 + + 15 +
    -   - func TestLoadCustomNetworkConfig(t *testing.T) { + - + func (a *Aggregator) tryGenerateBatchProof(ctx context.Context, prover proverInterface) (bool, error) {
    - 30 + + 16 +
    -   - tcs := []struct { + - + log := log.WithFields(
    - 31 + + 17 +
    -   - description string + - + "prover", prover.Name(),
    -
    @@ -37,7 +24,8 @@
    -
    - 37 + + 18 +
    -   - description: "happy path", + - + "proverId", prover.ID(),
    - 38 + + 19 +
    -   - inputConfigStr: `{ + - + "proverAddr", prover.Addr(),
    - 39 + + 20 +
    -   - "root": "0xBEEF", + - + )
    - 40 + + 21 +
    - - "genesisBlockNumber": 69, + log.Debug("tryGenerateBatchProof start")
    - + + 22 -
    -   +
    +
    + -
    - 41 + + 23 +
    -   - "l1Config" : { + - + batchToProve, proof, err0 := a.getAndLockBatchToProve(ctx, prover)
    - 42 + + 24 +
    -   - "chainId": 420, + - + if errors.Is(err0, state.ErrNotFound) {
    - 43 + + 25 +
    -   - "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4", + - + // nothing to proof, swallow the error
    -
    @@ -89,8 +77,9 @@
    +
    + 26 + +
    + - + log.Debug("Nothing to generate proof") +
    - 89 + + 27 +
    -   - GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + - + return false, nil
    - 90 + + 28 +
    -   - }, + - + }
    - 91 + + 29 +
    -   - Genesis: state.Genesis{ + - + if err0 != nil {
    - 92 + + 30 +
    - - Root: common.HexToHash("0xBEEF"), + return false, err0
    - 93 + + 31 +
    - - BlockNumber: 69, + }
    - + + 32 -
    -   +
    +
    + -
    - 94 + + 33 +
    -   - Actions: []*state.GenesisAction{ + - + log = log.WithFields("batch", batchToProve.BatchNumber)
    - 95 + + 34 +
    -   - { + - +
    - 96 + + 35 +
    -   - Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4", + - + var (
    -
    + + + 36 + + +
    + - + genProofID *string
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 13 + + 37 +
    -   - "github.com/urfave/cli/v2" + - + err error
    - 14 + + 38 +
    -   - ) + - + )
    - 15 + + 39 +
    -   + -
    - + + 40 -
    -   -
    +
    +
    + - + defer func() {
    - + + 41 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 42 -
    -   -
    +
    +
    + - + err2 := a.State.DeleteBatchProofs(a.ctx, proof.BatchNumber, proof.BatchNumberFinal, nil)
    - + + 43 -
    -   -
    +
    +
    + - + if err2 != nil {
    - + + 44 -
    -   -
    +
    +
    + - + log.Errorf("Failed to delete proof in progress, err: %v", err2)
    - + + 45 -
    -   -
    +
    +
    + - + }
    - + + 46 -
    -   -
    +
    +
    + - + }
    - + + 47 -
    -   -
    +
    +
    + - + log.Debug("tryGenerateBatchProof end")
    - + + 48 -
    -   -
    +
    +
    + - + }()
    - + + 49 -
    -   +
    +
    + -
    - + + 50 -
    -   -
    +
    +
    + - + log.Info("Generating proof from batch")
    - + + 51 -
    -   +
    +
    + -
    - 16 + + 52 +
    -   - func TestLoadCustomNetworkConfig(t *testing.T) { + - + log.Infof("Sending zki + batch to the prover, batchNumber [%d]", batchToProve.BatchNumber)
    - 17 + + 53 +
    -   - tcs := []struct { + - + inputProver, err := a.buildInputProver(ctx, batchToProve)
    - 18 + + 54 +
    -   - description string + - + if err != nil {
    -
     
    +
    + 55 + +
    + - + err = fmt.Errorf("failed to build input prover, %w", err) +
    - 24 + + 56 +
    -   - description: "happy path", + - + log.Error(FirstToUpper(err.Error()))
    - 25 + + 57 +
    -   - inputConfigStr: `{ + - + return false, err
    - 26 + + 58 +
    -   - "root": "0xBEEF", + - + }
    - 27 + + 59 +
    - + - "rollupCreationBlockNumber": 69, + - +
    - 28 + + 60 +
    - + - "rollupManagerCreationBlockNumber": 60, + - + b, err := json.Marshal(inputProver)
    - 29 + + 61 +
    -   - "l1Config" : { + - + if err != nil {
    - 30 + + 62 +
    -   - "chainId": 420, + - + err = fmt.Errorf("failed to serialize input prover, %w", err)
    - 31 + + 63 +
    -   - "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4", + - + log.Error(FirstToUpper(err.Error()))
    -
     
    +
    + 64 + +
    + - + return false, err +
    - 77 + + 65 +
    -   - GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), + - + }
    - 78 + + 66 +
    -   - }, + - +
    - 79 + + 67 +
    -   - Genesis: state.Genesis{ + - + proof.InputProver = string(b)
    - 80 + + 68 +
    - + - Root: common.HexToHash("0xBEEF"), + - +
    - 81 + + 69 +
    - + - RollupBlockNumber: 69, + - + log.Infof("Sending a batch to the prover. OldStateRoot [%#x], OldBatchNum [%d]",
    - 82 + + 70 +
    - + - RollupManagerBlockNumber: 60, + - + inputProver.PublicInputs.OldStateRoot, inputProver.PublicInputs.OldBatchNum)
    - 83 + + 71 +
    -   - Actions: []*state.GenesisAction{ + - +
    - 84 + + 72 +
    -   - { + - + genProofID, err = prover.BatchProof(inputProver)
    - 85 + + 73 +
    -   - Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4", + - + if err != nil {
    -
    + + + 74 + + +
    + - + err = fmt.Errorf("failed to get batch proof id, %w", err)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/testnetgenesis.go - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -1,108 +0,0 @@
    - 1 + 75
    - - package config + log.Error(FirstToUpper(err.Error()))
    - 2 + 76
    - -
    + return false, err
    - 3 + 77
    - - // TestnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup + }
    - 4 + 78
    - - const TestnetNetworkConfigJSON = ` +
    - 5 + 79
    - - { + proof.ProofID = genProofID
    - 6 + 80
    - - "l1Config" : { +
    - 7 + 81
    - - "chainId": 5, + log.Infof("Proof ID %v", *proof.ProofID)
    - 8 + 82
    - - "polygonZkEVMAddress": "0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A", + log = log.WithFields("proofId", *proof.ProofID)
    - 9 + 83
    - - "polTokenAddress": "0x1319D23c2F7034F52Eb07399702B040bA278Ca49", +
    - 10 + 84
    - - "polygonZkEVMGlobalExitRootAddress": "0x4d9427DCA0406358445bC0a8F88C26b704004f74" + resGetProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID)
    - 11 + 85
    - - }, + if err != nil {
    - 12 + 86
    - - "root": "0x13a14c4a8288e782863d7ce916d224546c69dc428fbfa7115a0cc33a27a05b26", + err = fmt.Errorf("failed to get proof from prover, %w", err)
    - 13 + 87
    - - "genesisBlockNumber": 8572998, + log.Error(FirstToUpper(err.Error()))
    - 14 + 88
    - - "genesis": [ + return false, err
    - 15 + 89
    - - { + }
    - 16 + 90
    - - "contractName": "PolygonZkEVMDeployer", +
    - 17 + 91
    - - "balance": "0", + log.Info("Batch proof generated")
    - 18 + 92
    - - "nonce": "4", +
    - 19 + 93
    - - "address": "0x39877a0c3cd148476DaA2475c77c478C62eC7509", + proof.Proof = resGetProof
    - 20 + 94
    - - "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212200b8e3cd6bd762444a7eeff86e1cfcd7e1ce9524b715dcb70b2a4c2b70fd5188464736f6c63430008110033", +
    - 21 + 95
    - - "storage": { + // NOTE(pg): the defer func is useless from now on, use a different variable
    - 22 + 96
    - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000a0b02b28920812324f1cc3255bd8840867d3f227" + // name for errors (or shadow err in inner scopes) to not trigger it.
    - 23 + 97
    - - } +
    - 24 + 98
    - - }, + finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof)
    - 25 + 99
    - - { + if finalProofErr != nil {
    - 26 + 100
    - - "contractName": "ProxyAdmin", + // just log the error and continue to handle the generated proof
    - 27 + 101
    - - "balance": "0", + log.Errorf("Error trying to build final proof: %v", finalProofErr)
    - 28 + 102
    - - "nonce": "1", + }
    - 29 + 103
    - - "address": "0x40797c2f93298a44a893F43EdF1B33B63d7BA333", +
    - 30 + 104
    - - "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220babd4ff1f5daee002b96cc86d8bb6c2c2c210ae3132df5ea384713352f7f15fe64736f6c63430008110033", + // NOTE(pg): prover is done, use a.ctx from now on
    - 31 + 105
    - - "storage": { +
    - 32 + 106
    - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x00000000000000000000000002245d7b6cb0b6870d1e28ac877ee355b9588869" + if !finalProofBuilt {
    - 33 + 107
    - - } + proof.GeneratingSince = nil
    - 34 + 108
    - - }, +
    - 35 + 109
    - - { + // final proof has not been generated, update the batch proof
    - 36 + 110
    - - "contractName": "PolygonZkEVMBridge implementation", + err := a.State.UpdateBatchProof(a.ctx, proof, nil)
    - 37 + 111
    - - "balance": "0", + if err != nil {
    - 38 + 112
    - - "nonce": "1", + err = fmt.Errorf("failed to store batch proof result, %w", err)
    - 39 + 113
    - - "address": "0x39e780D8800f7396e8B7530A8925B14025AedC77", + log.Error(FirstToUpper(err.Error()))
    - 40 + 114
    - - "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220addfd62f466d34ee002afbb4ae37b6be56ad421fe773f800badeb4ce1025089864736f6c63430008110033" + return false, err
    - 41 + 115
    - - }, + }
    - 42 + 116
    - - { + }
    - 43 + 117
    - - "contractName": "PolygonZkEVMBridge proxy", +
    - 44 + 118
    - - "balance": "200000000000000000000000000", + return true, nil
    - 45 + 119
    - - "nonce": "1", + }
    - 46 + 120
    - - "address": "0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7", +
    - 47 + 121
    - - "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", + func (a *Aggregator) getAndLockBatchToProve(ctx context.Context, prover proverInterface) (*state.Batch, *state.Proof, error) {
    - 48 + 122
    - - "storage": { + proverID := prover.ID()
    - 49 + 123
    - - "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", + proverName := prover.Name()
    - 50 + 124
    - - "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    - 51 + 125
    - - "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", + log := log.WithFields(
    - 52 + 126
    - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333", + "prover", proverName,
    - 53 + 127
    - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000039e780d8800f7396e8b7530a8925b14025aedc77" + "proverId", proverID,
    - 54 + 128
    - - } + "proverAddr", prover.Addr(),
    - 55 + 129
    - - }, + )
    - 56 + 130
    - - { +
    - 57 + 131
    - - "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", + a.StateDBMutex.Lock()
    - 58 + 132
    - - "balance": "0", + defer a.StateDBMutex.Unlock()
    - 59 + 133
    - - "nonce": "1", +
    - 60 + 134
    - - "address": "0x77Fc57b154fCF8320Df2C2e6C044AA50141c023b", + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil)
    - 61 + 135
    - - "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a781565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a7161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" + if err != nil {
    - 62 + 136
    - - }, + return nil, nil, err
    - 63 + 137
    - - { + }
    - 64 + 138
    - - "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +
    - 65 + 139
    - - "balance": "0", + // Get header of the last L1 block
    - 66 + 140
    - - "nonce": "1", + lastL1BlockHeader, err := a.Ethman.GetLatestBlockHeader(ctx)
    - 67 + 141
    - - "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", + if err != nil {
    - 68 + 142
    - - "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033", + log.Errorf("Failed to get last L1 block header, err: %v", err)
    - 69 + 143
    - - "storage": { + return nil, nil, err
    - 70 + 144
    - - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333", + }
    - 71 + 145
    - - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000077fc57b154fcf8320df2c2e6c044aa50141c023b" + lastL1BlockNumber := lastL1BlockHeader.Number.Uint64()
    - 72 + 146
    - - } +
    - 73 + 147
    - - }, + // Calculate max L1 block number for getting next virtual batch to prove
    - 74 + 148
    - - { + maxL1BlockNumber := uint64(0)
    - 75 + 149
    - - "contractName": "PolygonZkEVMTimelock", + if a.cfg.BatchProofL1BlockConfirmations <= lastL1BlockNumber {
    - 76 + 150
    - - "balance": "0", + maxL1BlockNumber = lastL1BlockNumber - a.cfg.BatchProofL1BlockConfirmations
    - 77 + 151
    - - "nonce": "1", + }
    - 78 + 152
    - - "address": "0x02245d7B6CB0b6870d1e28AC877EE355b9588869", + log.Debugf("Max L1 block number for getting next virtual batch to prove: %d", maxL1BlockNumber)
    - 79 + 153
    - - "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c12565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611c87565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611cc9565b6107df565b3480156102be57600080fd5b506102146102cd366004611d35565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e5a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d35565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d35565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611ec2565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d35565b610927565b3480156103f457600080fd5b506101f2610403366004611ec2565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d35565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d35565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611cc9565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f33565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611ec2565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004611fe5565b610d4f565b3480156105db57600080fd5b506103166105ea36600461210e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d35565b610d94565b34801561064057600080fd5b5061025d61064f366004611d35565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611ec2565b610e8f565b6101f261068f366004611fe5565b610eb4565b3480156106a057600080fd5b506103166106af3660046121b8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611204565b6000610728898989898989610ade565b90506107348184611211565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161077096959493929190612266565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261135e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c81336113f5565b600061086c888888888888610ade565b905061087881856114ad565b610884888888886115ea565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122b1565b60405180910390a36108cd816116ee565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611204565b6109228383611797565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f48282611887565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb96959493929190612266565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611204565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611211565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc36122f1565b9050602002016020810190610cd89190612320565b8d8d86818110610cea57610cea6122f1565b905060200201358c8c87818110610d0357610d036122f1565b9050602002810190610d15919061233b565b8c8b604051610d2996959493929190612266565b60405180910390a3610d3a816123cf565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124b7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611204565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611204565b6109228383611887565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f3181336113f5565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ad565b60005b8981101561114b5760008b8b8381811061108c5761108c6122f1565b90506020020160208101906110a19190612320565b905060008a8a848181106110b7576110b76122f1565b9050602002013590503660008a8a868181106110d5576110d56122f1565b90506020028101906110e7919061233b565b915091506110f7848484846115ea565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122b1565b60405180910390a35050505080611144906123cf565b9050611070565b50611155816116ee565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f2919061257e565b156111fd5750600090565b5060025490565b61120e81336113f5565b50565b61121a82610927565b156112a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112af611161565b81101561133e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61134881426125a0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114338161193e565b61143e83602061195d565b60405160200161144f9291906125d7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612658565b6114b6826108d7565b611542576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061155e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116149291906126a9565b60006040518083038185875af1925050503d8060008114611651576040519150601f19603f3d011682016040523d82523d6000602084013e611656565b606091505b50509050806116e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b6116f7816108d7565b611783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118293390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b6060600061196c8360026126b9565b6119779060026125a0565b67ffffffffffffffff81111561198f5761198f611d4e565b6040519080825280601f01601f1916602001820160405280156119b9576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106119f0576119f06122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a5357611a536122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611a8f8460026126b9565b611a9a9060016125a0565b90505b6001811115611b37577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611adb57611adb6122f1565b1a60f81b828281518110611af157611af16122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b30816126d0565b9050611a9d565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bc457600080fd5b919050565b60008083601f840112611bdb57600080fd5b50813567ffffffffffffffff811115611bf357600080fd5b602083019150836020828501011115611c0b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c2d57600080fd5b611c3688611ba0565b965060208801359550604088013567ffffffffffffffff811115611c5957600080fd5b611c658a828b01611bc9565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611c9957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611ce257600080fd5b611ceb87611ba0565b955060208701359450604087013567ffffffffffffffff811115611d0e57600080fd5b611d1a89828a01611bc9565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d4757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611dc457611dc4611d4e565b604052919050565b600082601f830112611ddd57600080fd5b813567ffffffffffffffff811115611df757611df7611d4e565b611e2860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d7d565b818152846020838601011115611e3d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611e7057600080fd5b611e7985611ba0565b9350611e8760208601611ba0565b925060408501359150606085013567ffffffffffffffff811115611eaa57600080fd5b611eb687828801611dcc565b91505092959194509250565b60008060408385031215611ed557600080fd5b82359150611ee560208401611ba0565b90509250929050565b60008083601f840112611f0057600080fd5b50813567ffffffffffffffff811115611f1857600080fd5b6020830191508360208260051b8501011115611c0b57600080fd5b600080600080600080600080600060c08a8c031215611f5157600080fd5b893567ffffffffffffffff80821115611f6957600080fd5b611f758d838e01611eee565b909b50995060208c0135915080821115611f8e57600080fd5b611f9a8d838e01611eee565b909950975060408c0135915080821115611fb357600080fd5b50611fc08c828d01611eee565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561200157600080fd5b883567ffffffffffffffff8082111561201957600080fd5b6120258c838d01611eee565b909a50985060208b013591508082111561203e57600080fd5b61204a8c838d01611eee565b909850965060408b013591508082111561206357600080fd5b506120708b828c01611eee565b999c989b509699959896976060870135966080013595509350505050565b600082601f83011261209f57600080fd5b8135602067ffffffffffffffff8211156120bb576120bb611d4e565b8160051b6120ca828201611d7d565b92835284810182019282810190878511156120e457600080fd5b83870192505b84831015612103578235825291830191908301906120ea565b979650505050505050565b600080600080600060a0868803121561212657600080fd5b61212f86611ba0565b945061213d60208701611ba0565b9350604086013567ffffffffffffffff8082111561215a57600080fd5b61216689838a0161208e565b9450606088013591508082111561217c57600080fd5b61218889838a0161208e565b9350608088013591508082111561219e57600080fd5b506121ab88828901611dcc565b9150509295509295909350565b600080600080600060a086880312156121d057600080fd5b6121d986611ba0565b94506121e760208701611ba0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561221157600080fd5b6121ab88828901611dcc565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061229c60a08301868861221d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006122e760608301848661221d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561233257600080fd5b6108f682611ba0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261237057600080fd5b83018035915067ffffffffffffffff82111561238b57600080fd5b602001915036819003821315611c0b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612400576124006123a0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124aa57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe188360301811261246057600080fd5b8701858101903567ffffffffffffffff81111561247c57600080fd5b80360382131561248b57600080fd5b61249686828461221d565b9a87019a9550505090840190600101612421565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125055773ffffffffffffffffffffffffffffffffffffffff6124f084611ba0565b168252602092830192909101906001016124ca565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561253e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125669082018789612407565b60608401959095525050608001529695505050505050565b60006020828403121561259057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123a0565b60005b838110156125ce5781810151838201526020016125b6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161260f8160178501602088016125b3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161264c8160288401602088016125b3565b01602801949350505050565b60208152600082518060208401526126778160408501602087016125b3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123a0565b6000816126df576126df6123a0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220288c3dd40a2ba96edf066502722584177809ebdb47c0cf9ee8df6f07954c373064736f6c63430008110033", +
    - 80 + 154
    - - "storage": { + // Get virtual batch pending to generate proof
    - 81 + 155
    - - "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000015180", + batchToVerify, err := a.State.GetVirtualBatchToProve(ctx, lastVerifiedBatch.BatchNumber, maxL1BlockNumber, nil)
    - 82 + 156
    - - "0xbdd73c6ebfb442c137537be0985acf11af8e6133078bc51ef9094071cb0ca475": "0x0000000000000000000000000000000000000000000000000000000000000001", + if err != nil {
    - 83 + 157
    - - "0x92b79801e6a3d148a516c908cc0bbad93771fa74468b7757a14aa55532d092de": "0x0000000000000000000000000000000000000000000000000000000000000001", + return nil, nil, err
    - 84 + 158
    - - "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + }
    - 85 + 159
    - - "0x43e090632490f7d46c400129311fff008a7688bb3d4aebdf80607456b452cf04": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    - 86 + 160
    - - "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", + log.Infof("Found virtual batch %d pending to generate proof", batchToVerify.BatchNumber)
    - 87 + 161
    - - "0x5af21cf0316499c6925cf9be0331b8bd150a1fa4c19d24a043b45f0cf15357c3": "0x0000000000000000000000000000000000000000000000000000000000000001", + log = log.WithFields("batch", batchToVerify.BatchNumber)
    - 88 + 162
    - - "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    - 89 + 163
    - - "0xaf021eeb38644155cd697b3ce0ec4fdac818d29c448a9f9d9bafc293723c6cd8": "0x0000000000000000000000000000000000000000000000000000000000000001", + log.Info("Checking profitability to aggregate batch")
    - 90 + 164
    - - "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +
    - 91 + 165
    - - } + // pass pol collateral as zero here, bcs in smart contract fee for aggregator is not defined yet
    - 92 + 166
    - - }, + isProfitable, err := a.ProfitabilityChecker.IsProfitable(ctx, big.NewInt(0))
    - 93 + 167
    - - { + if err != nil {
    - 94 + 168
    - - "accountName": "keyless Deployer", + log.Errorf("Failed to check aggregator profitability, err: %v", err)
    - 95 + 169
    - - "balance": "0", + return nil, nil, err
    - 96 + 170
    - - "nonce": "1", + }
    - 97 + 171
    - - "address": "0xB83a574B3966F7dc1d38d162FA154F2A57D608Bb" +
    - 98 + 172
    - - }, + if !isProfitable {
    - 99 + 173
    - - { + log.Infof("Batch is not profitable, pol collateral %d", big.NewInt(0))
    - 100 + 174
    - - "accountName": "deployer", + return nil, nil, err
    - 101 + 175
    - - "balance": "0", + }
    - 102 + 176
    - - "nonce": "8", +
    - 103 + 177
    - - "address": "0xA0B02B28920812324f1cC3255bd8840867d3f227" + now := time.Now().Round(time.Microsecond)
    - 104 + 178
    - - } + proof := &state.Proof{
    - 105 + 179
    - - ] + BatchNumber: batchToVerify.BatchNumber,
    - 106 + 180
    - - } + BatchNumberFinal: batchToVerify.BatchNumber,
    - 107 + 181
    - -
    + Prover: &proverName,
    - 108 + 182
    - - ` + ProverID: &proverID,
    -
    + + + 183 + + +
    + - + GeneratingSince: &now,
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - + + 184 -
    -   -
    +
    +
    + - + }
    - + + 185 -
    -   +
    +
    + -
    - + + 186 -
    -   -
    +
    +
    + - + // Avoid other prover to process the same batch
    - + + 187 -
    -   -
    +
    +
    + - + err = a.State.AddBatchProof(ctx, proof, nil)
    - + + 188 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 189 -
    -   -
    +
    +
    + - + log.Errorf("Failed to add batch proof, err: %v", err)
    - + + 190 -
    -   -
    +
    +
    + - + return nil, nil, err
    - + + 191 -
    -   -
    +
    +
    + - + }
    - + + 192 -
    -   +
    +
    + -
    - + + 193 -
    -   -
    +
    +
    + - + return batchToVerify, proof, nil
    - + + 194 -
    -   -
    +
    +
    + - + }
    - + + 195 -
    -   +
    +
    + -
    - + + 196 -
    -   -
    +
    +
    + - + func (a *Aggregator) tryAggregateBatchProofs(ctx context.Context, prover proverInterface) (bool, error) {
    - + + 197 -
    -   -
    +
    +
    + - + proverName := prover.Name()
    - + + 198 -
    -   -
    +
    +
    + - + proverID := prover.ID()
    - + + 199 -
    -   +
    +
    + -
    - + + 200 -
    -   -
    +
    +
    + - + log := log.WithFields(
    - + + 201 -
    -   -
    +
    +
    + - + "prover", proverName,
    - + + 202 -
    -   -
    +
    +
    + - + "proverId", proverID,
    - + + 203 -
    -   -
    +
    +
    + - + "proverAddr", prover.Addr(),
    - + + 204 -
    -   -
    +
    +
    + - + )
    - + + 205 -
    -   -
    +
    +
    + - + log.Debug("tryAggregateProofs start")
    - + + 206 -
    -   +
    +
    + -
    - + + 207 -
    -   -
    +
    +
    + - + proof1, proof2, err0 := a.getAndLockBatchProofsToAggregate(ctx, prover)
    - + + 208 -
    -   -
    +
    +
    + - + if errors.Is(err0, state.ErrNotFound) {
    - + + 209 -
    -   -
    +
    +
    + - + // nothing to aggregate, swallow the error
    - + + 210 -
    -   -
    +
    +
    + - + log.Debug("Nothing to aggregate")
    - + + 211 -
    -   -
    +
    +
    + - + return false, nil
    - + + 212 -
    -   -
    +
    +
    + - + }
    - + + 213 -
    -   -
    +
    +
    + - + if err0 != nil {
    - + + 214 -
    -   -
    +
    +
    + - + return false, err0
    - + + 215 -
    -   -
    +
    +
    + - + }
    - + + 216 -
    -   +
    +
    + -
    - + + 217 -
    -   -
    +
    +
    + - + var (
    - + + 218 -
    -   -
    +
    +
    + - + aggrProofID *string
    - + + 219 -
    -   -
    +
    +
    + - + err error
    - + + 220 -
    -   -
    +
    +
    + - + )
    - + + 221 -
    -   +
    +
    + -
    - + + 222 -
    -   -
    +
    +
    + - + defer func() {
    - + + 223 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 224 -
    -   -
    +
    +
    + - + err2 := a.unlockBatchProofsToAggregate(a.ctx, proof1, proof2)
    - + + 225 -
    -   -
    +
    +
    + - + if err2 != nil {
    - + + 226 -
    -   -
    +
    +
    + - + log.Errorf("Failed to release aggregated proofs, err: %v", err2)
    - + + 227 -
    -   -
    +
    +
    + - + }
    - + + 228 -
    -   -
    +
    +
    + - + }
    - + + 229 -
    -   -
    +
    +
    + - + log.Debug("tryAggregateProofs end")
    - + + 230 -
    -   -
    +
    +
    + - + }()
    - + + 231 -
    -   +
    +
    + -
    - + + 232 -
    -   -
    +
    +
    + - + log.Infof("Aggregating proofs: %d-%d and %d-%d", proof1.BatchNumber, proof1.BatchNumberFinal, proof2.BatchNumber, proof2.BatchNumberFinal)
    - + + 233 -
    -   +
    +
    + -
    - + + 234 -
    -   -
    +
    +
    + - + batches := fmt.Sprintf("%d-%d", proof1.BatchNumber, proof2.BatchNumberFinal)
    - + + 235 -
    -   -
    +
    +
    + - + log = log.WithFields("batches", batches)
    - + + 236 -
    -   +
    +
    + -
    - + + 237 -
    -   -
    +
    +
    + - + inputProver := map[string]interface{}{
    - + + 238 -
    -   -
    +
    +
    + - + "recursive_proof_1": proof1.Proof,
    - + + 239 -
    -   -
    +
    +
    + - + "recursive_proof_2": proof2.Proof,
    - + + 240 -
    -   -
    +
    +
    + - + }
    - + + 241 -
    -   -
    +
    +
    + - + b, err := json.Marshal(inputProver)
    - + + 242 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 243 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to serialize input prover, %w", err)
    - + + 244 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 245 -
    -   -
    +
    +
    + - + return false, err
    - + + 246 -
    -   -
    +
    +
    + - + }
    - + + 247 -
    -   +
    +
    + -
    - + + 248 -
    -   -
    +
    +
    + - + proof := &state.Proof{
    - + + 249 -
    -   -
    +
    +
    + - + BatchNumber: proof1.BatchNumber,
    - + + 250 -
    -   -
    +
    +
    + - + BatchNumberFinal: proof2.BatchNumberFinal,
    - + + 251 -
    -   -
    +
    +
    + - + Prover: &proverName,
    - + + 252 -
    -   -
    +
    +
    + - + ProverID: &proverID,
    - + + 253 -
    -   -
    +
    +
    + - + InputProver: string(b),
    - + + 254 -
    -   -
    +
    +
    + - + }
    - + + 255 -
    -   +
    +
    + -
    - + + 256 -
    -   -
    +
    +
    + - + aggrProofID, err = prover.AggregatedProof(proof1.Proof, proof2.Proof)
    - + + 257 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 258 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to get aggregated proof id, %w", err)
    - + + 259 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 260 -
    -   -
    +
    +
    + - + return false, err
    - + + 261 -
    -   -
    +
    +
    + - + }
    - + + 262 -
    -   +
    +
    + -
    - + + 263 -
    -   -
    +
    +
    + - + proof.ProofID = aggrProofID
    - + + 264 -
    -   +
    +
    + -
    - + + 265 -
    -   -
    +
    +
    + - + log.Infof("Proof ID for aggregated proof: %v", *proof.ProofID)
    - + + 266 -
    -   -
    +
    +
    + - + log = log.WithFields("proofId", *proof.ProofID)
    - + + 267 -
    -   +
    +
    + -
    - + + 268 -
    -   -
    +
    +
    + - + recursiveProof, err := prover.WaitRecursiveProof(ctx, *proof.ProofID)
    - + + 269 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 270 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to get aggregated proof from prover, %w", err)
    - + + 271 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 272 -
    -   -
    +
    +
    + - + return false, err
    - + + 273 -
    -   -
    +
    +
    + - + }
    - + + 274 -
    -   +
    +
    + -
    - + + 275 -
    -   -
    +
    +
    + - + log.Info("Aggregated proof generated")
    - + + 276 -
    -   +
    +
    + -
    - + + 277 -
    -   -
    +
    +
    + - + proof.Proof = recursiveProof
    - + + 278 -
    -   +
    +
    + -
    - + + 279 -
    -   -
    +
    +
    + - + // update the state by removing the 2 aggregated proofs and storing the
    - + + 280 -
    -   -
    +
    +
    + - + // newly generated recursive proof
    - + + 281 -
    -   -
    +
    +
    + - + dbTx, err := a.State.BeginStateTransaction(ctx)
    - + + 282 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 283 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to begin transaction to update proof aggregation state, %w", err)
    - + + 284 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 285 -
    -   -
    +
    +
    + - + return false, err
    - + + 286 -
    -   -
    +
    +
    + - + }
    - + + 287 -
    -   +
    +
    + -
    - + + 288 -
    -   -
    +
    +
    + - + err = a.State.DeleteBatchProofs(ctx, proof1.BatchNumber, proof2.BatchNumberFinal, dbTx)
    - + + 289 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 290 -
    -   -
    +
    +
    + - + if err := dbTx.Rollback(ctx); err != nil {
    - - -
    -   -
    -
    +
    + 291
    -
    + +
    + - + err := fmt.Errorf("failed to rollback proof aggregation state, %w", err)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/config/types/duration.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -38,3 +38,13 @@
    - 38 + + 292 +
    -   - }, + - + log.Error(FirstToUpper(err.Error()))
    - 39 + + 293 +
    -   - } + - + return false, err
    - 40 + + 294 +
    -   - } + - + }
    - + + 295 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to delete previously aggregated proofs, %w", err)
    - + + 296 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 297 -
    -   -
    +
    +
    + - + return false, err
    - + + 298 -
    -   -
    +
    +
    + - + }
    - + + 299 -
    -   +
    +
    + -
    - + + 300 -
    -   -
    +
    +
    + - + now := time.Now().Round(time.Microsecond)
    - + + 301 -
    -   -
    +
    +
    + - + proof.GeneratingSince = &now
    - + + 302 -
    -   +
    +
    + -
    - + + 303 -
    -   -
    +
    +
    + - + err = a.State.AddBatchProof(ctx, proof, dbTx)
    - + + 304 -
    -   -
    +
    +
    + - + if err != nil {
    -
    + + + 305 + + +
    + - + if err := dbTx.Rollback(ctx); err != nil {
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 38 + + 306 +
    -   - }, + - + err := fmt.Errorf("failed to rollback proof aggregation state, %w", err)
    - 39 + + 307 +
    -   - } + - + log.Error(FirstToUpper(err.Error()))
    - 40 + + 308 +
    -   - } + - + return false, err
    - 41 + + 309 +
    - + -
    + - + }
    - 42 + + 310 +
    - + - // MarshalJSON marshalls time duration into text. + - + err = fmt.Errorf("failed to store the recursive proof, %w", err)
    - 43 + + 311 +
    - + - func (d Duration) MarshalJSON() ([]byte, error) { + - + log.Error(FirstToUpper(err.Error()))
    - 44 + + 312 +
    - + - return []byte(`"` + d.String() + `"`), nil + - + return false, err
    - 45 + + 313 +
    - + - } + - + }
    - 46 + + 314 +
    - + + -
    - 47 + + 315 +
    - + - // MarshalText marshalls time duration into text. + - + err = dbTx.Commit(ctx)
    - 48 + + 316 +
    - + - func (d *Duration) MarshalText() ([]byte, error) { + - + if err != nil {
    - 49 + + 317 +
    - + - return []byte(d.String()), nil + - + err = fmt.Errorf("failed to store the recursive proof, %w", err)
    - 50 + + 318 +
    - + - } -
    -
    -
    + - + log.Error(FirstToUpper(err.Error()))
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,9 @@
    - + + 319 -
    -   -
    +
    +
    + - + return false, err
    - + + 320 -
    -   -
    +
    +
    + - + }
    - + + 321 -
    -   +
    +
    + -
    - + + 322 -
    -   -
    +
    +
    + - + // The defer func is useless from now on, use a different variable
    - + + 323 -
    -   -
    +
    +
    + - + // name for errors (or shadow err in inner scopes) to not trigger it.
    - + + 324 -
    -   +
    +
    + -
    - + + 325 -
    -   -
    +
    +
    + - + // state is up to date, check if we can send the final proof using the
    - + + 326 -
    -   -
    +
    +
    + - + // one just crafted.
    - - -
    -   -
    -
    +
    + 327
    -
    + +
    + - + finalProofBuilt, finalProofErr := a.tryBuildFinalProof(ctx, prover, proof)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + 328 +
    - + - package dataavailability + - + if finalProofErr != nil {
    - 2 + + 329 +
    - + -
    + - + // just log the error and continue to handle the aggregated proof
    - 3 + + 330 +
    - + - // DABackendType is the data availability protocol for the CDK + - + log.Errorf("Failed trying to check if recursive proof can be verified: %v", finalProofErr)
    - 4 + + 331 +
    - + - type DABackendType string + - + }
    - 5 + + 332 +
    - + + -
    - 6 + + 333 +
    - + - const ( + - + // Prover is done, use a.ctx from now on
    - 7 + + 334 +
    - + - // DataAvailabilityCommittee is the DAC protocol backend + - +
    - 8 + + 335 +
    - + - DataAvailabilityCommittee DABackendType = "DataAvailabilityCommittee" + - + if !finalProofBuilt {
    - 9 + + 336 +
    - + - ) -
    -
    -
    + - + proof.GeneratingSince = nil
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
    @@ -0,0 +1,152 @@
    - + + 337 -
    -   +
    +
    + -
    - + + 338 -
    -   -
    +
    +
    + - + // final proof has not been generated, update the recursive proof
    - + + 339 -
    -   -
    +
    +
    + - + err := a.State.UpdateBatchProof(a.ctx, proof, nil)
    - + + 340 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 341 -
    -   -
    +
    +
    + - + err = fmt.Errorf("failed to store batch proof result, %w", err)
    - + + 342 -
    -   -
    +
    +
    + - + log.Error(FirstToUpper(err.Error()))
    - + + 343 -
    -   -
    +
    +
    + - + return false, err
    - + + 344 -
    -   -
    +
    +
    + - + }
    - + + 345 -
    -   -
    +
    +
    + - + }
    - + + 346 -
    -   +
    +
    + -
    - + + 347 -
    -   -
    +
    +
    + - + return true, nil
    - + + 348 -
    -   -
    +
    +
    + - + }
    - + + 349 -
    -   +
    +
    + -
    - + + 350 -
    -   -
    +
    +
    + - + func (a *Aggregator) getAndLockBatchProofsToAggregate(ctx context.Context, prover proverInterface) (*state.Proof, *state.Proof, error) {
    - + + 351 -
    -   -
    +
    +
    + - + log := log.WithFields(
    - + + 352 -
    -   -
    +
    +
    + - + "prover", prover.Name(),
    - + + 353 -
    -   -
    +
    +
    + - + "proverId", prover.ID(),
    - + + 354 -
    -   -
    +
    +
    + - + "proverAddr", prover.Addr(),
    - + + 355 -
    -   -
    +
    +
    + - + )
    - + + 356 -
    -   +
    +
    + -
    - + + 357 -
    -   -
    +
    +
    + - + a.StateDBMutex.Lock()
    - + + 358 -
    -   -
    +
    +
    + - + defer a.StateDBMutex.Unlock()
    - + + 359 -
    -   +
    +
    + -
    - + + 360 -
    -   -
    +
    +
    + - + proof1, proof2, err := a.State.GetBatchProofsToAggregate(ctx, nil)
    - + + 361 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 362 -
    -   -
    +
    +
    + - + return nil, nil, err
    - - + 363 + +
    + - + } +
    +
    + 364 + +
    + - +
    +
    +
    + 365 + +
    + - + // Set proofs in generating state in a single transaction +
    +
    + 366 + +
    + - + dbTx, err := a.State.BeginStateTransaction(ctx) +
    +
    + 367 + +
    + - + if err != nil { +
    +
    + 368 + +
    + - + log.Errorf("Failed to begin transaction to set proof aggregation state, err: %v", err) +
    +
    + 369 + +
    + - + return nil, nil, err +
    +
    + 370 + +
    + - + } +
    +
    + 371 + +
    + - +
    +
    +
    + 372 + +
    + - + now := time.Now().Round(time.Microsecond) +
    +
    + 373 + +
    + - + proof1.GeneratingSince = &now +
    +
    + 374 + +
    + - + err = a.State.UpdateBatchProof(ctx, proof1, dbTx) +
    +
    + 375 + +
    + - + if err == nil { +
    +
    + 376 + +
    + - + proof2.GeneratingSince = &now +
    +
    + 377 + +
    + - + err = a.State.UpdateBatchProof(ctx, proof2, dbTx) +
    +
    + 378 + +
    + - + } +
    +
    + 379 + +
    + - +
    +
    +
    + 380 + +
    + - + if err != nil { +
    +
    + 381 + +
    + - + if err := dbTx.Rollback(ctx); err != nil { +
    +
    + 382 + +
    + - + err := fmt.Errorf("failed to rollback proof aggregation state %w", err) +
    +
    + 383 + +
    + - + log.Error(FirstToUpper(err.Error())) +
    +
    + 384 + +
    + - + return nil, nil, err +
    +
    + 385 + +
    + - + } +
    +
    + 386 + +
    + - + return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err) +
    +
    + 387 + +
    + - + } +
    +
    + 388 + +
    + - +
    +
    +
    + 389 + +
    + - + err = dbTx.Commit(ctx) +
    +
    + 390 + +
    + - + if err != nil { +
    +
    + 391 + +
    + - + return nil, nil, fmt.Errorf("failed to set proof aggregation state %w", err) +
    +
    + 392 + +
    + - + } +
    +
    + 393 + +
    + - +
    +
    +
    + 394 + +
    + - + return proof1, proof2, nil +
    +
    + 395 + +
    + - + } +
    +
    + 396 + +
    + - +
    +
    +
    + 397 + +
    + - + func (a *Aggregator) unlockBatchProofsToAggregate(ctx context.Context, proof1 *state.Proof, proof2 *state.Proof) error { +
    +
    + 398 + +
    + - + // Release proofs from generating state in a single transaction +
    +
    + 399 + +
    + - + dbTx, err := a.State.BeginStateTransaction(ctx) +
    +
    + 400 + +
    + - + if err != nil { +
    +
    + 401 + +
    + - + log.Warnf("Failed to begin transaction to release proof aggregation state, err: %v", err) +
    +
    + 402 + +
    + - + return err +
    +
    + 403 + +
    + - + } +
    +
    + 404 + +
    + - +
    +
    +
    + 405 + +
    + - + proof1.GeneratingSince = nil +
    +
    + 406 + +
    + - + err = a.State.UpdateBatchProof(ctx, proof1, dbTx) +
    +
    + 407 + +
    + - + if err == nil { +
    +
    + 408 + +
    + - + proof2.GeneratingSince = nil +
    +
    + 409 + +
    + - + err = a.State.UpdateBatchProof(ctx, proof2, dbTx) +
    +
    + 410 + +
    + - + } +
    +
    + 411 + +
    + - +
    +
    +
    + 412 + +
    + - + if err != nil { +
    +
    + 413 + +
    + - + if err := dbTx.Rollback(ctx); err != nil { +
    +
    + 414 + +
    + - + err := fmt.Errorf("failed to rollback proof aggregation state: %w", err) +
    +
    + 415 + +
    + - + log.Error(FirstToUpper(err.Error())) +
    +
    + 416 + +
    + - + return err +
    +
    + 417 + +
    + - + } +
    +
    + 418 + +
    + - + return fmt.Errorf("failed to release proof aggregation state: %w", err) +
    +
    + 419 + +
    + - + } +
    +
    + 420 + +
    + - +
    +
    +
    + 421 + +
    + - + err = dbTx.Commit(ctx) +
    +
    + 422 + +
    + - + if err != nil { +
    +
    + 423 + +
    + - + return fmt.Errorf("failed to release proof aggregation state %w", err) +
    +
    + 424 + +
    + - + } +
    +
    + 425 + +
    + - +
    +
    +
    + 426 + +
    + - + return nil +
    +
    + 427 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + - - -
    +
     
    +
    + +
      @@ -35184,1538 +36351,75646 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    -
    - 1 + + -
    - + - package dataavailability +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import ( +
    +
    +   +
    - 4 + + -
    - + - "context" +
    +
    +   +
    - 5 + + -
    - + - "fmt" +
    +
    +   +
    - 6 + + -
    - + - "math/big" +
    +
    +   +
    - 7 + + -
    - + +
    +
    +  
    - 8 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/etherman/types" +
    +
    +   +
    - 9 + + -
    - + - jsontypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    +   +
    - 10 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    +   +
    - 11 + + -
    - + - "github.com/ethereum/go-ethereum/common" +
    +
    +   +
    - 12 + + -
    - + - "github.com/ethereum/go-ethereum/crypto" +
    +
    +   +
    - 13 + + -
    - + - ) +
    +
    +   +
    - 14 + + -
    - + +
    +
    +  
    - 15 + + -
    - + - const ( +
    +
    +   +
    - 16 + + -
    - + - unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s" +
    +
    +   +
    - 17 + + -
    - + - failedDataRetrievalTemplate = "failed to retrieve local data for batches %v: %s" +
    +
    +   +
    - 18 + + -
    - + - invalidBatchRetrievalArgs = "invalid L2 batch data retrieval arguments, %d != %d" +
    +
    +   +
    - 19 + + -
    - + - ) +
    +
    +   +
    - 20 + + -
    - + +
    +
    +  
    - 21 + + -
    - + - // DataAvailability implements an abstract data availability integration +
    +
    +   +
    - 22 + + -
    - + - type DataAvailability struct { +
    +
    +   +
    - 23 + + -
    - + - isTrustedSequencer bool +
    +
    +   +
    - 24 + + -
    - + +
    +
    +  
    - 25 + + -
    - + - state stateInterface +
    +
    +   +
    - 26 + + -
    - + - zkEVMClient ZKEVMClientTrustedBatchesGetter +
    +
    +   +
    - 27 + + -
    - + - backend DABackender +
    +
    +   +
    - 28 + + -
    - + +
    +
    +  
    - 29 + + -
    - + - ctx context.Context +
    +
    +   +
    - 30 + + -
    - + - } +
    +
    +   +
    - 31 + + -
    - + +
    +
    +  
    - 32 + + -
    - + - // New creates a DataAvailability instance +
    +
    +   +
    - 33 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobinner.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,7 +0,0 @@
    +
    + 1 + +
    + - + package aggregator +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import "context" +
    +
    + 4 + +
    + - +
    +
    +
    + 5 + +
    + - + func (a *Aggregator) tryGenerateBlobInnerProof(ctx context.Context, prover proverInterface) (bool, error) { +
    +
    + 6 + +
    + - + return false, nil +
    +
    + 7 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/blobouter.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,11 +0,0 @@
    +
    + 1 + +
    + - + package aggregator +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import "context" +
    +
    + 4 + +
    + - +
    +
    +
    + 5 + +
    + - + func (a *Aggregator) tryGenerateBlobOuterProof(ctx context.Context, prover proverInterface) (bool, error) { +
    +
    + 6 + +
    + - + return false, nil +
    +
    + 7 + +
    + - + } +
    +
    + 8 + +
    + - +
    +
    +
    + 9 + +
    + - + func (a *Aggregator) tryAggregateBlobOuterProofs(ctx context.Context, prover proverInterface) (bool, error) { +
    +
    + 10 + +
    + - + return false, nil +
    +
    + 11 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/config.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -8,6 +8,17 @@
    +
    + 8 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/encoding" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 11 + +
    +   + // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int +
    +
    + 12 + +
    +   + type TokenAmountWithDecimals struct { +
    +
    + 13 + +
    +   + *big.Int `validate:"required"` +
    +
    +
    @@ -89,6 +100,18 @@
    +
    + 89 + +
    +   + // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog +
    +
    + 90 + +
    +   + UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"` +
    +
    + 91 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 92 + +
    +   + // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch +
    +
    + 93 + +
    +   + BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"` +
    +
    + 94 + +
    +   + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 8 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/encoding" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
    +   +
    +
    +
    + 11 + +
    + + + // SettlementBackend is the type of the settlement backend +
    +
    + 12 + +
    + + + type SettlementBackend string +
    +
    + 13 + +
    + + +
    +
    +
    + 14 + +
    + + + const ( +
    +
    + 15 + +
    + + + // AggLayer settlement backend +
    +
    + 16 + +
    + + + AggLayer SettlementBackend = "agglayer" +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + // L1 settlement backend +
    +
    + 19 + +
    + + + L1 SettlementBackend = "l1" +
    +
    + 20 + +
    + + + ) +
    +
    + 21 + +
    + + +
    +
    +
    + 22 + +
    +   + // TokenAmountWithDecimals is a wrapper type that parses token amount with decimals to big int +
    +
    + 23 + +
    +   + type TokenAmountWithDecimals struct { +
    +
    + 24 + +
    +   + *big.Int `validate:"required"` +
    +
    +
     
    +
    + 100 + +
    +   + // UpgradeEtrogBatchNumber is the number of the first batch after upgrading to etrog +
    +
    + 101 + +
    +   + UpgradeEtrogBatchNumber uint64 `mapstructure:"UpgradeEtrogBatchNumber"` +
    +
    + 102 + +
    +   +
    +
    +
    + 103 + +
    + + + // SettlementBackend configuration defines how a final ZKP should be settled. Directly to L1 or over the Beethoven service. +
    +
    + 104 + +
    + + + SettlementBackend SettlementBackend `mapstructure:"SettlementBackend"` +
    +
    + 105 + +
    + + +
    +
    +
    + 106 + +
    + + + // AggLayerTxTimeout is the interval time to wait for a tx to be mined from the agglayer +
    +
    + 107 + +
    + + + AggLayerTxTimeout types.Duration `mapstructure:"AggLayerTxTimeout"` +
    +
    + 108 + +
    + + +
    +
    +
    + 109 + +
    + + + // AggLayerURL url of the agglayer service +
    +
    + 110 + +
    + + + AggLayerURL string `mapstructure:"AggLayerURL"` +
    +
    + 111 + +
    + + +
    +
    +
    + 112 + +
    + + + // SequencerPrivateKey Private key of the trusted sequencer +
    +
    + 113 + +
    + + + SequencerPrivateKey types.KeystoreFileConfig `mapstructure:"SequencerPrivateKey"` +
    +
    + 114 + +
    + + +
    +
    +
    + 115 + +
    +   + // BatchProofL1BlockConfirmations is number of L1 blocks to consider we can generate the proof for a virtual batch +
    +
    + 116 + +
    +   + BatchProofL1BlockConfirmations uint64 `mapstructure:"BatchProofL1BlockConfirmations"` +
    +
    + 117 + +
    +   + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/final.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,288 +0,0 @@
    +
    + 1 + +
    + - + package aggregator +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "context" +
    +
    + 5 + +
    + - + "errors" +
    +
    + 6 + +
    + - + "fmt" +
    +
    + 7 + +
    + - + "time" +
    +
    + 8 + +
    + - +
    +
    +
    + 9 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/aggregator/prover" +
    +
    + 10 + +
    + - + ethmanTypes "github.com/0xPolygonHermez/zkevm-node/etherman/types" +
    +
    + 11 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/ethtxmanager" +
    +
    + 12 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 13 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 14 + +
    + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 15 + +
    + - + "github.com/jackc/pgx/v4" +
    +
    + 16 + +
    + - + ) +
    +
    + 17 + +
    + - +
    +
    +
    + 18 + +
    + - + // tryBuildFinalProof checks if the provided proof is eligible to be used to +
    +
    + 19 + +
    + - + // build the final proof. If no proof is provided it looks for a previously +
    +
    + 20 + +
    + - + // generated proof. If the proof is eligible, then the final proof generation +
    +
    + 21 + +
    + - + // is triggered. +
    +
    + 22 + +
    + - + func (a *Aggregator) tryBuildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (bool, error) { +
    +
    + 23 + +
    + - + proverName := prover.Name() +
    +
    + 24 + +
    + - + proverID := prover.ID() +
    +
    + 25 + +
    + - +
    +
    +
    + 26 + +
    + - + log := log.WithFields( +
    +
    + 27 + +
    + - + "prover", proverName, +
    +
    + 28 + +
    + - + "proverId", proverID, +
    +
    + 29 + +
    + - + "proverAddr", prover.Addr(), +
    +
    + 30 + +
    + - + ) +
    +
    + 31 + +
    + - + log.Debug("tryBuildFinalProof start") +
    +
    + 32 + +
    + - +
    +
    +
    + 33 + +
    + - + var err error +
    +
    + 34 + +
    + - + if !a.canVerifyProof() { +
    +
    + 35 + +
    + - + log.Debug("Time to verify proof not reached or proof verification in progress") +
    +
    + 36 + +
    + - + return false, nil +
    +
    + 37 + +
    + - + } +
    +
    + 38 + +
    + - + log.Debug("Send final proof time reached") +
    +
    + 39 + +
    + - +
    +
    +
    + 40 + +
    + - + for !a.isSynced(ctx, nil) { +
    +
    + 41 + +
    + - + log.Info("Waiting for synchronizer to sync...") +
    +
    + 42 + +
    + - + time.Sleep(a.cfg.RetryTime.Duration) +
    +
    + 43 + +
    + - + continue +
    +
    + 44 + +
    + - + } +
    +
    + 45 + +
    + - +
    +
    +
    + 46 + +
    + - + var lastVerifiedBatchNum uint64 +
    +
    + 47 + +
    + - + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) +
    +
    + 48 + +
    + - + if err != nil && !errors.Is(err, state.ErrNotFound) { +
    +
    + 49 + +
    + - + return false, fmt.Errorf("failed to get last verified batch, %w", err) +
    +
    + 50 + +
    + - + } +
    +
    + 51 + +
    + - + if lastVerifiedBatch != nil { +
    +
    + 52 + +
    + - + lastVerifiedBatchNum = lastVerifiedBatch.BatchNumber +
    +
    + 53 + +
    + - + } +
    +
    + 54 + +
    + - +
    +
    +
    + 55 + +
    + - + if proof == nil { +
    +
    + 56 + +
    + - + // we don't have a proof generating at the moment, check if we +
    +
    + 57 + +
    + - + // have a proof ready to verify +
    +
    + 58 + +
    + - +
    +
    +
    + 59 + +
    + - + proof, err = a.getAndLockProofReadyForFinal(ctx, prover, lastVerifiedBatchNum) +
    +
    + 60 + +
    + - + if errors.Is(err, state.ErrNotFound) { +
    +
    + 61 + +
    + - + // nothing to verify, swallow the error +
    +
    + 62 + +
    + - + log.Debug("No proof ready to verify") +
    +
    + 63 + +
    + - + return false, nil +
    +
    + 64 + +
    + - + } +
    +
    + 65 + +
    + - + if err != nil { +
    +
    + 66 + +
    + - + return false, err +
    +
    + 67 + +
    + - + } +
    +
    + 68 + +
    + - +
    +
    +
    + 69 + +
    + - + defer func() { +
    +
    + 70 + +
    + - + if err != nil { +
    +
    + 71 + +
    + - + // Set the generating state to false for the proof ("unlock" it) +
    +
    + 72 + +
    + - + proof.GeneratingSince = nil +
    +
    + 73 + +
    + - + err2 := a.State.UpdateBatchProof(a.ctx, proof, nil) +
    +
    + 74 + +
    + - + if err2 != nil { +
    +
    + 75 + +
    + - + log.Errorf("Failed to unlock proof: %v", err2) +
    +
    + 76 + +
    + - + } +
    +
    + 77 + +
    + - + } +
    +
    + 78 + +
    + - + }() +
    +
    + 79 + +
    + - + } else { +
    +
    + 80 + +
    + - + // we do have a proof generating at the moment, check if it is +
    +
    + 81 + +
    + - + // eligible to be verified +
    +
    + 82 + +
    + - + eligible, err := a.validateEligibleFinalProof(ctx, proof, lastVerifiedBatchNum) +
    +
    + 83 + +
    + - + if err != nil { +
    +
    + 84 + +
    + - + return false, fmt.Errorf("failed to validate eligible final proof, %w", err) +
    +
    + 85 + +
    + - + } +
    +
    + 86 + +
    + - + if !eligible { +
    +
    + 87 + +
    + - + return false, nil +
    +
    + 88 + +
    + - + } +
    +
    + 89 + +
    + - + } +
    +
    + 90 + +
    + - +
    +
    +
    + 91 + +
    + - + log = log.WithFields( +
    +
    + 92 + +
    + - + "proofId", *proof.ProofID, +
    +
    + 93 + +
    + - + "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal), +
    +
    + 94 + +
    + - + ) +
    +
    + 95 + +
    + - +
    +
    +
    + 96 + +
    + - + // at this point we have an eligible proof, build the final one using it +
    +
    + 97 + +
    + - + finalProof, err := a.buildFinalProof(ctx, prover, proof) +
    +
    + 98 + +
    + - + if err != nil { +
    +
    + 99 + +
    + - + err = fmt.Errorf("failed to build final proof, %w", err) +
    +
    + 100 + +
    + - + log.Error(FirstToUpper(err.Error())) +
    +
    + 101 + +
    + - + return false, err +
    +
    + 102 + +
    + - + } +
    +
    + 103 + +
    + - +
    +
    +
    + 104 + +
    + - + msg := finalProofMsg{ +
    +
    + 105 + +
    + - + proverName: proverName, +
    +
    + 106 + +
    + - + proverID: proverID, +
    +
    + 107 + +
    + - + recursiveProof: proof, +
    +
    + 108 + +
    + - + finalProof: finalProof, +
    +
    + 109 + +
    + - + } +
    +
    + 110 + +
    + - +
    +
    +
    + 111 + +
    + - + select { +
    +
    + 112 + +
    + - + case <-a.ctx.Done(): +
    +
    + 113 + +
    + - + return false, a.ctx.Err() +
    +
    + 114 + +
    + - + case a.finalProof <- msg: +
    +
    + 115 + +
    + - + } +
    +
    + 116 + +
    + - +
    +
    +
    + 117 + +
    + - + log.Debug("tryBuildFinalProof end") +
    +
    + 118 + +
    + - + return true, nil +
    +
    + 119 + +
    + - + } +
    +
    + 120 + +
    + - +
    +
    +
    + 121 + +
    + - + // buildFinalProof builds and return the final proof for an aggregated/batch proof. +
    +
    + 122 + +
    + - + func (a *Aggregator) buildFinalProof(ctx context.Context, prover proverInterface, proof *state.Proof) (*prover.FinalProof, error) { +
    +
    + 123 + +
    + - + log := log.WithFields( +
    +
    + 124 + +
    + - + "prover", prover.Name(), +
    +
    + 125 + +
    + - + "proverId", prover.ID(), +
    +
    + 126 + +
    + - + "proverAddr", prover.Addr(), +
    +
    + 127 + +
    + - + "recursiveProofId", *proof.ProofID, +
    +
    + 128 + +
    + - + "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal), +
    +
    + 129 + +
    + - + ) +
    +
    + 130 + +
    + - + log.Info("Generating final proof") +
    +
    + 131 + +
    + - +
    +
    +
    + 132 + +
    + - + finalProofID, err := prover.FinalProof(proof.Proof, a.cfg.SenderAddress) +
    +
    + 133 + +
    + - + if err != nil { +
    +
    + 134 + +
    + - + return nil, fmt.Errorf("failed to get final proof id: %w", err) +
    +
    + 135 + +
    + - + } +
    +
    + 136 + +
    + - + proof.ProofID = finalProofID +
    +
    + 137 + +
    + - +
    +
    +
    + 138 + +
    + - + log.Infof("Final proof ID for batches [%d-%d]: %s", proof.BatchNumber, proof.BatchNumberFinal, *proof.ProofID) +
    +
    + 139 + +
    + - + log = log.WithFields("finalProofId", finalProofID) +
    +
    + 140 + +
    + - +
    +
    +
    + 141 + +
    + - + finalProof, err := prover.WaitFinalProof(ctx, *proof.ProofID) +
    +
    + 142 + +
    + - + if err != nil { +
    +
    + 143 + +
    + - + return nil, fmt.Errorf("failed to get final proof from prover: %w", err) +
    +
    + 144 + +
    + - + } +
    +
    + 145 + +
    + - +
    +
    +
    + 146 + +
    + - + log.Info("Final proof generated") +
    +
    + 147 + +
    + - +
    +
    +
    + 148 + +
    + - + // mock prover sanity check +
    +
    + 149 + +
    + - + if string(finalProof.Public.NewStateRoot) == mockedStateRoot && string(finalProof.Public.NewLocalExitRoot) == mockedLocalExitRoot { +
    +
    + 150 + +
    + - + // This local exit root and state root come from the mock +
    +
    + 151 + +
    + - + // prover, use the one captured by the executor instead +
    +
    + 152 + +
    + - + finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil) +
    +
    + 153 + +
    + - + if err != nil { +
    +
    + 154 + +
    + - + return nil, fmt.Errorf("failed to retrieve batch with number [%d]", proof.BatchNumberFinal) +
    +
    + 155 + +
    + - + } +
    +
    + 156 + +
    + - + log.Warnf("NewLocalExitRoot and NewStateRoot look like a mock values, using values from executor instead: LER: %v, SR: %v", +
    +
    + 157 + +
    + - + finalBatch.LocalExitRoot.TerminalString(), finalBatch.StateRoot.TerminalString()) +
    +
    + 158 + +
    + - + finalProof.Public.NewStateRoot = finalBatch.StateRoot.Bytes() +
    +
    + 159 + +
    + - + finalProof.Public.NewLocalExitRoot = finalBatch.LocalExitRoot.Bytes() +
    +
    + 160 + +
    + - + } +
    +
    + 161 + +
    + - +
    +
    +
    + 162 + +
    + - + return finalProof, nil +
    +
    + 163 + +
    + - + } +
    +
    + 164 + +
    + - +
    +
    +
    + 165 + +
    + - + func (a *Aggregator) getAndLockProofReadyForFinal(ctx context.Context, prover proverInterface, lastVerifiedBatchNum uint64) (*state.Proof, error) { +
    +
    + 166 + +
    + - + a.StateDBMutex.Lock() +
    +
    + 167 + +
    + - + defer a.StateDBMutex.Unlock() +
    +
    + 168 + +
    + - +
    +
    +
    + 169 + +
    + - + // Get proof ready to be verified +
    +
    + 170 + +
    + - + proofToVerify, err := a.State.GetProofReadyForFinal(ctx, lastVerifiedBatchNum, nil) +
    +
    + 171 + +
    + - + if err != nil { +
    +
    + 172 + +
    + - + return nil, err +
    +
    + 173 + +
    + - + } +
    +
    + 174 + +
    + - +
    +
    +
    + 175 + +
    + - + now := time.Now().Round(time.Microsecond) +
    +
    + 176 + +
    + - + proofToVerify.GeneratingSince = &now +
    +
    + 177 + +
    + - +
    +
    +
    + 178 + +
    + - + err = a.State.UpdateBatchProof(ctx, proofToVerify, nil) +
    +
    + 179 + +
    + - + if err != nil { +
    +
    + 180 + +
    + - + return nil, err +
    +
    + 181 + +
    + - + } +
    +
    + 182 + +
    + - +
    +
    +
    + 183 + +
    + - + return proofToVerify, nil +
    +
    + 184 + +
    + - + } +
    +
    + 185 + +
    + - +
    +
    +
    + 186 + +
    + - + func (a *Aggregator) validateEligibleFinalProof(ctx context.Context, proof *state.Proof, lastVerifiedBatchNum uint64) (bool, error) { +
    +
    + 187 + +
    + - + batchNumberToVerify := lastVerifiedBatchNum + 1 +
    +
    + 188 + +
    + - +
    +
    +
    + 189 + +
    + - + if proof.BatchNumber != batchNumberToVerify { +
    +
    + 190 + +
    + - + if proof.BatchNumber < batchNumberToVerify && proof.BatchNumberFinal >= batchNumberToVerify { +
    +
    + 191 + +
    + - + // We have a proof that contains some batches below the last batch verified, anyway can be eligible as final proof +
    +
    + 192 + +
    + - + log.Warnf("Proof %d-%d contains some batches lower than last batch verified %d. Check anyway if it is eligible", proof.BatchNumber, proof.BatchNumberFinal, lastVerifiedBatchNum) +
    +
    + 193 + +
    + - + } else if proof.BatchNumberFinal < batchNumberToVerify { +
    +
    + 194 + +
    + - + // We have a proof that contains batches below that the last batch verified, we need to delete this proof +
    +
    + 195 + +
    + - + log.Warnf("Proof %d-%d lower than next batch to verify %d. Deleting it", proof.BatchNumber, proof.BatchNumberFinal, batchNumberToVerify) +
    +
    + 196 + +
    + - + err := a.State.DeleteBatchProofs(ctx, proof.BatchNumber, proof.BatchNumberFinal, nil) +
    +
    + 197 + +
    + - + if err != nil { +
    +
    + 198 + +
    + - + return false, fmt.Errorf("failed to delete discarded proof, err: %w", err) +
    +
    + 199 + +
    + - + } +
    +
    + 200 + +
    + - + return false, nil +
    +
    + 201 + +
    + - + } else { +
    +
    + 202 + +
    + - + log.Debugf("Proof batch number %d is not the following to last verfied batch number %d", proof.BatchNumber, lastVerifiedBatchNum) +
    +
    + 203 + +
    + - + return false, nil +
    +
    + 204 + +
    + - + } +
    +
    + 205 + +
    + - + } +
    +
    + 206 + +
    + - +
    +
    +
    + 207 + +
    + - + bComplete, err := a.State.CheckProofContainsCompleteSequences(ctx, proof, nil) +
    +
    + 208 + +
    + - + if err != nil { +
    +
    + 209 + +
    + - + return false, fmt.Errorf("failed to check if proof contains complete sequences, %w", err) +
    +
    + 210 + +
    + - + } +
    +
    + 211 + +
    + - + if !bComplete { +
    +
    + 212 + +
    + - + log.Infof("Recursive proof %d-%d not eligible to be verified: not containing complete sequences", proof.BatchNumber, proof.BatchNumberFinal) +
    +
    + 213 + +
    + - + return false, nil +
    +
    + 214 + +
    + - + } +
    +
    + 215 + +
    + - + return true, nil +
    +
    + 216 + +
    + - + } +
    +
    + 217 + +
    + - +
    +
    +
    + 218 + +
    + - + // This function waits to receive a final proof from a prover. Once it receives +
    +
    + 219 + +
    + - + // the proof, it performs these steps in order: +
    +
    + 220 + +
    + - + // - send the final proof to L1 +
    +
    + 221 + +
    + - + // - wait for the synchronizer to catch up +
    +
    + 222 + +
    + - + // - clean up the cache of recursive proofs +
    +
    + 223 + +
    + - + func (a *Aggregator) sendFinalProof() { +
    +
    + 224 + +
    + - + for { +
    +
    + 225 + +
    + - + select { +
    +
    + 226 + +
    + - + case <-a.ctx.Done(): +
    +
    + 227 + +
    + - + return +
    +
    + 228 + +
    + - + case msg := <-a.finalProof: +
    +
    + 229 + +
    + - + ctx := a.ctx +
    +
    + 230 + +
    + - + proof := msg.recursiveProof +
    +
    + 231 + +
    + - +
    +
    +
    + 232 + +
    + - + log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    +
    + 233 + +
    + - + log.Info("Verifying final proof with ethereum smart contract") +
    +
    + 234 + +
    + - +
    +
    +
    + 235 + +
    + - + a.startProofVerification() +
    +
    + 236 + +
    + - +
    +
    +
    + 237 + +
    + - + finalBatch, err := a.State.GetBatchByNumber(ctx, proof.BatchNumberFinal, nil) +
    +
    + 238 + +
    + - + if err != nil { +
    +
    + 239 + +
    + - + log.Errorf("Failed to retrieve batch with number [%d]: %v", proof.BatchNumberFinal, err) +
    +
    + 240 + +
    + - + a.endProofVerification() +
    +
    + 241 + +
    + - + continue +
    +
    + 242 + +
    + - + } +
    +
    + 243 + +
    + - +
    +
    +
    + 244 + +
    + - + inputs := ethmanTypes.FinalProofInputs{ +
    +
    + 245 + +
    + - + FinalProof: msg.finalProof, +
    +
    + 246 + +
    + - + NewLocalExitRoot: finalBatch.LocalExitRoot.Bytes(), +
    +
    + 247 + +
    + - + NewStateRoot: finalBatch.StateRoot.Bytes(), +
    +
    + 248 + +
    + - + } +
    +
    + 249 + +
    + - +
    +
    +
    + 250 + +
    + - + log.Infof("Final proof inputs: NewLocalExitRoot [%#x], NewStateRoot [%#x]", inputs.NewLocalExitRoot, inputs.NewStateRoot) +
    +
    + 251 + +
    + - +
    +
    +
    + 252 + +
    + - + // add batch verification to be monitored +
    +
    + 253 + +
    + - + sender := common.HexToAddress(a.cfg.SenderAddress) +
    +
    + 254 + +
    + - + to, data, err := a.Ethman.BuildTrustedVerifyBatchesTxData(proof.BatchNumber-1, proof.BatchNumberFinal, &inputs, sender) +
    +
    + 255 + +
    + - + if err != nil { +
    +
    + 256 + +
    + - + log.Errorf("Error estimating batch verification to add to eth tx manager: %v", err) +
    +
    + 257 + +
    + - + a.handleErrorSendFinalProof(ctx, proof) +
    +
    + 258 + +
    + - + continue +
    +
    + 259 + +
    + - + } +
    +
    + 260 + +
    + - + monitoredTxID := buildMonitoredTxID(proof.BatchNumber, proof.BatchNumberFinal) +
    +
    + 261 + +
    + - + err = a.EthTxManager.Add(ctx, ethTxManagerOwner, monitoredTxID, sender, to, nil, data, a.cfg.GasOffset, nil) +
    +
    + 262 + +
    + - + if err != nil { +
    +
    + 263 + +
    + - + mTxLogger := ethtxmanager.CreateLogger(ethTxManagerOwner, monitoredTxID, sender, to) +
    +
    + 264 + +
    + - + mTxLogger.Errorf("Error to add batch verification tx to eth tx manager: %v", err) +
    +
    + 265 + +
    + - + a.handleErrorSendFinalProof(ctx, proof) +
    +
    + 266 + +
    + - + continue +
    +
    + 267 + +
    + - + } +
    +
    + 268 + +
    + - +
    +
    +
    + 269 + +
    + - + // process monitored batch verifications before starting a next cycle +
    +
    + 270 + +
    + - + a.EthTxManager.ProcessPendingMonitoredTxs(ctx, ethTxManagerOwner, func(result ethtxmanager.MonitoredTxResult, dbTx pgx.Tx) { +
    +
    + 271 + +
    + - + a.handleMonitoredTxResult(result) +
    +
    + 272 + +
    + - + }, nil) +
    +
    + 273 + +
    + - +
    +
    +
    + 274 + +
    + - + a.resetVerifyProofTime() +
    +
    + 275 + +
    + - + a.endProofVerification() +
    +
    + 276 + +
    + - + } +
    +
    + 277 + +
    + - + } +
    +
    + 278 + +
    + - + } +
    +
    + 279 + +
    + - +
    +
    +
    + 280 + +
    + - + func (a *Aggregator) handleErrorSendFinalProof(ctx context.Context, proof *state.Proof) { +
    +
    + 281 + +
    + - + log := log.WithFields("proofId", proof.ProofID, "batches", fmt.Sprintf("%d-%d", proof.BatchNumber, proof.BatchNumberFinal)) +
    +
    + 282 + +
    + - + proof.GeneratingSince = nil +
    +
    + 283 + +
    + - + err := a.State.UpdateBatchProof(ctx, proof, nil) +
    +
    + 284 + +
    + - + if err != nil { +
    +
    + 285 + +
    + - + log.Errorf("Failed updating proof state (false): %v", err) +
    +
    + 286 + +
    + - + } +
    +
    + 287 + +
    + - + a.endProofVerification() +
    +
    + 288 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -38,6 +38,7 @@
    +
    + 38 + +
    +   +
    +
    +
    + 39 + +
    +   + // etherman contains the methods required to interact with ethereum +
    +
    + 40 + +
    +   + type etherman interface { +
    +
    + + +
    +   +
    +
    +
    + 41 + +
    +   + GetLatestVerifiedBatchNum() (uint64, error) +
    +
    + 42 + +
    +   + BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error) +
    +
    + 43 + +
    +   + GetLatestBlockHeader(ctx context.Context) (*types.Header, error) +
    +
    +
    @@ -54,16 +55,16 @@
    +
    + 54 + +
    +   + BeginStateTransaction(ctx context.Context) (pgx.Tx, error) +
    +
    + 55 + +
    +   + CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error) +
    +
    + 56 + +
    +   + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) +
    +
    + 57 + +
    + - + GetProofReadyForFinal(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) +
    +
    + 58 + +
    +   + GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 59 + +
    + - + GetBatchProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) +
    +
    + 60 + +
    +   + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 61 + +
    + - + AddBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error +
    +
    + 62 + +
    + - + UpdateBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error +
    +
    + 63 + +
    + - + DeleteBatchProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error +
    +
    + 64 + +
    + - + DeleteUngeneratedBatchProofs(ctx context.Context, dbTx pgx.Tx) error +
    +
    + 65 + +
    + - + CleanupBatchProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    +
    + 66 + +
    + - + CleanupLockedBatchProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) +
    +
    + 67 + +
    +   + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) +
    +
    + 68 + +
    +   + GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) +
    +
    + 69 + +
    +   + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 38 + +
    +   +
    +
    +
    + 39 + +
    +   + // etherman contains the methods required to interact with ethereum +
    +
    + 40 + +
    +   + type etherman interface { +
    +
    + 41 + +
    + + + GetRollupId() uint32 +
    +
    + 42 + +
    +   + GetLatestVerifiedBatchNum() (uint64, error) +
    +
    + 43 + +
    +   + BuildTrustedVerifyBatchesTxData(lastVerifiedBatch, newVerifiedBatch uint64, inputs *ethmanTypes.FinalProofInputs, beneficiary common.Address) (to *common.Address, data []byte, err error) +
    +
    + 44 + +
    +   + GetLatestBlockHeader(ctx context.Context) (*types.Header, error) +
    +
    +
     
    +
    + 55 + +
    +   + BeginStateTransaction(ctx context.Context) (pgx.Tx, error) +
    +
    + 56 + +
    +   + CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error) +
    +
    + 57 + +
    +   + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) +
    +
    + 58 + +
    + + + GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) +
    +
    + 59 + +
    +   + GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 60 + +
    + + + GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) +
    +
    + 61 + +
    +   + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 62 + +
    + + + AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error +
    +
    + 63 + +
    + + + UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error +
    +
    + 64 + +
    + + + DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error +
    +
    + 65 + +
    + + + DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error +
    +
    + 66 + +
    + + + CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    +
    + 67 + +
    + + + CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) +
    +
    + 68 + +
    +   + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) +
    +
    + 69 + +
    +   + GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) +
    +
    + 70 + +
    +   + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/beacon_client.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,68 +0,0 @@
    +
    + 1 + +
    + - + //go:generate oapi-codegen -package=examplepkg -generate=types,client,spec -o=examplepkg/example-client.go beacon-node-oapi.json +
    +
    + 2 + +
    + - + package beaconclient +
    +
    + 3 + +
    + - +
    +
    +
    + 4 + +
    + - + import ( +
    +
    + 5 + +
    + - + "context" +
    +
    + 6 + +
    + - + "encoding/json" +
    +
    + 7 + +
    + - + "fmt" +
    +
    + 8 + +
    + - + "io" +
    +
    + 9 + +
    + - + "net/http" +
    +
    + 10 + +
    + - + ) +
    +
    + 11 + +
    + - +
    +
    +
    + 12 + +
    + - + // BeaconAPIClient client of Beacon API +
    +
    + 13 + +
    + - + // https://ethereum.github.io/beacon-APIs/ +
    +
    + 14 + +
    + - + type BeaconAPIClient struct { +
    +
    + 15 + +
    + - + urlBase string +
    +
    + 16 + +
    + - + } +
    +
    + 17 + +
    + - +
    +
    +
    + 18 + +
    + - + // NewBeaconAPIClient creates an instance of client +
    +
    + 19 + +
    + - + func NewBeaconAPIClient(url string) *BeaconAPIClient { +
    +
    + 20 + +
    + - + return &BeaconAPIClient{ +
    +
    + 21 + +
    + - + urlBase: url, +
    +
    + 22 + +
    + - + } +
    +
    + 23 + +
    + - + } +
    +
    + 24 + +
    + - +
    +
    +
    + 25 + +
    + - + // BeaconAPIResponse represents the response of the beacon API +
    +
    + 26 + +
    + - + type BeaconAPIResponse struct { +
    +
    + 27 + +
    + - + Result json.RawMessage +
    +
    + 28 + +
    + - + } +
    +
    + 29 + +
    + - +
    +
    +
    + 30 + +
    + - + // JSONRPCBeaconCall executes restapi call to beacon-api node +
    +
    + 31 + +
    + - + func JSONRPCBeaconCall(ctx context.Context, urlBase, methodPath string) (BeaconAPIResponse, error) { +
    +
    + 32 + +
    + - + //url := path.Join(urlBase, methodPath) +
    +
    + 33 + +
    + - + url := fmt.Sprintf("%s%s", urlBase, methodPath) +
    +
    + 34 + +
    + - + httpReq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody) +
    +
    + 35 + +
    + - + if err != nil { +
    +
    + 36 + +
    + - + return BeaconAPIResponse{}, err +
    +
    + 37 + +
    + - + } +
    +
    + 38 + +
    + - + httpReq.Header.Add("Content-type", "application/json") +
    +
    + 39 + +
    + - +
    +
    +
    + 40 + +
    + - + httpRes, err := http.DefaultClient.Do(httpReq) +
    +
    + 41 + +
    + - + if err != nil { +
    +
    + 42 + +
    + - + return BeaconAPIResponse{}, err +
    +
    + 43 + +
    + - + } +
    +
    + 44 + +
    + - +
    +
    +
    + 45 + +
    + - + resBody, err := io.ReadAll(httpRes.Body) +
    +
    + 46 + +
    + - + if err != nil { +
    +
    + 47 + +
    + - + return BeaconAPIResponse{}, err +
    +
    + 48 + +
    + - + } +
    +
    + 49 + +
    + - + defer httpRes.Body.Close() +
    +
    + 50 + +
    + - +
    +
    +
    + 51 + +
    + - + if httpRes.StatusCode != http.StatusOK { +
    +
    + 52 + +
    + - + return BeaconAPIResponse{}, fmt.Errorf("BeaconClient fails url:%s status_code:%v response:%v", url, httpRes.StatusCode, string(resBody)) +
    +
    + 53 + +
    + - + } +
    +
    + 54 + +
    + - +
    +
    +
    + 55 + +
    + - + return BeaconAPIResponse{ +
    +
    + 56 + +
    + - + Result: resBody, +
    +
    + 57 + +
    + - + }, nil +
    +
    + 58 + +
    + - + } +
    +
    + 59 + +
    + - +
    +
    +
    + 60 + +
    + - + func unserializeGenericResponse[T any](response BeaconAPIResponse) (T, error) { +
    +
    + 61 + +
    + - + var result T +
    +
    + 62 + +
    + - + err := json.Unmarshal(response.Result, &result) +
    +
    + 63 + +
    + - + if err != nil { +
    +
    + 64 + +
    + - + var zero T +
    +
    + 65 + +
    + - + return zero, err +
    +
    + 66 + +
    + - + } +
    +
    + 67 + +
    + - + return result, nil +
    +
    + 68 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_beacon_blob_sidecars.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,92 +0,0 @@
    +
    + 1 + +
    + - + package beaconclient +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "context" +
    +
    + 5 + +
    + - + "fmt" +
    +
    + 6 + +
    + - + "strconv" +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 9 + +
    + - + ) +
    +
    + 10 + +
    + - +
    +
    +
    + 11 + +
    + - + const beaconBlobSidecarsPath = "/eth/v1/beacon/blob_sidecars/" +
    +
    + 12 + +
    + - +
    +
    +
    + 13 + +
    + - + // BeaconBlobSidecarsResponse represents the response of the beacon blob sidecars endpoint +
    +
    + 14 + +
    + - + type BeaconBlobSidecarsResponse struct { +
    +
    + 15 + +
    + - + Sidecars map[uint64]BeaconBlobSidecarResponse +
    +
    + 16 + +
    + - + } +
    +
    + 17 + +
    + - +
    +
    +
    + 18 + +
    + - + // BeaconBlobSidecarResponse represents the response of the config spec endpoint +
    +
    + 19 + +
    + - + type BeaconBlobSidecarResponse struct { +
    +
    + 20 + +
    + - + Index uint64 +
    +
    + 21 + +
    + - + KzgCommitment string +
    +
    + 22 + +
    + - + Blob []byte +
    +
    + 23 + +
    + - + } +
    +
    + 24 + +
    + - +
    +
    +
    + 25 + +
    + - + type beaconBlobSidecarsResponseInternal struct { +
    +
    + 26 + +
    + - + Data []struct { +
    +
    + 27 + +
    + - + Index string `json:"index"` +
    +
    + 28 + +
    + - + Blob string `json:"blob"` +
    +
    + 29 + +
    + - + KzgCommitment string `json:"kzg_commitment"` +
    +
    + 30 + +
    + - + KzgProof string `json:"kzg_proof"` +
    +
    + 31 + +
    + - + SignedBlockHeader struct { +
    +
    + 32 + +
    + - + Message struct { +
    +
    + 33 + +
    + - + Slot string `json:"slot"` +
    +
    + 34 + +
    + - + ProposerIndex string `json:"proposer_index"` +
    +
    + 35 + +
    + - + ParentRoot string `json:"parent_root"` +
    +
    + 36 + +
    + - + StateRoot string `json:"state_root"` +
    +
    + 37 + +
    + - + BodyRoot string `json:"body_root"` +
    +
    + 38 + +
    + - + } `json:"message"` +
    +
    + 39 + +
    + - + Signature string `json:"signature"` +
    +
    + 40 + +
    + - + } `json:"signed_block_header"` +
    +
    + 41 + +
    + - + KzgCommitmentInclusionProof []string `json:"kzg_commitment_inclusion_proof"` +
    +
    + 42 + +
    + - + } `json:"data"` +
    +
    + 43 + +
    + - + } +
    +
    + 44 + +
    + - +
    +
    +
    + 45 + +
    + - + func has0xPrefix(str string) bool { +
    +
    + 46 + +
    + - + return len(str) >= 2 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X') +
    +
    + 47 + +
    + - + } +
    +
    + 48 + +
    + - +
    +
    +
    + 49 + +
    + - + func convertBeaconBlobSidecarsResponseInternal(data beaconBlobSidecarsResponseInternal) (*BeaconBlobSidecarsResponse, error) { +
    +
    + 50 + +
    + - + response := BeaconBlobSidecarsResponse{ +
    +
    + 51 + +
    + - + Sidecars: make(map[uint64]BeaconBlobSidecarResponse), +
    +
    + 52 + +
    + - + } +
    +
    + 53 + +
    + - + for _, sidecar := range data.Data { +
    +
    + 54 + +
    + - + index, err := strconv.ParseUint(sidecar.Index, 0, hex.BitSize64) +
    +
    + 55 + +
    + - + if err != nil { +
    +
    + 56 + +
    + - + return nil, fmt.Errorf("error parsing Index: %v", err) +
    +
    + 57 + +
    + - + } +
    +
    + 58 + +
    + - + //common.Hex2Bytes(sidecar.Blob) +
    +
    + 59 + +
    + - + if has0xPrefix(sidecar.Blob) { +
    +
    + 60 + +
    + - + sidecar.Blob = sidecar.Blob[2:] +
    +
    + 61 + +
    + - + } +
    +
    + 62 + +
    + - + blob, err := hex.DecodeHex(sidecar.Blob) +
    +
    + 63 + +
    + - + if err != nil { +
    +
    + 64 + +
    + - + return nil, fmt.Errorf("error decoding Blob: %v", err) +
    +
    + 65 + +
    + - + } +
    +
    + 66 + +
    + - + response.Sidecars[index] = BeaconBlobSidecarResponse{ +
    +
    + 67 + +
    + - + Index: index, +
    +
    + 68 + +
    + - + KzgCommitment: sidecar.KzgCommitment, +
    +
    + 69 + +
    + - + Blob: blob, +
    +
    + 70 + +
    + - + } +
    +
    + 71 + +
    + - + } +
    +
    + 72 + +
    + - + return &response, nil +
    +
    + 73 + +
    + - + } +
    +
    + 74 + +
    + - +
    +
    +
    + 75 + +
    + - + // BeaconBlobSidecars fetches the blob sidecars for a given blockID +
    +
    + 76 + +
    + - + func (c *BeaconAPIClient) BeaconBlobSidecars(ctx context.Context, blockID uint64) (*BeaconBlobSidecarsResponse, error) { +
    +
    + 77 + +
    + - + response, err := JSONRPCBeaconCall(ctx, c.urlBase, beaconBlobSidecarsPath+fmt.Sprintf("%d", blockID)) +
    +
    + 78 + +
    + - + if err != nil { +
    +
    + 79 + +
    + - + return nil, err +
    +
    + 80 + +
    + - + } +
    +
    + 81 + +
    + - +
    +
    +
    + 82 + +
    + - + internalStruct, err := unserializeGenericResponse[beaconBlobSidecarsResponseInternal](response) +
    +
    + 83 + +
    + - + if err != nil { +
    +
    + 84 + +
    + - + return nil, err +
    +
    + 85 + +
    + - + } +
    +
    + 86 + +
    + - +
    +
    +
    + 87 + +
    + - + responseData, err := convertBeaconBlobSidecarsResponseInternal(internalStruct) +
    +
    + 88 + +
    + - + if err != nil { +
    +
    + 89 + +
    + - + return nil, err +
    +
    + 90 + +
    + - + } +
    +
    + 91 + +
    + - + return responseData, nil +
    +
    + 92 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_beacon_genesis.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,60 +0,0 @@
    +
    + 1 + +
    + - + package beaconclient +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "context" +
    +
    + 5 + +
    + - + "fmt" +
    +
    + 6 + +
    + - + "strconv" +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 9 + +
    + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 10 + +
    + - + ) +
    +
    + 11 + +
    + - +
    +
    +
    + 12 + +
    + - + // /eth/v1/beacon/genesis +
    +
    + 13 + +
    + - + const beaconGenesisPath = "/eth/v1/beacon/genesis" +
    +
    + 14 + +
    + - +
    +
    +
    + 15 + +
    + - + // BeaconGenesisResponse represents the response of the beacon genesis endpoint +
    +
    + 16 + +
    + - + type BeaconGenesisResponse struct { +
    +
    + 17 + +
    + - + GenesisTime uint64 +
    +
    + 18 + +
    + - + GenesisValidatorsRoot common.Address +
    +
    + 19 + +
    + - + GenesisForkVersion string +
    +
    + 20 + +
    + - + } +
    +
    + 21 + +
    + - +
    +
    +
    + 22 + +
    + - + type beaconGenesisResponseInternal struct { +
    +
    + 23 + +
    + - + Data struct { +
    +
    + 24 + +
    + - + GenesisTime string `json:"genesis_time"` +
    +
    + 25 + +
    + - + GenesisValidatorsRoot string `json:"genesis_validators_root"` +
    +
    + 26 + +
    + - + GenesisForkVersion string `json:"genesis_fork_version"` +
    +
    + 27 + +
    + - + } `json:"data"` +
    +
    + 28 + +
    + - + } +
    +
    + 29 + +
    + - +
    +
    +
    + 30 + +
    + - + func convertBeaconGenesisResponseInternal(data beaconGenesisResponseInternal) (BeaconGenesisResponse, error) { +
    +
    + 31 + +
    + - + genesisTime, err := strconv.ParseUint(data.Data.GenesisTime, 0, hex.BitSize64) +
    +
    + 32 + +
    + - + if err != nil { +
    +
    + 33 + +
    + - + return BeaconGenesisResponse{}, fmt.Errorf("error parsing genesisTime: %v", err) +
    +
    + 34 + +
    + - + } +
    +
    + 35 + +
    + - + res := BeaconGenesisResponse{ +
    +
    + 36 + +
    + - + GenesisTime: genesisTime, +
    +
    + 37 + +
    + - + GenesisValidatorsRoot: common.HexToAddress(data.Data.GenesisValidatorsRoot), +
    +
    + 38 + +
    + - + GenesisForkVersion: data.Data.GenesisForkVersion, +
    +
    + 39 + +
    + - + } +
    +
    + 40 + +
    + - + return res, nil +
    +
    + 41 + +
    + - + } +
    +
    + 42 + +
    + - +
    +
    +
    + 43 + +
    + - + // BeaconGenesis request the current beacon chain genesis +
    +
    + 44 + +
    + - + func (c *BeaconAPIClient) BeaconGenesis(ctx context.Context) (*BeaconGenesisResponse, error) { +
    +
    + 45 + +
    + - + response, err := JSONRPCBeaconCall(ctx, c.urlBase, beaconGenesisPath) +
    +
    + 46 + +
    + - + if err != nil { +
    +
    + 47 + +
    + - + return nil, err +
    +
    + 48 + +
    + - + } +
    +
    + 49 + +
    + - +
    +
    +
    + 50 + +
    + - + internalStruct, err := unserializeGenericResponse[beaconGenesisResponseInternal](response) +
    +
    + 51 + +
    + - + if err != nil { +
    +
    + 52 + +
    + - + return nil, err +
    +
    + 53 + +
    + - + } +
    +
    + 54 + +
    + - +
    +
    +
    + 55 + +
    + - + responseData, err := convertBeaconGenesisResponseInternal(internalStruct) +
    +
    + 56 + +
    + - + if err != nil { +
    +
    + 57 + +
    + - + return nil, err +
    +
    + 58 + +
    + - + } +
    +
    + 59 + +
    + - + return &responseData, nil +
    +
    + 60 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/beacon_client/req_config_spec.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,64 +0,0 @@
    +
    + 1 + +
    + - + package beaconclient +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "context" +
    +
    + 5 + +
    + - + "fmt" +
    +
    + 6 + +
    + - + "strconv" +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 9 + +
    + - + ) +
    +
    + 10 + +
    + - +
    +
    +
    + 11 + +
    + - + // ConfigSpec returns the current beacon chain configuration +
    +
    + 12 + +
    + - + // Curl example: +
    +
    + 13 + +
    + - + // curl -X 'GET' \ +
    +
    + 14 + +
    + - + // 'http://localhost/eth/v1/config/spec' \ +
    +
    + 15 + +
    + - + // -H 'accept: application/json' +
    +
    + 16 + +
    + - + const configSpecPath = "/eth/v1/config/spec" +
    +
    + 17 + +
    + - +
    +
    +
    + 18 + +
    + - + // ConfigSpecNodeResponse represents the response of the config spec endpoint +
    +
    + 19 + +
    + - + type ConfigSpecNodeResponse struct { +
    +
    + 20 + +
    + - + SecondsPerSlot uint64 +
    +
    + 21 + +
    + - + SecondsPerEth1Block uint64 +
    +
    + 22 + +
    + - + } +
    +
    + 23 + +
    + - +
    +
    +
    + 24 + +
    + - + type configSpecNodeResponseInternal struct { +
    +
    + 25 + +
    + - + Data struct { +
    +
    + 26 + +
    + - + SecondsPerSlot string `json:"SECONDS_PER_SLOT"` +
    +
    + 27 + +
    + - + SecondsPerEth1Block string `json:"SECONDS_PER_ETH1_BLOCK"` +
    +
    + 28 + +
    + - + } +
    +
    + 29 + +
    + - + } +
    +
    + 30 + +
    + - +
    +
    +
    + 31 + +
    + - + func convertConfigSpecResponseInternal(data configSpecNodeResponseInternal) (ConfigSpecNodeResponse, error) { +
    +
    + 32 + +
    + - + tmpSecondsPerSlot, err := strconv.ParseUint(data.Data.SecondsPerSlot, 0, hex.BitSize64) +
    +
    + 33 + +
    + - + if err != nil { +
    +
    + 34 + +
    + - + return ConfigSpecNodeResponse{}, fmt.Errorf("error parsing SecondsPerSlot: %v", err) +
    +
    + 35 + +
    + - + } +
    +
    + 36 + +
    + - + tmpSecondsPerEth1Block, err := strconv.ParseUint(data.Data.SecondsPerEth1Block, 0, hex.BitSize64) +
    +
    + 37 + +
    + - + if err != nil { +
    +
    + 38 + +
    + - + return ConfigSpecNodeResponse{}, fmt.Errorf("error parsing SecondsPerSlot: %v", err) +
    +
    + 39 + +
    + - + } +
    +
    + 40 + +
    + - + res := ConfigSpecNodeResponse{ +
    +
    + 41 + +
    + - + SecondsPerSlot: tmpSecondsPerSlot, +
    +
    + 42 + +
    + - + SecondsPerEth1Block: tmpSecondsPerEth1Block, +
    +
    + 43 + +
    + - + } +
    +
    + 44 + +
    + - + return res, nil +
    +
    + 45 + +
    + - + } +
    +
    + 46 + +
    + - +
    +
    +
    + 47 + +
    + - + // ConfigSpec returns the current beacon chain configuration +
    +
    + 48 + +
    + - + func (c *BeaconAPIClient) ConfigSpec(ctx context.Context) (*ConfigSpecNodeResponse, error) { +
    +
    + 49 + +
    + - + response, err := JSONRPCBeaconCall(ctx, c.urlBase, configSpecPath) +
    +
    + 50 + +
    + - + if err != nil { +
    +
    + 51 + +
    + - + return nil, err +
    +
    + 52 + +
    + - + } +
    +
    + 53 + +
    + - +
    +
    +
    + 54 + +
    + - + internalStruct, err := unserializeGenericResponse[configSpecNodeResponseInternal](response) +
    +
    + 55 + +
    + - + if err != nil { +
    +
    + 56 + +
    + - + return nil, err +
    +
    + 57 + +
    + - + } +
    +
    + 58 + +
    + - +
    +
    +
    + 59 + +
    + - + responseData, err := convertConfigSpecResponseInternal(internalStruct) +
    +
    + 60 + +
    + - + if err != nil { +
    +
    + 61 + +
    + - + return nil, err +
    +
    + 62 + +
    + - + } +
    +
    + 63 + +
    + - + return &responseData, nil +
    +
    + 64 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/approve.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -51,14 +51,14 @@
    +
    + 51 + +
    +   + setupLog(c.Log) +
    +
    + 52 + +
    +   +
    +
    +
    + 53 + +
    +   + // Check if it is already registered +
    +
    + 54 + +
    + - + etherman, err := newEtherman(*c) +
    +
    + 55 + +
    +   + if err != nil { +
    +
    + 56 + +
    +   + log.Fatal(err) +
    +
    + 57 + +
    +   + return err +
    +
    + 58 + +
    +   + } +
    +
    + 59 + +
    +   +
    +
    +
    + 60 + +
    +   + // load auth from keystore file +
    +
    + 61 + +
    + - + auth, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    +
    + 62 + +
    +   + if err != nil { +
    +
    + 63 + +
    +   + log.Fatal(err) +
    +
    + 64 + +
    +   + return err +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 51 + +
    +   + setupLog(c.Log) +
    +
    + 52 + +
    +   +
    +
    +
    + 53 + +
    +   + // Check if it is already registered +
    +
    + 54 + +
    + + + etherman, err := newEtherman(*c, nil) +
    +
    + 55 + +
    +   + if err != nil { +
    +
    + 56 + +
    +   + log.Fatal(err) +
    +
    + 57 + +
    +   + return err +
    +
    + 58 + +
    +   + } +
    +
    + 59 + +
    +   +
    +
    +
    + 60 + +
    +   + // load auth from keystore file +
    +
    + 61 + +
    + + + auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    +
    + 62 + +
    +   + if err != nil { +
    +
    + 63 + +
    +   + log.Fatal(err) +
    +
    + 64 + +
    +   + return err +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/main.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -47,7 +47,7 @@
    +
    + 47 + +
    +   + networkFlag = cli.StringFlag{ +
    +
    + 48 + +
    +   + Name: config.FlagNetwork, +
    +
    + 49 + +
    +   + Aliases: []string{"net"}, +
    +
    + 50 + +
    + - + Usage: "Load default network configuration. Supported values: [`mainnet`, `testnet`, `cardona`, `custom`]", +
    +
    + 51 + +
    +   + Required: true, +
    +
    + 52 + +
    +   + } +
    +
    + 53 + +
    +   + customNetworkFlag = cli.StringFlag{ +
    +
    +
    @@ -186,6 +186,13 @@
    +
    + 186 + +
    +   + Action: restore, +
    +
    + 187 + +
    +   + Flags: restoreFlags, +
    +
    + 188 + +
    +   + }, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 189 + +
    +   + } +
    +
    + 190 + +
    +   +
    +
    +
    + 191 + +
    +   + err := app.Run(os.Args) +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 47 + +
    +   + networkFlag = cli.StringFlag{ +
    +
    + 48 + +
    +   + Name: config.FlagNetwork, +
    +
    + 49 + +
    +   + Aliases: []string{"net"}, +
    +
    + 50 + +
    + + + Usage: "Load default network configuration. Supported values: [`custom`]", +
    +
    + 51 + +
    +   + Required: true, +
    +
    + 52 + +
    +   + } +
    +
    + 53 + +
    +   + customNetworkFlag = cli.StringFlag{ +
    +
    +
     
    +
    + 186 + +
    +   + Action: restore, +
    +
    + 187 + +
    +   + Flags: restoreFlags, +
    +
    + 188 + +
    +   + }, +
    +
    + 189 + +
    + + + { +
    +
    + 190 + +
    + + + Name: "set-data-availability-protocol", +
    +
    + 191 + +
    + + + Aliases: []string{"set-dap"}, +
    +
    + 192 + +
    + + + Usage: "Sets the new data availability protocol", +
    +
    + 193 + +
    + + + Action: setDataAvailabilityProtocol, +
    +
    + 194 + +
    + + + Flags: setDataAvailabilityProtocolFlags, +
    +
    + 195 + +
    + + + }, +
    +
    + 196 + +
    +   + } +
    +
    + 197 + +
    +   +
    +
    +
    + 198 + +
    +   + err := app.Run(os.Args) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/policy.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,308 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package main +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "encoding/csv" +
    +
    + 6 + +
    + + + "errors" +
    +
    + 7 + +
    + + + "fmt" +
    +
    + 8 + +
    + + + "os" +
    +
    + 9 + +
    + + + "strings" +
    +
    + 10 + +
    + + +
    +
    +
    + 11 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/config" +
    +
    + 12 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/pool" +
    +
    + 13 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/pool/pgpoolstorage" +
    +
    + 14 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 15 + +
    + + + "github.com/urfave/cli/v2" +
    +
    + 16 + +
    + + + ) +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + var ( +
    +
    + 19 + +
    + + + policyFlag = cli.StringFlag{ +
    +
    + 20 + +
    + + + Name: "policy", +
    +
    + 21 + +
    + + + Aliases: []string{"p"}, +
    +
    + 22 + +
    + + + Usage: "Name of policy to operate on", +
    +
    + 23 + +
    + + + Required: false, +
    +
    + 24 + +
    + + + } +
    +
    + 25 + +
    + + + csvFlag = cli.StringFlag{ +
    +
    + 26 + +
    + + + Name: "csv", +
    +
    + 27 + +
    + + + Usage: "CSV file with addresses", +
    +
    + 28 + +
    + + + Required: false, +
    +
    + 29 + +
    + + + } +
    +
    + 30 + +
    + + + allowFlag = cli.BoolFlag{ +
    +
    + 31 + +
    + + + Name: "allow", +
    +
    + 32 + +
    + + + Usage: "Update policy to 'allow' addresses on list", +
    +
    + 33 + +
    + + + Required: false, +
    +
    + 34 + +
    + + + } +
    +
    + 35 + +
    + + + denyFlag = cli.BoolFlag{ +
    +
    + 36 + +
    + + + Name: "deny", +
    +
    + 37 + +
    + + + Usage: "Update policy to 'deny' addresses on list", +
    +
    + 38 + +
    + + + Required: false, +
    +
    + 39 + +
    + + + } +
    +
    + 40 + +
    + + + noHeaderFlag = cli.BoolFlag{ +
    +
    + 41 + +
    + + + Name: "no-header", +
    +
    + 42 + +
    + + + Value: false, +
    +
    + 43 + +
    + + + Required: false, +
    +
    + 44 + +
    + + + } +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + policyActionFlags = []cli.Flag{&policyFlag} +
    +
    + 47 + +
    + + + ) +
    +
    + 48 + +
    + + +
    +
    +
    + 49 + +
    + + + var policyCommands = cli.Command{ +
    +
    + 50 + +
    + + + Name: "policy", +
    +
    + 51 + +
    + + + Usage: "View, update, and apply policies", +
    +
    + 52 + +
    + + + Action: describe, +
    +
    + 53 + +
    + + + Flags: []cli.Flag{&configFileFlag}, +
    +
    + 54 + +
    + + + Subcommands: []*cli.Command{ +
    +
    + 55 + +
    + + + { +
    +
    + 56 + +
    + + + Name: "add", +
    +
    + 57 + +
    + + + Usage: "Add address(es) to a policy exclusion list", +
    +
    + 58 + +
    + + + Action: addAcl, +
    +
    + 59 + +
    + + + Flags: append(policyActionFlags, &csvFlag), +
    +
    + 60 + +
    + + + }, { +
    +
    + 61 + +
    + + + Name: "clear", +
    +
    + 62 + +
    + + + Usage: "Clear the addresses listed as exceptions to a policy", +
    +
    + 63 + +
    + + + Action: clearAcl, +
    +
    + 64 + +
    + + + Flags: policyActionFlags, +
    +
    + 65 + +
    + + + }, { +
    +
    + 66 + +
    + + + Name: "describe", +
    +
    + 67 + +
    + + + Usage: "Describe the default actions for the policies", +
    +
    + 68 + +
    + + + Action: describe, +
    +
    + 69 + +
    + + + Flags: append(policyActionFlags, &noHeaderFlag), +
    +
    + 70 + +
    + + + }, { +
    +
    + 71 + +
    + + + Name: "remove", +
    +
    + 72 + +
    + + + Usage: "Remove address(es) from a policy exclusion list", +
    +
    + 73 + +
    + + + Action: removeAcl, +
    +
    + 74 + +
    + + + Flags: append(policyActionFlags, &csvFlag), +
    +
    + 75 + +
    + + + }, { +
    +
    + 76 + +
    + + + Name: "update", +
    +
    + 77 + +
    + + + Usage: "Update the default action for a policy", +
    +
    + 78 + +
    + + + Action: updatePolicy, +
    +
    + 79 + +
    + + + Flags: append(policyActionFlags, &allowFlag, &denyFlag), +
    +
    + 80 + +
    + + + }, +
    +
    + 81 + +
    + + + }, +
    +
    + 82 + +
    + + + } +
    +
    + 83 + +
    + + +
    +
    +
    + 84 + +
    + + + func updatePolicy(cli *cli.Context) error { +
    +
    + 85 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 86 + +
    + + + if err != nil { +
    +
    + 87 + +
    + + + return err +
    +
    + 88 + +
    + + + } +
    +
    + 89 + +
    + + + policy, err := resolvePolicy(cli) +
    +
    + 90 + +
    + + + if err != nil { +
    +
    + 91 + +
    + + + return err +
    +
    + 92 + +
    + + + } +
    +
    + 93 + +
    + + +
    +
    +
    + 94 + +
    + + + allow := cli.Bool(allowFlag.Name) +
    +
    + 95 + +
    + + + deny := cli.Bool(denyFlag.Name) +
    +
    + 96 + +
    + + +
    +
    +
    + 97 + +
    + + + // exactly one must be set +
    +
    + 98 + +
    + + + if (allow && deny) || (!allow && !deny) { +
    +
    + 99 + +
    + + + return errors.New("supply one policy action [--allow or --deny]") +
    +
    + 100 + +
    + + + } +
    +
    + 101 + +
    + + +
    +
    +
    + 102 + +
    + + + var setting bool +
    +
    + 103 + +
    + + + if allow { +
    +
    + 104 + +
    + + + setting = true +
    +
    + 105 + +
    + + + } else if deny { +
    +
    + 106 + +
    + + + setting = false +
    +
    + 107 + +
    + + + } +
    +
    + 108 + +
    + + +
    +
    +
    + 109 + +
    + + + err = db.UpdatePolicy(context.Background(), policy, setting) +
    +
    + 110 + +
    + + + if err != nil { +
    +
    + 111 + +
    + + + return err +
    +
    + 112 + +
    + + + } +
    +
    + 113 + +
    + + + return nil +
    +
    + 114 + +
    + + + } +
    +
    + 115 + +
    + + +
    +
    +
    + 116 + +
    + + + func addAcl(cli *cli.Context) error { +
    +
    + 117 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 118 + +
    + + + if err != nil { +
    +
    + 119 + +
    + + + return err +
    +
    + 120 + +
    + + + } +
    +
    + 121 + +
    + + + policy, addresses, err := requirePolicyAndAddresses(cli) +
    +
    + 122 + +
    + + + if err != nil { +
    +
    + 123 + +
    + + + return err +
    +
    + 124 + +
    + + + } +
    +
    + 125 + +
    + + + err = db.AddAddressesToPolicy(context.Background(), policy, addresses) +
    +
    + 126 + +
    + + + if err != nil { +
    +
    + 127 + +
    + + + return err +
    +
    + 128 + +
    + + + } +
    +
    + 129 + +
    + + + return nil +
    +
    + 130 + +
    + + + } +
    +
    + 131 + +
    + + +
    +
    +
    + 132 + +
    + + + func removeAcl(cli *cli.Context) error { +
    +
    + 133 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 134 + +
    + + + if err != nil { +
    +
    + 135 + +
    + + + return err +
    +
    + 136 + +
    + + + } +
    +
    + 137 + +
    + + + policy, addresses, err := requirePolicyAndAddresses(cli) +
    +
    + 138 + +
    + + + if err != nil { +
    +
    + 139 + +
    + + + return err +
    +
    + 140 + +
    + + + } +
    +
    + 141 + +
    + + + err = db.RemoveAddressesFromPolicy(context.Background(), policy, addresses) +
    +
    + 142 + +
    + + + if err != nil { +
    +
    + 143 + +
    + + + return err +
    +
    + 144 + +
    + + + } +
    +
    + 145 + +
    + + + return nil +
    +
    + 146 + +
    + + + } +
    +
    + 147 + +
    + + +
    +
    +
    + 148 + +
    + + + func clearAcl(cli *cli.Context) error { +
    +
    + 149 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 150 + +
    + + + if err != nil { +
    +
    + 151 + +
    + + + return err +
    +
    + 152 + +
    + + + } +
    +
    + 153 + +
    + + + policy, err := resolvePolicy(cli) +
    +
    + 154 + +
    + + + if err != nil { +
    +
    + 155 + +
    + + + return err +
    +
    + 156 + +
    + + + } +
    +
    + 157 + +
    + + + err = db.ClearPolicy(context.Background(), policy) +
    +
    + 158 + +
    + + + if err != nil { +
    +
    + 159 + +
    + + + return err +
    +
    + 160 + +
    + + + } +
    +
    + 161 + +
    + + + return nil +
    +
    + 162 + +
    + + + } +
    +
    + 163 + +
    + + +
    +
    +
    + 164 + +
    + + + func describe(cli *cli.Context) error { +
    +
    + 165 + +
    + + + showHeader := !cli.Bool(noHeaderFlag.Name) +
    +
    + 166 + +
    + + + if cli.IsSet(policyFlag.Name) { +
    +
    + 167 + +
    + + + return describePolicy(cli, showHeader) +
    +
    + 168 + +
    + + + } +
    +
    + 169 + +
    + + + return describePolicies(cli, showHeader) +
    +
    + 170 + +
    + + + } +
    +
    + 171 + +
    + + +
    +
    +
    + 172 + +
    + + + func describePolicy(cli *cli.Context, showHeader bool) error { +
    +
    + 173 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 174 + +
    + + + if err != nil { +
    +
    + 175 + +
    + + + return err +
    +
    + 176 + +
    + + + } +
    +
    + 177 + +
    + + +
    +
    +
    + 178 + +
    + + + policyName, err := resolvePolicy(cli) +
    +
    + 179 + +
    + + + if err != nil { +
    +
    + 180 + +
    + + + return err +
    +
    + 181 + +
    + + + } +
    +
    + 182 + +
    + + +
    +
    +
    + 183 + +
    + + + if showHeader { +
    +
    + 184 + +
    + + + policy, err := db.DescribePolicy(context.Background(), policyName) +
    +
    + 185 + +
    + + + if err != nil { +
    +
    + 186 + +
    + + + return err +
    +
    + 187 + +
    + + + } +
    +
    + 188 + +
    + + + fmt.Printf("%s: %s\n", "Policy", policy.Name) +
    +
    + 189 + +
    + + + fmt.Printf("%s: %s\n", "Action", policy.Desc()) +
    +
    + 190 + +
    + + + } +
    +
    + 191 + +
    + + + query, err := resolveAddresses(cli, false) +
    +
    + 192 + +
    + + + if err != nil { +
    +
    + 193 + +
    + + + return nil +
    +
    + 194 + +
    + + + } +
    +
    + 195 + +
    + + + list, err := db.ListAcl(context.Background(), policyName, query) +
    +
    + 196 + +
    + + + if err != nil { +
    +
    + 197 + +
    + + + return err +
    +
    + 198 + +
    + + + } +
    +
    + 199 + +
    + + +
    +
    +
    + 200 + +
    + + + if showHeader { +
    +
    + 201 + +
    + + + fmt.Println("Addresses:") +
    +
    + 202 + +
    + + + } +
    +
    + 203 + +
    + + + for _, address := range list { +
    +
    + 204 + +
    + + + fmt.Println(address.Hex()) +
    +
    + 205 + +
    + + + } +
    +
    + 206 + +
    + + + return nil +
    +
    + 207 + +
    + + + } +
    +
    + 208 + +
    + + +
    +
    +
    + 209 + +
    + + + func describePolicies(cli *cli.Context, showHeader bool) error { +
    +
    + 210 + +
    + + + _, db, err := configAndStorage(cli) +
    +
    + 211 + +
    + + + if err != nil { +
    +
    + 212 + +
    + + + return err +
    +
    + 213 + +
    + + + } +
    +
    + 214 + +
    + + + list, err := db.DescribePolicies(context.Background()) +
    +
    + 215 + +
    + + + if err != nil { +
    +
    + 216 + +
    + + + return err +
    +
    + 217 + +
    + + + } +
    +
    + 218 + +
    + + +
    +
    +
    + 219 + +
    + + + if showHeader { +
    +
    + 220 + +
    + + + fmt.Printf("%7s: %s\n", "Policy", "Action") +
    +
    + 221 + +
    + + + } +
    +
    + 222 + +
    + + + for _, p := range list { +
    +
    + 223 + +
    + + + fmt.Printf("%7s: %s\n", p.Name, p.Desc()) +
    +
    + 224 + +
    + + + } +
    +
    + 225 + +
    + + +
    +
    +
    + 226 + +
    + + + return nil +
    +
    + 227 + +
    + + + } +
    +
    + 228 + +
    + + +
    +
    +
    + 229 + +
    + + + func configAndStorage(cli *cli.Context) (*config.Config, *pgpoolstorage.PostgresPoolStorage, error) { +
    +
    + 230 + +
    + + + c, err := config.Load(cli, false) +
    +
    + 231 + +
    + + + if err != nil { +
    +
    + 232 + +
    + + + return nil, nil, err +
    +
    + 233 + +
    + + + } +
    +
    + 234 + +
    + + + setupLog(c.Log) +
    +
    + 235 + +
    + + +
    +
    +
    + 236 + +
    + + + db, err := pgpoolstorage.NewPostgresPoolStorage(c.Pool.DB) +
    +
    + 237 + +
    + + + if err != nil { +
    +
    + 238 + +
    + + + return nil, nil, err +
    +
    + 239 + +
    + + + } +
    +
    + 240 + +
    + + + return c, db, nil +
    +
    + 241 + +
    + + + } +
    +
    + 242 + +
    + + +
    +
    +
    + 243 + +
    + + + func requirePolicyAndAddresses(cli *cli.Context) (pool.PolicyName, []common.Address, error) { +
    +
    + 244 + +
    + + + policy, err := resolvePolicy(cli) +
    +
    + 245 + +
    + + + if err != nil { +
    +
    + 246 + +
    + + + return "", nil, err +
    +
    + 247 + +
    + + + } +
    +
    + 248 + +
    + + + addresses, err := resolveAddresses(cli, true) +
    +
    + 249 + +
    + + + if err != nil { +
    +
    + 250 + +
    + + + return "", nil, err +
    +
    + 251 + +
    + + + } +
    +
    + 252 + +
    + + + return policy, addresses, nil +
    +
    + 253 + +
    + + + } +
    +
    + 254 + +
    + + +
    +
    +
    + 255 + +
    + + + func resolvePolicy(cli *cli.Context) (pool.PolicyName, error) { +
    +
    + 256 + +
    + + + policy := cli.String(policyFlag.Name) +
    +
    + 257 + +
    + + + if policy == "" { +
    +
    + 258 + +
    + + + return "", nil +
    +
    + 259 + +
    + + + } +
    +
    + 260 + +
    + + + if !pool.IsPolicy(policy) { +
    +
    + 261 + +
    + + + return "", fmt.Errorf("invalid policy name: %s", policy) +
    +
    + 262 + +
    + + + } +
    +
    + 263 + +
    + + + return pool.PolicyName(policy), nil +
    +
    + 264 + +
    + + + } +
    +
    + 265 + +
    + + +
    +
    +
    + 266 + +
    + + + func resolveAddresses(cli *cli.Context, failIfEmpty bool) ([]common.Address, error) { +
    +
    + 267 + +
    + + + var set = make(map[common.Address]struct{}) +
    +
    + 268 + +
    + + + if cli.IsSet("csv") { +
    +
    + 269 + +
    + + + file := cli.String(csvFlag.Name) +
    +
    + 270 + +
    + + + fd, err := os.Open(file) +
    +
    + 271 + +
    + + + if err != nil { +
    +
    + 272 + +
    + + + return nil, err +
    +
    + 273 + +
    + + + } +
    +
    + 274 + +
    + + + defer func(fd *os.File) { +
    +
    + 275 + +
    + + + _ = fd.Close() +
    +
    + 276 + +
    + + + }(fd) +
    +
    + 277 + +
    + + +
    +
    +
    + 278 + +
    + + + fileReader := csv.NewReader(fd) +
    +
    + 279 + +
    + + + records, err := fileReader.ReadAll() +
    +
    + 280 + +
    + + +
    +
    +
    + 281 + +
    + + + if err != nil { +
    +
    + 282 + +
    + + + return nil, err +
    +
    + 283 + +
    + + + } +
    +
    + 284 + +
    + + + for _, row := range records { +
    +
    + 285 + +
    + + + for _, cell := range row { +
    +
    + 286 + +
    + + + hex := strings.TrimSpace(cell) +
    +
    + 287 + +
    + + + set[common.HexToAddress(hex)] = struct{}{} +
    +
    + 288 + +
    + + + } +
    +
    + 289 + +
    + + + } +
    +
    + 290 + +
    + + + } +
    +
    + 291 + +
    + + +
    +
    +
    + 292 + +
    + + + for _, a := range cli.Args().Slice() { +
    +
    + 293 + +
    + + + a = strings.TrimSpace(a) +
    +
    + 294 + +
    + + + a = strings.Trim(a, ",|") +
    +
    + 295 + +
    + + + if !strings.HasPrefix(a, "0x") { +
    +
    + 296 + +
    + + + a = "0x" + a +
    +
    + 297 + +
    + + + } +
    +
    + 298 + +
    + + + set[common.HexToAddress(a)] = struct{}{} +
    +
    + 299 + +
    + + + } +
    +
    + 300 + +
    + + + var ret []common.Address +
    +
    + 301 + +
    + + + for a := range set { +
    +
    + 302 + +
    + + + ret = append(ret, a) +
    +
    + 303 + +
    + + + } +
    +
    + 304 + +
    + + + if failIfEmpty && len(ret) == 0 { +
    +
    + 305 + +
    + + + return nil, errors.New("no addresses given") +
    +
    + 306 + +
    + + + } +
    +
    + 307 + +
    + + + return ret, nil +
    +
    + 308 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/run.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -2,6 +2,7 @@
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "context" +
    +
    + + +
    +   +
    +
    +
    + 5 + +
    +   + "errors" +
    +
    + 6 + +
    +   + "fmt" +
    +
    + 7 + +
    +   + "net" +
    +
    +
    @@ -108,19 +113,27 @@
    +
    + 108 + +
    +   + log.Fatal(err) +
    +
    + 109 + +
    +   + } +
    +
    + 110 + +
    +   +
    +
    +
    + 111 + +
    + - + etherman, err := newEtherman(*c) +
    +
    + + +
    +   +
    +
    +
    + 112 + +
    +   + if err != nil { +
    +
    + 113 + +
    +   + log.Fatal(err) +
    +
    + 114 + +
    +   + } +
    +
    + 115 + +
    + - +
    +
    +
    + 116 + +
    + - + // READ CHAIN ID FROM POE SC +
    +
    + 117 + +
    + - + l2ChainID, err := etherman.GetL2ChainID() +
    +
    + 118 + +
    +   + if err != nil { +
    +
    + 119 + +
    +   + log.Fatal(err) +
    +
    + 120 + +
    +   + } +
    +
    + 121 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 122 + +
    +   + st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false) +
    +
    + 123 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 124 + +
    +   + c.Aggregator.ChainID = l2ChainID +
    +
    + 125 + +
    +   + c.Sequencer.StreamServer.ChainID = l2ChainID +
    +
    + 126 + +
    +   + log.Infof("Chain ID read from POE SC = %v", l2ChainID) +
    +
    +
    @@ -277,8 +290,79 @@
    +
    + 277 + +
    +   + } +
    +
    + 278 + +
    +   + } +
    +
    + 279 + +
    +   +
    +
    +
    + 280 + +
    + - + func newEtherman(c config.Config) (*etherman.Client, error) { +
    +
    + 281 + +
    + - + return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 282 + +
    +   + } +
    +
    + 283 + +
    +   +
    +
    +
    + 284 + +
    +   + func newL2EthClient(url string) (*ethclient.Client, error) { +
    +
    +
    @@ -321,7 +405,7 @@
    +
    + 321 + +
    +   + // If synchronizer are using sequential mode, we only need one etherman client +
    +
    + 322 + +
    +   + if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode { +
    +
    + 323 + +
    +   + for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ { +
    +
    + 324 + +
    + - + eth, err := newEtherman(cfg) +
    +
    + 325 + +
    +   + if err != nil { +
    +
    + 326 + +
    +   + log.Fatal(err) +
    +
    + 327 + +
    +   + } +
    +
    +
    @@ -424,12 +508,12 @@
    +
    + 424 + +
    +   + } +
    +
    + 425 + +
    +   +
    +
    +
    + 426 + +
    +   + func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender { +
    +
    + 427 + +
    + - + etherman, err := newEtherman(cfg) +
    +
    + 428 + +
    +   + if err != nil { +
    +
    + 429 + +
    +   + log.Fatal(err) +
    +
    + 430 + +
    +   + } +
    +
    + 431 + +
    +   +
    +
    +
    + 432 + +
    + - + auth, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password) +
    +
    + 433 + +
    +   + if err != nil { +
    +
    + 434 + +
    +   + log.Fatal(err) +
    +
    + 435 + +
    +   + } +
    +
    +
    @@ -439,7 +523,12 @@
    +
    + 439 + +
    +   +
    +
    +
    + 440 + +
    +   + ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st) +
    +
    + 441 + +
    +   +
    +
    +
    + 442 + +
    + - + seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 443 + +
    +   + if err != nil { +
    +
    + 444 + +
    +   + log.Fatal(err) +
    +
    + 445 + +
    +   + } +
    +
    +
    @@ -448,7 +537,23 @@
    +
    + 448 + +
    +   + } +
    +
    + 449 + +
    +   +
    +
    +
    + 450 + +
    +   + func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) { +
    +
    + 451 + +
    + - + agg, err := aggregator.New(c, st, ethTxManager, etherman) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 452 + +
    +   + if err != nil { +
    +
    + 453 + +
    +   + log.Fatal(err) +
    +
    + 454 + +
    +   + } +
    +
    +
    @@ -510,29 +615,22 @@
    +
    + 510 + +
    +   + AvoidForkIDInMemory: avoidForkIDInMemory, +
    +
    + 511 + +
    +   + } +
    +
    + 512 + +
    +   + stateDb := pgstatestorage.NewPostgresStorage(stateCfg, sqlDB) +
    +
    + 513 + +
    + - +
    +
    +
    + 514 + +
    + - + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, nil, nil) +
    +
    + 515 + +
    +   + // This is to force to build cache, and check that DB is ok before starting the application +
    +
    + 516 + +
    + - + l1InfoRoot, err := st.GetCurrentL1InfoRoot(ctx, nil) +
    +
    + 517 + +
    +   + if err != nil { +
    +
    + 518 + +
    +   + log.Fatal("error getting current L1InfoRoot. Error: ", err) +
    +
    + 519 + +
    +   + } +
    +
    + 520 + +
    + - + log.Infof("Starting L1InfoRoot: %v", l1InfoRoot.String()) +
    +
    + 521 + +
    +   +
    +
    +
    + 522 + +
    + - + l1InfoTreeRecursiveRoot, err := st.GetCurrentL1InfoTreeRecursiveRoot(ctx, nil) +
    +
    + 523 + +
    + - + if err != nil { +
    +
    + 524 + +
    + - + log.Fatal("error getting current l1InfoTreeRecursiveRoot. Error: ", err) +
    +
    + 525 + +
    + - + } +
    +
    + 526 + +
    + - + log.Infof("Starting l1InfoTreeRecursiveRoot: %v", l1InfoTreeRecursiveRoot.String()) +
    +
    + 527 + +
    + - +
    +
    +
    + 528 + +
    + - + forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.BlockNumber) +
    +
    + 529 + +
    +   + if err != nil { +
    +
    + 530 + +
    +   + log.Fatal("error getting forkIDs. Error: ", err) +
    +
    + 531 + +
    +   + } +
    +
    + 532 + +
    +   + st.UpdateForkIDIntervalsInMemory(forkIDIntervals) +
    +
    + 533 + +
    +   +
    +
    +
    + 534 + +
    +   + currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId +
    +
    + 535 + +
    + - + log.Infof("Fork ID read from POE SC = %v", forkIDIntervals[len(forkIDIntervals)-1].ForkId) +
    +
    + 536 + +
    +   +
    +
    +
    + 537 + +
    +   + return st, currentForkID +
    +
    + 538 + +
    +   + } +
    +
    +
    @@ -548,13 +646,13 @@
    +
    + 548 + +
    +   + } +
    +
    + 549 + +
    +   +
    +
    +
    + 550 + +
    +   + func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client { +
    +
    + 551 + +
    + - + etherman, err := newEtherman(cfg) +
    +
    + 552 + +
    +   + if err != nil { +
    +
    + 553 + +
    +   + log.Fatal(err) +
    +
    + 554 + +
    +   + } +
    +
    + 555 + +
    +   +
    +
    +
    + 556 + +
    +   + for _, privateKey := range cfg.EthTxManager.PrivateKeys { +
    +
    + 557 + +
    + - + _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password) +
    +
    + 558 + +
    +   + if err != nil { +
    +
    + 559 + +
    +   + log.Fatal(err) +
    +
    + 560 + +
    +   + } +
    +
    +
    @@ -646,8 +744,7 @@
    +
    + 646 + +
    +   + if err != nil && !errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 647 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error checking lastL1BlockSynced. Error: %v", err) +
    +
    + 648 + +
    +   + } +
    +
    + 649 + +
    + - + // If lastBlock is below genesisBlock means state.ErrStateNotSynchronized (haven't started yet the sync process, is doing pregenesis sync) +
    +
    + 650 + +
    + - + if lastBlock != nil && lastBlock.BlockNumber > genesisBlockNumber { +
    +
    + 651 + +
    +   + log.Info("Getting forkIDs intervals. Please wait...") +
    +
    + 652 + +
    +   + // Read Fork ID FROM POE SC +
    +
    + 653 + +
    +   + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, lastBlock.BlockNumber) +
    +
    +
    @@ -687,14 +784,32 @@
    +
    + 687 + +
    +   + } +
    +
    + 688 + +
    +   + forkIDIntervals = forkIntervals +
    +
    + 689 + +
    +   + } else { +
    +
    + 690 + +
    + - + log.Debug("Getting initial forkID") +
    +
    + 691 + +
    + - + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, genesisBlockNumber) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 692 + +
    +   + if err != nil { +
    +
    + 693 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err) +
    +
    + 694 + +
    +   + } else if len(forkIntervals) == 0 { +
    +
    + 695 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...") +
    +
    + 696 + +
    +   + } +
    +
    + 697 + +
    +   + forkIDIntervals = forkIntervals +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 698 + +
    +   + } +
    +
    + 699 + +
    +   + } +
    +
    + 700 + +
    +   + return forkIDIntervals, nil +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "context" +
    +
    + 5 + +
    + + + "crypto/ecdsa" +
    +
    + 6 + +
    +   + "errors" +
    +
    + 7 + +
    +   + "fmt" +
    +
    + 8 + +
    +   + "net" +
    +
    +
     
    +
    + 113 + +
    +   + log.Fatal(err) +
    +
    + 114 + +
    +   + } +
    +
    + 115 + +
    +   +
    +
    +
    + 116 + +
    + + + // READ CHAIN ID FROM POE SC +
    +
    + 117 + +
    + + + tmpEthMan, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) +
    +
    + 118 + +
    +   + if err != nil { +
    +
    + 119 + +
    +   + log.Fatal(err) +
    +
    + 120 + +
    +   + } +
    +
    + 121 + +
    + + + l2ChainID, err := tmpEthMan.GetL2ChainID() +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 122 + +
    +   + if err != nil { +
    +
    + 123 + +
    +   + log.Fatal(err) +
    +
    + 124 + +
    +   + } +
    +
    + 125 + +
    +   +
    +
    +
    + 126 + +
    + + + etherman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) +
    +
    + 127 + +
    + + + if err != nil { +
    +
    + 128 + +
    + + + log.Fatal(err) +
    +
    + 129 + +
    + + + } +
    +
    + 130 + +
    +   + st, currentForkID := newState(cliCtx.Context, c, etherman, l2ChainID, stateSqlDB, eventLog, needsExecutor, needsStateTree, false) +
    +
    + 131 + +
    +   +
    +
    +
    + 132 + +
    + + + etherman, err = newEtherman(*c, st) +
    +
    + 133 + +
    + + + if err != nil { +
    +
    + 134 + +
    + + + log.Fatal(err) +
    +
    + 135 + +
    + + + } +
    +
    + 136 + +
    + + +
    +
    +
    + 137 + +
    +   + c.Aggregator.ChainID = l2ChainID +
    +
    + 138 + +
    +   + c.Sequencer.StreamServer.ChainID = l2ChainID +
    +
    + 139 + +
    +   + log.Infof("Chain ID read from POE SC = %v", l2ChainID) +
    +
    +
     
    +
    + 290 + +
    +   + } +
    +
    + 291 + +
    +   + } +
    +
    + 292 + +
    +   +
    +
    +
    + 293 + +
    + + + func newEtherman(c config.Config, st *state.State) (*etherman.Client, error) { +
    +
    + 294 + +
    + + + ethman, err := etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, nil, nil) +
    +
    + 295 + +
    + + + if err != nil { +
    +
    + 296 + +
    + + + return nil, err +
    +
    + 297 + +
    + + + } +
    +
    + 298 + +
    + + + da, err := newDataAvailability(c, st, ethman, false) +
    +
    + 299 + +
    + + + if err != nil { +
    +
    + 300 + +
    + + + return nil, err +
    +
    + 301 + +
    + + + } +
    +
    + 302 + +
    + + + return etherman.NewClient(c.Etherman, c.NetworkConfig.L1Config, da, st) +
    +
    + 303 + +
    + + + } +
    +
    + 304 + +
    + + +
    +
    +
    + 305 + +
    + + + func newDataAvailability(c config.Config, st *state.State, etherman *etherman.Client, isSequenceSender bool) (*dataavailability.DataAvailability, error) { +
    +
    + 306 + +
    + + + var ( +
    +
    + 307 + +
    + + + trustedSequencerURL string +
    +
    + 308 + +
    + + + err error +
    +
    + 309 + +
    + + + ) +
    +
    + 310 + +
    + + + if !c.IsTrustedSequencer { +
    +
    + 311 + +
    + + + if c.Synchronizer.TrustedSequencerURL != "" { +
    +
    + 312 + +
    + + + trustedSequencerURL = c.Synchronizer.TrustedSequencerURL +
    +
    + 313 + +
    + + + } else { +
    +
    + 314 + +
    + + + log.Debug("getting trusted sequencer URL from smc") +
    +
    + 315 + +
    + + + trustedSequencerURL, err = etherman.GetTrustedSequencerURL() +
    +
    + 316 + +
    + + + if err != nil { +
    +
    + 317 + +
    + + + return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err) +
    +
    + 318 + +
    + + + } +
    +
    + 319 + +
    + + + } +
    +
    + 320 + +
    + + + log.Debug("trustedSequencerURL ", trustedSequencerURL) +
    +
    + 321 + +
    + + + } +
    +
    + 322 + +
    + + + zkEVMClient := client.NewClient(trustedSequencerURL) +
    +
    + 323 + +
    + + +
    +
    +
    + 324 + +
    + + + // Backend specific config +
    +
    + 325 + +
    + + + daProtocolName, err := etherman.GetDAProtocolName() +
    +
    + 326 + +
    + + + if err != nil { +
    +
    + 327 + +
    + + + return nil, fmt.Errorf("error getting data availability protocol name: %v", err) +
    +
    + 328 + +
    + + + } +
    +
    + 329 + +
    + + + var daBackend dataavailability.DABackender +
    +
    + 330 + +
    + + + switch daProtocolName { +
    +
    + 331 + +
    + + + case string(dataavailability.DataAvailabilityCommittee): +
    +
    + 332 + +
    + + + var ( +
    +
    + 333 + +
    + + + pk *ecdsa.PrivateKey +
    +
    + 334 + +
    + + + err error +
    +
    + 335 + +
    + + + ) +
    +
    + 336 + +
    + + + if isSequenceSender { +
    +
    + 337 + +
    + + + _, pk, err = etherman.LoadAuthFromKeyStore(c.SequenceSender.PrivateKey.Path, c.SequenceSender.PrivateKey.Password) +
    +
    + 338 + +
    + + + if err != nil { +
    +
    + 339 + +
    + + + return nil, err +
    +
    + 340 + +
    + + + } +
    +
    + 341 + +
    + + + } +
    +
    + 342 + +
    + + + dacAddr, err := etherman.GetDAProtocolAddr() +
    +
    + 343 + +
    + + + if err != nil { +
    +
    + 344 + +
    + + + return nil, fmt.Errorf("error getting trusted sequencer URI. Error: %v", err) +
    +
    + 345 + +
    + + + } +
    +
    + 346 + +
    + + +
    +
    +
    + 347 + +
    + + + daBackend, err = datacommittee.New( +
    +
    + 348 + +
    + + + c.Etherman.URL, +
    +
    + 349 + +
    + + + dacAddr, +
    +
    + 350 + +
    + + + pk, +
    +
    + 351 + +
    + + + dataCommitteeClient.NewFactory(), +
    +
    + 352 + +
    + + + ) +
    +
    + 353 + +
    + + + if err != nil { +
    +
    + 354 + +
    + + + return nil, err +
    +
    + 355 + +
    + + + } +
    +
    + 356 + +
    + + + default: +
    +
    + 357 + +
    + + + return nil, fmt.Errorf("unexpected / unsupported DA protocol: %s", daProtocolName) +
    +
    + 358 + +
    + + + } +
    +
    + 359 + +
    + + +
    +
    +
    + 360 + +
    + + + return dataavailability.New( +
    +
    + 361 + +
    + + + c.IsTrustedSequencer, +
    +
    + 362 + +
    + + + daBackend, +
    +
    + 363 + +
    + + + st, +
    +
    + 364 + +
    + + + zkEVMClient, +
    +
    + 365 + +
    + + + ) +
    +
    + 366 + +
    +   + } +
    +
    + 367 + +
    +   +
    +
    +
    + 368 + +
    +   + func newL2EthClient(url string) (*ethclient.Client, error) { +
    +
    +
     
    +
    + 405 + +
    +   + // If synchronizer are using sequential mode, we only need one etherman client +
    +
    + 406 + +
    +   + if cfg.Synchronizer.L1SynchronizationMode == synchronizer.ParallelMode { +
    +
    + 407 + +
    +   + for i := 0; i < int(cfg.Synchronizer.L1ParallelSynchronization.MaxClients+1); i++ { +
    +
    + 408 + +
    + + + eth, err := newEtherman(cfg, st) +
    +
    + 409 + +
    +   + if err != nil { +
    +
    + 410 + +
    +   + log.Fatal(err) +
    +
    + 411 + +
    +   + } +
    +
    +
     
    +
    + 508 + +
    +   + } +
    +
    + 509 + +
    +   +
    +
    +
    + 510 + +
    +   + func createSequenceSender(cfg config.Config, pool *pool.Pool, etmStorage *ethtxmanager.PostgresStorage, st *state.State, eventLog *event.EventLog) *sequencesender.SequenceSender { +
    +
    + 511 + +
    + + + etherman, err := newEtherman(cfg, st) +
    +
    + 512 + +
    +   + if err != nil { +
    +
    + 513 + +
    +   + log.Fatal(err) +
    +
    + 514 + +
    +   + } +
    +
    + 515 + +
    +   +
    +
    +
    + 516 + +
    + + + auth, _, err := etherman.LoadAuthFromKeyStore(cfg.SequenceSender.PrivateKey.Path, cfg.SequenceSender.PrivateKey.Password) +
    +
    + 517 + +
    +   + if err != nil { +
    +
    + 518 + +
    +   + log.Fatal(err) +
    +
    + 519 + +
    +   + } +
    +
    +
     
    +
    + 523 + +
    +   +
    +
    +
    + 524 + +
    +   + ethTxManager := ethtxmanager.New(cfg.EthTxManager, etherman, etmStorage, st) +
    +
    + 525 + +
    +   +
    +
    +
    + 526 + +
    + + + da, err := newDataAvailability(cfg, st, etherman, true) +
    +
    + 527 + +
    + + + if err != nil { +
    +
    + 528 + +
    + + + log.Fatal(err) +
    +
    + 529 + +
    + + + } +
    +
    + 530 + +
    + + +
    +
    +
    + 531 + +
    + + + seqSender, err := sequencesender.New(cfg.SequenceSender, st, etherman, ethTxManager, eventLog, da) +
    +
    + 532 + +
    +   + if err != nil { +
    +
    + 533 + +
    +   + log.Fatal(err) +
    +
    + 534 + +
    +   + } +
    +
    +
     
    +
    + 537 + +
    +   + } +
    +
    + 538 + +
    +   +
    +
    +
    + 539 + +
    +   + func runAggregator(ctx context.Context, c aggregator.Config, etherman *etherman.Client, ethTxManager *ethtxmanager.Client, st *state.State) { +
    +
    + 540 + +
    + + + var ( +
    +
    + 541 + +
    + + + aggCli *agglayerClient.Client +
    +
    + 542 + +
    + + + pk *ecdsa.PrivateKey +
    +
    + 543 + +
    + + + err error +
    +
    + 544 + +
    + + + ) +
    +
    + 545 + +
    + + +
    +
    +
    + 546 + +
    + + + if c.SettlementBackend == aggregator.AggLayer { +
    +
    + 547 + +
    + + + aggCli = agglayerClient.New(c.AggLayerURL) +
    +
    + 548 + +
    + + +
    +
    +
    + 549 + +
    + + + // Load private key +
    +
    + 550 + +
    + + + pk, err = config.NewKeyFromKeystore(c.SequencerPrivateKey) +
    +
    + 551 + +
    + + + if err != nil { +
    +
    + 552 + +
    + + + log.Fatal(err) +
    +
    + 553 + +
    + + + } +
    +
    + 554 + +
    + + + } +
    +
    + 555 + +
    + + +
    +
    +
    + 556 + +
    + + + agg, err := aggregator.New(c, st, ethTxManager, etherman, aggCli, pk) +
    +
    + 557 + +
    +   + if err != nil { +
    +
    + 558 + +
    +   + log.Fatal(err) +
    +
    + 559 + +
    +   + } +
    +
    +
     
    +
    + 615 + +
    +   + AvoidForkIDInMemory: avoidForkIDInMemory, +
    +
    + 616 + +
    +   + } +
    +
    + 617 + +
    +   + stateDb := pgstatestorage.NewPostgresStorage(stateCfg, sqlDB) +
    +
    + 618 + +
    + + + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, nil) +
    +
    + + +
    +   +
    +
    +
    + 619 + +
    +   + // This is to force to build cache, and check that DB is ok before starting the application +
    +
    + 620 + +
    + + + l1inforoot, err := st.GetCurrentL1InfoRoot(ctx, nil) +
    +
    + 621 + +
    +   + if err != nil { +
    +
    + 622 + +
    +   + log.Fatal("error getting current L1InfoRoot. Error: ", err) +
    +
    + 623 + +
    +   + } +
    +
    + 624 + +
    + + + log.Infof("Starting L1InfoRoot: %v", l1inforoot.String()) +
    +
    + 625 + +
    +   +
    +
    +
    + 626 + +
    + + + forkIDIntervals, err := forkIDIntervals(ctx, st, etherman, c.NetworkConfig.Genesis.RollupBlockNumber) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 627 + +
    +   + if err != nil { +
    +
    + 628 + +
    +   + log.Fatal("error getting forkIDs. Error: ", err) +
    +
    + 629 + +
    +   + } +
    +
    + 630 + +
    +   + st.UpdateForkIDIntervalsInMemory(forkIDIntervals) +
    +
    + 631 + +
    +   +
    +
    +
    + 632 + +
    +   + currentForkID := forkIDIntervals[len(forkIDIntervals)-1].ForkId +
    +
    + 633 + +
    + + + log.Infof("Fork ID read from POE SC = %v", currentForkID) +
    +
    + 634 + +
    +   +
    +
    +
    + 635 + +
    +   + return st, currentForkID +
    +
    + 636 + +
    +   + } +
    +
    +
     
    +
    + 646 + +
    +   + } +
    +
    + 647 + +
    +   +
    +
    +
    + 648 + +
    +   + func createEthTxManager(cfg config.Config, etmStorage *ethtxmanager.PostgresStorage, st *state.State) *ethtxmanager.Client { +
    +
    + 649 + +
    + + + etherman, err := newEtherman(cfg, st) +
    +
    + 650 + +
    +   + if err != nil { +
    +
    + 651 + +
    +   + log.Fatal(err) +
    +
    + 652 + +
    +   + } +
    +
    + 653 + +
    +   +
    +
    +
    + 654 + +
    +   + for _, privateKey := range cfg.EthTxManager.PrivateKeys { +
    +
    + 655 + +
    + + + _, _, err := etherman.LoadAuthFromKeyStore(privateKey.Path, privateKey.Password) +
    +
    + 656 + +
    +   + if err != nil { +
    +
    + 657 + +
    +   + log.Fatal(err) +
    +
    + 658 + +
    +   + } +
    +
    +
     
    +
    + 744 + +
    +   + if err != nil && !errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 745 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error checking lastL1BlockSynced. Error: %v", err) +
    +
    + 746 + +
    +   + } +
    +
    + 747 + +
    + + + if lastBlock != nil { +
    +
    + + +
    +   +
    +
    +
    + 748 + +
    +   + log.Info("Getting forkIDs intervals. Please wait...") +
    +
    + 749 + +
    +   + // Read Fork ID FROM POE SC +
    +
    + 750 + +
    +   + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, lastBlock.BlockNumber) +
    +
    +
     
    +
    + 784 + +
    +   + } +
    +
    + 785 + +
    +   + forkIDIntervals = forkIntervals +
    +
    + 786 + +
    +   + } else { +
    +
    + 787 + +
    + + + log.Debug("Getting all forkIDs") +
    +
    + 788 + +
    + + +
    +
    +
    + 789 + +
    + + + // Get last L1 block number +
    +
    + 790 + +
    + + + bn, err := etherman.GetLatestBlockNumber(ctx) +
    +
    + 791 + +
    + + + if err != nil { +
    +
    + 792 + +
    + + + return []state.ForkIDInterval{}, fmt.Errorf("error getting latest block number. Error: %v", err) +
    +
    + 793 + +
    + + + } +
    +
    + 794 + +
    + + +
    +
    +
    + 795 + +
    + + + // Get all forkIDs since genesis +
    +
    + 796 + +
    + + + forkIntervals, err := etherman.GetForks(ctx, genesisBlockNumber, bn) +
    +
    + 797 + +
    +   + if err != nil { +
    +
    + 798 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error getting forks. Please check the configuration. Error: %v", err) +
    +
    + 799 + +
    +   + } else if len(forkIntervals) == 0 { +
    +
    + 800 + +
    +   + return []state.ForkIDInterval{}, fmt.Errorf("error: no forkID received. It should receive at least one, please check the configuration...") +
    +
    + 801 + +
    +   + } +
    +
    + 802 + +
    +   + forkIDIntervals = forkIntervals +
    +
    + 803 + +
    + + +
    +
    +
    + 804 + +
    + + + log.Debugf("Retrieved %d forkIDs", len(forkIDIntervals)) +
    +
    + 805 + +
    + + +
    +
    +
    + 806 + +
    + + + log.Debug("Adding forkIDs to db and memory") +
    +
    + 807 + +
    + + + for _, forkID := range forkIDIntervals { +
    +
    + 808 + +
    + + + err = st.AddForkIDInterval(ctx, forkID, nil) +
    +
    + 809 + +
    + + + if err != nil { +
    +
    + 810 + +
    + + + log.Fatal("error adding forkID to db. Error: ", err) +
    +
    + 811 + +
    + + + } +
    +
    + 812 + +
    + + + } +
    +
    + 813 + +
    +   + } +
    +
    + 814 + +
    +   + } +
    +
    + 815 + +
    +   + return forkIDIntervals, nil +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/cmd/set_data_availability_protocol.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,68 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package main +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/config" +
    +
    + 5 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 6 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 7 + +
    + + + "github.com/urfave/cli/v2" +
    +
    + 8 + +
    + + + ) +
    +
    + 9 + +
    + + +
    +
    +
    + 10 + +
    + + + const flagDAAddress = "data-availability-address" +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + var setDataAvailabilityProtocolFlags = []cli.Flag{ +
    +
    + 13 + +
    + + + &cli.StringFlag{ +
    +
    + 14 + +
    + + + Name: flagDAAddress, +
    +
    + 15 + +
    + + + Aliases: []string{"da-addr"}, +
    +
    + 16 + +
    + + + Usage: "address of the new data availibility protocol", +
    +
    + 17 + +
    + + + Required: true, +
    +
    + 18 + +
    + + + }, +
    +
    + 19 + +
    + + + &cli.StringFlag{ +
    +
    + 20 + +
    + + + Name: config.FlagKeyStorePath, +
    +
    + 21 + +
    + + + Aliases: []string{"ksp"}, +
    +
    + 22 + +
    + + + Usage: "the path of the key store file containing the private key of the account going to set new data availability protocol", +
    +
    + 23 + +
    + + + Required: true, +
    +
    + 24 + +
    + + + }, +
    +
    + 25 + +
    + + + &cli.StringFlag{ +
    +
    + 26 + +
    + + + Name: config.FlagPassword, +
    +
    + 27 + +
    + + + Aliases: []string{"pw"}, +
    +
    + 28 + +
    + + + Usage: "the password do decrypt the key store file", +
    +
    + 29 + +
    + + + Required: true, +
    +
    + 30 + +
    + + + }, +
    +
    + 31 + +
    + + + &configFileFlag, +
    +
    + 32 + +
    + + + &networkFlag, +
    +
    + 33 + +
    + + + &customNetworkFlag, +
    +
    + 34 + +
    + + + } +
    +
    + 35 + +
    + + +
    +
    +
    + 36 + +
    + + + func setDataAvailabilityProtocol(ctx *cli.Context) error { +
    +
    + 37 + +
    + + + c, err := config.Load(ctx, true) +
    +
    + 38 + +
    + + + if err != nil { +
    +
    + 39 + +
    + + + return err +
    +
    + 40 + +
    + + + } +
    +
    + 41 + +
    + + +
    +
    +
    + 42 + +
    + + + setupLog(c.Log) +
    +
    + 43 + +
    + + +
    +
    +
    + 44 + +
    + + + daAddress := common.HexToAddress(ctx.String(flagDAAddress)) +
    +
    + 45 + +
    + + + addrKeyStorePath := ctx.String(config.FlagKeyStorePath) +
    +
    + 46 + +
    + + + addrPassword := ctx.String(config.FlagPassword) +
    +
    + 47 + +
    + + +
    +
    +
    + 48 + +
    + + + etherman, err := newEtherman(*c, nil) +
    +
    + 49 + +
    + + + if err != nil { +
    +
    + 50 + +
    + + + log.Fatal(err) +
    +
    + 51 + +
    + + + return err +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + +
    +
    +
    + 54 + +
    + + + auth, _, err := etherman.LoadAuthFromKeyStore(addrKeyStorePath, addrPassword) +
    +
    + 55 + +
    + + + if err != nil { +
    +
    + 56 + +
    + + + log.Fatal(err) +
    +
    + 57 + +
    + + + return err +
    +
    + 58 + +
    + + + } +
    +
    + 59 + +
    + + +
    +
    +
    + 60 + +
    + + + tx, err := etherman.SetDataAvailabilityProtocol(auth.From, daAddress) +
    +
    + 61 + +
    + + + if err != nil { +
    +
    + 62 + +
    + + + return err +
    +
    + 63 + +
    + + + } +
    +
    + 64 + +
    + + +
    +
    +
    + 65 + +
    + + + log.Infof("Transaction to set new data availability protocol sent. Hash: %s", tx.Hash()) +
    +
    + 66 + +
    + + +
    +
    +
    + 67 + +
    + + + return nil +
    +
    + 68 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/cardonagenesis.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,109 +0,0 @@
    +
    + 1 + +
    + - + package config +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + // CardonaNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup +
    +
    + 4 + +
    + - + const CardonaNetworkConfigJSON = ` +
    +
    + 5 + +
    + - + { +
    +
    + 6 + +
    + - + "l1Config": { +
    +
    + 7 + +
    + - + "polygonZkEVMAddress": "0xA13Ddb14437A8F34897131367ad3ca78416d6bCa", +
    +
    + 8 + +
    + - + "polygonZkEVMBridgeAddress": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582", +
    +
    + 9 + +
    + - + "polygonZkEVMGlobalExitRootAddress": "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF", +
    +
    + 10 + +
    + - + "polTokenAddress": "0x6a7c3F4B0651d6DA389AD1d11D962ea458cDCA70", +
    +
    + 11 + +
    + - + "polygonRollupManagerAddress": "0x32d33D5137a7cFFb54c5Bf8371172bcEc5f310ff", +
    +
    + 12 + +
    + - + "chainId": 11155111 +
    +
    + 13 + +
    + - + }, +
    +
    + 14 + +
    + - + "genesisBlockNumber": 4789190, +
    +
    + 15 + +
    + - + "root": "0x91dfcdeb628dfdc51f3a2ee38cb17c78581e4e7ff91bcc2e327d24a9dfa46982", +
    +
    + 16 + +
    + - + "genesis": [ +
    +
    + 17 + +
    + - + { +
    +
    + 18 + +
    + - + "contractName": "PolygonZkEVMDeployer", +
    +
    + 19 + +
    + - + "balance": "0", +
    +
    + 20 + +
    + - + "nonce": "4", +
    +
    + 21 + +
    + - + "address": "0x36810012486fc134D0679c07f85fe5ba5A087D8C", +
    +
    + 22 + +
    + - + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033", +
    +
    + 23 + +
    + - + "storage": { +
    +
    + 24 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000ff6250d0e86a2465b0c1bf8e36409503d6a26963" +
    +
    + 25 + +
    + - + } +
    +
    + 26 + +
    + - + }, +
    +
    + 27 + +
    + - + { +
    +
    + 28 + +
    + - + "contractName": "ProxyAdmin", +
    +
    + 29 + +
    + - + "balance": "0", +
    +
    + 30 + +
    + - + "nonce": "1", +
    +
    + 31 + +
    + - + "address": "0x85cEB41028B1a5ED2b88E395145344837308b251", +
    +
    + 32 + +
    + - + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033", +
    +
    + 33 + +
    + - + "storage": { +
    +
    + 34 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000dbc6981a11fc2b000c635bfa7c47676b25c87d39" +
    +
    + 35 + +
    + - + } +
    +
    + 36 + +
    + - + }, +
    +
    + 37 + +
    + - + { +
    +
    + 38 + +
    + - + "contractName": "PolygonZkEVMBridge implementation", +
    +
    + 39 + +
    + - + "balance": "0", +
    +
    + 40 + +
    + - + "nonce": "1", +
    +
    + 41 + +
    + - + "address": "0x8BD36ca1A55e389335004872aA3C3Be0969D3aA7", +
    +
    + 42 + +
    + - + "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033" +
    +
    + 43 + +
    + - + }, +
    +
    + 44 + +
    + - + { +
    +
    + 45 + +
    + - + "contractName": "PolygonZkEVMBridge proxy", +
    +
    + 46 + +
    + - + "balance": "200000000000000000000000000", +
    +
    + 47 + +
    + - + "nonce": "1", +
    +
    + 48 + +
    + - + "address": "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582", +
    +
    + 49 + +
    + - + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", +
    +
    + 50 + +
    + - + "storage": { +
    +
    + 51 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 52 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 53 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", +
    +
    + 54 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251", +
    +
    + 55 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000008bd36ca1a55e389335004872aa3c3be0969d3aa7" +
    +
    + 56 + +
    + - + } +
    +
    + 57 + +
    + - + }, +
    +
    + 58 + +
    + - + { +
    +
    + 59 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", +
    +
    + 60 + +
    + - + "balance": "0", +
    +
    + 61 + +
    + - + "nonce": "1", +
    +
    + 62 + +
    + - + "address": "0x282a631D9F3Ef04Bf1A44B4C9e8bDC8EB278917f", +
    +
    + 63 + +
    + - + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed58281565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000528e26b25a34a4a5d0dbda1d57d318153d2ed582161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" +
    +
    + 64 + +
    + - + }, +
    +
    + 65 + +
    + - + { +
    +
    + 66 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +
    +
    + 67 + +
    + - + "balance": "0", +
    +
    + 68 + +
    + - + "nonce": "1", +
    +
    + 69 + +
    + - + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", +
    +
    + 70 + +
    + - + "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", +
    +
    + 71 + +
    + - + "storage": { +
    +
    + 72 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000085ceb41028b1a5ed2b88e395145344837308b251", +
    +
    + 73 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000282a631d9f3ef04bf1a44b4c9e8bdc8eb278917f" +
    +
    + 74 + +
    + - + } +
    +
    + 75 + +
    + - + }, +
    +
    + 76 + +
    + - + { +
    +
    + 77 + +
    + - + "contractName": "PolygonZkEVMTimelock", +
    +
    + 78 + +
    + - + "balance": "0", +
    +
    + 79 + +
    + - + "nonce": "1", +
    +
    + 80 + +
    + - + "address": "0xdbC6981a11fc2B000c635bFA7C47676b25C87D39", +
    +
    + 81 + +
    + - + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033", +
    +
    + 82 + +
    + - + "storage": { +
    +
    + 83 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", +
    +
    + 84 + +
    + - + "0xf587dde6f8846415188f807710a3304f72092565918b30307d60efdc8014f20b": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 85 + +
    + - + "0x07020fe9de9b8274d1e6cc0668a6f6344a870f35e5a847590c8069dfa85ac78f": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 86 + +
    + - + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 87 + +
    + - + "0xc8e266e0814671642b74f3807affd27009fcc23f713ea92d1743e0ee0c1e7603": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 88 + +
    + - + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 89 + +
    + - + "0x9b3efc411c5f69533db363941e091f6f3af8b7e306525413577a56d27e5dbe73": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 90 + +
    + - + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 91 + +
    + - + "0xa2001bdd6a5944149e83176d089ee9a8246bd56aecf38fe4d6c66f5fbac18675": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 92 + +
    + - + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +
    +
    + 93 + +
    + - + } +
    +
    + 94 + +
    + - + }, +
    +
    + 95 + +
    + - + { +
    +
    + 96 + +
    + - + "accountName": "keyless Deployer", +
    +
    + 97 + +
    + - + "balance": "0", +
    +
    + 98 + +
    + - + "nonce": "1", +
    +
    + 99 + +
    + - + "address": "0x1754175c450BEbB9B6E14dEe542649c0402A25d2" +
    +
    + 100 + +
    + - + }, +
    +
    + 101 + +
    + - + { +
    +
    + 102 + +
    + - + "accountName": "deployer", +
    +
    + 103 + +
    + - + "balance": "100000000000000000000000", +
    +
    + 104 + +
    + - + "nonce": "8", +
    +
    + 105 + +
    + - + "address": "0xff6250d0E86A2465B0C1bF8e36409503d6a26963" +
    +
    + 106 + +
    + - + } +
    +
    + 107 + +
    + - + ] +
    +
    + 108 + +
    + - + } +
    +
    + 109 + +
    + - + ` +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -2,6 +2,8 @@
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "bytes" +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 5 + +
    +   + "path/filepath" +
    +
    + 6 + +
    +   + "strings" +
    +
    + 7 + +
    +   +
    +
    +
    +
    @@ -21,6 +24,7 @@
    +
    + 21 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 22 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" +
    +
    + 23 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer" +
    +
    + + +
    +   +
    +
    +
    + 24 + +
    +   + "github.com/mitchellh/mapstructure" +
    +
    + 25 + +
    +   + "github.com/spf13/viper" +
    +
    + 26 + +
    +   + "github.com/urfave/cli/v2" +
    +
    +
    @@ -31,7 +35,7 @@
    +
    + 31 + +
    +   + FlagYes = "yes" +
    +
    + 32 + +
    +   + // FlagCfg is the flag for cfg. +
    +
    + 33 + +
    +   + FlagCfg = "cfg" +
    +
    + 34 + +
    + - + // FlagNetwork is the flag for the network name. Valid values: ["testnet", "mainnet", "cardona", "custom"]. +
    +
    + 35 + +
    +   + FlagNetwork = "network" +
    +
    + 36 + +
    +   + // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom +
    +
    + 37 + +
    +   + FlagCustomNetwork = "custom-network-file" +
    +
    +
    @@ -183,3 +187,19 @@
    +
    + 183 + +
    +   + } +
    +
    + 184 + +
    +   + return cfg, nil +
    +
    + 185 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "bytes" +
    +
    + 5 + +
    + + + "crypto/ecdsa" +
    +
    + 6 + +
    + + + "os" +
    +
    + 7 + +
    +   + "path/filepath" +
    +
    + 8 + +
    +   + "strings" +
    +
    + 9 + +
    +   +
    +
    +
    +
     
    +
    + 24 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 25 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" +
    +
    + 26 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/synchronizer" +
    +
    + 27 + +
    + + + "github.com/ethereum/go-ethereum/accounts/keystore" +
    +
    + 28 + +
    +   + "github.com/mitchellh/mapstructure" +
    +
    + 29 + +
    +   + "github.com/spf13/viper" +
    +
    + 30 + +
    +   + "github.com/urfave/cli/v2" +
    +
    +
     
    +
    + 35 + +
    +   + FlagYes = "yes" +
    +
    + 36 + +
    +   + // FlagCfg is the flag for cfg. +
    +
    + 37 + +
    +   + FlagCfg = "cfg" +
    +
    + 38 + +
    + + + // FlagNetwork is the flag for the network name. Valid values: ["custom"]. +
    +
    + 39 + +
    +   + FlagNetwork = "network" +
    +
    + 40 + +
    +   + // FlagCustomNetwork is the flag for the custom network file. This is required if --network=custom +
    +
    + 41 + +
    +   + FlagCustomNetwork = "custom-network-file" +
    +
    +
     
    +
    + 187 + +
    +   + } +
    +
    + 188 + +
    +   + return cfg, nil +
    +
    + 189 + +
    +   + } +
    +
    + 190 + +
    + + +
    +
    +
    + 191 + +
    + + + // NewKeyFromKeystore creates a private key from a keystore file +
    +
    + 192 + +
    + + + func NewKeyFromKeystore(cfg types.KeystoreFileConfig) (*ecdsa.PrivateKey, error) { +
    +
    + 193 + +
    + + + if cfg.Path == "" && cfg.Password == "" { +
    +
    + 194 + +
    + + + return nil, nil +
    +
    + 195 + +
    + + + } +
    +
    + 196 + +
    + + + keystoreEncrypted, err := os.ReadFile(filepath.Clean(cfg.Path)) +
    +
    + 197 + +
    + + + if err != nil { +
    +
    + 198 + +
    + + + return nil, err +
    +
    + 199 + +
    + + + } +
    +
    + 200 + +
    + + + key, err := keystore.DecryptKey(keystoreEncrypted, cfg.Password) +
    +
    + 201 + +
    + + + if err != nil { +
    +
    + 202 + +
    + + + return nil, err +
    +
    + 203 + +
    + + + } +
    +
    + 204 + +
    + + + return key.PrivateKey, nil +
    +
    + 205 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/config_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -58,7 +58,7 @@
    +
    + 58 + +
    +   + }, +
    +
    + 59 + +
    +   + { +
    +
    + 60 + +
    +   + path: "Synchronizer.L2Synchronization.ReprocessFullBatchOnClose", +
    +
    + 61 + +
    + - + expectedValue: true, +
    +
    + 62 + +
    +   + }, +
    +
    + 63 + +
    +   + { +
    +
    + 64 + +
    +   + path: "Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch", +
    +
    +
    @@ -174,24 +174,28 @@
    +
    + 174 + +
    +   + expectedValue: uint64(80000), +
    +
    + 175 + +
    +   + }, +
    +
    + 176 + +
    +   + { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 177 + +
    +   + path: "Etherman.URL", +
    +
    + 178 + +
    +   + expectedValue: "http://localhost:8545", +
    +
    + 179 + +
    +   + }, +
    +
    + 180 + +
    +   + { +
    +
    + 181 + +
    +   + path: "NetworkConfig.L1Config.L1ChainID", +
    +
    + 182 + +
    + - + expectedValue: uint64(5), +
    +
    + 183 + +
    +   + }, +
    +
    + 184 + +
    +   + { +
    +
    + 185 + +
    +   + path: "NetworkConfig.L1Config.ZkEVMAddr", +
    +
    + 186 + +
    + - + expectedValue: common.HexToAddress("0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A"), +
    +
    + 187 + +
    +   + }, +
    +
    + 188 + +
    +   + { +
    +
    + 189 + +
    +   + path: "NetworkConfig.L1Config.PolAddr", +
    +
    + 190 + +
    + - + expectedValue: common.HexToAddress("0x1319D23c2F7034F52Eb07399702B040bA278Ca49"), +
    +
    + 191 + +
    +   + }, +
    +
    + 192 + +
    +   + { +
    +
    + 193 + +
    +   + path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", +
    +
    + 194 + +
    + - + expectedValue: common.HexToAddress("0x4d9427DCA0406358445bC0a8F88C26b704004f74"), +
    +
    + 195 + +
    +   + }, +
    +
    + 196 + +
    +   + { +
    +
    + 197 + +
    +   + path: "Etherman.MultiGasProvider", +
    +
    +
    @@ -547,7 +551,8 @@
    +
    + 547 + +
    +   + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) +
    +
    + 548 + +
    +   +
    +
    +
    + 549 + +
    +   + flagSet := flag.NewFlagSet("", flag.PanicOnError) +
    +
    + 550 + +
    + - + flagSet.String(config.FlagNetwork, "testnet", "") +
    +
    + + +
    +   +
    +
    +
    + 551 + +
    +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil) +
    +
    + 552 + +
    +   + cfg, err := config.Load(ctx, true) +
    +
    + 553 + +
    +   + if err != nil { +
    +
    +
    @@ -585,7 +590,8 @@
    +
    + 585 + +
    +   + }() +
    +
    + 586 + +
    +   + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) +
    +
    + 587 + +
    +   + flagSet := flag.NewFlagSet("", flag.PanicOnError) +
    +
    + 588 + +
    + - + flagSet.String(config.FlagNetwork, "testnet", "") +
    +
    + + +
    +   +
    +
    +
    + 589 + +
    +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil) +
    +
    + 590 + +
    +   +
    +
    +
    + 591 + +
    +   + os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c") +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 58 + +
    +   + }, +
    +
    + 59 + +
    +   + { +
    +
    + 60 + +
    +   + path: "Synchronizer.L2Synchronization.ReprocessFullBatchOnClose", +
    +
    + 61 + +
    + + + expectedValue: false, +
    +
    + 62 + +
    +   + }, +
    +
    + 63 + +
    +   + { +
    +
    + 64 + +
    +   + path: "Synchronizer.L2Synchronization.CheckLastL2BlockHashOnCloseBatch", +
    +
    +
     
    +
    + 174 + +
    +   + expectedValue: uint64(80000), +
    +
    + 175 + +
    +   + }, +
    +
    + 176 + +
    +   + { +
    +
    + 177 + +
    + + + path: "SequenceSender.MaxBatchesForL1", +
    +
    + 178 + +
    + + + expectedValue: uint64(300), +
    +
    + 179 + +
    + + + }, +
    +
    + 180 + +
    + + + { +
    +
    + 181 + +
    +   + path: "Etherman.URL", +
    +
    + 182 + +
    +   + expectedValue: "http://localhost:8545", +
    +
    + 183 + +
    +   + }, +
    +
    + 184 + +
    +   + { +
    +
    + 185 + +
    +   + path: "NetworkConfig.L1Config.L1ChainID", +
    +
    + 186 + +
    + + + expectedValue: uint64(1337), +
    +
    + 187 + +
    +   + }, +
    +
    + 188 + +
    +   + { +
    +
    + 189 + +
    +   + path: "NetworkConfig.L1Config.ZkEVMAddr", +
    +
    + 190 + +
    + + + expectedValue: common.HexToAddress("0x8dAF17A20c9DBA35f005b6324F493785D239719d"), +
    +
    + 191 + +
    +   + }, +
    +
    + 192 + +
    +   + { +
    +
    + 193 + +
    +   + path: "NetworkConfig.L1Config.PolAddr", +
    +
    + 194 + +
    + + + expectedValue: common.HexToAddress("0x5FbDB2315678afecb367f032d93F642f64180aa3"), +
    +
    + 195 + +
    +   + }, +
    +
    + 196 + +
    +   + { +
    +
    + 197 + +
    +   + path: "NetworkConfig.L1Config.GlobalExitRootManagerAddr", +
    +
    + 198 + +
    + + + expectedValue: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), +
    +
    + 199 + +
    +   + }, +
    +
    + 200 + +
    +   + { +
    +
    + 201 + +
    +   + path: "Etherman.MultiGasProvider", +
    +
    +
     
    +
    + 551 + +
    +   + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) +
    +
    + 552 + +
    +   +
    +
    +
    + 553 + +
    +   + flagSet := flag.NewFlagSet("", flag.PanicOnError) +
    +
    + 554 + +
    + + + flagSet.String(config.FlagNetwork, "custom", "") +
    +
    + 555 + +
    + + + flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") +
    +
    + 556 + +
    +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil) +
    +
    + 557 + +
    +   + cfg, err := config.Load(ctx, true) +
    +
    + 558 + +
    +   + if err != nil { +
    +
    +
     
    +
    + 590 + +
    +   + }() +
    +
    + 591 + +
    +   + require.NoError(t, os.WriteFile(file.Name(), []byte("{}"), 0600)) +
    +
    + 592 + +
    +   + flagSet := flag.NewFlagSet("", flag.PanicOnError) +
    +
    + 593 + +
    + + + flagSet.String(config.FlagNetwork, "custom", "") +
    +
    + 594 + +
    + + + flagSet.String(config.FlagCustomNetwork, "../test/config/test.genesis.config.json", "") +
    +
    + 595 + +
    +   + ctx := cli.NewContext(cli.NewApp(), flagSet, nil) +
    +
    + 596 + +
    +   +
    +
    +
    + 597 + +
    +   + os.Setenv("ZKEVM_NODE_LOG_OUTPUTS", "a,b,c") +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/default.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -105,7 +105,7 @@
    +
    + 105 + +
    +   + SyncBlockProtection = "safe" # latest, finalized, safe +
    +
    + 106 + +
    +   + L1SynchronizationMode = "sequential" +
    +
    + 107 + +
    +   + L1SyncCheckL2BlockHash = true +
    +
    + 108 + +
    + - + L1SyncCheckL2BlockNumberModulus = 600 +
    +
    + 109 + +
    +   + [Synchronizer.L1BlockCheck] +
    +
    + 110 + +
    +   + Enable = true +
    +
    + 111 + +
    +   + L1SafeBlockPoint = "finalized" +
    +
    +
    @@ -129,7 +129,7 @@
    +
    + 129 + +
    +   + ApplyAfterNumRollupReceived = 10 +
    +
    + 130 + +
    +   + [Synchronizer.L2Synchronization] +
    +
    + 131 + +
    +   + AcceptEmptyClosedBatches = false +
    +
    + 132 + +
    + - + ReprocessFullBatchOnClose = true +
    +
    + 133 + +
    +   + CheckLastL2BlockHashOnCloseBatch = true +
    +
    + 134 + +
    +   +
    +
    +
    + 135 + +
    +   + [Sequencer] +
    +
    +
    @@ -169,6 +169,7 @@
    +
    + 169 + +
    +   + L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" +
    +
    + 170 + +
    +   + PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} +
    +
    + 171 + +
    +   + GasOffset = 80000 +
    +
    + + +
    +   +
    +
    +
    + 172 + +
    +   +
    +
    +
    + 173 + +
    +   + [Aggregator] +
    +
    + 174 + +
    +   + Host = "0.0.0.0" +
    +
    +
    @@ -183,6 +184,10 @@
    +
    + 183 + +
    +   + GasOffset = 0 +
    +
    + 184 + +
    +   + UpgradeEtrogBatchNumber = 0 +
    +
    + 185 + +
    +   + BatchProofL1BlockConfirmations = 2 +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 186 + +
    +   +
    +
    +
    + 187 + +
    +   + [L2GasPriceSuggester] +
    +
    + 188 + +
    +   + Type = "follower" +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 105 + +
    +   + SyncBlockProtection = "safe" # latest, finalized, safe +
    +
    + 106 + +
    +   + L1SynchronizationMode = "sequential" +
    +
    + 107 + +
    +   + L1SyncCheckL2BlockHash = true +
    +
    + 108 + +
    + + + L1SyncCheckL2BlockNumberhModulus = 600 +
    +
    + 109 + +
    +   + [Synchronizer.L1BlockCheck] +
    +
    + 110 + +
    +   + Enable = true +
    +
    + 111 + +
    +   + L1SafeBlockPoint = "finalized" +
    +
    +
     
    +
    + 129 + +
    +   + ApplyAfterNumRollupReceived = 10 +
    +
    + 130 + +
    +   + [Synchronizer.L2Synchronization] +
    +
    + 131 + +
    +   + AcceptEmptyClosedBatches = false +
    +
    + 132 + +
    + + + ReprocessFullBatchOnClose = false +
    +
    + 133 + +
    +   + CheckLastL2BlockHashOnCloseBatch = true +
    +
    + 134 + +
    +   +
    +
    +
    + 135 + +
    +   + [Sequencer] +
    +
    +
     
    +
    + 169 + +
    +   + L2Coinbase = "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" +
    +
    + 170 + +
    +   + PrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} +
    +
    + 171 + +
    +   + GasOffset = 80000 +
    +
    + 172 + +
    + + + MaxBatchesForL1 = 300 +
    +
    + 173 + +
    +   +
    +
    +
    + 174 + +
    +   + [Aggregator] +
    +
    + 175 + +
    +   + Host = "0.0.0.0" +
    +
    +
     
    +
    + 184 + +
    +   + GasOffset = 0 +
    +
    + 185 + +
    +   + UpgradeEtrogBatchNumber = 0 +
    +
    + 186 + +
    +   + BatchProofL1BlockConfirmations = 2 +
    +
    + 187 + +
    + + + SettlementBackend = "agglayer" +
    +
    + 188 + +
    + + + AggLayerTxTimeout = "5m" +
    +
    + 189 + +
    + + + AggLayerURL = "http://zkevm-agglayer" +
    +
    + 190 + +
    + + + SequencerPrivateKey = {Path = "/pk/sequencer.keystore", Password = "testonly"} +
    +
    + 191 + +
    +   +
    +
    +
    + 192 + +
    +   + [L2GasPriceSuggester] +
    +
    + 193 + +
    +   + Type = "follower" +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/mainnetgenesis.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,108 +0,0 @@
    +
    + 1 + +
    + - + package config +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + // MainnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup +
    +
    + 4 + +
    + - + const MainnetNetworkConfigJSON = ` +
    +
    + 5 + +
    + - + { +
    +
    + 6 + +
    + - + "l1Config" : { +
    +
    + 7 + +
    + - + "chainId": 1, +
    +
    + 8 + +
    + - + "polygonZkEVMAddress": "0x519E42c24163192Dca44CD3fBDCEBF6be9130987", +
    +
    + 9 + +
    + - + "polygonRollupManagerAddress": "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2", +
    +
    + 10 + +
    + - + "polTokenAddress": "0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6", +
    +
    + 11 + +
    + - + "polygonZkEVMGlobalExitRootAddress": "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb" +
    +
    + 12 + +
    + - + }, +
    +
    + 13 + +
    + - + "root": "0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9", +
    +
    + 14 + +
    + - + "genesisBlockNumber": 16896721, +
    +
    + 15 + +
    + - + "genesis": [ +
    +
    + 16 + +
    + - + { +
    +
    + 17 + +
    + - + "contractName": "PolygonZkEVMDeployer", +
    +
    + 18 + +
    + - + "balance": "0", +
    +
    + 19 + +
    + - + "nonce": "4", +
    +
    + 20 + +
    + - + "address": "0xCB19eDdE626906eB1EE52357a27F62dd519608C2", +
    +
    + 21 + +
    + - + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212203e70ce334e8ec9d8d03e87415afd36dce4e82633bd277b08937095a6bd66367764736f6c63430008110033", +
    +
    + 22 + +
    + - + "storage": { +
    +
    + 23 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000004c1665d6651ecefa59b9b3041951608468b18891" +
    +
    + 24 + +
    + - + } +
    +
    + 25 + +
    + - + }, +
    +
    + 26 + +
    + - + { +
    +
    + 27 + +
    + - + "contractName": "ProxyAdmin", +
    +
    + 28 + +
    + - + "balance": "0", +
    +
    + 29 + +
    + - + "nonce": "1", +
    +
    + 30 + +
    + - + "address": "0x0F99738B2Fc14D77308337f3e2596b63aE7BCC4A", +
    +
    + 31 + +
    + - + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220372a0e10eebea1b7fa43ae4c976994e6ed01d85eedc3637b83f01d3f06be442064736f6c63430008110033", +
    +
    + 32 + +
    + - + "storage": { +
    +
    + 33 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000bba0935fa93eb23de7990b47f0d96a8f75766d13" +
    +
    + 34 + +
    + - + } +
    +
    + 35 + +
    + - + }, +
    +
    + 36 + +
    + - + { +
    +
    + 37 + +
    + - + "contractName": "PolygonZkEVMBridge implementation", +
    +
    + 38 + +
    + - + "balance": "0", +
    +
    + 39 + +
    + - + "nonce": "1", +
    +
    + 40 + +
    + - + "address": "0x5ac4182A1dd41AeEf465E40B82fd326BF66AB82C", +
    +
    + 41 + +
    + - + "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220d9b3ca7b13ec80ac58634ddf0ecebe71e209a71f532614949b9e720413f50c8364736f6c63430008110033" +
    +
    + 42 + +
    + - + }, +
    +
    + 43 + +
    + - + { +
    +
    + 44 + +
    + - + "contractName": "PolygonZkEVMBridge proxy", +
    +
    + 45 + +
    + - + "balance": "200000000000000000000000000", +
    +
    + 46 + +
    + - + "nonce": "1", +
    +
    + 47 + +
    + - + "address": "0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe", +
    +
    + 48 + +
    + - + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", +
    +
    + 49 + +
    + - + "storage": { +
    +
    + 50 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 51 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 52 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", +
    +
    + 53 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a", +
    +
    + 54 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000005ac4182a1dd41aeef465e40b82fd326bf66ab82c" +
    +
    + 55 + +
    + - + } +
    +
    + 56 + +
    + - + }, +
    +
    + 57 + +
    + - + { +
    +
    + 58 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", +
    +
    + 59 + +
    + - + "balance": "0", +
    +
    + 60 + +
    + - + "nonce": "1", +
    +
    + 61 + +
    + - + "address": "0x0200143Fa295EE4dffEF22eE2616c2E008D81688", +
    +
    + 62 + +
    + - + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000002a3dd3eb832af982ec71669e178424b10dca2ede161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" +
    +
    + 63 + +
    + - + }, +
    +
    + 64 + +
    + - + { +
    +
    + 65 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +
    +
    + 66 + +
    + - + "balance": "0", +
    +
    + 67 + +
    + - + "nonce": "1", +
    +
    + 68 + +
    + - + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", +
    +
    + 69 + +
    + - + "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033", +
    +
    + 70 + +
    + - + "storage": { +
    +
    + 71 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x0000000000000000000000000f99738b2fc14d77308337f3e2596b63ae7bcc4a", +
    +
    + 72 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x0000000000000000000000000200143fa295ee4dffef22ee2616c2e008d81688" +
    +
    + 73 + +
    + - + } +
    +
    + 74 + +
    + - + }, +
    +
    + 75 + +
    + - + { +
    +
    + 76 + +
    + - + "contractName": "PolygonZkEVMTimelock", +
    +
    + 77 + +
    + - + "balance": "0", +
    +
    + 78 + +
    + - + "nonce": "1", +
    +
    + 79 + +
    + - + "address": "0xBBa0935Fa93Eb23de7990b47F0D96a8f75766d13", +
    +
    + 80 + +
    + - + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea26469706673582212206416c4e08f97752b4bb06159524dac058d3dccd8775e57ef1b01505751ebf7af64736f6c63430008110033", +
    +
    + 81 + +
    + - + "storage": { +
    +
    + 82 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x00000000000000000000000000000000000000000000000000000000000d2f00", +
    +
    + 83 + +
    + - + "0x33d4aa03df3f12c4f615b40676f67fdafecd3edb5a9c0ca2a47a923dae33a023": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 84 + +
    + - + "0x9fa2d8034dbcb437bee38d61fbd100910e1342ffc07f128aa1b8e6790b7f3f68": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 85 + +
    + - + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 86 + +
    + - + "0x531a7c25761aa4b0f2310edca9bb25e1e3ceb49ad4b0422aec866b3ce7567c87": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 87 + +
    + - + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 88 + +
    + - + "0xedbedc78c4240c7613622a35de050b48bd6c6d9a31b3d485b68fbbed54a4802d": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 89 + +
    + - + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 90 + +
    + - + "0x76616448da8d124a07383c26a6b2433b3259de946aa40f51524ec96ee05e871a": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 91 + +
    + - + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +
    +
    + 92 + +
    + - + } +
    +
    + 93 + +
    + - + }, +
    +
    + 94 + +
    + - + { +
    +
    + 95 + +
    + - + "accountName": "keyless Deployer", +
    +
    + 96 + +
    + - + "balance": "0", +
    +
    + 97 + +
    + - + "nonce": "1", +
    +
    + 98 + +
    + - + "address": "0x9d90066e7478496e2284E54c3548106bb4F90E50" +
    +
    + 99 + +
    + - + }, +
    +
    + 100 + +
    + - + { +
    +
    + 101 + +
    + - + "accountName": "deployer", +
    +
    + 102 + +
    + - + "balance": "0", +
    +
    + 103 + +
    + - + "nonce": "8", +
    +
    + 104 + +
    + - + "address": "0x4c1665d6651ecEfa59B9B3041951608468b18891" +
    +
    + 105 + +
    + - + } +
    +
    + 106 + +
    + - + ] +
    +
    + 107 + +
    + - + } +
    +
    + 108 + +
    + - + ` +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -25,17 +25,16 @@
    +
    + 25 + +
    +   +
    +
    +
    + 26 + +
    +   + type network string +
    +
    + 27 + +
    +   +
    +
    +
    + 28 + +
    + - + const mainnet network = "mainnet" +
    +
    + 29 + +
    + - + const testnet network = "testnet" +
    +
    + 30 + +
    + - + const cardona network = "cardona" +
    +
    + 31 + +
    +   + const custom network = "custom" +
    +
    + 32 + +
    +   +
    +
    +
    + 33 + +
    +   + // GenesisFromJSON is the config file for network_custom +
    +
    + 34 + +
    +   + type GenesisFromJSON struct { +
    +
    + 35 + +
    +   + // L1: root hash of the genesis block +
    +
    + 36 + +
    +   + Root string `json:"root"` +
    +
    + 37 + +
    + - + // L1: block number of the genesis block +
    +
    + 38 + +
    + - + GenesisBlockNum uint64 `json:"genesisBlockNumber"` +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 39 + +
    +   + // L2: List of states contracts used to populate merkle tree at initial state +
    +
    + 40 + +
    +   + Genesis []genesisAccountFromJSON `json:"genesis"` +
    +
    + 41 + +
    +   + // L1: configuration of the network +
    +
    +
    @@ -60,12 +59,6 @@
    +
    + 60 + +
    +   + func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { +
    +
    + 61 + +
    +   + var networkJSON string +
    +
    + 62 + +
    +   + switch ctx.String(FlagNetwork) { +
    +
    + 63 + +
    + - + case string(mainnet): +
    +
    + 64 + +
    + - + networkJSON = MainnetNetworkConfigJSON +
    +
    + 65 + +
    + - + case string(testnet): +
    +
    + 66 + +
    + - + networkJSON = TestnetNetworkConfigJSON +
    +
    + 67 + +
    + - + case string(cardona): +
    +
    + 68 + +
    + - + networkJSON = CardonaNetworkConfigJSON +
    +
    + 69 + +
    +   + case string(custom): +
    +
    + 70 + +
    +   + var err error +
    +
    + 71 + +
    +   + cfgPath := ctx.String(FlagCustomNetwork) +
    +
    +
    @@ -74,7 +67,7 @@
    +
    + 74 + +
    +   + panic(err.Error()) +
    +
    + 75 + +
    +   + } +
    +
    + 76 + +
    +   + default: +
    +
    + 77 + +
    + - + log.Fatalf("unsupported --network value. Must be one of: [%s, %s, %s]", mainnet, testnet, cardona, custom) +
    +
    + 78 + +
    +   + } +
    +
    + 79 + +
    +   + config, err := LoadGenesisFromJSONString(networkJSON) +
    +
    + 80 + +
    +   + if err != nil { +
    +
    +
    @@ -122,9 +115,10 @@
    +
    + 122 + +
    +   +
    +
    +
    + 123 + +
    +   + cfg.L1Config = cfgJSON.L1Config +
    +
    + 124 + +
    +   + cfg.Genesis = state.Genesis{ +
    +
    + 125 + +
    + - + BlockNumber: cfgJSON.GenesisBlockNum, +
    +
    + 126 + +
    + - + Root: common.HexToHash(cfgJSON.Root), +
    +
    + 127 + +
    + - + Actions: []*state.GenesisAction{}, +
    +
    + + +
    +   +
    +
    +
    + 128 + +
    +   + } +
    +
    + 129 + +
    +   +
    +
    +
    + 130 + +
    +   + for _, account := range cfgJSON.Genesis { +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 25 + +
    +   +
    +
    +
    + 26 + +
    +   + type network string +
    +
    + 27 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 28 + +
    +   + const custom network = "custom" +
    +
    + 29 + +
    +   +
    +
    +
    + 30 + +
    +   + // GenesisFromJSON is the config file for network_custom +
    +
    + 31 + +
    +   + type GenesisFromJSON struct { +
    +
    + 32 + +
    +   + // L1: root hash of the genesis block +
    +
    + 33 + +
    +   + Root string `json:"root"` +
    +
    + 34 + +
    + + + // L1: block number in which the rollup was created +
    +
    + 35 + +
    + + + RollupCreationBlockNum uint64 `json:"rollupCreationBlockNumber"` +
    +
    + 36 + +
    + + + // L1: block number in which the rollup manager was created +
    +
    + 37 + +
    + + + RollupManagerCreationBlockNum uint64 `json:"rollupManagerCreationBlockNumber"` +
    +
    + 38 + +
    +   + // L2: List of states contracts used to populate merkle tree at initial state +
    +
    + 39 + +
    +   + Genesis []genesisAccountFromJSON `json:"genesis"` +
    +
    + 40 + +
    +   + // L1: configuration of the network +
    +
    +
     
    +
    + 59 + +
    +   + func (cfg *Config) loadNetworkConfig(ctx *cli.Context) { +
    +
    + 60 + +
    +   + var networkJSON string +
    +
    + 61 + +
    +   + switch ctx.String(FlagNetwork) { +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 62 + +
    +   + case string(custom): +
    +
    + 63 + +
    +   + var err error +
    +
    + 64 + +
    +   + cfgPath := ctx.String(FlagCustomNetwork) +
    +
    +
     
    +
    + 67 + +
    +   + panic(err.Error()) +
    +
    + 68 + +
    +   + } +
    +
    + 69 + +
    +   + default: +
    +
    + 70 + +
    + + + log.Fatalf("unsupported --network value. Must be %s", custom) +
    +
    + 71 + +
    +   + } +
    +
    + 72 + +
    +   + config, err := LoadGenesisFromJSONString(networkJSON) +
    +
    + 73 + +
    +   + if err != nil { +
    +
    +
     
    +
    + 115 + +
    +   +
    +
    +
    + 116 + +
    +   + cfg.L1Config = cfgJSON.L1Config +
    +
    + 117 + +
    +   + cfg.Genesis = state.Genesis{ +
    +
    + 118 + +
    + + + RollupBlockNumber: cfgJSON.RollupCreationBlockNum, +
    +
    + 119 + +
    + + + RollupManagerBlockNumber: cfgJSON.RollupManagerCreationBlockNum, +
    +
    + 120 + +
    + + + Root: common.HexToHash(cfgJSON.Root), +
    +
    + 121 + +
    + + + Actions: []*state.GenesisAction{}, +
    +
    + 122 + +
    +   + } +
    +
    + 123 + +
    +   +
    +
    +
    + 124 + +
    +   + for _, account := range cfgJSON.Genesis { +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/network_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -14,18 +13,6 @@
    +
    + 14 + +
    +   + "github.com/urfave/cli/v2" +
    +
    + 15 + +
    +   + ) +
    +
    + 16 + +
    +   +
    +
    +
    + 17 + +
    + - + func TestCardona(t *testing.T) { +
    +
    + 18 + +
    + - + cfg := Config{} +
    +
    + 19 + +
    + - + fs := flag.NewFlagSet("", flag.ExitOnError) +
    +
    + 20 + +
    + - + fs.String(FlagNetwork, string(cardona), string(cardona)) +
    +
    + 21 + +
    + - + err := fs.Set(FlagNetwork, string(cardona)) +
    +
    + 22 + +
    + - + require.NoError(t, err) +
    +
    + 23 + +
    + - + app := cli.NewApp() +
    +
    + 24 + +
    + - + ctx := cli.NewContext(app, fs, nil) +
    +
    + 25 + +
    + - +
    +
    +
    + 26 + +
    + - + log.Info("flag=", ctx.String(FlagNetwork)) +
    +
    + 27 + +
    + - + cfg.loadNetworkConfig(ctx) +
    +
    + 28 + +
    + - + } +
    +
    + 29 + +
    +   + func TestLoadCustomNetworkConfig(t *testing.T) { +
    +
    + 30 + +
    +   + tcs := []struct { +
    +
    + 31 + +
    +   + description string +
    +
    +
    @@ -37,7 +24,8 @@
    +
    + 37 + +
    +   + description: "happy path", +
    +
    + 38 + +
    +   + inputConfigStr: `{ +
    +
    + 39 + +
    +   + "root": "0xBEEF", +
    +
    + 40 + +
    + - + "genesisBlockNumber": 69, +
    +
    + + +
    +   +
    +
    +
    + 41 + +
    +   + "l1Config" : { +
    +
    + 42 + +
    +   + "chainId": 420, +
    +
    + 43 + +
    +   + "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4", +
    +
    +
    @@ -89,8 +77,9 @@
    +
    + 89 + +
    +   + GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), +
    +
    + 90 + +
    +   + }, +
    +
    + 91 + +
    +   + Genesis: state.Genesis{ +
    +
    + 92 + +
    + - + Root: common.HexToHash("0xBEEF"), +
    +
    + 93 + +
    + - + BlockNumber: 69, +
    +
    + + +
    +   +
    +
    +
    + 94 + +
    +   + Actions: []*state.GenesisAction{ +
    +
    + 95 + +
    +   + { +
    +
    + 96 + +
    +   + Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4", +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 13 + +
    +   + "github.com/urfave/cli/v2" +
    +
    + 14 + +
    +   + ) +
    +
    + 15 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 16 + +
    +   + func TestLoadCustomNetworkConfig(t *testing.T) { +
    +
    + 17 + +
    +   + tcs := []struct { +
    +
    + 18 + +
    +   + description string +
    +
    +
     
    +
    + 24 + +
    +   + description: "happy path", +
    +
    + 25 + +
    +   + inputConfigStr: `{ +
    +
    + 26 + +
    +   + "root": "0xBEEF", +
    +
    + 27 + +
    + + + "rollupCreationBlockNumber": 69, +
    +
    + 28 + +
    + + + "rollupManagerCreationBlockNumber": 60, +
    +
    + 29 + +
    +   + "l1Config" : { +
    +
    + 30 + +
    +   + "chainId": 420, +
    +
    + 31 + +
    +   + "polygonZkEVMAddress": "0xc949254d682d8c9ad5682521675b8f43b102aec4", +
    +
    +
     
    +
    + 77 + +
    +   + GlobalExitRootManagerAddr: common.HexToAddress("0xc949254d682d8c9ad5682521675b8f43b102aec4"), +
    +
    + 78 + +
    +   + }, +
    +
    + 79 + +
    +   + Genesis: state.Genesis{ +
    +
    + 80 + +
    + + + Root: common.HexToHash("0xBEEF"), +
    +
    + 81 + +
    + + + RollupBlockNumber: 69, +
    +
    + 82 + +
    + + + RollupManagerBlockNumber: 60, +
    +
    + 83 + +
    +   + Actions: []*state.GenesisAction{ +
    +
    + 84 + +
    +   + { +
    +
    + 85 + +
    +   + Address: "0xc949254d682d8c9ad5682521675b8f43b102aec4", +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/testnetgenesis.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,108 +0,0 @@
    +
    + 1 + +
    + - + package config +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + // TestnetNetworkConfigJSON is the hardcoded network configuration to be used for the official mainnet setup +
    +
    + 4 + +
    + - + const TestnetNetworkConfigJSON = ` +
    +
    + 5 + +
    + - + { +
    +
    + 6 + +
    + - + "l1Config" : { +
    +
    + 7 + +
    + - + "chainId": 5, +
    +
    + 8 + +
    + - + "polygonZkEVMAddress": "0xa997cfD539E703921fD1e3Cf25b4c241a27a4c7A", +
    +
    + 9 + +
    + - + "polTokenAddress": "0x1319D23c2F7034F52Eb07399702B040bA278Ca49", +
    +
    + 10 + +
    + - + "polygonZkEVMGlobalExitRootAddress": "0x4d9427DCA0406358445bC0a8F88C26b704004f74" +
    +
    + 11 + +
    + - + }, +
    +
    + 12 + +
    + - + "root": "0x13a14c4a8288e782863d7ce916d224546c69dc428fbfa7115a0cc33a27a05b26", +
    +
    + 13 + +
    + - + "genesisBlockNumber": 8572998, +
    +
    + 14 + +
    + - + "genesis": [ +
    +
    + 15 + +
    + - + { +
    +
    + 16 + +
    + - + "contractName": "PolygonZkEVMDeployer", +
    +
    + 17 + +
    + - + "balance": "0", +
    +
    + 18 + +
    + - + "nonce": "4", +
    +
    + 19 + +
    + - + "address": "0x39877a0c3cd148476DaA2475c77c478C62eC7509", +
    +
    + 20 + +
    + - + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a26469706673582212200b8e3cd6bd762444a7eeff86e1cfcd7e1ce9524b715dcb70b2a4c2b70fd5188464736f6c63430008110033", +
    +
    + 21 + +
    + - + "storage": { +
    +
    + 22 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000a0b02b28920812324f1cc3255bd8840867d3f227" +
    +
    + 23 + +
    + - + } +
    +
    + 24 + +
    + - + }, +
    +
    + 25 + +
    + - + { +
    +
    + 26 + +
    + - + "contractName": "ProxyAdmin", +
    +
    + 27 + +
    + - + "balance": "0", +
    +
    + 28 + +
    + - + "nonce": "1", +
    +
    + 29 + +
    + - + "address": "0x40797c2f93298a44a893F43EdF1B33B63d7BA333", +
    +
    + 30 + +
    + - + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220babd4ff1f5daee002b96cc86d8bb6c2c2c210ae3132df5ea384713352f7f15fe64736f6c63430008110033", +
    +
    + 31 + +
    + - + "storage": { +
    +
    + 32 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x00000000000000000000000002245d7b6cb0b6870d1e28ac877ee355b9588869" +
    +
    + 33 + +
    + - + } +
    +
    + 34 + +
    + - + }, +
    +
    + 35 + +
    + - + { +
    +
    + 36 + +
    + - + "contractName": "PolygonZkEVMBridge implementation", +
    +
    + 37 + +
    + - + "balance": "0", +
    +
    + 38 + +
    + - + "nonce": "1", +
    +
    + 39 + +
    + - + "address": "0x39e780D8800f7396e8B7530A8925B14025AedC77", +
    +
    + 40 + +
    + - + "bytecode": "0x6080604052600436106200019f5760003560e01c8063647c576c11620000e7578063be5831c71162000089578063dbc169761162000060578063dbc169761462000639578063ee25560b1462000651578063fb570834146200068257600080fd5b8063be5831c714620005ae578063cd58657914620005ea578063d02103ca146200060157600080fd5b80639e34070f11620000be5780639e34070f146200050a578063aaa13cc2146200054f578063bab161bf146200057457600080fd5b8063647c576c146200048657806379e2cf9714620004ab57806381b1c17414620004c357600080fd5b80632d2c9d94116200015157806334ac9cf2116200012857806334ac9cf2146200034b5780633ae05047146200037a5780633e197043146200039257600080fd5b80632d2c9d9414620002765780632dfdf0b5146200029b578063318aee3d14620002c257600080fd5b806322e95f2c116200018657806322e95f2c14620001ef578063240ff378146200023a5780632cffd02e146200025157600080fd5b806315064c9614620001a45780632072f6c514620001d5575b600080fd5b348015620001b157600080fd5b50606854620001c09060ff1681565b60405190151581526020015b60405180910390f35b348015620001e257600080fd5b50620001ed620006a7565b005b348015620001fc57600080fd5b50620002146200020e366004620032db565b62000705565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620001cc565b620001ed6200024b36600462003372565b620007a8565b3480156200025e57600080fd5b50620001ed6200027036600462003409565b620009d0565b3480156200028357600080fd5b50620001ed6200029536600462003409565b62000f74565b348015620002a857600080fd5b50620002b360535481565b604051908152602001620001cc565b348015620002cf57600080fd5b5062000319620002e1366004620034ef565b606b6020526000908152604090205463ffffffff811690640100000000900473ffffffffffffffffffffffffffffffffffffffff1682565b6040805163ffffffff909316835273ffffffffffffffffffffffffffffffffffffffff909116602083015201620001cc565b3480156200035857600080fd5b50606c54620002149073ffffffffffffffffffffffffffffffffffffffff1681565b3480156200038757600080fd5b50620002b362001178565b3480156200039f57600080fd5b50620002b3620003b136600462003526565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b3480156200049357600080fd5b50620001ed620004a5366004620035b0565b6200125e565b348015620004b857600080fd5b50620001ed620014ad565b348015620004d057600080fd5b5062000214620004e236600462003600565b606a6020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200051757600080fd5b50620001c06200052936600462003600565b600881901c600090815260696020526040902054600160ff9092169190911b9081161490565b3480156200055c57600080fd5b50620002146200056e3660046200361a565b620014e7565b3480156200058157600080fd5b506068546200059890610100900463ffffffff1681565b60405163ffffffff9091168152602001620001cc565b348015620005bb57600080fd5b506068546200059890790100000000000000000000000000000000000000000000000000900463ffffffff1681565b620001ed620005fb366004620036ce565b620016d3565b3480156200060e57600080fd5b50606854620002149065010000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b3480156200064657600080fd5b50620001ed62001c37565b3480156200065e57600080fd5b50620002b36200067036600462003600565b60696020526000908152604090205481565b3480156200068f57600080fd5b50620001c0620006a136600462003770565b62001c93565b606c5473ffffffffffffffffffffffffffffffffffffffff163314620006f9576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362001d7c565b565b6040805160e084901b7fffffffff0000000000000000000000000000000000000000000000000000000016602080830191909152606084901b7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016602483015282516018818403018152603890920183528151918101919091206000908152606a909152205473ffffffffffffffffffffffffffffffffffffffff165b92915050565b60685460ff1615620007e6576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff8681166101009092041614806200080c5750600263ffffffff861610155b1562000844576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff163388883488886053546040516200089a9998979695949392919062003806565b60405180910390a1620009b8620009b26001606860019054906101000a900463ffffffff16338989348989604051620008d592919062003881565b60405180910390206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b62001e10565b8215620009c957620009c962001f27565b5050505050565b60685460ff161562000a0e576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000a258b8b8b8b8b8b8b8b8b8b8b600062001ffc565b73ffffffffffffffffffffffffffffffffffffffff861662000b01576040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff861690859060405162000a7a9190620038e6565b60006040518083038185875af1925050503d806000811462000ab9576040519150601f19603f3d011682016040523d82523d6000602084013e62000abe565b606091505b505090508062000afa576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5062000efc565b60685463ffffffff61010090910481169088160362000b435762000b3d73ffffffffffffffffffffffffffffffffffffffff87168585620021ed565b62000efc565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b166024820152600090603801604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152606a90935291205490915073ffffffffffffffffffffffffffffffffffffffff168062000e6e576000808062000c1886880188620039fb565b92509250925060008584848460405162000c329062003292565b62000c409392919062003abd565b8190604051809103906000f590508015801562000c61573d6000803e3d6000fd5b506040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81166004830152602482018c9052919250908216906340c10f1990604401600060405180830381600087803b15801562000cd757600080fd5b505af115801562000cec573d6000803e3d6000fd5b5050505080606a600088815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060405180604001604052808e63ffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff16815250606b60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398d8d838b8b60405162000e5c95949392919062003afa565b60405180910390a15050505062000ef9565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018790528216906340c10f1990604401600060405180830381600087803b15801562000edf57600080fd5b505af115801562000ef4573d6000803e3d6000fd5b505050505b50505b6040805163ffffffff8c811682528916602082015273ffffffffffffffffffffffffffffffffffffffff88811682840152861660608201526080810185905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a15050505050505050505050565b60685460ff161562000fb2576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62000fc98b8b8b8b8b8b8b8b8b8b8b600162001ffc565b60008473ffffffffffffffffffffffffffffffffffffffff1684888a868660405160240162000ffc949392919062003b42565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f1806b5f200000000000000000000000000000000000000000000000000000000179052516200107f9190620038e6565b60006040518083038185875af1925050503d8060008114620010be576040519150601f19603f3d011682016040523d82523d6000602084013e620010c3565b606091505b5050905080620010ff576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805163ffffffff8d811682528a16602082015273ffffffffffffffffffffffffffffffffffffffff89811682840152871660608201526080810186905290517f25308c93ceeed162da955b3f7ce3e3f93606579e40fb92029faa9efe275459839181900360a00190a1505050505050505050505050565b605354600090819081805b602081101562001255578083901c600116600103620011e65760338160208110620011b257620011b262003b8a565b0154604080516020810192909252810185905260600160405160208183030381529060405280519060200120935062001213565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806200124c9062003be8565b91505062001183565b50919392505050565b600054610100900460ff16158080156200127f5750600054600160ff909116105b806200129b5750303b1580156200129b575060005460ff166001145b6200132d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156200138c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8716027fffffffffffffff0000000000000000000000000000000000000000ffffffffff16176501000000000073ffffffffffffffffffffffffffffffffffffffff8681169190910291909117909155606c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001691841691909117905562001443620022c3565b8015620014a757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b605354606854790100000000000000000000000000000000000000000000000000900463ffffffff16101562000703576200070362001f27565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e089901b1660208201527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606088901b1660248201526000908190603801604051602081830303815290604052805190602001209050600060ff60f81b3083604051806020016200157d9062003292565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f909101166040819052620015c8908d908d908d908d908d9060200162003c23565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905262001606929160200162003c64565b604051602081830303815290604052805190602001206040516020016200168f94939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b7fffffffffffffffffffffffffffffffffffffffff0000000000000000000000001660018401526015830152603582015260550190565b604080518083037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001815291905280516020909101209a9950505050505050505050565b60685460ff161562001711576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200171b62002366565b60685463ffffffff888116610100909204161480620017415750600263ffffffff881610155b1562001779576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060608773ffffffffffffffffffffffffffffffffffffffff8816620017df57883414620017d5576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000925062001ad9565b341562001818576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8089166000908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901562001908576040517f9dc29fac000000000000000000000000000000000000000000000000000000008152336004820152602481018b905273ffffffffffffffffffffffffffffffffffffffff8a1690639dc29fac90604401600060405180830381600087803b158015620018db57600080fd5b505af1158015620018f0573d6000803e3d6000fd5b50505050806020015194508060000151935062001ad7565b85156200191d576200191d898b8989620023db565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8b16906370a0823190602401602060405180830381865afa1580156200198b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620019b1919062003c97565b9050620019d773ffffffffffffffffffffffffffffffffffffffff8b1633308e620028f9565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8c16906370a0823190602401602060405180830381865afa15801562001a45573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a6b919062003c97565b905062001a79828262003cb1565b6068548c9850610100900463ffffffff169650935062001a998762002959565b62001aa48c62002a71565b62001aaf8d62002b7e565b60405160200162001ac39392919062003abd565b604051602081830303815290604052945050505b505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e868860535460405162001b1b98979695949392919062003cc7565b60405180910390a162001c0f620009b2600085878f8f8789805190602001206040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201527fffffffff0000000000000000000000000000000000000000000000000000000060e088811b821660218401527fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b861562001c205762001c2062001f27565b5050505062001c2e60018055565b50505050505050565b606c5473ffffffffffffffffffffffffffffffffffffffff16331462001c89576040517fe2e8106b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6200070362002c80565b600084815b602081101562001d6e57600163ffffffff8616821c8116900362001d0a5785816020811062001ccb5762001ccb62003b8a565b60200201358260405160200162001cec929190918252602082015260400190565b60405160208183030381529060405280519060200120915062001d59565b8186826020811062001d205762001d2062003b8a565b602002013560405160200162001d40929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b8062001d658162003be8565b91505062001c98565b50821490505b949350505050565b60685460ff161562001dba576040517f2f0047fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b80600162001e216020600262003e79565b62001e2d919062003cb1565b6053541062001e68576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060536000815462001e7b9062003be8565b9182905550905060005b602081101562001f17578082901c60011660010362001ebd57826033826020811062001eb55762001eb562003b8a565b015550505050565b6033816020811062001ed35762001ed362003b8a565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808062001f0e9062003be8565b91505062001e85565b5062001f2262003e87565b505050565b6053546068805463ffffffff909216790100000000000000000000000000000000000000000000000000027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179081905573ffffffffffffffffffffffffffffffffffffffff65010000000000909104166333d6247d62001fad62001178565b6040518263ffffffff1660e01b815260040162001fcc91815260200190565b600060405180830381600087803b15801562001fe757600080fd5b505af1158015620014a7573d6000803e3d6000fd5b6200200d8b63ffffffff1662002d10565b6068546040805160208082018e90528183018d9052825180830384018152606083019384905280519101207f257b363200000000000000000000000000000000000000000000000000000000909252606481019190915260009165010000000000900473ffffffffffffffffffffffffffffffffffffffff169063257b3632906084016020604051808303816000875af1158015620020b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620020d6919062003c97565b90508060000362002112576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60685463ffffffff88811661010090920416146200215c576040517f0595ea2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606854600090610100900463ffffffff166200217a5750896200217d565b508a5b620021a66200219d848c8c8c8c8c8c8c604051620008d592919062003881565b8f8f8462001c93565b620021dd576040517fe0417cec00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff831660248201526044810182905262001f229084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915262002d75565b600054610100900460ff166200235c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6200070362002e88565b600260015403620023d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640162001324565b6002600155565b6000620023ec600482848662003eb6565b620023f79162003ee2565b90507f2afa5331000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000821601620026765760008080808080806200245a896004818d62003eb6565b81019062002469919062003f2b565b96509650965096509650965096503373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614620024dd576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff861630146200252d576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8a851462002567576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff89811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e1691620026229190620038e6565b6000604051808303816000865af19150503d806000811462002661576040519150601f19603f3d011682016040523d82523d6000602084013e62002666565b606091505b50505050505050505050620009c9565b7fffffffff0000000000000000000000000000000000000000000000000000000081167f8fcbaf0c0000000000000000000000000000000000000000000000000000000014620026f2576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808080808080806200270a8a6004818e62003eb6565b81019062002719919062003f86565b975097509750975097509750975097503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16146200278f576040517f912ecce700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff87163014620027df576040517f750643af00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f8fcbaf0c000000000000000000000000000000000000000000000000000000001790529151918f1691620028a39190620038e6565b6000604051808303816000865af19150503d8060008114620028e2576040519150601f19603f3d011682016040523d82523d6000602084013e620028e7565b606091505b50505050505050505050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052620014a79085907f23b872dd000000000000000000000000000000000000000000000000000000009060840162002240565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f06fdde03000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff861691620029dd9190620038e6565b600060405180830381855afa9150503d806000811462002a1a576040519150601f19603f3d011682016040523d82523d6000602084013e62002a1f565b606091505b50915091508162002a66576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525062001d74565b62001d748162002f21565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f95d89b41000000000000000000000000000000000000000000000000000000001790529051606091600091829173ffffffffffffffffffffffffffffffffffffffff86169162002af59190620038e6565b600060405180830381855afa9150503d806000811462002b32576040519150601f19603f3d011682016040523d82523d6000602084013e62002b37565b606091505b50915091508162002a66576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525062001d74565b60408051600481526024810182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f313ce5670000000000000000000000000000000000000000000000000000000017905290516000918291829173ffffffffffffffffffffffffffffffffffffffff86169162002c019190620038e6565b600060405180830381855afa9150503d806000811462002c3e576040519150601f19603f3d011682016040523d82523d6000602084013e62002c43565b606091505b509150915081801562002c57575080516020145b62002c6457601262001d74565b8080602001905181019062001d74919062004012565b60018055565b60685460ff1662002cbd576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606880547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600881901c60008181526069602052604081208054600160ff861690811b91821892839055929091908183169003620009c9576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600062002dd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16620031119092919063ffffffff16565b80519091501562001f22578080602001905181019062002dfa919062004032565b62001f22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840162001324565b600054610100900460ff1662002c7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162001324565b6060604082511062002f435781806020019051810190620007a2919062004052565b8151602003620030d35760005b60208110801562002f9b575082818151811062002f715762002f7162003b8a565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b1562002fb6578062002fad8162003be8565b91505062002f50565b8060000362002ffa57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b60008167ffffffffffffffff81111562003018576200301862003891565b6040519080825280601f01601f19166020018201604052801562003043576020820181803683370190505b50905060005b82811015620030cb5784818151811062003067576200306762003b8a565b602001015160f81c60f81b82828151811062003087576200308762003b8a565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080620030c28162003be8565b91505062003049565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b606062001d748484600085856000808673ffffffffffffffffffffffffffffffffffffffff168587604051620031489190620038e6565b60006040518083038185875af1925050503d806000811462003187576040519150601f19603f3d011682016040523d82523d6000602084013e6200318c565b606091505b50915091506200319f87838387620031aa565b979650505050505050565b60608315620032455782516000036200323d5773ffffffffffffffffffffffffffffffffffffffff85163b6200323d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640162001324565b508162001d74565b62001d7483838151156200325c5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620013249190620040d2565b611b6680620040e883390190565b803563ffffffff811681146200310c57600080fd5b73ffffffffffffffffffffffffffffffffffffffff81168114620032d857600080fd5b50565b60008060408385031215620032ef57600080fd5b620032fa83620032a0565b915060208301356200330c81620032b5565b809150509250929050565b8015158114620032d857600080fd5b60008083601f8401126200333957600080fd5b50813567ffffffffffffffff8111156200335257600080fd5b6020830191508360208285010111156200336b57600080fd5b9250929050565b6000806000806000608086880312156200338b57600080fd5b6200339686620032a0565b94506020860135620033a881620032b5565b93506040860135620033ba8162003317565b9250606086013567ffffffffffffffff811115620033d757600080fd5b620033e58882890162003326565b969995985093965092949392505050565b806104008101831015620007a257600080fd5b60008060008060008060008060008060006105208c8e0312156200342c57600080fd5b620034388d8d620033f6565b9a50620034496104008d01620032a0565b99506104208c013598506104408c013597506200346a6104608d01620032a0565b96506104808c01356200347d81620032b5565b95506200348e6104a08d01620032a0565b94506104c08c0135620034a181620032b5565b93506104e08c013592506105008c013567ffffffffffffffff811115620034c757600080fd5b620034d58e828f0162003326565b915080935050809150509295989b509295989b9093969950565b6000602082840312156200350257600080fd5b81356200350f81620032b5565b9392505050565b60ff81168114620032d857600080fd5b600080600080600080600060e0888a0312156200354257600080fd5b87356200354f8162003516565b96506200355f60208901620032a0565b955060408801356200357181620032b5565b94506200358160608901620032a0565b935060808801356200359381620032b5565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215620035c657600080fd5b620035d184620032a0565b92506020840135620035e381620032b5565b91506040840135620035f581620032b5565b809150509250925092565b6000602082840312156200361357600080fd5b5035919050565b600080600080600080600060a0888a0312156200363657600080fd5b6200364188620032a0565b965060208801356200365381620032b5565b9550604088013567ffffffffffffffff808211156200367157600080fd5b6200367f8b838c0162003326565b909750955060608a01359150808211156200369957600080fd5b50620036a88a828b0162003326565b9094509250506080880135620036be8162003516565b8091505092959891949750929550565b600080600080600080600060c0888a031215620036ea57600080fd5b620036f588620032a0565b965060208801356200370781620032b5565b95506040880135945060608801356200372081620032b5565b93506080880135620037328162003317565b925060a088013567ffffffffffffffff8111156200374f57600080fd5b6200375d8a828b0162003326565b989b979a50959850939692959293505050565b60008060008061046085870312156200378857600080fd5b843593506200379b8660208701620033f6565b9250620037ac6104208601620032a0565b939692955092936104400135925050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600061010060ff8c16835263ffffffff808c16602085015273ffffffffffffffffffffffffffffffffffffffff808c166040860152818b166060860152808a166080860152508760a08501528160c0850152620038678285018789620037bd565b925080851660e085015250509a9950505050505050505050565b8183823760009101908152919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60005b83811015620038dd578181015183820152602001620038c3565b50506000910152565b60008251620038fa818460208701620038c0565b9190910192915050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156200394e576200394e62003891565b604052919050565b600067ffffffffffffffff82111562003973576200397362003891565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f830112620039b157600080fd5b8135620039c8620039c28262003956565b62003904565b818152846020838601011115620039de57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121562003a1157600080fd5b833567ffffffffffffffff8082111562003a2a57600080fd5b62003a38878388016200399f565b9450602086013591508082111562003a4f57600080fd5b5062003a5e868287016200399f565b9250506040840135620035f58162003516565b6000815180845262003a8b816020860160208601620038c0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60608152600062003ad2606083018662003a71565b828103602084015262003ae6818662003a71565b91505060ff83166040830152949350505050565b63ffffffff86168152600073ffffffffffffffffffffffffffffffffffffffff8087166020840152808616604084015250608060608301526200319f608083018486620037bd565b73ffffffffffffffffffffffffffffffffffffffff8516815263ffffffff8416602082015260606040820152600062003b80606083018486620037bd565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820362003c1c5762003c1c62003bb9565b5060010190565b60608152600062003c39606083018789620037bd565b828103602084015262003c4e818688620037bd565b91505060ff831660408301529695505050505050565b6000835162003c78818460208801620038c0565b83519083019062003c8e818360208801620038c0565b01949350505050565b60006020828403121562003caa57600080fd5b5051919050565b81810381811115620007a257620007a262003bb9565b600061010060ff8b16835263ffffffff808b16602085015273ffffffffffffffffffffffffffffffffffffffff808b166040860152818a1660608601528089166080860152508660a08501528160c085015262003d278285018762003a71565b925080851660e085015250509998505050505050505050565b600181815b8085111562003d9f57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003d835762003d8362003bb9565b8085161562003d9157918102915b93841c939080029062003d45565b509250929050565b60008262003db857506001620007a2565b8162003dc757506000620007a2565b816001811462003de0576002811462003deb5762003e0b565b6001915050620007a2565b60ff84111562003dff5762003dff62003bb9565b50506001821b620007a2565b5060208310610133831016604e8410600b841016171562003e30575081810a620007a2565b62003e3c838362003d40565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111562003e715762003e7162003bb9565b029392505050565b60006200350f838362003da7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6000808585111562003ec757600080fd5b8386111562003ed557600080fd5b5050820193919092039150565b7fffffffff00000000000000000000000000000000000000000000000000000000813581811691600485101562003f235780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a03121562003f4757600080fd5b873562003f5481620032b5565b9650602088013562003f6681620032b5565b955060408801359450606088013593506080880135620035938162003516565b600080600080600080600080610100898b03121562003fa457600080fd5b883562003fb181620032b5565b9750602089013562003fc381620032b5565b96506040890135955060608901359450608089013562003fe38162003317565b935060a089013562003ff58162003516565b979a969950949793969295929450505060c08201359160e0013590565b6000602082840312156200402557600080fd5b81516200350f8162003516565b6000602082840312156200404557600080fd5b81516200350f8162003317565b6000602082840312156200406557600080fd5b815167ffffffffffffffff8111156200407d57600080fd5b8201601f810184136200408f57600080fd5b8051620040a0620039c28262003956565b818152856020838501011115620040b657600080fd5b620040c9826020830160208601620038c0565b95945050505050565b6020815260006200350f602083018462003a7156fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220addfd62f466d34ee002afbb4ae37b6be56ad421fe773f800badeb4ce1025089864736f6c63430008110033" +
    +
    + 41 + +
    + - + }, +
    +
    + 42 + +
    + - + { +
    +
    + 43 + +
    + - + "contractName": "PolygonZkEVMBridge proxy", +
    +
    + 44 + +
    + - + "balance": "200000000000000000000000000", +
    +
    + 45 + +
    + - + "nonce": "1", +
    +
    + 46 + +
    + - + "address": "0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7", +
    +
    + 47 + +
    + - + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461088b565b610135565b61006b6100a33660046108a6565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461088b565b610231565b34801561011257600080fd5b506100bd61025e565b6101236102d4565b61013361012e6103ab565b6103b5565b565b61013d6103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481604051806020016040528060008152506000610419565b50565b61017461011b565b6101876103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610419915050565b505050565b6101e661011b565b60006101fd6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103ab565b905090565b61022e61011b565b90565b6102396103d9565b73ffffffffffffffffffffffffffffffffffffffff1633036101775761017481610444565b60006102686103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610226576102216103d9565b60606102b183836040518060600160405280602781526020016109bb602791396104a5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6102dc6103d9565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161052a565b3660008037600080366000845af43d6000803e8080156103d4573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b61042283610552565b60008251118061042f5750805b156101e65761043e838361028c565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61046d6103d9565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a16101748161059f565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516104cf919061094d565b600060405180830381855af49150503d806000811461050a576040519150601f19603f3d011682016040523d82523d6000602084013e61050f565b606091505b5091509150610520868383876106ab565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103fd565b61055b81610753565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b73ffffffffffffffffffffffffffffffffffffffff8116610642576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103a2565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060831561074157825160000361073a5773ffffffffffffffffffffffffffffffffffffffff85163b61073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103a2565b508161074b565b61074b838361081e565b949350505050565b73ffffffffffffffffffffffffffffffffffffffff81163b6107f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e74726163740000000000000000000000000000000000000060648201526084016103a2565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610665565b81511561082e5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103a29190610969565b803573ffffffffffffffffffffffffffffffffffffffff8116811461088657600080fd5b919050565b60006020828403121561089d57600080fd5b6102b182610862565b6000806000604084860312156108bb57600080fd5b6108c484610862565b9250602084013567ffffffffffffffff808211156108e157600080fd5b818601915086601f8301126108f557600080fd5b81358181111561090457600080fd5b87602082850101111561091657600080fd5b6020830194508093505050509250925092565b60005b8381101561094457818101518382015260200161092c565b50506000910152565b6000825161095f818460208701610929565b9190910192915050565b6020815260008251806020840152610988816040850160208701610929565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a1af0d6cb4f1e31496a4c5c1448913bce4bd6ad3a39e47c6f7190c114d6f9bf464736f6c63430008110033", +
    +
    + 48 + +
    + - + "storage": { +
    +
    + 49 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 50 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 51 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000068": "0x00000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa0000000100", +
    +
    + 52 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333", +
    +
    + 53 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000039e780d8800f7396e8b7530a8925b14025aedc77" +
    +
    + 54 + +
    + - + } +
    +
    + 55 + +
    + - + }, +
    +
    + 56 + +
    + - + { +
    +
    + 57 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 implementation", +
    +
    + 58 + +
    + - + "balance": "0", +
    +
    + 59 + +
    + - + "nonce": "1", +
    +
    + 60 + +
    + - + "address": "0x77Fc57b154fCF8320Df2C2e6C044AA50141c023b", +
    +
    + 61 + +
    + - + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a781565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000f6beeebb578e214ca9e23b0e9683454ff88ed2a7161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220a187fc278346c1b61c449ea3641002b6eac2bda3351a122a12c35099f933696864736f6c63430008110033" +
    +
    + 62 + +
    + - + }, +
    +
    + 63 + +
    + - + { +
    +
    + 64 + +
    + - + "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", +
    +
    + 65 + +
    + - + "balance": "0", +
    +
    + 66 + +
    + - + "nonce": "1", +
    +
    + 67 + +
    + - + "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", +
    +
    + 68 + +
    + - + "bytecode": "0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106ca565b610118565b61005b6100933660046106e5565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106ca565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103f1565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107e460279139610445565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb610519565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b83610541565b6040516001600160a01b038416907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a26000825111806103dc5750805b156101c3576103eb8383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61041a61035f565b604080516001600160a01b03928316815291841660208301520160405180910390a1610154816105e9565b6060833b6104a45760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b0316856040516104bf9190610794565b600060405180830381855af49150503d80600081146104fa576040519150601f19603f3d011682016040523d82523d6000602084013e6104ff565b606091505b509150915061050f828286610675565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b803b6105a55760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b6001600160a01b03811661064e5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61036105c8565b60608315610684575081610285565b8251156106945782518084602001fd5b8160405162461bcd60e51b815260040161032891906107b0565b80356001600160a01b03811681146106c557600080fd5b919050565b6000602082840312156106dc57600080fd5b610285826106ae565b6000806000604084860312156106fa57600080fd5b610703846106ae565b9250602084013567ffffffffffffffff8082111561072057600080fd5b818601915086601f83011261073457600080fd5b81358181111561074357600080fd5b87602082850101111561075557600080fd5b6020830194508093505050509250925092565b60005b8381101561078357818101518382015260200161076b565b838111156103eb5750506000910152565b600082516107a6818460208701610768565b9190910192915050565b60208152600082518060208401526107cf816040850160208701610768565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204675187caf3a43285d9a2c1844a981e977bd52a85ff073e7fc649f73847d70a464736f6c63430008090033", +
    +
    + 69 + +
    + - + "storage": { +
    +
    + 70 + +
    + - + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x00000000000000000000000040797c2f93298a44a893f43edf1b33b63d7ba333", +
    +
    + 71 + +
    + - + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x00000000000000000000000077fc57b154fcf8320df2c2e6c044aa50141c023b" +
    +
    + 72 + +
    + - + } +
    +
    + 73 + +
    + - + }, +
    +
    + 74 + +
    + - + { +
    +
    + 75 + +
    + - + "contractName": "PolygonZkEVMTimelock", +
    +
    + 76 + +
    + - + "balance": "0", +
    +
    + 77 + +
    + - + "nonce": "1", +
    +
    + 78 + +
    + - + "address": "0x02245d7B6CB0b6870d1e28AC877EE355b9588869", +
    +
    + 79 + +
    + - + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c12565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611c87565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611cc9565b6107df565b3480156102be57600080fd5b506102146102cd366004611d35565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e5a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d35565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d35565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611ec2565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d35565b610927565b3480156103f457600080fd5b506101f2610403366004611ec2565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d35565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d35565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611cc9565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f33565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611ec2565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004611fe5565b610d4f565b3480156105db57600080fd5b506103166105ea36600461210e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d35565b610d94565b34801561064057600080fd5b5061025d61064f366004611d35565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611ec2565b610e8f565b6101f261068f366004611fe5565b610eb4565b3480156106a057600080fd5b506103166106af3660046121b8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611204565b6000610728898989898989610ade565b90506107348184611211565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161077096959493929190612266565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261135e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c81336113f5565b600061086c888888888888610ade565b905061087881856114ad565b610884888888886115ea565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122b1565b60405180910390a36108cd816116ee565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611204565b6109228383611797565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f48282611887565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb96959493929190612266565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611204565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611211565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc36122f1565b9050602002016020810190610cd89190612320565b8d8d86818110610cea57610cea6122f1565b905060200201358c8c87818110610d0357610d036122f1565b9050602002810190610d15919061233b565b8c8b604051610d2996959493929190612266565b60405180910390a3610d3a816123cf565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124b7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611204565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611204565b6109228383611887565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f3181336113f5565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ad565b60005b8981101561114b5760008b8b8381811061108c5761108c6122f1565b90506020020160208101906110a19190612320565b905060008a8a848181106110b7576110b76122f1565b9050602002013590503660008a8a868181106110d5576110d56122f1565b90506020028101906110e7919061233b565b915091506110f7848484846115ea565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122b1565b60405180910390a35050505080611144906123cf565b9050611070565b50611155816116ee565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f2919061257e565b156111fd5750600090565b5060025490565b61120e81336113f5565b50565b61121a82610927565b156112a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112af611161565b81101561133e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61134881426125a0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114338161193e565b61143e83602061195d565b60405160200161144f9291906125d7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612658565b6114b6826108d7565b611542576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061155e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116149291906126a9565b60006040518083038185875af1925050503d8060008114611651576040519150601f19603f3d011682016040523d82523d6000602084013e611656565b606091505b50509050806116e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b6116f7816108d7565b611783576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118293390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b6060600061196c8360026126b9565b6119779060026125a0565b67ffffffffffffffff81111561198f5761198f611d4e565b6040519080825280601f01601f1916602001820160405280156119b9576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106119f0576119f06122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a5357611a536122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611a8f8460026126b9565b611a9a9060016125a0565b90505b6001811115611b37577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611adb57611adb6122f1565b1a60f81b828281518110611af157611af16122f1565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b30816126d0565b9050611a9d565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bc457600080fd5b919050565b60008083601f840112611bdb57600080fd5b50813567ffffffffffffffff811115611bf357600080fd5b602083019150836020828501011115611c0b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c2d57600080fd5b611c3688611ba0565b965060208801359550604088013567ffffffffffffffff811115611c5957600080fd5b611c658a828b01611bc9565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611c9957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611ce257600080fd5b611ceb87611ba0565b955060208701359450604087013567ffffffffffffffff811115611d0e57600080fd5b611d1a89828a01611bc9565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d4757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611dc457611dc4611d4e565b604052919050565b600082601f830112611ddd57600080fd5b813567ffffffffffffffff811115611df757611df7611d4e565b611e2860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d7d565b818152846020838601011115611e3d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611e7057600080fd5b611e7985611ba0565b9350611e8760208601611ba0565b925060408501359150606085013567ffffffffffffffff811115611eaa57600080fd5b611eb687828801611dcc565b91505092959194509250565b60008060408385031215611ed557600080fd5b82359150611ee560208401611ba0565b90509250929050565b60008083601f840112611f0057600080fd5b50813567ffffffffffffffff811115611f1857600080fd5b6020830191508360208260051b8501011115611c0b57600080fd5b600080600080600080600080600060c08a8c031215611f5157600080fd5b893567ffffffffffffffff80821115611f6957600080fd5b611f758d838e01611eee565b909b50995060208c0135915080821115611f8e57600080fd5b611f9a8d838e01611eee565b909950975060408c0135915080821115611fb357600080fd5b50611fc08c828d01611eee565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561200157600080fd5b883567ffffffffffffffff8082111561201957600080fd5b6120258c838d01611eee565b909a50985060208b013591508082111561203e57600080fd5b61204a8c838d01611eee565b909850965060408b013591508082111561206357600080fd5b506120708b828c01611eee565b999c989b509699959896976060870135966080013595509350505050565b600082601f83011261209f57600080fd5b8135602067ffffffffffffffff8211156120bb576120bb611d4e565b8160051b6120ca828201611d7d565b92835284810182019282810190878511156120e457600080fd5b83870192505b84831015612103578235825291830191908301906120ea565b979650505050505050565b600080600080600060a0868803121561212657600080fd5b61212f86611ba0565b945061213d60208701611ba0565b9350604086013567ffffffffffffffff8082111561215a57600080fd5b61216689838a0161208e565b9450606088013591508082111561217c57600080fd5b61218889838a0161208e565b9350608088013591508082111561219e57600080fd5b506121ab88828901611dcc565b9150509295509295909350565b600080600080600060a086880312156121d057600080fd5b6121d986611ba0565b94506121e760208701611ba0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561221157600080fd5b6121ab88828901611dcc565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a06040820152600061229c60a08301868861221d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff851681528360208201526060604082015260006122e760608301848661221d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561233257600080fd5b6108f682611ba0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261237057600080fd5b83018035915067ffffffffffffffff82111561238b57600080fd5b602001915036819003821315611c0b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612400576124006123a0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124aa57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe188360301811261246057600080fd5b8701858101903567ffffffffffffffff81111561247c57600080fd5b80360382131561248b57600080fd5b61249686828461221d565b9a87019a9550505090840190600101612421565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125055773ffffffffffffffffffffffffffffffffffffffff6124f084611ba0565b168252602092830192909101906001016124ca565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561253e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125669082018789612407565b60608401959095525050608001529695505050505050565b60006020828403121561259057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123a0565b60005b838110156125ce5781810151838201526020016125b6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161260f8160178501602088016125b3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161264c8160288401602088016125b3565b01602801949350505050565b60208152600082518060208401526126778160408501602087016125b3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123a0565b6000816126df576126df6123a0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220288c3dd40a2ba96edf066502722584177809ebdb47c0cf9ee8df6f07954c373064736f6c63430008110033", +
    +
    + 80 + +
    + - + "storage": { +
    +
    + 81 + +
    + - + "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000015180", +
    +
    + 82 + +
    + - + "0xbdd73c6ebfb442c137537be0985acf11af8e6133078bc51ef9094071cb0ca475": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 83 + +
    + - + "0x92b79801e6a3d148a516c908cc0bbad93771fa74468b7757a14aa55532d092de": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 84 + +
    + - + "0x64494413541ff93b31aa309254e3fed72a7456e9845988b915b4c7a7ceba8814": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 85 + +
    + - + "0x43e090632490f7d46c400129311fff008a7688bb3d4aebdf80607456b452cf04": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 86 + +
    + - + "0x3412d5605ac6cd444957cedb533e5dacad6378b4bc819ebe3652188a665066d6": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 87 + +
    + - + "0x5af21cf0316499c6925cf9be0331b8bd150a1fa4c19d24a043b45f0cf15357c3": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 88 + +
    + - + "0xdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d706a": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5", +
    +
    + 89 + +
    + - + "0xaf021eeb38644155cd697b3ce0ec4fdac818d29c448a9f9d9bafc293723c6cd8": "0x0000000000000000000000000000000000000000000000000000000000000001", +
    +
    + 90 + +
    + - + "0xc3ad33e20b0c56a223ad5104fff154aa010f8715b9c981fd38fdc60a4d1a52fc": "0x5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca5" +
    +
    + 91 + +
    + - + } +
    +
    + 92 + +
    + - + }, +
    +
    + 93 + +
    + - + { +
    +
    + 94 + +
    + - + "accountName": "keyless Deployer", +
    +
    + 95 + +
    + - + "balance": "0", +
    +
    + 96 + +
    + - + "nonce": "1", +
    +
    + 97 + +
    + - + "address": "0xB83a574B3966F7dc1d38d162FA154F2A57D608Bb" +
    +
    + 98 + +
    + - + }, +
    +
    + 99 + +
    + - + { +
    +
    + 100 + +
    + - + "accountName": "deployer", +
    +
    + 101 + +
    + - + "balance": "0", +
    +
    + 102 + +
    + - + "nonce": "8", +
    +
    + 103 + +
    + - + "address": "0xA0B02B28920812324f1cC3255bd8840867d3f227" +
    +
    + 104 + +
    + - + } +
    +
    + 105 + +
    + - + ] +
    +
    + 106 + +
    + - + } +
    +
    + 107 + +
    + - +
    +
    +
    + 108 + +
    + - + ` +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/config/types/duration.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -38,3 +38,13 @@
    +
    + 38 + +
    +   + }, +
    +
    + 39 + +
    +   + } +
    +
    + 40 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 38 + +
    +   + }, +
    +
    + 39 + +
    +   + } +
    +
    + 40 + +
    +   + } +
    +
    + 41 + +
    + + +
    +
    +
    + 42 + +
    + + + // MarshalJSON marshalls time duration into text. +
    +
    + 43 + +
    + + + func (d Duration) MarshalJSON() ([]byte, error) { +
    +
    + 44 + +
    + + + return []byte(`"` + d.String() + `"`), nil +
    +
    + 45 + +
    + + + } +
    +
    + 46 + +
    + + +
    +
    +
    + 47 + +
    + + + // MarshalText marshalls time duration into text. +
    +
    + 48 + +
    + + + func (d *Duration) MarshalText() ([]byte, error) { +
    +
    + 49 + +
    + + + return []byte(d.String()), nil +
    +
    + 50 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/config.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,9 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package dataavailability +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + // DABackendType is the data availability protocol for the CDK +
    +
    + 4 + +
    + + + type DABackendType string +
    +
    + 5 + +
    + + +
    +
    +
    + 6 + +
    + + + const ( +
    +
    + 7 + +
    + + + // DataAvailabilityCommittee is the DAC protocol backend +
    +
    + 8 + +
    + + + DataAvailabilityCommittee DABackendType = "DataAvailabilityCommittee" +
    +
    + 9 + +
    + + + ) +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/dataavailability.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,152 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package dataavailability +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "fmt" +
    +
    + 6 + +
    + + + "math/big" +
    +
    + 7 + +
    + + +
    +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/types" +
    +
    + 9 + +
    + + + jsontypes "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    + 10 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 11 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 12 + +
    + + + "github.com/ethereum/go-ethereum/crypto" +
    +
    + 13 + +
    + + + ) +
    +
    + 14 + +
    + + +
    +
    +
    + 15 + +
    + + + const ( +
    +
    + 16 + +
    + + + unexpectedHashTemplate = "mismatch on transaction data for batch num %d. Expected hash %s, actual hash: %s" +
    +
    + 17 + +
    + + + failedDataRetrievalTemplate = "failed to retrieve local data for batches %v: %s" +
    +
    + 18 + +
    + + + invalidBatchRetrievalArgs = "invalid L2 batch data retrieval arguments, %d != %d" +
    +
    + 19 + +
    + + + ) +
    +
    + 20 + +
    + + +
    +
    +
    + 21 + +
    + + + // DataAvailability implements an abstract data availability integration +
    +
    + 22 + +
    + + + type DataAvailability struct { +
    +
    + 23 + +
    + + + isTrustedSequencer bool +
    +
    + 24 + +
    + + +
    +
    +
    + 25 + +
    + + + state stateInterface +
    +
    + 26 + +
    + + + zkEVMClient ZKEVMClientTrustedBatchesGetter +
    +
    + 27 + +
    + + + backend DABackender +
    +
    + 28 + +
    + + +
    +
    +
    + 29 + +
    + + + ctx context.Context +
    +
    + 30 + +
    + + + } +
    +
    + 31 + +
    + + +
    +
    +
    + 32 + +
    + + + // New creates a DataAvailability instance +
    +
    + 33 + +
    + + + func New( +
    +
    + 34 + +
    + + + isTrustedSequencer bool, +
    +
    + 35 + +
    + + + backend DABackender, +
    +
    + 36 + +
    + + + state stateInterface, +
    +
    + 37 + +
    + + + zkEVMClient ZKEVMClientTrustedBatchesGetter, +
    +
    + 38 + +
    + + + ) (*DataAvailability, error) { +
    +
    + 39 + +
    + + + da := &DataAvailability{ +
    +
    + 40 + +
    + + + isTrustedSequencer: isTrustedSequencer, +
    +
    + 41 + +
    + + + backend: backend, +
    +
    + 42 + +
    + + + state: state, +
    +
    + 43 + +
    + + + zkEVMClient: zkEVMClient, +
    +
    + 44 + +
    + + + ctx: context.Background(), +
    +
    + 45 + +
    + + + } +
    +
    + 46 + +
    + + + err := da.backend.Init() +
    +
    + 47 + +
    + + + return da, err +
    +
    + 48 + +
    + + + } +
    +
    + 49 + +
    + + +
    +
    +
    + 50 + +
    + + + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage +
    +
    + 51 + +
    + + + // as expected by the contract +
    +
    + 52 + +
    + + + func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) { +
    +
    + 53 + +
    + + + batchesData := [][]byte{} +
    +
    + 54 + +
    + + + for _, batch := range sequences { +
    +
    + 55 + +
    + + + // Do not send to the DA backend data that will be stored to L1 +
    +
    + 56 + +
    + + + if batch.ForcedBatchTimestamp == 0 { +
    +
    + 57 + +
    + + + batchesData = append(batchesData, batch.BatchL2Data) +
    +
    + 58 + +
    + + + } +
    +
    + 59 + +
    + + + } +
    +
    + 60 + +
    + + + return d.backend.PostSequence(ctx, batchesData) +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + // GetBatchL2Data tries to return the data from a batch, in the following priorities. batchNums should not include forced batches. +
    +
    + 64 + +
    + + + // 1. From local DB +
    +
    + 65 + +
    + + + // 2. From Trusted Sequencer (if not self) +
    +
    + 66 + +
    + + + // 3. From DA backend +
    +
    + 67 + +
    + + + func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) { +
    +
    + 68 + +
    + + + if len(batchNums) != len(batchHashes) { +
    +
    + 69 + +
    + + + return nil, fmt.Errorf(invalidBatchRetrievalArgs, len(batchNums), len(batchHashes)) +
    +
    + 70 + +
    + + + } +
    +
    + 71 + +
    + + + localData, err := d.state.GetBatchL2DataByNumbers(d.ctx, batchNums, nil) +
    +
    + 72 + +
    + + + if err != nil { +
    +
    + 73 + +
    + + + return nil, err +
    +
    + 74 + +
    + + + } +
    +
    + 75 + +
    + + +
    +
    +
    + 76 + +
    + + + data, err := checkBatches(batchNums, batchHashes, localData) +
    +
    + 77 + +
    + + + if err != nil { +
    +
    + 78 + +
    + + + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error()) +
    +
    + 79 + +
    + + + } else { +
    +
    + 80 + +
    + + + return data, nil +
    +
    + 81 + +
    + + + } +
    +
    + 82 + +
    + + +
    +
    +
    + 83 + +
    + + + if !d.isTrustedSequencer { +
    +
    + 84 + +
    + + + data, err = d.rpcData(batchNums, batchHashes, d.zkEVMClient.BatchesByNumbers) +
    +
    + 85 + +
    + + + if err != nil { +
    +
    + 86 + +
    + + + log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error()) +
    +
    + 87 + +
    + + + } else { +
    +
    + 88 + +
    + + + return data, nil +
    +
    + 89 + +
    + + + } +
    +
    + 90 + +
    + + + } +
    +
    + 91 + +
    + + + return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage) +
    +
    + 92 + +
    + + + } +
    +
    + 93 + +
    + + +
    +
    +
    + 94 + +
    + + + func checkBatches(batchNumbers []uint64, expectedHashes []common.Hash, batchData map[uint64][]byte) ([][]byte, error) { +
    +
    + 95 + +
    + + + if len(batchNumbers) != len(expectedHashes) { +
    +
    + 96 + +
    + + + return nil, fmt.Errorf("invalid batch parameters") +
    +
    + 97 + +
    + + + } +
    +
    + 98 + +
    + + + result := make([][]byte, len(batchNumbers)) +
    +
    + 99 + +
    + + + for i := 0; i < len(batchNumbers); i++ { +
    +
    + 100 + +
    + + + batchNumber := batchNumbers[i] +
    +
    + 101 + +
    + + + expectedHash := expectedHashes[i] +
    +
    + 102 + +
    + + + bd, ok := batchData[batchNumber] +
    +
    + 103 + +
    + + + if !ok { +
    +
    + 104 + +
    + + + return nil, fmt.Errorf("missing batch data: [%d] %s", batchNumber, expectedHash.Hex()) +
    +
    + 105 + +
    + + + } +
    +
    + 106 + +
    + + + actualHash := crypto.Keccak256Hash(bd) +
    +
    + 107 + +
    + + + if actualHash != expectedHash { +
    +
    + 108 + +
    + + + err := fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash) +
    +
    + 109 + +
    + + + log.Warnf("wrong local data for hash: %s", err.Error()) +
    +
    + 110 + +
    + + + return nil, err +
    +
    + 111 + +
    + + + } +
    +
    + 112 + +
    + + + result[i] = bd +
    +
    + 113 + +
    + + + } +
    +
    + 114 + +
    + + + return result, nil +
    +
    + 115 + +
    + + + } +
    +
    + 116 + +
    + + +
    +
    +
    + 117 + +
    + + + type rpcBatchDataFunc func(ctx context.Context, numbers []*big.Int) ([]*jsontypes.BatchData, error) +
    +
    + 118 + +
    + + +
    +
    +
    + 119 + +
    + + + // rpcData retrieves batch data from rpcBatchDataFunc, returns an error unless all are found and correct +
    +
    + 120 + +
    + + + func (d *DataAvailability) rpcData(batchNums []uint64, expectedHashes []common.Hash, rpcFunc rpcBatchDataFunc) ([][]byte, error) { +
    +
    + 121 + +
    + + + if len(batchNums) != len(expectedHashes) { +
    +
    + 122 + +
    + + + return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d", +
    +
    + 123 + +
    + + + len(batchNums), len(expectedHashes)) +
    +
    + 124 + +
    + + + } +
    +
    + 125 + +
    + + + nums := make([]*big.Int, 0, len(batchNums)) +
    +
    + 126 + +
    + + + for _, n := range batchNums { +
    +
    + 127 + +
    + + + nums = append(nums, new(big.Int).SetUint64(n)) +
    +
    + 128 + +
    + + + } +
    +
    + 129 + +
    + + + batchData, err := rpcFunc(d.ctx, nums) +
    +
    + 130 + +
    + + + if err != nil { +
    +
    + 131 + +
    + + + return nil, err +
    +
    + 132 + +
    + + + } +
    +
    + 133 + +
    + + + if len(batchData) != len(batchNums) { +
    +
    + 134 + +
    + + + return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData)) +
    +
    + 135 + +
    + + + } +
    +
    + 136 + +
    + + + result := make(map[uint64][]byte) +
    +
    + 137 + +
    + + + for i := 0; i < len(batchNums); i++ { +
    +
    + 138 + +
    + + + number := batchNums[i] +
    +
    + 139 + +
    + + + batch := batchData[i] +
    +
    + 140 + +
    + + + expectedTransactionsHash := expectedHashes[i] +
    +
    + 141 + +
    + + + actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data) +
    +
    + 142 + +
    + + + if expectedTransactionsHash != actualTransactionsHash { +
    +
    + 143 + +
    + + + return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash) +
    +
    + 144 + +
    + + + } +
    +
    + 145 + +
    + + + result[number] = batch.BatchL2Data +
    +
    + 146 + +
    + + + } +
    +
    + 147 + +
    + + + checked, err := checkBatches(batchNums, expectedHashes, result) +
    +
    + 148 + +
    + + + if err != nil { +
    +
    + 149 + +
    + + + return nil, err +
    +
    + 150 + +
    + + + } +
    +
    + 151 + +
    + + + return checked, nil +
    +
    + 152 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,309 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package datacommittee +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "crypto/ecdsa" +
    +
    + 5 + +
    + + + "errors" +
    +
    + 6 + +
    + + + "fmt" +
    +
    + 7 + +
    + + + "math/big" +
    +
    + 8 + +
    + + + "math/rand" +
    +
    + 9 + +
    + + + "sort" +
    +
    + 10 + +
    + + + "strings" +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + "github.com/0xPolygon/cdk-data-availability/client" +
    +
    + 13 + +
    + + + daTypes "github.com/0xPolygon/cdk-data-availability/types" +
    +
    + 14 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +
    +
    + 15 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 16 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi/bind" +
    +
    + 17 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 18 + +
    + + + "github.com/ethereum/go-ethereum/crypto" +
    +
    + 19 + +
    + + + "github.com/ethereum/go-ethereum/ethclient" +
    +
    + 20 + +
    + + + "golang.org/x/net/context" +
    +
    + 21 + +
    + + + ) +
    +
    + 22 + +
    + + +
    +
    +
    + 23 + +
    + + + const unexpectedHashTemplate = "missmatch on transaction data. Expected hash %s, actual hash: %s" +
    +
    + 24 + +
    + + +
    +
    +
    + 25 + +
    + + + // DataCommitteeMember represents a member of the Data Committee +
    +
    + 26 + +
    + + + type DataCommitteeMember struct { +
    +
    + 27 + +
    + + + Addr common.Address +
    +
    + 28 + +
    + + + URL string +
    +
    + 29 + +
    + + + } +
    +
    + 30 + +
    + + +
    +
    +
    + 31 + +
    + + + // DataCommittee represents a specific committee +
    +
    + 32 + +
    + + + type DataCommittee struct { +
    +
    + 33 + +
    + + + AddressesHash common.Hash +
    +
    + 34 + +
    + + + Members []DataCommitteeMember +
    +
    + 35 + +
    + + + RequiredSignatures uint64 +
    +
    + 36 + +
    + + + } +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + // DataCommitteeBackend implements the DAC integration +
    +
    + 39 + +
    + + + type DataCommitteeBackend struct { +
    +
    + 40 + +
    + + + dataCommitteeContract *polygondatacommittee.Polygondatacommittee +
    +
    + 41 + +
    + + + privKey *ecdsa.PrivateKey +
    +
    + 42 + +
    + + + dataCommitteeClientFactory client.Factory +
    +
    + 43 + +
    + + +
    +
    +
    + 44 + +
    + + + committeeMembers []DataCommitteeMember +
    +
    + 45 + +
    + + + selectedCommitteeMember int +
    +
    + 46 + +
    + + + ctx context.Context +
    +
    + 47 + +
    + + + } +
    +
    + 48 + +
    + + +
    +
    +
    + 49 + +
    + + + // New creates an instance of DataCommitteeBackend +
    +
    + 50 + +
    + + + func New( +
    +
    + 51 + +
    + + + l1RPCURL string, +
    +
    + 52 + +
    + + + dataCommitteeAddr common.Address, +
    +
    + 53 + +
    + + + privKey *ecdsa.PrivateKey, +
    +
    + 54 + +
    + + + dataCommitteeClientFactory client.Factory, +
    +
    + 55 + +
    + + + ) (*DataCommitteeBackend, error) { +
    +
    + 56 + +
    + + + ethClient, err := ethclient.Dial(l1RPCURL) +
    +
    + 57 + +
    + + + if err != nil { +
    +
    + 58 + +
    + + + log.Errorf("error connecting to %s: %+v", l1RPCURL, err) +
    +
    + 59 + +
    + + + return nil, err +
    +
    + 60 + +
    + + + } +
    +
    + 61 + +
    + + + dataCommittee, err := polygondatacommittee.NewPolygondatacommittee(dataCommitteeAddr, ethClient) +
    +
    + 62 + +
    + + + if err != nil { +
    +
    + 63 + +
    + + + return nil, err +
    +
    + 64 + +
    + + + } +
    +
    + 65 + +
    + + + return &DataCommitteeBackend{ +
    +
    + 66 + +
    + + + dataCommitteeContract: dataCommittee, +
    +
    + 67 + +
    + + + privKey: privKey, +
    +
    + 68 + +
    + + + dataCommitteeClientFactory: dataCommitteeClientFactory, +
    +
    + 69 + +
    + + + ctx: context.Background(), +
    +
    + 70 + +
    + + + }, nil +
    +
    + 71 + +
    + + + } +
    +
    + 72 + +
    + + +
    +
    +
    + 73 + +
    + + + // Init loads the DAC to be cached when needed +
    +
    + 74 + +
    + + + func (d *DataCommitteeBackend) Init() error { +
    +
    + 75 + +
    + + + committee, err := d.getCurrentDataCommittee() +
    +
    + 76 + +
    + + + if err != nil { +
    +
    + 77 + +
    + + + return err +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + + selectedCommitteeMember := -1 +
    +
    + 80 + +
    + + + if committee != nil { +
    +
    + 81 + +
    + + + d.committeeMembers = committee.Members +
    +
    + 82 + +
    + + + if len(committee.Members) > 0 { +
    +
    + 83 + +
    + + + selectedCommitteeMember = rand.Intn(len(committee.Members)) //nolint:gosec +
    +
    + 84 + +
    + + + } +
    +
    + 85 + +
    + + + } +
    +
    + 86 + +
    + + + d.selectedCommitteeMember = selectedCommitteeMember +
    +
    + 87 + +
    + + + return nil +
    +
    + 88 + +
    + + + } +
    +
    + 89 + +
    + + +
    +
    +
    + 90 + +
    + + + // GetSequence gets backend data one hash at a time. This should be optimized on the DAC side to get them all at once. +
    +
    + 91 + +
    + + + func (d *DataCommitteeBackend) GetSequence(ctx context.Context, hashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) { +
    +
    + 92 + +
    + + + // TODO: optimize this on the DAC side by implementing a multi batch retrieve api +
    +
    + 93 + +
    + + + var batchData [][]byte +
    +
    + 94 + +
    + + + for _, h := range hashes { +
    +
    + 95 + +
    + + + data, err := d.GetBatchL2Data(h) +
    +
    + 96 + +
    + + + if err != nil { +
    +
    + 97 + +
    + + + return nil, err +
    +
    + 98 + +
    + + + } +
    +
    + 99 + +
    + + + batchData = append(batchData, data) +
    +
    + 100 + +
    + + + } +
    +
    + 101 + +
    + + + return batchData, nil +
    +
    + 102 + +
    + + + } +
    +
    + 103 + +
    + + +
    +
    +
    + 104 + +
    + + + // GetBatchL2Data returns the data from the DAC. It checks that it matches with the expected hash +
    +
    + 105 + +
    + + + func (d *DataCommitteeBackend) GetBatchL2Data(hash common.Hash) ([]byte, error) { +
    +
    + 106 + +
    + + + intialMember := d.selectedCommitteeMember +
    +
    + 107 + +
    + + + found := false +
    +
    + 108 + +
    + + + for !found && intialMember != -1 { +
    +
    + 109 + +
    + + + member := d.committeeMembers[d.selectedCommitteeMember] +
    +
    + 110 + +
    + + + log.Infof("trying to get data from %s at %s", member.Addr.Hex(), member.URL) +
    +
    + 111 + +
    + + + c := d.dataCommitteeClientFactory.New(member.URL) +
    +
    + 112 + +
    + + + data, err := c.GetOffChainData(d.ctx, hash) +
    +
    + 113 + +
    + + + if err != nil { +
    +
    + 114 + +
    + + + log.Warnf( +
    +
    + 115 + +
    + + + "error getting data from DAC node %s at %s: %s", +
    +
    + 116 + +
    + + + member.Addr.Hex(), member.URL, err, +
    +
    + 117 + +
    + + + ) +
    +
    + 118 + +
    + + + d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers) +
    +
    + 119 + +
    + + + if d.selectedCommitteeMember == intialMember { +
    +
    + 120 + +
    + + + break +
    +
    + 121 + +
    + + + } +
    +
    + 122 + +
    + + + continue +
    +
    + 123 + +
    + + + } +
    +
    + 124 + +
    + + + actualTransactionsHash := crypto.Keccak256Hash(data) +
    +
    + 125 + +
    + + + if actualTransactionsHash != hash { +
    +
    + 126 + +
    + + + unexpectedHash := fmt.Errorf( +
    +
    + 127 + +
    + + + unexpectedHashTemplate, hash, actualTransactionsHash, +
    +
    + 128 + +
    + + + ) +
    +
    + 129 + +
    + + + log.Warnf( +
    +
    + 130 + +
    + + + "error getting data from DAC node %s at %s: %s", +
    +
    + 131 + +
    + + + member.Addr.Hex(), member.URL, unexpectedHash, +
    +
    + 132 + +
    + + + ) +
    +
    + 133 + +
    + + + d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers) +
    +
    + 134 + +
    + + + if d.selectedCommitteeMember == intialMember { +
    +
    + 135 + +
    + + + break +
    +
    + 136 + +
    + + + } +
    +
    + 137 + +
    + + + continue +
    +
    + 138 + +
    + + + } +
    +
    + 139 + +
    + + + return data, nil +
    +
    + 140 + +
    + + + } +
    +
    + 141 + +
    + + + if err := d.Init(); err != nil { +
    +
    + 142 + +
    + + + return nil, fmt.Errorf("error loading data committee: %s", err) +
    +
    + 143 + +
    + + + } +
    +
    + 144 + +
    + + + return nil, fmt.Errorf("couldn't get the data from any committee member") +
    +
    + 145 + +
    + + + } +
    +
    + 146 + +
    + + +
    +
    +
    + 147 + +
    + + + type signatureMsg struct { +
    +
    + 148 + +
    + + + addr common.Address +
    +
    + 149 + +
    + + + signature []byte +
    +
    + 150 + +
    + + + err error +
    +
    + 151 + +
    + + + } +
    +
    + 152 + +
    + + +
    +
    +
    + 153 + +
    + + + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage +
    +
    + 154 + +
    + + + // as expected by the contract +
    +
    + 155 + +
    + + + func (s *DataCommitteeBackend) PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) { +
    +
    + 156 + +
    + + + // Get current committee +
    +
    + 157 + +
    + + + committee, err := s.getCurrentDataCommittee() +
    +
    + 158 + +
    + + + if err != nil { +
    +
    + 159 + +
    + + + return nil, err +
    +
    + 160 + +
    + + + } +
    +
    + 161 + +
    + + +
    +
    +
    + 162 + +
    + + + // Authenticate as trusted sequencer by signing the sequences +
    +
    + 163 + +
    + + + sequence := daTypes.Sequence{} +
    +
    + 164 + +
    + + + for _, seq := range batchesData { +
    +
    + 165 + +
    + + + sequence = append(sequence, seq) +
    +
    + 166 + +
    + + + } +
    +
    + 167 + +
    + + + signedSequence, err := sequence.Sign(s.privKey) +
    +
    + 168 + +
    + + + if err != nil { +
    +
    + 169 + +
    + + + return nil, err +
    +
    + 170 + +
    + + + } +
    +
    + 171 + +
    + + +
    +
    +
    + 172 + +
    + + + // Request signatures to all members in parallel +
    +
    + 173 + +
    + + + ch := make(chan signatureMsg, len(committee.Members)) +
    +
    + 174 + +
    + + + signatureCtx, cancelSignatureCollection := context.WithCancel(ctx) +
    +
    + 175 + +
    + + + for _, member := range committee.Members { +
    +
    + 176 + +
    + + + go requestSignatureFromMember(signatureCtx, *signedSequence, member, ch) +
    +
    + 177 + +
    + + + } +
    +
    + 178 + +
    + + +
    +
    +
    + 179 + +
    + + + // Collect signatures +
    +
    + 180 + +
    + + + msgs := []signatureMsg{} +
    +
    + 181 + +
    + + + var ( +
    +
    + 182 + +
    + + + collectedSignatures uint64 +
    +
    + 183 + +
    + + + failedToCollect uint64 +
    +
    + 184 + +
    + + + ) +
    +
    + 185 + +
    + + + for collectedSignatures < committee.RequiredSignatures { +
    +
    + 186 + +
    + + + msg := <-ch +
    +
    + 187 + +
    + + + if msg.err != nil { +
    +
    + 188 + +
    + + + log.Errorf("error when trying to get signature from %s: %s", msg.addr, msg.err) +
    +
    + 189 + +
    + + + failedToCollect++ +
    +
    + 190 + +
    + + + if len(committee.Members)-int(failedToCollect) < int(committee.RequiredSignatures) { +
    +
    + 191 + +
    + + + cancelSignatureCollection() +
    +
    + 192 + +
    + + + return nil, errors.New("too many members failed to send their signature") +
    +
    + 193 + +
    + + + } +
    +
    + 194 + +
    + + + } else { +
    +
    + 195 + +
    + + + log.Infof("received signature from %s", msg.addr) +
    +
    + 196 + +
    + + + collectedSignatures++ +
    +
    + 197 + +
    + + + } +
    +
    + 198 + +
    + + + msgs = append(msgs, msg) +
    +
    + 199 + +
    + + + } +
    +
    + 200 + +
    + + +
    +
    +
    + 201 + +
    + + + // Stop requesting as soon as we have N valid signatures +
    +
    + 202 + +
    + + + cancelSignatureCollection() +
    +
    + 203 + +
    + + +
    +
    +
    + 204 + +
    + + + return buildSignaturesAndAddrs(signatureMsgs(msgs), committee.Members), nil +
    +
    + 205 + +
    + + + } +
    +
    + 206 + +
    + + +
    +
    +
    + 207 + +
    + + + func requestSignatureFromMember(ctx context.Context, signedSequence daTypes.SignedSequence, member DataCommitteeMember, ch chan signatureMsg) { +
    +
    + 208 + +
    + + + // request +
    +
    + 209 + +
    + + + c := client.New(member.URL) +
    +
    + 210 + +
    + + + log.Infof("sending request to sign the sequence to %s at %s", member.Addr.Hex(), member.URL) +
    +
    + 211 + +
    + + + signature, err := c.SignSequence(signedSequence) +
    +
    + 212 + +
    + + + if err != nil { +
    +
    + 213 + +
    + + + ch <- signatureMsg{ +
    +
    + 214 + +
    + + + addr: member.Addr, +
    +
    + 215 + +
    + + + err: err, +
    +
    + 216 + +
    + + + } +
    +
    + 217 + +
    + + + return +
    +
    + 218 + +
    + + + } +
    +
    + 219 + +
    + + + // verify returned signature +
    +
    + 220 + +
    + + + signedSequence.Signature = signature +
    +
    + 221 + +
    + + + signer, err := signedSequence.Signer() +
    +
    + 222 + +
    + + + if err != nil { +
    +
    + 223 + +
    + + + ch <- signatureMsg{ +
    +
    + 224 + +
    + + + addr: member.Addr, +
    +
    + 225 + +
    + + + err: err, +
    +
    + 226 + +
    + + + } +
    +
    + 227 + +
    + + + return +
    +
    + 228 + +
    + + + } +
    +
    + 229 + +
    + + + if signer != member.Addr { +
    +
    + 230 + +
    + + + ch <- signatureMsg{ +
    +
    + 231 + +
    + + + addr: member.Addr, +
    +
    + 232 + +
    + + + err: fmt.Errorf("invalid signer. Expected %s, actual %s", member.Addr.Hex(), signer.Hex()), +
    +
    + 233 + +
    + + + } +
    +
    + 234 + +
    + + + return +
    +
    + 235 + +
    + + + } +
    +
    + 236 + +
    + + + ch <- signatureMsg{ +
    +
    + 237 + +
    + + + addr: member.Addr, +
    +
    + 238 + +
    + + + signature: signature, +
    +
    + 239 + +
    + + + } +
    +
    + 240 + +
    + + + } +
    +
    + 241 + +
    + + +
    +
    +
    + 242 + +
    + + + func buildSignaturesAndAddrs(sigs signatureMsgs, members []DataCommitteeMember) []byte { +
    +
    + 243 + +
    + + + const ( +
    +
    + 244 + +
    + + + sigLen = 65 +
    +
    + 245 + +
    + + + addrLen = 20 +
    +
    + 246 + +
    + + + ) +
    +
    + 247 + +
    + + + res := make([]byte, 0, len(sigs)*sigLen+len(members)*addrLen) +
    +
    + 248 + +
    + + + sort.Sort(sigs) +
    +
    + 249 + +
    + + + for _, msg := range sigs { +
    +
    + 250 + +
    + + + log.Debugf("adding signature %s from %s", common.Bytes2Hex(msg.signature), msg.addr.Hex()) +
    +
    + 251 + +
    + + + res = append(res, msg.signature...) +
    +
    + 252 + +
    + + + } +
    +
    + 253 + +
    + + + for _, member := range members { +
    +
    + 254 + +
    + + + log.Debugf("adding addr %s", common.Bytes2Hex(member.Addr.Bytes())) +
    +
    + 255 + +
    + + + res = append(res, member.Addr.Bytes()...) +
    +
    + 256 + +
    + + + } +
    +
    + 257 + +
    + + + log.Debugf("full res %s", common.Bytes2Hex(res)) +
    +
    + 258 + +
    + + + return res +
    +
    + 259 + +
    + + + } +
    +
    + 260 + +
    + + +
    +
    +
    + 261 + +
    + + + type signatureMsgs []signatureMsg +
    +
    + 262 + +
    + + +
    +
    +
    + 263 + +
    + + + func (s signatureMsgs) Len() int { return len(s) } +
    +
    + 264 + +
    + + + func (s signatureMsgs) Less(i, j int) bool { +
    +
    + 265 + +
    + + + return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex()) +
    +
    + 266 + +
    + + + } +
    +
    + 267 + +
    + + + func (s signatureMsgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +
    +
    + 268 + +
    + + +
    +
    +
    + 269 + +
    + + + // getCurrentDataCommittee return the currently registered data committee +
    +
    + 270 + +
    + + + func (d *DataCommitteeBackend) getCurrentDataCommittee() (*DataCommittee, error) { +
    +
    + 271 + +
    + + + addrsHash, err := d.dataCommitteeContract.CommitteeHash(&bind.CallOpts{Pending: false}) +
    +
    + 272 + +
    + + + if err != nil { +
    +
    + 273 + +
    + + + return nil, fmt.Errorf("error getting CommitteeHash from L1 SC: %w", err) +
    +
    + 274 + +
    + + + } +
    +
    + 275 + +
    + + + reqSign, err := d.dataCommitteeContract.RequiredAmountOfSignatures(&bind.CallOpts{Pending: false}) +
    +
    + 276 + +
    + + + if err != nil { +
    +
    + 277 + +
    + + + return nil, fmt.Errorf("error getting RequiredAmountOfSignatures from L1 SC: %w", err) +
    +
    + 278 + +
    + + + } +
    +
    + 279 + +
    + + + members, err := d.getCurrentDataCommitteeMembers() +
    +
    + 280 + +
    + + + if err != nil { +
    +
    + 281 + +
    + + + return nil, err +
    +
    + 282 + +
    + + + } +
    +
    + 283 + +
    + + +
    +
    +
    + 284 + +
    + + + return &DataCommittee{ +
    +
    + 285 + +
    + + + AddressesHash: common.Hash(addrsHash), +
    +
    + 286 + +
    + + + RequiredSignatures: reqSign.Uint64(), +
    +
    + 287 + +
    + + + Members: members, +
    +
    + 288 + +
    + + + }, nil +
    +
    + 289 + +
    + + + } +
    +
    + 290 + +
    + + +
    +
    +
    + 291 + +
    + + + // getCurrentDataCommitteeMembers return the currently registered data committee members +
    +
    + 292 + +
    + + + func (d *DataCommitteeBackend) getCurrentDataCommitteeMembers() ([]DataCommitteeMember, error) { +
    +
    + 293 + +
    + + + nMembers, err := d.dataCommitteeContract.GetAmountOfMembers(&bind.CallOpts{Pending: false}) +
    +
    + 294 + +
    + + + if err != nil { +
    +
    + 295 + +
    + + + return nil, fmt.Errorf("error getting GetAmountOfMembers from L1 SC: %w", err) +
    +
    + 296 + +
    + + + } +
    +
    + 297 + +
    + + + members := make([]DataCommitteeMember, 0, nMembers.Int64()) +
    +
    + 298 + +
    + + + for i := int64(0); i < nMembers.Int64(); i++ { +
    +
    + 299 + +
    + + + member, err := d.dataCommitteeContract.Members(&bind.CallOpts{Pending: false}, big.NewInt(i)) +
    +
    + 300 + +
    + + + if err != nil { +
    +
    + 301 + +
    + + + return nil, fmt.Errorf("error getting Members %d from L1 SC: %w", i, err) +
    +
    + 302 + +
    + + + } +
    +
    + 303 + +
    + + + members = append(members, DataCommitteeMember{ +
    +
    + 304 + +
    + + + Addr: member.Addr, +
    +
    + 305 + +
    + + + URL: member.Url, +
    +
    + 306 + +
    + + + }) +
    +
    + 307 + +
    + + + } +
    +
    + 308 + +
    + + + return members, nil +
    +
    + 309 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,131 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package datacommittee +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "math/big" +
    +
    + 5 + +
    + + + "testing" +
    +
    + 6 + +
    + + +
    +
    +
    + 7 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 9 + +
    + + + "github.com/ethereum/go-ethereum/accounts/abi/bind" +
    +
    + 10 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 11 + +
    + + + "github.com/ethereum/go-ethereum/core" +
    +
    + 12 + +
    + + + "github.com/ethereum/go-ethereum/crypto" +
    +
    + 13 + +
    + + + "github.com/ethereum/go-ethereum/ethclient/simulated" +
    +
    + 14 + +
    + + + "github.com/stretchr/testify/assert" +
    +
    + 15 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 16 + +
    + + + ) +
    +
    + 17 + +
    + + +
    +
    +
    + 18 + +
    + + + func TestUpdateDataCommitteeEvent(t *testing.T) { +
    +
    + 19 + +
    + + + // Set up testing environment +
    +
    + 20 + +
    + + + dac, ethBackend, auth, da := newTestingEnv(t) +
    +
    + 21 + +
    + + +
    +
    +
    + 22 + +
    + + + // Update the committee +
    +
    + 23 + +
    + + + requiredAmountOfSignatures := big.NewInt(2) +
    +
    + 24 + +
    + + + URLs := []string{"1", "2", "3"} +
    +
    + 25 + +
    + + + addrs := []common.Address{ +
    +
    + 26 + +
    + + + common.HexToAddress("0x1"), +
    +
    + 27 + +
    + + + common.HexToAddress("0x2"), +
    +
    + 28 + +
    + + + common.HexToAddress("0x3"), +
    +
    + 29 + +
    + + + } +
    +
    + 30 + +
    + + + addrsBytes := []byte{} +
    +
    + 31 + +
    + + + for _, addr := range addrs { +
    +
    + 32 + +
    + + + addrsBytes = append(addrsBytes, addr.Bytes()...) +
    +
    + 33 + +
    + + + } +
    +
    + 34 + +
    + + + _, err := da.SetupCommittee(auth, requiredAmountOfSignatures, URLs, addrsBytes) +
    +
    + 35 + +
    + + + require.NoError(t, err) +
    +
    + 36 + +
    + + + ethBackend.Commit() +
    +
    + 37 + +
    + + +
    +
    +
    + 38 + +
    + + + // Assert the committee update +
    +
    + 39 + +
    + + + actualSetup, err := dac.getCurrentDataCommittee() +
    +
    + 40 + +
    + + + require.NoError(t, err) +
    +
    + 41 + +
    + + + expectedMembers := []DataCommitteeMember{} +
    +
    + 42 + +
    + + + expectedSetup := DataCommittee{ +
    +
    + 43 + +
    + + + RequiredSignatures: uint64(len(URLs) - 1), +
    +
    + 44 + +
    + + + AddressesHash: crypto.Keccak256Hash(addrsBytes), +
    +
    + 45 + +
    + + + } +
    +
    + 46 + +
    + + + for i, url := range URLs { +
    +
    + 47 + +
    + + + expectedMembers = append(expectedMembers, DataCommitteeMember{ +
    +
    + 48 + +
    + + + URL: url, +
    +
    + 49 + +
    + + + Addr: addrs[i], +
    +
    + 50 + +
    + + + }) +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + + expectedSetup.Members = expectedMembers +
    +
    + 53 + +
    + + + assert.Equal(t, expectedSetup, *actualSetup) +
    +
    + 54 + +
    + + + } +
    +
    + 55 + +
    + + +
    +
    +
    + 56 + +
    + + + func init() { +
    +
    + 57 + +
    + + + log.Init(log.Config{ +
    +
    + 58 + +
    + + + Level: "debug", +
    +
    + 59 + +
    + + + Outputs: []string{"stderr"}, +
    +
    + 60 + +
    + + + }) +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + +
    +
    +
    + 63 + +
    + + + // This function prepare the blockchain, the wallet with funds and deploy the smc +
    +
    + 64 + +
    + + + func newTestingEnv(t *testing.T) ( +
    +
    + 65 + +
    + + + dac *DataCommitteeBackend, +
    +
    + 66 + +
    + + + ethBackend *simulated.Backend, +
    +
    + 67 + +
    + + + auth *bind.TransactOpts, +
    +
    + 68 + +
    + + + da *polygondatacommittee.Polygondatacommittee, +
    +
    + 69 + +
    + + + ) { +
    +
    + 70 + +
    + + + t.Helper() +
    +
    + 71 + +
    + + + privateKey, err := crypto.GenerateKey() +
    +
    + 72 + +
    + + + if err != nil { +
    +
    + 73 + +
    + + + log.Fatal(err) +
    +
    + 74 + +
    + + + } +
    +
    + 75 + +
    + + + auth, err = bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1337)) +
    +
    + 76 + +
    + + + if err != nil { +
    +
    + 77 + +
    + + + log.Fatal(err) +
    +
    + 78 + +
    + + + } +
    +
    + 79 + +
    + + + dac, ethBackend, da, err = newSimulatedDacman(t, auth) +
    +
    + 80 + +
    + + + if err != nil { +
    +
    + 81 + +
    + + + log.Fatal(err) +
    +
    + 82 + +
    + + + } +
    +
    + 83 + +
    + + + return dac, ethBackend, auth, da +
    +
    + 84 + +
    + + + } +
    +
    + 85 + +
    + + +
    +
    +
    + 86 + +
    + + + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth +
    +
    + 87 + +
    + + + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH +
    +
    + 88 + +
    + + + func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) ( +
    +
    + 89 + +
    + + + dacman *DataCommitteeBackend, +
    +
    + 90 + +
    + + + ethBackend *simulated.Backend, +
    +
    + 91 + +
    + + + da *polygondatacommittee.Polygondatacommittee, +
    +
    + 92 + +
    + + + err error, +
    +
    + 93 + +
    + + + ) { +
    +
    + 94 + +
    + + + t.Helper() +
    +
    + 95 + +
    + + + if auth == nil { +
    +
    + 96 + +
    + + + // read only client +
    +
    + 97 + +
    + + + return &DataCommitteeBackend{}, nil, nil, nil +
    +
    + 98 + +
    + + + } +
    +
    + 99 + +
    + + + // 10000000 ETH in wei +
    +
    + 100 + +
    + + + balance, _ := new(big.Int).SetString("10000000000000000000000000", 10) //nolint:gomnd +
    +
    + 101 + +
    + + + address := auth.From +
    +
    + 102 + +
    + + + genesisAlloc := map[common.Address]core.GenesisAccount{ +
    +
    + 103 + +
    + + + address: { +
    +
    + 104 + +
    + + + Balance: balance, +
    +
    + 105 + +
    + + + }, +
    +
    + 106 + +
    + + + } +
    +
    + 107 + +
    + + + blockGasLimit := uint64(999999999999999999) //nolint:gomnd +
    +
    + 108 + +
    + + + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) +
    +
    + 109 + +
    + + +
    +
    +
    + 110 + +
    + + + // DAC Setup +
    +
    + 111 + +
    + + + _, _, da, err = polygondatacommittee.DeployPolygondatacommittee(auth, client.Client()) +
    +
    + 112 + +
    + + + if err != nil { +
    +
    + 113 + +
    + + + return &DataCommitteeBackend{}, nil, nil, err +
    +
    + 114 + +
    + + + } +
    +
    + 115 + +
    + + + client.Commit() +
    +
    + 116 + +
    + + + _, err = da.Initialize(auth) +
    +
    + 117 + +
    + + + if err != nil { +
    +
    + 118 + +
    + + + return &DataCommitteeBackend{}, nil, nil, err +
    +
    + 119 + +
    + + + } +
    +
    + 120 + +
    + + + client.Commit() +
    +
    + 121 + +
    + + + _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{}) +
    +
    + 122 + +
    + + + if err != nil { +
    +
    + 123 + +
    + + + return &DataCommitteeBackend{}, nil, nil, err +
    +
    + 124 + +
    + + + } +
    +
    + 125 + +
    + + + client.Commit() +
    +
    + 126 + +
    + + +
    +
    +
    + 127 + +
    + + + c := &DataCommitteeBackend{ +
    +
    + 128 + +
    + + + dataCommitteeContract: da, +
    +
    + 129 + +
    + + + } +
    +
    + 130 + +
    + + + return c, client, da, nil +
    +
    + 131 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,60 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + package dataavailability +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + import ( +
    +
    + 4 + +
    + + + "context" +
    +
    + 5 + +
    + + + "math/big" +
    +
    + 6 + +
    + + +
    +
    +
    + 7 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 9 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 10 + +
    + + + "github.com/jackc/pgx/v4" +
    +
    + 11 + +
    + + + ) +
    +
    + 12 + +
    + + +
    +
    +
    + 13 + +
    + + + // DABackender is an interface for components that store and retrieve batch data +
    +
    + 14 + +
    + + + type DABackender interface { +
    +
    + 15 + +
    + + + SequenceRetriever +
    +
    + 16 + +
    + + + SequenceSender +
    +
    + 17 + +
    + + + // Init initializes the DABackend +
    +
    + 18 + +
    + + + Init() error +
    +
    + 19 + +
    + + + } +
    +
    + 20 + +
    + + +
    +
    +
    + 21 + +
    + + + // SequenceSender is used to send provided sequence of batches +
    +
    + 22 + +
    + + + type SequenceSender interface { +
    +
    + 23 + +
    + + + // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage +
    +
    + 24 + +
    + + + // as expected by the contract +
    +
    + 25 + +
    + + + PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) +
    +
    + 26 + +
    + + + } +
    +
    + 27 + +
    + + +
    +
    +
    + 28 + +
    + + + // SequenceRetriever is used to retrieve batch data +
    +
    + 29 + +
    + + + type SequenceRetriever interface { +
    +
    + 30 + +
    + + + // GetSequence retrieves the sequence data from the data availability backend +
    +
    + 31 + +
    + + + GetSequence(ctx context.Context, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) +
    +
    + 32 + +
    + + + } +
    +
    + 33 + +
    + + +
    +
    +
    + 34 + +
    + + + // === Internal interfaces === +
    +
    + 35 + +
    + + +
    +
    +
    + 36 + +
    + + + type stateInterface interface { +
    +
    + 37 + +
    + + + GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) +
    +
    + 38 + +
    + + + GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    +
    + 39 + +
    + + + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 40 + +
    + + + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    +
    + 41 + +
    + + + } +
    +
    + 42 + +
    + + +
    +
    +
    + 43 + +
    + + + // BatchDataProvider is used to retrieve batch data +
    +
    + 44 + +
    + + + type BatchDataProvider interface { +
    +
    + 45 + +
    + + + // GetBatchL2Data retrieve the data of a batch from the DA backend. The returned data must be the pre-image of the hash +
    +
    + 46 + +
    + + + GetBatchL2Data(batchNum []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) +
    +
    + 47 + +
    + + + } +
    +
    + 48 + +
    + + +
    +
    +
    + 49 + +
    + + + // DataManager is an interface for components that send and retrieve batch data +
    +
    + 50 + +
    + + + type DataManager interface { +
    +
    + 51 + +
    + + + BatchDataProvider +
    +
    + 52 + +
    + + + SequenceSender +
    +
    + 53 + +
    + + + } +
    +
    + 54 + +
    + + +
    +
    +
    + 55 + +
    + + + // ZKEVMClientTrustedBatchesGetter contains the methods required to interact with zkEVM-RPC +
    +
    + 56 + +
    + + + type ZKEVMClientTrustedBatchesGetter interface { +
    +
    + 57 + +
    + + + BatchByNumber(ctx context.Context, number *big.Int) (*types.Batch, error) +
    +
    + 58 + +
    + + + BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) +
    +
    + 59 + +
    + + + ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) +
    +
    + 60 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/pool/validium-001.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,20 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    + + + -- +migrate Down +
    +
    + 2 + +
    + + + DROP TABLE IF EXISTS pool.acl CASCADE; +
    +
    + 3 + +
    + + + DROP TABLE IF EXISTS pool.policy CASCADE; +
    +
    + 4 + +
    + + +
    +
    +
    + 5 + +
    + + + -- +migrate Up +
    +
    + 6 + +
    + + + CREATE TABLE pool.policy +
    +
    + 7 + +
    + + + ( +
    +
    + 8 + +
    + + + name VARCHAR PRIMARY KEY, +
    +
    + 9 + +
    + + + allow BOOLEAN NOT NULL DEFAULT false +
    +
    + 10 + +
    + + + ); +
    +
    + 11 + +
    + + +
    +
    +
    + 12 + +
    + + + INSERT INTO pool.policy (name, allow) VALUES ('send_tx', false); +
    +
    + 13 + +
    + + + INSERT INTO pool.policy (name, allow) VALUES ('deploy', false); +
    +
    + 14 + +
    + + +
    +
    +
    + 15 + +
    + + + CREATE TABLE pool.acl +
    +
    + 16 + +
    + + + ( +
    +
    + 17 + +
    + + + address VARCHAR, +
    +
    + 18 + +
    + + + policy VARCHAR, +
    +
    + 19 + +
    + + + PRIMARY KEY (address, policy) +
    +
    + 20 + +
    + + + ); +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0013_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -8,19 +8,21 @@
    +
    + 8 + +
    +   + "github.com/stretchr/testify/assert" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 11 + +
    +   + // this migration changes length of the token name +
    +
    + 12 + +
    + - + type migrationTest0013 struct { +
    +
    + 13 + +
    + - + blockHashValue string +
    +
    + 14 + +
    + - + mainExitRootValue string +
    +
    + 15 + +
    + - + rollupExitRootValue string +
    +
    + 16 + +
    + - + globalExitRootValue string +
    +
    + 17 + +
    + - + previousBlockHashValue string +
    +
    + 18 + +
    + - + l1InfoRootValue string +
    +
    + 19 + +
    + - + } +
    +
    + 20 + +
    +   +
    +
    +
    + 21 + +
    +   + func (m migrationTest0013) insertBlock(blockNumber uint64, db *sql.DB) error { +
    +
    + 22 + +
    +   + const addBlock = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES ($1, $2, $3)" +
    +
    + 23 + +
    + - + if _, err := db.Exec(addBlock, blockNumber, time.Now(), m.blockHashValue); err != nil { +
    +
    + 24 + +
    +   + return err +
    +
    + 25 + +
    +   + } +
    +
    + 26 + +
    +   + return nil +
    +
    +
    @@ -43,10 +45,10 @@
    +
    + 43 + +
    +   + if err = m.insertBlock(uint64(124), db); err != nil { +
    +
    + 44 + +
    +   + return err +
    +
    + 45 + +
    +   + } +
    +
    + 46 + +
    + - + if err = m.insertRowInOldTable(db, []interface{}{123, time.Now(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue}); err != nil { +
    +
    + 47 + +
    +   + return err +
    +
    + 48 + +
    +   + } +
    +
    + 49 + +
    + - + if err = m.insertRowInOldTable(db, []interface{}{124, time.Now(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue}); err != nil { +
    +
    + 50 + +
    +   + return err +
    +
    + 51 + +
    +   + } +
    +
    + 52 + +
    +   +
    +
    +
    +
    @@ -111,16 +113,16 @@
    +
    + 111 + +
    +   + assert.NoError(t, err) +
    +
    + 112 + +
    +   + err = m.insertBlock(uint64(127), db) +
    +
    + 113 + +
    +   + assert.NoError(t, err) +
    +
    + 114 + +
    + - + prevBlockHash := m.previousBlockHashValue +
    +
    + 115 + +
    + - + l1InfoRoot := m.l1InfoRootValue +
    +
    + 116 + +
    + - + err = m.insertRowInMigratedTable(db, []interface{}{125, time.Now(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, prevBlockHash, l1InfoRoot, 1}) +
    +
    + 117 + +
    +   + assert.NoError(t, err) +
    +
    + 118 + +
    +   + // insert duplicated l1_info_root +
    +
    + 119 + +
    + - + err = m.insertRowInMigratedTable(db, []interface{}{126, time.Now(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, prevBlockHash, l1InfoRoot, 1}) +
    +
    + 120 + +
    +   + assert.Error(t, err) +
    +
    + 121 + +
    +   +
    +
    +
    + 122 + +
    +   + // insert in the old way must work +
    +
    + 123 + +
    + - + err = m.insertRowInOldTable(db, []interface{}{127, time.Now(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue}) +
    +
    + 124 + +
    +   + assert.NoError(t, err) +
    +
    + 125 + +
    +   +
    +
    +
    + 126 + +
    +   + sqlSelect := `SELECT prev_block_hash, l1_info_root FROM state.exit_root WHERE l1_info_tree_index = $1` +
    +
    +
    @@ -183,13 +185,5 @@
    +
    + 183 + +
    +   + } +
    +
    + 184 + +
    +   +
    +
    +
    + 185 + +
    +   + func TestMigration0013(t *testing.T) { +
    +
    + 186 + +
    + - + m := migrationTest0013{ +
    +
    + 187 + +
    + - + blockHashValue: "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1", +
    +
    + 188 + +
    + - + mainExitRootValue: "0x83fc198de31e1b2b1a8212d2430fbb7766c13d9ad305637dea3759065606475d", +
    +
    + 189 + +
    + - + rollupExitRootValue: "0xadb91a6a1fce56eaea561002bc9a993f4e65a7710bd72f4eee3067cbd73a743c", +
    +
    + 190 + +
    + - + globalExitRootValue: "0x5bf4af1a651a2a74b36e6eb208481f94c69fc959f756223dfa49608061937585", +
    +
    + 191 + +
    + - + previousBlockHashValue: "0xe865e912b504572a4d80ad018e29797e3c11f00bf9ae2549548a25779c9d7e57", +
    +
    + 192 + +
    + - + l1InfoRootValue: "0x2b9484b83c6398033241865b015fb9430eb3e159182a6075d00c924845cc393e", +
    +
    + 193 + +
    + - + } +
    +
    + 194 + +
    + - + runMigrationTest(t, 13, m) +
    +
    + 195 + +
    +   + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 8 + +
    +   + "github.com/stretchr/testify/assert" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
    +   +
    +
    +
    + 11 + +
    + + + const ( +
    +
    + 12 + +
    + + + blockHashValue = "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1" +
    +
    + 13 + +
    + + + mainExitRootValue = "0x83fc198de31e1b2b1a8212d2430fbb7766c13d9ad305637dea3759065606475d" +
    +
    + 14 + +
    + + + rollupExitRootValue = "0xadb91a6a1fce56eaea561002bc9a993f4e65a7710bd72f4eee3067cbd73a743c" +
    +
    + 15 + +
    + + + globalExitRootValue = "0x5bf4af1a651a2a74b36e6eb208481f94c69fc959f756223dfa49608061937585" +
    +
    + 16 + +
    + + + previousBlockHashValue = "0xe865e912b504572a4d80ad018e29797e3c11f00bf9ae2549548a25779c9d7e57" +
    +
    + 17 + +
    + + + l1InfoRootValue = "0x2b9484b83c6398033241865b015fb9430eb3e159182a6075d00c924845cc393e" +
    +
    + 18 + +
    + + + ) +
    +
    + 19 + +
    + + +
    +
    +
    + 20 + +
    +   + // this migration changes length of the token name +
    +
    + 21 + +
    + + + type migrationTest0013 struct{} +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 22 + +
    +   +
    +
    +
    + 23 + +
    +   + func (m migrationTest0013) insertBlock(blockNumber uint64, db *sql.DB) error { +
    +
    + 24 + +
    +   + const addBlock = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES ($1, $2, $3)" +
    +
    + 25 + +
    + + + if _, err := db.Exec(addBlock, blockNumber, time.Now(), blockHashValue); err != nil { +
    +
    + 26 + +
    +   + return err +
    +
    + 27 + +
    +   + } +
    +
    + 28 + +
    +   + return nil +
    +
    +
     
    +
    + 45 + +
    +   + if err = m.insertBlock(uint64(124), db); err != nil { +
    +
    + 46 + +
    +   + return err +
    +
    + 47 + +
    +   + } +
    +
    + 48 + +
    + + + if err = m.insertRowInOldTable(db, []interface{}{123, time.Now(), mainExitRootValue, rollupExitRootValue, globalExitRootValue}); err != nil { +
    +
    + 49 + +
    +   + return err +
    +
    + 50 + +
    +   + } +
    +
    + 51 + +
    + + + if err = m.insertRowInOldTable(db, []interface{}{124, time.Now(), mainExitRootValue, rollupExitRootValue, globalExitRootValue}); err != nil { +
    +
    + 52 + +
    +   + return err +
    +
    + 53 + +
    +   + } +
    +
    + 54 + +
    +   +
    +
    +
    +
     
    +
    + 113 + +
    +   + assert.NoError(t, err) +
    +
    + 114 + +
    +   + err = m.insertBlock(uint64(127), db) +
    +
    + 115 + +
    +   + assert.NoError(t, err) +
    +
    + 116 + +
    + + + prevBlockHash := previousBlockHashValue +
    +
    + 117 + +
    + + + l1InfoRoot := l1InfoRootValue +
    +
    + 118 + +
    + + + err = m.insertRowInMigratedTable(db, []interface{}{125, time.Now(), mainExitRootValue, rollupExitRootValue, globalExitRootValue, prevBlockHash, l1InfoRoot, 1}) +
    +
    + 119 + +
    +   + assert.NoError(t, err) +
    +
    + 120 + +
    +   + // insert duplicated l1_info_root +
    +
    + 121 + +
    + + + err = m.insertRowInMigratedTable(db, []interface{}{126, time.Now(), mainExitRootValue, rollupExitRootValue, globalExitRootValue, prevBlockHash, l1InfoRoot, 1}) +
    +
    + 122 + +
    +   + assert.Error(t, err) +
    +
    + 123 + +
    +   +
    +
    +
    + 124 + +
    +   + // insert in the old way must work +
    +
    + 125 + +
    + + + err = m.insertRowInOldTable(db, []interface{}{127, time.Now(), mainExitRootValue, rollupExitRootValue, globalExitRootValue}) +
    +
    + 126 + +
    +   + assert.NoError(t, err) +
    +
    + 127 + +
    +   +
    +
    +
    + 128 + +
    +   + sqlSelect := `SELECT prev_block_hash, l1_info_root FROM state.exit_root WHERE l1_info_tree_index = $1` +
    +
    +
     
    +
    + 185 + +
    +   + } +
    +
    + 186 + +
    +   +
    +
    +
    + 187 + +
    +   + func TestMigration0013(t *testing.T) { +
    +
    + 188 + +
    + + + runMigrationTest(t, 13, migrationTest0013{}) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 189 + +
    +   + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,81 +1,25 @@
    +
    + 1 + +
    +   + -- +migrate Up +
    +
    + 2 + +
    + - + CREATE TABLE state.blob_inner +
    +
    + 3 + +
    + - + ( +
    +
    + 4 + +
    + - + blob_inner_num BIGINT PRIMARY KEY, +
    +
    + 5 + +
    + - + data BYTEA, +
    +
    + 6 + +
    + - + block_num BIGINT NOT NULL REFERENCES state.block (block_num) ON DELETE CASCADE +
    +
    + 7 + +
    + - + ); +
    +
    + 8 + +
    +   +
    +
    +
    + 9 + +
    + - + ALTER TABLE state.virtual_batch +
    +
    + 10 + +
    + - + ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT, -- REFERENCES state.blob_inner (blob_inner_num), +
    +
    + 11 + +
    + - + ADD COLUMN IF NOT EXISTS prev_l1_it_root VARCHAR, +
    +
    + 12 + +
    + - + ADD COLUMN IF NOT EXISTS prev_l1_it_index BIGINT; +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 13 + +
    +   +
    +
    +
    + 14 + +
    + - + ALTER TABLE IF EXISTS state.proof RENAME TO batch_proof; +
    +
    + 15 + +
    + - +
    +
    +
    + 16 + +
    + - + ALTER TABLE state.batch_proof +
    +
    + 17 + +
    + - + ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT; -- NOT NULL REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE; +
    +
    + 18 + +
    + - +
    +
    +
    + 19 + +
    + - + CREATE TABLE state.blob_inner_proof +
    +
    + 20 + +
    + - + ( +
    +
    + 21 + +
    + - + blob_inner_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, +
    +
    + 22 + +
    + - + proof_id VARCHAR, +
    +
    + 23 + +
    + - + proof VARCHAR, +
    +
    + 24 + +
    + - + input_prover VARCHAR, +
    +
    + 25 + +
    + - + prover VARCHAR, +
    +
    + 26 + +
    + - + prover_id VARCHAR, +
    +
    + 27 + +
    + - + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 28 + +
    + - + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 29 + +
    + - + generating_since TIMESTAMP WITH TIME ZONE, +
    +
    + 30 + +
    + - + PRIMARY KEY (blob_inner_num) +
    +
    + 31 + +
    + - + ); +
    +
    + 32 + +
    + - +
    +
    +
    + 33 + +
    + - + CREATE TABLE state.blob_outer_proof +
    +
    + 34 + +
    + - + ( +
    +
    + 35 + +
    + - + blob_outer_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, +
    +
    + 36 + +
    + - + blob_outer_num_final BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, +
    +
    + 37 + +
    + - + proof_id VARCHAR, +
    +
    + 38 + +
    + - + proof VARCHAR, +
    +
    + 39 + +
    + - + input_prover VARCHAR, +
    +
    + 40 + +
    + - + prover VARCHAR, +
    +
    + 41 + +
    + - + prover_id VARCHAR, +
    +
    + 42 + +
    + - + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 43 + +
    + - + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 44 + +
    + - + generating_since TIMESTAMP WITH TIME ZONE, +
    +
    + 45 + +
    + - + PRIMARY KEY (blob_outer_num, blob_outer_num_final) +
    +
    + 46 + +
    + - + ); +
    +
    + 47 + +
    +   +
    +
    +
    + 48 + +
    +   + -- +migrate Down +
    +
    + 49 + +
    + - + ALTER TABLE state.virtual_batch +
    +
    + 50 + +
    + - + DROP COLUMN IF EXISTS blob_inner_num, +
    +
    + 51 + +
    + - + DROP COLUMN IF EXISTS prev_l1_it_root, +
    +
    + 52 + +
    + - + DROP COLUMN IF EXISTS prev_l1_it_index; +
    +
    + 53 + +
    + - +
    +
    +
    + 54 + +
    + - + DROP TABLE state.blob_outer_proof; +
    +
    + 55 + +
    + - +
    +
    +
    + 56 + +
    + - + DROP TABLE state.blob_inner_proof; +
    +
    + 57 + +
    + - +
    +
    +
    + 58 + +
    + - + DROP TABLE state.batch_proof; +
    +
    + 59 + +
    + - +
    +
    +
    + 60 + +
    + - + DROP TABLE state.blob_inner; +
    +
    + 61 + +
    + - +
    +
    +
    + 62 + +
    + - + CREATE TABLE state.proof +
    +
    + 63 + +
    + - + ( +
    +
    + 64 + +
    + - + batch_num BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, +
    +
    + 65 + +
    + - + batch_num_final BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, +
    +
    + 66 + +
    + - + proof_id VARCHAR, +
    +
    + 67 + +
    + - + proof VARCHAR, +
    +
    + 68 + +
    + - + input_prover VARCHAR, +
    +
    + 69 + +
    + - + prover VARCHAR, +
    +
    + 70 + +
    + - + prover_id VARCHAR, +
    +
    + 71 + +
    + - + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 72 + +
    + - + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 73 + +
    + - + generating_since TIMESTAMP WITH TIME ZONE, +
    +
    + 74 + +
    + - + PRIMARY KEY (batch_num, batch_num_final) +
    +
    + 75 + +
    + - + ); +
    +
    + 76 + +
    +   +
    +
    +
    + 77 + +
    + - + ALTER TABLE state.virtual_batch +
    +
    + 78 + +
    + - + DROP COLUMN IF EXISTS blob_inner_num, +
    +
    + 79 + +
    + - + DROP COLUMN IF EXISTS prev_l1_it_root, +
    +
    + 80 + +
    + - + DROP COLUMN IF EXISTS prev_l1_it_index; +
    +
    + 81 + +
    + - + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 + +
    +   + -- +migrate Up +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    + + + -- the update below fix the wrong receipt TX indexes +
    +
    + 4 + +
    + + + WITH map_fix_tx_index AS ( +
    +
    + 5 + +
    + + + SELECT t.l2_block_num AS block_num +
    +
    + 6 + +
    + + + , t.hash AS tx_hash +
    +
    + 7 + +
    + + + , r.tx_index AS current_index +
    +
    + 8 + +
    + + + , (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index +
    +
    + 9 + +
    + + + FROM state.receipt r +
    +
    + 10 + +
    + + + INNER JOIN state."transaction" t +
    +
    + 11 + +
    + + + ON t.hash = r.tx_hash +
    +
    + 12 + +
    + + + ) +
    +
    + 13 + +
    + + + UPDATE state.receipt AS r +
    +
    + 14 + +
    + + + SET tx_index = m.correct_index +
    +
    + 15 + +
    + + + FROM map_fix_tx_index m +
    +
    + 16 + +
    + + + WHERE m.block_num = r.block_num +
    +
    + 17 + +
    + + + AND m.tx_hash = r.tx_hash +
    +
    + 18 + +
    + + + AND m.current_index = r.tx_index +
    +
    + 19 + +
    + + + AND m.current_index != m.correct_index; +
    +
    + 20 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 21 + +
    +   +
    +
    +
    + 22 + +
    +   + -- +migrate Down +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 23 + +
    +   +
    +
    +
    + 24 + +
    + + + -- no action is needed, the data fixed by the +
    +
    + 25 + +
    + + + -- migrate up must remain fixed +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -4,116 +4,142 @@
    +
    + 4 + +
    +   + "database/sql" +
    +
    + 5 + +
    +   + "testing" +
    +
    + 6 + +
    +   +
    +
    +
    + 7 + +
    + - + "github.com/stretchr/testify/assert" +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 8 + +
    +   + ) +
    +
    + 9 + +
    +   +
    +
    +
    + 10 + +
    + - + type migrationTest0019 struct { +
    +
    + 11 + +
    + - + migrationBase +
    +
    + + +
    +   +
    +
    +
    + 12 + +
    +   + } +
    +
    + 13 + +
    +   +
    +
    +
    + 14 + +
    + - + func (m migrationTest0019) InsertData(db *sql.DB) error { +
    +
    + 15 + +
    + - + const insertBatch1 = ` +
    +
    + 16 + +
    + - + 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) +
    +
    + 17 + +
    + - + VALUES (1,'0x0001', '0x0001', '0x0001', '0x0001', now(), '0x0001', null, null, true)` +
    +
    + 18 + +
    +   +
    +
    +
    + 19 + +
    + - + _, err := db.Exec(insertBatch1) +
    +
    + 20 + +
    + - + if err != nil { +
    +
    + 21 + +
    + - + return err +
    +
    + 22 + +
    + - + } +
    +
    + 23 + +
    +   +
    +
    +
    + 24 + +
    + - + const insertBatch2 = ` +
    +
    + 25 + +
    + - + 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) +
    +
    + 26 + +
    + - + VALUES (2,'0x0002', '0x0002', '0x0002', '0x0002', now(), '0x0002', null, null, true)` +
    +
    + 27 + +
    +   +
    +
    +
    + 28 + +
    + - + _, err = db.Exec(insertBatch2) +
    +
    + 29 + +
    + - + if err != nil { +
    +
    + + +
    +   +
    +
    +
    + 30 + +
    +   + return err +
    +
    + 31 + +
    +   + } +
    +
    + 32 + +
    +   +
    +
    +
    + 33 + +
    + - + const insertBlock1 = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at) VALUES (1,'0x0001', '0x0001', now())" +
    +
    + 34 + +
    + - +
    +
    +
    + 35 + +
    + - + _, err = db.Exec(insertBlock1) +
    +
    + 36 + +
    + - + if err != nil { +
    +
    + 37 + +
    +   + return err +
    +
    + 38 + +
    +   + } +
    +
    + 39 + +
    +   +
    +
    +
    + 40 + +
    + - + const insertBlock2 = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at) VALUES (2,'0x0002', '0x0002', now())" +
    +
    + 41 + +
    + - +
    +
    +
    + 42 + +
    + - + _, err = db.Exec(insertBlock2) +
    +
    + 43 + +
    + - + if err != nil { +
    +
    + 44 + +
    + - + return err +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 45 + +
    +   + } +
    +
    + 46 + +
    +   +
    +
    +
    + 47 + +
    +   + return nil +
    +
    + 48 + +
    +   + } +
    +
    + 49 + +
    +   +
    +
    +
    + 50 + +
    +   + func (m migrationTest0019) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    + 51 + +
    + - + m.AssertNewAndRemovedItemsAfterMigrationUp(t, db) +
    +
    + 52 + +
    +   +
    +
    +
    + 53 + +
    + - + // Insert blobInner 1 +
    +
    + 54 + +
    + - + const insertBlobInner = `INSERT INTO state.blob_inner (blob_inner_num, data, block_num) VALUES (1, E'\\x1234', 1);` +
    +
    + 55 + +
    + - + _, err := db.Exec(insertBlobInner) +
    +
    + 56 + +
    + - + assert.NoError(t, err) +
    +
    + 57 + +
    + - +
    +
    +
    + 58 + +
    + - + const insertBatch1 = ` +
    +
    + 59 + +
    + - + INSERT INTO state.virtual_batch (batch_num, tx_hash, coinbase, block_num, sequencer_addr, timestamp_batch_etrog, l1_info_root, blob_inner_num, prev_l1_it_root, prev_l1_it_index) +
    +
    + 60 + +
    + - + VALUES (1,'0x0001', '0x0001', 1, '0x0001', now(), '0x0001', 1, '0x0001', 1)` +
    +
    + 61 + +
    + - +
    +
    +
    + 62 + +
    + - + _, err = db.Exec(insertBatch1) +
    +
    + 63 + +
    + - + assert.NoError(t, err) +
    +
    + 64 + +
    + - +
    +
    +
    + 65 + +
    + - + const insertBatch2 = ` +
    +
    + 66 + +
    + - + INSERT INTO state.virtual_batch (batch_num, tx_hash, coinbase, block_num, sequencer_addr, timestamp_batch_etrog, l1_info_root, blob_inner_num, prev_l1_it_root, prev_l1_it_index) +
    +
    + 67 + +
    + - + VALUES (2,'0x0002', '0x0002', 2, '0x0002', now(), '0x0002', 1, '0x0002', 2)` +
    +
    + 68 + +
    +   +
    +
    +
    + 69 + +
    + - + _, err = db.Exec(insertBatch2) +
    +
    + 70 + +
    + - + assert.NoError(t, err) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 71 + +
    +   + } +
    +
    + 72 + +
    +   +
    +
    +
    + 73 + +
    +   + func (m migrationTest0019) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +
    +
    + 74 + +
    + - + var result int +
    +
    + 75 + +
    + - +
    +
    +
    + 76 + +
    + - + m.AssertNewAndRemovedItemsAfterMigrationDown(t, db) +
    +
    + 77 + +
    + - +
    +
    +
    + 78 + +
    + - + // Check column blob_inner_num doesn't exists in state.virtual_batch table +
    +
    + 79 + +
    + - + const getBlobInnerNumColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='virtual_batch' and column_name='blob_inner_num'` +
    +
    + 80 + +
    + - + row := db.QueryRow(getBlobInnerNumColumn) +
    +
    + 81 + +
    + - + assert.NoError(t, row.Scan(&result)) +
    +
    + 82 + +
    + - + assert.Equal(t, 0, result) +
    +
    + 83 + +
    + - +
    +
    +
    + 84 + +
    + - + // Check column prev_l1_it_root doesn't exists in state.virtual_batch table +
    +
    + 85 + +
    + - + const getPrevL1ITRootColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='virtual_batch' and column_name='prev_l1_it_root'` +
    +
    + 86 + +
    + - + row = db.QueryRow(getPrevL1ITRootColumn) +
    +
    + 87 + +
    + - + assert.NoError(t, row.Scan(&result)) +
    +
    + 88 + +
    + - + assert.Equal(t, 0, result) +
    +
    + 89 + +
    + - +
    +
    +
    + 90 + +
    + - + // Check column prev_l1_it_index doesn't exists in state.virtual_batch table +
    +
    + 91 + +
    + - + const getPrevL1ITIndexColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='virtual_batch' and column_name='prev_l1_it_index'` +
    +
    + 92 + +
    + - + row = db.QueryRow(getPrevL1ITIndexColumn) +
    +
    + 93 + +
    + - + assert.NoError(t, row.Scan(&result)) +
    +
    + 94 + +
    + - + assert.Equal(t, 0, result) +
    +
    + 95 + +
    +   + } +
    +
    + 96 + +
    +   +
    +
    +
    + 97 + +
    +   + func TestMigration0019(t *testing.T) { +
    +
    + 98 + +
    + - + m := migrationTest0019{ +
    +
    + 99 + +
    + - + migrationBase: migrationBase{ +
    +
    + 100 + +
    + - + removedTables: []tableMetadata{ +
    +
    + 101 + +
    + - + {"state", "proof"}, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 102 + +
    +   + }, +
    +
    + 103 + +
    + - +
    +
    +
    + 104 + +
    + - + newTables: []tableMetadata{ +
    +
    + 105 + +
    + - + {"state", "blob_inner"}, +
    +
    + 106 + +
    + - + {"state", "batch_proof"}, +
    +
    + 107 + +
    + - + {"state", "blob_inner_proof"}, +
    +
    + 108 + +
    + - + {"state", "blob_outer_proof"}, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 109 + +
    +   + }, +
    +
    + 110 + +
    + - +
    +
    +
    + 111 + +
    + - + newColumns: []columnMetadata{ +
    +
    + 112 + +
    + - + {"state", "virtual_batch", "blob_inner_num"}, +
    +
    + 113 + +
    + - + {"state", "virtual_batch", "prev_l1_it_root"}, +
    +
    + 114 + +
    + - + {"state", "virtual_batch", "prev_l1_it_index"}, +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 115 + +
    +   + }, +
    +
    + 116 + +
    +   + }, +
    +
    + 117 + +
    + - + } +
    +
    + 118 + +
    + - + runMigrationTest(t, 19, m) +
    +
    + 119 + +
    +   + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 4 + +
    +   + "database/sql" +
    +
    + 5 + +
    +   + "testing" +
    +
    + 6 + +
    +   +
    +
    +
    + 7 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 8 + +
    + + + "github.com/ethereum/go-ethereum/common" +
    +
    + 9 + +
    + + + "github.com/stretchr/testify/require" +
    +
    + 10 + +
    +   + ) +
    +
    + 11 + +
    +   +
    +
    +
    + 12 + +
    + + + type migrationTest0019TestCase struct { +
    +
    + 13 + +
    + + + Name string +
    +
    + 14 + +
    + + + Block migrationTest0019TestCaseBlock +
    +
    + 15 + +
    +   + } +
    +
    + 16 + +
    +   +
    +
    +
    + 17 + +
    + + + type migrationTest0019TestCaseBlock struct { +
    +
    + 18 + +
    + + + Transactions []migrationTest0019TestCaseTransaction +
    +
    + 19 + +
    + + + } +
    +
    + + +
    +   +
    +
    +
    + 20 + +
    +   +
    +
    +
    + 21 + +
    + + + type migrationTest0019TestCaseTransaction struct { +
    +
    + 22 + +
    + + + CurrentIndex uint +
    +
    + 23 + +
    + + + } +
    +
    + + +
    +   +
    +
    +
    + 24 + +
    +   +
    +
    +
    + 25 + +
    + + + type migrationTest0019 struct { +
    +
    + 26 + +
    + + + TestCases []migrationTest0019TestCase +
    +
    + 27 + +
    + + + } +
    +
    + 28 + +
    +   +
    +
    +
    + 29 + +
    + + + func (m migrationTest0019) InsertData(db *sql.DB) error { +
    +
    + 30 + +
    + + + const addBlock0 = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES (0, now(), '0x0')" +
    +
    + 31 + +
    + + + if _, err := db.Exec(addBlock0); err != nil { +
    +
    + 32 + +
    +   + return err +
    +
    + 33 + +
    +   + } +
    +
    + 34 + +
    +   +
    +
    +
    + 35 + +
    + + + const addBatch0 = ` +
    +
    + 36 + +
    + + + 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) +
    +
    + 37 + +
    + + + VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)` +
    +
    + 38 + +
    + + + if _, err := db.Exec(addBatch0); err != nil { +
    +
    + 39 + +
    +   + return err +
    +
    + 40 + +
    +   + } +
    +
    + 41 + +
    +   +
    +
    +
    + 42 + +
    + + + const addL2Block = "INSERT INTO state.l2block (block_num, block_hash, header, uncles, parent_hash, state_root, received_at, batch_num, created_at) VALUES ($1, $2, '{}', '{}', '0x0', '0x0', now(), 0, now())" +
    +
    + 43 + +
    + + + const addTransaction = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num, effective_percentage, l2_hash) VALUES ($1, 'ABCDEF', '{}', $2, 255, $1)" +
    +
    + 44 + +
    + + + const addReceipt = "INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address) VALUES ($1, 1, null, 1, 1234, 1234, 1, $2, $3, '')" +
    +
    + 45 + +
    + + +
    +
    +
    + 46 + +
    + + + txUnique := 0 +
    +
    + 47 + +
    + + + for tci, testCase := range m.TestCases { +
    +
    + 48 + +
    + + + blockNum := uint64(tci + 1) +
    +
    + 49 + +
    + + + blockHash := common.HexToHash(hex.EncodeUint64(blockNum)).String() +
    +
    + 50 + +
    + + + if _, err := db.Exec(addL2Block, blockNum, blockHash); err != nil { +
    +
    + 51 + +
    + + + return err +
    +
    + 52 + +
    + + + } +
    +
    + 53 + +
    + + + for _, tx := range testCase.Block.Transactions { +
    +
    + 54 + +
    + + + txUnique++ +
    +
    + 55 + +
    + + + txHash := common.HexToHash(hex.EncodeUint64(uint64(txUnique))).String() +
    +
    + 56 + +
    + + + if _, err := db.Exec(addTransaction, txHash, blockNum); err != nil { +
    +
    + 57 + +
    + + + return err +
    +
    + 58 + +
    + + + } +
    +
    + 59 + +
    + + + if _, err := db.Exec(addReceipt, txHash, blockNum, tx.CurrentIndex); err != nil { +
    +
    + 60 + +
    + + + return err +
    +
    + 61 + +
    + + + } +
    +
    + 62 + +
    + + + } +
    +
    + 63 + +
    +   + } +
    +
    + 64 + +
    +   +
    +
    +
    + 65 + +
    +   + return nil +
    +
    + 66 + +
    +   + } +
    +
    + 67 + +
    +   +
    +
    +
    + 68 + +
    +   + func (m migrationTest0019) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    + 69 + +
    + + + const getReceiptsByBlock = "SELECT r.tx_index FROM state.receipt r WHERE r.block_num = $1 ORDER BY r.tx_index" +
    +
    + 70 + +
    +   +
    +
    +
    + 71 + +
    + + + for tci := range m.TestCases { +
    +
    + 72 + +
    + + + blockNum := uint64(tci + 1) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 73 + +
    +   +
    +
    +
    + 74 + +
    + + + rows, err := db.Query(getReceiptsByBlock, blockNum) +
    +
    + 75 + +
    + + + require.NoError(t, err) +
    +
    + 76 + +
    + + +
    +
    +
    + 77 + +
    + + + var expectedIndex = uint(0) +
    +
    + 78 + +
    + + + var txIndex uint +
    +
    + 79 + +
    + + + for rows.Next() { +
    +
    + 80 + +
    + + + err := rows.Scan(&txIndex) +
    +
    + 81 + +
    + + + require.NoError(t, err) +
    +
    + 82 + +
    + + + require.Equal(t, expectedIndex, txIndex) +
    +
    + 83 + +
    + + + expectedIndex++ +
    +
    + 84 + +
    + + + } +
    +
    + 85 + +
    + + + } +
    +
    + 86 + +
    +   + } +
    +
    + 87 + +
    +   +
    +
    +
    + 88 + +
    +   + func (m migrationTest0019) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +
    +
    + 89 + +
    + + + m.RunAssertsAfterMigrationUp(t, db) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 90 + +
    +   + } +
    +
    + 91 + +
    +   +
    +
    +
    + 92 + +
    +   + func TestMigration0019(t *testing.T) { +
    +
    + 93 + +
    + + + runMigrationTest(t, 19, migrationTest0019{ +
    +
    + 94 + +
    + + + TestCases: []migrationTest0019TestCase{ +
    +
    + 95 + +
    + + + { +
    +
    + 96 + +
    + + + Name: "single tx with correct index", +
    +
    + 97 + +
    + + + Block: migrationTest0019TestCaseBlock{ +
    +
    + 98 + +
    + + + Transactions: []migrationTest0019TestCaseTransaction{ +
    +
    + 99 + +
    + + + {CurrentIndex: 0}, +
    +
    + 100 + +
    + + + }, +
    +
    + 101 + +
    + + + }, +
    +
    + 102 + +
    +   + }, +
    +
    + 103 + +
    + + + { +
    +
    + 104 + +
    + + + Name: "multiple txs indexes are correct", +
    +
    + 105 + +
    + + + Block: migrationTest0019TestCaseBlock{ +
    +
    + 106 + +
    + + + Transactions: []migrationTest0019TestCaseTransaction{ +
    +
    + 107 + +
    + + + {CurrentIndex: 0}, +
    +
    + 108 + +
    + + + {CurrentIndex: 1}, +
    +
    + 109 + +
    + + + {CurrentIndex: 2}, +
    +
    + 110 + +
    + + + }, +
    +
    + 111 + +
    + + + }, +
    +
    + 112 + +
    +   + }, +
    +
    + 113 + +
    + + + { +
    +
    + 114 + +
    + + + Name: "single tx with wrong tx index", +
    +
    + 115 + +
    + + + Block: migrationTest0019TestCaseBlock{ +
    +
    + 116 + +
    + + + Transactions: []migrationTest0019TestCaseTransaction{ +
    +
    + 117 + +
    + + + {CurrentIndex: 3}, +
    +
    + 118 + +
    + + + }, +
    +
    + 119 + +
    + + + }, +
    +
    + 120 + +
    + + + }, +
    +
    + 121 + +
    + + + { +
    +
    + 122 + +
    + + + Name: "multiple txs missing 0 index", +
    +
    + 123 + +
    + + + Block: migrationTest0019TestCaseBlock{ +
    +
    + 124 + +
    + + + Transactions: []migrationTest0019TestCaseTransaction{ +
    +
    + 125 + +
    + + + {CurrentIndex: 1}, +
    +
    + 126 + +
    + + + {CurrentIndex: 2}, +
    +
    + 127 + +
    + + + {CurrentIndex: 3}, +
    +
    + 128 + +
    + + + {CurrentIndex: 4}, +
    +
    + 129 + +
    + + + }, +
    +
    + 130 + +
    + + + }, +
    +
    + 131 + +
    + + + }, +
    +
    + 132 + +
    + + + { +
    +
    + 133 + +
    + + + Name: "multiple has index 0 but also txs index gap", +
    +
    + 134 + +
    + + + Block: migrationTest0019TestCaseBlock{ +
    +
    + 135 + +
    + + + Transactions: []migrationTest0019TestCaseTransaction{ +
    +
    + 136 + +
    + + + {CurrentIndex: 0}, +
    +
    + 137 + +
    + + + {CurrentIndex: 2}, +
    +
    + 138 + +
    + + + {CurrentIndex: 4}, +
    +
    + 139 + +
    + + + {CurrentIndex: 6}, +
    +
    + 140 + +
    + + + }, +
    +
    + 141 + +
    + + + }, +
    +
    + 142 + +
    +   + }, +
    +
    + 143 + +
    +   + }, +
    +
    + 144 + +
    + + + }) +
    +
    + + +
    +   +
    +
    +
    + 145 + +
    +   + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0021.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,25 +0,0 @@
    +
    + 1 + +
    + - + -- +migrate Up +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + -- the update below fix the wrong receipt TX indexes +
    +
    + 4 + +
    + - + WITH map_fix_tx_index AS ( +
    +
    + 5 + +
    + - + SELECT t.l2_block_num AS block_num +
    +
    + 6 + +
    + - + , t.hash AS tx_hash +
    +
    + 7 + +
    + - + , r.tx_index AS current_index +
    +
    + 8 + +
    + - + , (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index +
    +
    + 9 + +
    + - + FROM state.receipt r +
    +
    + 10 + +
    + - + INNER JOIN state."transaction" t +
    +
    + 11 + +
    + - + ON t.hash = r.tx_hash +
    +
    + 12 + +
    + - + ) +
    +
    + 13 + +
    + - + UPDATE state.receipt AS r +
    +
    + 14 + +
    + - + SET tx_index = m.correct_index +
    +
    + 15 + +
    + - + FROM map_fix_tx_index m +
    +
    + 16 + +
    + - + WHERE m.block_num = r.block_num +
    +
    + 17 + +
    + - + AND m.tx_hash = r.tx_hash +
    +
    + 18 + +
    + - + AND m.current_index = r.tx_index +
    +
    + 19 + +
    + - + AND m.current_index != m.correct_index; +
    +
    + 20 + +
    + - +
    +
    +
    + 21 + +
    + - +
    +
    +
    + 22 + +
    + - + -- +migrate Down +
    +
    + 23 + +
    + - +
    +
    +
    + 24 + +
    + - + -- no action is needed, the data fixed by the +
    +
    + 25 + +
    + - + -- migrate up must remain fixed +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0021_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,145 +0,0 @@
    +
    + 1 + +
    + - + package migrations_test +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "database/sql" +
    +
    + 5 + +
    + - + "testing" +
    +
    + 6 + +
    + - +
    +
    +
    + 7 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 8 + +
    + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 9 + +
    + - + "github.com/stretchr/testify/require" +
    +
    + 10 + +
    + - + ) +
    +
    + 11 + +
    + - +
    +
    +
    + 12 + +
    + - + type migrationTest0021TestCase struct { +
    +
    + 13 + +
    + - + Name string +
    +
    + 14 + +
    + - + Block migrationTest0021TestCaseBlock +
    +
    + 15 + +
    + - + } +
    +
    + 16 + +
    + - +
    +
    +
    + 17 + +
    + - + type migrationTest0021TestCaseBlock struct { +
    +
    + 18 + +
    + - + Transactions []migrationTest0021TestCaseTransaction +
    +
    + 19 + +
    + - + } +
    +
    + 20 + +
    + - +
    +
    +
    + 21 + +
    + - + type migrationTest0021TestCaseTransaction struct { +
    +
    + 22 + +
    + - + CurrentIndex uint +
    +
    + 23 + +
    + - + } +
    +
    + 24 + +
    + - +
    +
    +
    + 25 + +
    + - + type migrationTest0021 struct { +
    +
    + 26 + +
    + - + TestCases []migrationTest0021TestCase +
    +
    + 27 + +
    + - + } +
    +
    + 28 + +
    + - +
    +
    +
    + 29 + +
    + - + func (m migrationTest0021) InsertData(db *sql.DB) error { +
    +
    + 30 + +
    + - + const addBlock0 = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES (0, now(), '0x0')" +
    +
    + 31 + +
    + - + if _, err := db.Exec(addBlock0); err != nil { +
    +
    + 32 + +
    + - + return err +
    +
    + 33 + +
    + - + } +
    +
    + 34 + +
    + - +
    +
    +
    + 35 + +
    + - + const addBatch0 = ` +
    +
    + 36 + +
    + - + 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) +
    +
    + 37 + +
    + - + VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)` +
    +
    + 38 + +
    + - + if _, err := db.Exec(addBatch0); err != nil { +
    +
    + 39 + +
    + - + return err +
    +
    + 40 + +
    + - + } +
    +
    + 41 + +
    + - +
    +
    +
    + 42 + +
    + - + const addL2Block = "INSERT INTO state.l2block (block_num, block_hash, header, uncles, parent_hash, state_root, received_at, batch_num, created_at) VALUES ($1, $2, '{}', '{}', '0x0', '0x0', now(), 0, now())" +
    +
    + 43 + +
    + - + const addTransaction = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num, effective_percentage, l2_hash) VALUES ($1, 'ABCDEF', '{}', $2, 255, $1)" +
    +
    + 44 + +
    + - + const addReceipt = "INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address) VALUES ($1, 1, null, 1, 1234, 1234, 1, $2, $3, '')" +
    +
    + 45 + +
    + - +
    +
    +
    + 46 + +
    + - + txUnique := 0 +
    +
    + 47 + +
    + - + for tci, testCase := range m.TestCases { +
    +
    + 48 + +
    + - + blockNum := uint64(tci + 1) +
    +
    + 49 + +
    + - + blockHash := common.HexToHash(hex.EncodeUint64(blockNum)).String() +
    +
    + 50 + +
    + - + if _, err := db.Exec(addL2Block, blockNum, blockHash); err != nil { +
    +
    + 51 + +
    + - + return err +
    +
    + 52 + +
    + - + } +
    +
    + 53 + +
    + - + for _, tx := range testCase.Block.Transactions { +
    +
    + 54 + +
    + - + txUnique++ +
    +
    + 55 + +
    + - + txHash := common.HexToHash(hex.EncodeUint64(uint64(txUnique))).String() +
    +
    + 56 + +
    + - + if _, err := db.Exec(addTransaction, txHash, blockNum); err != nil { +
    +
    + 57 + +
    + - + return err +
    +
    + 58 + +
    + - + } +
    +
    + 59 + +
    + - + if _, err := db.Exec(addReceipt, txHash, blockNum, tx.CurrentIndex); err != nil { +
    +
    + 60 + +
    + - + return err +
    +
    + 61 + +
    + - + } +
    +
    + 62 + +
    + - + } +
    +
    + 63 + +
    + - + } +
    +
    + 64 + +
    + - +
    +
    +
    + 65 + +
    + - + return nil +
    +
    + 66 + +
    + - + } +
    +
    + 67 + +
    + - +
    +
    +
    + 68 + +
    + - + func (m migrationTest0021) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    + 69 + +
    + - + const getReceiptsByBlock = "SELECT r.tx_index FROM state.receipt r WHERE r.block_num = $1 ORDER BY r.tx_index" +
    +
    + 70 + +
    + - +
    +
    +
    + 71 + +
    + - + for tci := range m.TestCases { +
    +
    + 72 + +
    + - + blockNum := uint64(tci + 1) +
    +
    + 73 + +
    + - +
    +
    +
    + 74 + +
    + - + rows, err := db.Query(getReceiptsByBlock, blockNum) +
    +
    + 75 + +
    + - + require.NoError(t, err) +
    +
    + 76 + +
    + - +
    +
    +
    + 77 + +
    + - + var expectedIndex = uint(0) +
    +
    + 78 + +
    + - + var txIndex uint +
    +
    + 79 + +
    + - + for rows.Next() { +
    +
    + 80 + +
    + - + err := rows.Scan(&txIndex) +
    +
    + 81 + +
    + - + require.NoError(t, err) +
    +
    + 82 + +
    + - + require.Equal(t, expectedIndex, txIndex) +
    +
    + 83 + +
    + - + expectedIndex++ +
    +
    + 84 + +
    + - + } +
    +
    + 85 + +
    + - + } +
    +
    + 86 + +
    + - + } +
    +
    + 87 + +
    + - +
    +
    +
    + 88 + +
    + - + func (m migrationTest0021) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +
    +
    + 89 + +
    + - + m.RunAssertsAfterMigrationUp(t, db) +
    +
    + 90 + +
    + - + } +
    +
    + 91 + +
    + - +
    +
    +
    + 92 + +
    + - + func TestMigration0021(t *testing.T) { +
    +
    + 93 + +
    + - + runMigrationTest(t, 21, migrationTest0021{ +
    +
    + 94 + +
    + - + TestCases: []migrationTest0021TestCase{ +
    +
    + 95 + +
    + - + { +
    +
    + 96 + +
    + - + Name: "single tx with correct index", +
    +
    + 97 + +
    + - + Block: migrationTest0021TestCaseBlock{ +
    +
    + 98 + +
    + - + Transactions: []migrationTest0021TestCaseTransaction{ +
    +
    + 99 + +
    + - + {CurrentIndex: 0}, +
    +
    + 100 + +
    + - + }, +
    +
    + 101 + +
    + - + }, +
    +
    + 102 + +
    + - + }, +
    +
    + 103 + +
    + - + { +
    +
    + 104 + +
    + - + Name: "multiple txs indexes are correct", +
    +
    + 105 + +
    + - + Block: migrationTest0021TestCaseBlock{ +
    +
    + 106 + +
    + - + Transactions: []migrationTest0021TestCaseTransaction{ +
    +
    + 107 + +
    + - + {CurrentIndex: 0}, +
    +
    + 108 + +
    + - + {CurrentIndex: 1}, +
    +
    + 109 + +
    + - + {CurrentIndex: 2}, +
    +
    + 110 + +
    + - + }, +
    +
    + 111 + +
    + - + }, +
    +
    + 112 + +
    + - + }, +
    +
    + 113 + +
    + - + { +
    +
    + 114 + +
    + - + Name: "single tx with wrong tx index", +
    +
    + 115 + +
    + - + Block: migrationTest0021TestCaseBlock{ +
    +
    + 116 + +
    + - + Transactions: []migrationTest0021TestCaseTransaction{ +
    +
    + 117 + +
    + - + {CurrentIndex: 3}, +
    +
    + 118 + +
    + - + }, +
    +
    + 119 + +
    + - + }, +
    +
    + 120 + +
    + - + }, +
    +
    + 121 + +
    + - + { +
    +
    + 122 + +
    + - + Name: "multiple txs missing 0 index", +
    +
    + 123 + +
    + - + Block: migrationTest0021TestCaseBlock{ +
    +
    + 124 + +
    + - + Transactions: []migrationTest0021TestCaseTransaction{ +
    +
    + 125 + +
    + - + {CurrentIndex: 1}, +
    +
    + 126 + +
    + - + {CurrentIndex: 2}, +
    +
    + 127 + +
    + - + {CurrentIndex: 3}, +
    +
    + 128 + +
    + - + {CurrentIndex: 4}, +
    +
    + 129 + +
    + - + }, +
    +
    + 130 + +
    + - + }, +
    +
    + 131 + +
    + - + }, +
    +
    + 132 + +
    + - + { +
    +
    + 133 + +
    + - + Name: "multiple has index 0 but also txs index gap", +
    +
    + 134 + +
    + - + Block: migrationTest0021TestCaseBlock{ +
    +
    + 135 + +
    + - + Transactions: []migrationTest0021TestCaseTransaction{ +
    +
    + 136 + +
    + - + {CurrentIndex: 0}, +
    +
    + 137 + +
    + - + {CurrentIndex: 2}, +
    +
    + 138 + +
    + - + {CurrentIndex: 4}, +
    +
    + 139 + +
    + - + {CurrentIndex: 6}, +
    +
    + 140 + +
    + - + }, +
    +
    + 141 + +
    + - + }, +
    +
    + 142 + +
    + - + }, +
    +
    + 143 + +
    + - + }, +
    +
    + 144 + +
    + - + }) +
    +
    + 145 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,12 +0,0 @@
    +
    + 1 + +
    + - + -- +migrate Up +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + -- +migrate Up +
    +
    + 4 + +
    + - + ALTER TABLE state.exit_root +
    +
    + 5 + +
    + - + ADD COLUMN IF NOT EXISTS l1_info_tree_recursive_index BIGINT DEFAULT NULL UNIQUE; +
    +
    + 6 + +
    + - + CREATE INDEX IF NOT EXISTS idx_exit_root_l1_info_tree_recursive_index ON state.exit_root (l1_info_tree_recursive_index); +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + -- +migrate Down +
    +
    + 9 + +
    + - + ALTER TABLE state.exit_root +
    +
    + 10 + +
    + - + DROP COLUMN IF EXISTS l1_info_tree_recursive_index; +
    +
    + 11 + +
    + - + DROP INDEX IF EXISTS state.idx_exit_root_l1_info_tree_recursive_index; +
    +
    + 12 + +
    + - +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0022_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,106 +0,0 @@
    +
    + 1 + +
    + - + package migrations_test +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "database/sql" +
    +
    + 5 + +
    + - + "testing" +
    +
    + 6 + +
    + - + "time" +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + "github.com/stretchr/testify/assert" +
    +
    + 9 + +
    + - + ) +
    +
    + 10 + +
    + - +
    +
    +
    + 11 + +
    + - + type migrationTest0022 struct { +
    +
    + 12 + +
    + - + migrationBase +
    +
    + 13 + +
    + - +
    +
    +
    + 14 + +
    + - + blockHashValue string +
    +
    + 15 + +
    + - + mainExitRootValue string +
    +
    + 16 + +
    + - + rollupExitRootValue string +
    +
    + 17 + +
    + - + globalExitRootValue string +
    +
    + 18 + +
    + - + previousBlockHashValue string +
    +
    + 19 + +
    + - + l1InfoRootValue string +
    +
    + 20 + +
    + - + } +
    +
    + 21 + +
    + - +
    +
    +
    + 22 + +
    + - + func (m migrationTest0022) insertBlock(blockNumber uint64, db *sql.DB) error { +
    +
    + 23 + +
    + - + const addBlock = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES ($1, $2, $3)" +
    +
    + 24 + +
    + - + if _, err := db.Exec(addBlock, blockNumber, time.Now(), m.blockHashValue); err != nil { +
    +
    + 25 + +
    + - + return err +
    +
    + 26 + +
    + - + } +
    +
    + 27 + +
    + - + return nil +
    +
    + 28 + +
    + - + } +
    +
    + 29 + +
    + - +
    +
    +
    + 30 + +
    + - + func (m migrationTest0022) insertRowInOldTable(db *sql.DB, args ...interface{}) error { +
    +
    + 31 + +
    + - + sql := ` +
    +
    + 32 + +
    + - + INSERT INTO state.exit_root (block_num, "timestamp", mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index) +
    +
    + 33 + +
    + - + VALUES ( $1, $2, $3, $4, $5, $6, $7, $8);` +
    +
    + 34 + +
    + - +
    +
    +
    + 35 + +
    + - + _, err := db.Exec(sql, args...) +
    +
    + 36 + +
    + - + return err +
    +
    + 37 + +
    + - + } +
    +
    + 38 + +
    + - +
    +
    +
    + 39 + +
    + - + func (m migrationTest0022) insertRowInMigratedTable(db *sql.DB, args ...interface{}) error { +
    +
    + 40 + +
    + - + sql := ` +
    +
    + 41 + +
    + - + INSERT INTO state.exit_root (block_num, "timestamp", mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index, l1_info_tree_recursive_index) +
    +
    + 42 + +
    + - + VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9);` +
    +
    + 43 + +
    + - +
    +
    +
    + 44 + +
    + - + _, err := db.Exec(sql, args...) +
    +
    + 45 + +
    + - + return err +
    +
    + 46 + +
    + - + } +
    +
    + 47 + +
    + - +
    +
    +
    + 48 + +
    + - + func (m migrationTest0022) InsertData(db *sql.DB) error { +
    +
    + 49 + +
    + - + var err error +
    +
    + 50 + +
    + - + for i := uint64(1); i <= 6; i++ { +
    +
    + 51 + +
    + - + if err = m.insertBlock(i, db); err != nil { +
    +
    + 52 + +
    + - + return err +
    +
    + 53 + +
    + - + } +
    +
    + 54 + +
    + - + } +
    +
    + 55 + +
    + - +
    +
    +
    + 56 + +
    + - + return nil +
    +
    + 57 + +
    + - + } +
    +
    + 58 + +
    + - +
    +
    +
    + 59 + +
    + - + func (m migrationTest0022) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    + 60 + +
    + - + m.AssertNewAndRemovedItemsAfterMigrationUp(t, db) +
    +
    + 61 + +
    + - +
    +
    +
    + 62 + +
    + - + var nilL1InfoTreeIndex *uint = nil +
    +
    + 63 + +
    + - + err := m.insertRowInOldTable(db, 1, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, nilL1InfoTreeIndex) +
    +
    + 64 + +
    + - + assert.NoError(t, err) +
    +
    + 65 + +
    + - +
    +
    +
    + 66 + +
    + - + err = m.insertRowInOldTable(db, 2, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, uint(1)) +
    +
    + 67 + +
    + - + assert.NoError(t, err) +
    +
    + 68 + +
    + - +
    +
    +
    + 69 + +
    + - + err = m.insertRowInMigratedTable(db, 3, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, nilL1InfoTreeIndex, 1) +
    +
    + 70 + +
    + - + assert.NoError(t, err) +
    +
    + 71 + +
    + - + } +
    +
    + 72 + +
    + - +
    +
    +
    + 73 + +
    + - + func (m migrationTest0022) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +
    +
    + 74 + +
    + - + m.AssertNewAndRemovedItemsAfterMigrationDown(t, db) +
    +
    + 75 + +
    + - +
    +
    +
    + 76 + +
    + - + var nilL1InfoTreeIndex *uint = nil +
    +
    + 77 + +
    + - + err := m.insertRowInOldTable(db, 4, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, nilL1InfoTreeIndex) +
    +
    + 78 + +
    + - + assert.NoError(t, err) +
    +
    + 79 + +
    + - +
    +
    +
    + 80 + +
    + - + err = m.insertRowInOldTable(db, 5, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, uint(2)) +
    +
    + 81 + +
    + - + assert.NoError(t, err) +
    +
    + 82 + +
    + - +
    +
    +
    + 83 + +
    + - + err = m.insertRowInMigratedTable(db, 6, time.Now().UTC(), m.mainExitRootValue, m.rollupExitRootValue, m.globalExitRootValue, m.previousBlockHashValue, m.l1InfoRootValue, nilL1InfoTreeIndex, 2) +
    +
    + 84 + +
    + - + assert.Error(t, err) +
    +
    + 85 + +
    + - + } +
    +
    + 86 + +
    + - +
    +
    +
    + 87 + +
    + - + func TestMigration0022(t *testing.T) { +
    +
    + 88 + +
    + - + m := migrationTest0022{ +
    +
    + 89 + +
    + - + migrationBase: migrationBase{ +
    +
    + 90 + +
    + - + newIndexes: []string{ +
    +
    + 91 + +
    + - + "idx_exit_root_l1_info_tree_recursive_index", +
    +
    + 92 + +
    + - + }, +
    +
    + 93 + +
    + - + newColumns: []columnMetadata{ +
    +
    + 94 + +
    + - + {"state", "exit_root", "l1_info_tree_recursive_index"}, +
    +
    + 95 + +
    + - + }, +
    +
    + 96 + +
    + - + }, +
    +
    + 97 + +
    + - +
    +
    +
    + 98 + +
    + - + blockHashValue: "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1", +
    +
    + 99 + +
    + - + mainExitRootValue: "0x83fc198de31e1b2b1a8212d2430fbb7766c13d9ad305637dea3759065606475d", +
    +
    + 100 + +
    + - + rollupExitRootValue: "0xadb91a6a1fce56eaea561002bc9a993f4e65a7710bd72f4eee3067cbd73a743c", +
    +
    + 101 + +
    + - + globalExitRootValue: "0x5bf4af1a651a2a74b36e6eb208481f94c69fc959f756223dfa49608061937585", +
    +
    + 102 + +
    + - + previousBlockHashValue: "0xe865e912b504572a4d80ad018e29797e3c11f00bf9ae2549548a25779c9d7e57", +
    +
    + 103 + +
    + - + l1InfoRootValue: "0x2b9484b83c6398033241865b015fb9430eb3e159182a6075d00c924845cc393e", +
    +
    + 104 + +
    + - + } +
    +
    + 105 + +
    + - + runMigrationTest(t, 22, m) +
    +
    + 106 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0023.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,57 +0,0 @@
    +
    + 1 + +
    + - + -- +migrate Up +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + CREATE TABLE IF NOT EXISTS state.blob_sequence +
    +
    + 4 + +
    + - + ( +
    +
    + 5 + +
    + - + index BIGINT PRIMARY KEY, +
    +
    + 6 + +
    + - + coinbase VARCHAR, +
    +
    + 7 + +
    + - + final_acc_input_hash VARCHAR, +
    +
    + 8 + +
    + - + first_blob_sequenced BIGINT, +
    +
    + 9 + +
    + - + last_blob_sequenced BIGINT, +
    +
    + 10 + +
    + - + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 11 + +
    + - + received_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 12 + +
    + - + block_num BIGINT NOT NULL REFERENCES state.block (block_num) ON DELETE CASCADE +
    +
    + 13 + +
    + - + ); +
    +
    + 14 + +
    + - +
    +
    +
    + 15 + +
    + - + comment on column state.blob_sequence.index is 'It is the id of this sequence, this value is internal and incremental'; +
    +
    + 16 + +
    + - + comment on column state.blob_sequence.block_num is 'L1 Block where appear this sequence'; +
    +
    + 17 + +
    + - + comment on column state.blob_sequence.first_blob_sequenced is 'first (included) blob_inner_num of this sequence (state.blob_inner.blob_inner_num)'; +
    +
    + 18 + +
    + - + comment on column state.blob_sequence.first_blob_sequenced is 'last (included) blob_inner_num of this sequence (state.blob_inner.blob_inner_num)'; +
    +
    + 19 + +
    + - + comment on column state.blob_sequence.received_at is 'time when it was received in node'; +
    +
    + 20 + +
    + - + comment on column state.blob_sequence.created_at is 'time when was created on L1 (L1block tstamp)'; +
    +
    + 21 + +
    + - +
    +
    +
    + 22 + +
    + - + CREATE TABLE IF NOT EXISTS state.blob_inner_in +
    +
    + 23 + +
    + - + ( +
    +
    + 24 + +
    + - + blob_inner_num BIGINT PRIMARY KEY, +
    +
    + 25 + +
    + - + blob_sequence_index BIGINT NOT NULL REFERENCES state.blob_sequence (index) ON DELETE CASCADE, +
    +
    + 26 + +
    + - + blob_type VARCHAR, +
    +
    + 27 + +
    + - + max_sequence_timestamp TIMESTAMP WITH TIME ZONE, +
    +
    + 28 + +
    + - + zk_gas_limit BIGINT, +
    +
    + 29 + +
    + - + l1_info_tree_leaf_index BIGINT, +
    +
    + 30 + +
    + - + l1_info_tree_root VARCHAR, +
    +
    + 31 + +
    + - + blob_data_hash VARCHAR, +
    +
    + 32 + +
    + - + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 33 + +
    + - + -- if blob_type== blob +
    +
    + 34 + +
    + - + blob_type_index BIGINT, +
    +
    + 35 + +
    + - + blob_type_z VARCHAR, +
    +
    + 36 + +
    + - + blob_type_y VARCHAR, +
    +
    + 37 + +
    + - + blob_type_commitment VARCHAR, +
    +
    + 38 + +
    + - + blob_type_proof VARCHAR +
    +
    + 39 + +
    + - + ); +
    +
    + 40 + +
    + - +
    +
    +
    + 41 + +
    + - + comment on column state.blob_inner_in.updated_at is 'the creation time is blob_sequence.created_at, this is the last time when was updated (tipically Now() )'; +
    +
    + 42 + +
    + - + comment on column state.blob_inner_in.blob_type is 'call_data, blob or forced'; +
    +
    + 43 + +
    + - + comment on column state.blob_inner_in.blob_data_hash is 'is the hash of the blobData'; +
    +
    + 44 + +
    + - +
    +
    +
    + 45 + +
    + - + CREATE TABLE IF NOT EXISTS state.incoming_batch +
    +
    + 46 + +
    + - + ( +
    +
    + 47 + +
    + - + batch_num BIGINT PRIMARY KEY, +
    +
    + 48 + +
    + - + blob_inner_num BIGINT NOT NULL REFERENCES state.blob_inner_in (blob_inner_num) ON DELETE CASCADE, +
    +
    + 49 + +
    + - + data BYTEA, +
    +
    + 50 + +
    + - + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), +
    +
    + 51 + +
    + - + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() +
    +
    + 52 + +
    + - + ); +
    +
    + 53 + +
    + - +
    +
    +
    + 54 + +
    + - + -- +migrate Down +
    +
    + 55 + +
    + - + DROP TABLE IF EXISTS state.incoming_batch; +
    +
    + 56 + +
    + - + DROP TABLE IF EXISTS state.blob_inner_in; +
    +
    + 57 + +
    + - + DROP TABLE IF EXISTS state.blob_sequence; +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/utils_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -2,7 +2,6 @@
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "database/sql" +
    +
    + 5 + +
    + - + "errors" +
    +
    + 6 + +
    +   + "fmt" +
    +
    + 7 + +
    +   + "testing" +
    +
    + 8 + +
    +   +
    +
    +
    +
    @@ -13,7 +12,6 @@
    +
    + 13 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 14 + +
    +   + "github.com/jackc/pgx/v4/stdlib" +
    +
    + 15 + +
    +   + migrate "github.com/rubenv/sql-migrate" +
    +
    + 16 + +
    + - + "github.com/stretchr/testify/assert" +
    +
    + 17 + +
    +   + "github.com/stretchr/testify/require" +
    +
    + 18 + +
    +   + ) +
    +
    + 19 + +
    +   +
    +
    +
    +
    @@ -33,36 +31,6 @@
    +
    + 33 + +
    +   + }) +
    +
    + 34 + +
    +   + } +
    +
    + 35 + +
    +   +
    +
    +
    + 36 + +
    + - + type migrationBase struct { +
    +
    + 37 + +
    + - + newIndexes []string +
    +
    + 38 + +
    + - + newTables []tableMetadata +
    +
    + 39 + +
    + - + newColumns []columnMetadata +
    +
    + 40 + +
    + - +
    +
    +
    + 41 + +
    + - + removedIndexes []string +
    +
    + 42 + +
    + - + removedTables []tableMetadata +
    +
    + 43 + +
    + - + removedColumns []columnMetadata +
    +
    + 44 + +
    + - + } +
    +
    + 45 + +
    + - +
    +
    +
    + 46 + +
    + - + func (m migrationBase) AssertNewAndRemovedItemsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    + 47 + +
    + - + assertIndexesNotExist(t, db, m.removedIndexes) +
    +
    + 48 + +
    + - + assertTablesNotExist(t, db, m.removedTables) +
    +
    + 49 + +
    + - + assertColumnsNotExist(t, db, m.removedColumns) +
    +
    + 50 + +
    + - +
    +
    +
    + 51 + +
    + - + assertIndexesExist(t, db, m.newIndexes) +
    +
    + 52 + +
    + - + assertTablesExist(t, db, m.newTables) +
    +
    + 53 + +
    + - + assertColumnsExist(t, db, m.newColumns) +
    +
    + 54 + +
    + - + } +
    +
    + 55 + +
    + - +
    +
    +
    + 56 + +
    + - + func (m migrationBase) AssertNewAndRemovedItemsAfterMigrationDown(t *testing.T, db *sql.DB) { +
    +
    + 57 + +
    + - + assertIndexesExist(t, db, m.removedIndexes) +
    +
    + 58 + +
    + - + assertTablesExist(t, db, m.removedTables) +
    +
    + 59 + +
    + - + assertColumnsExist(t, db, m.removedColumns) +
    +
    + 60 + +
    + - +
    +
    +
    + 61 + +
    + - + assertIndexesNotExist(t, db, m.newIndexes) +
    +
    + 62 + +
    + - + assertTablesNotExist(t, db, m.newTables) +
    +
    + 63 + +
    + - + assertColumnsNotExist(t, db, m.newColumns) +
    +
    + 64 + +
    + - + } +
    +
    + 65 + +
    + - +
    +
    +
    + 66 + +
    +   + type migrationTester interface { +
    +
    + 67 + +
    +   + // InsertData used to insert data in the affected tables of the migration that is being tested +
    +
    + 68 + +
    +   + // data will be inserted with the schema as it was previous the migration that is being tested +
    +
    +
    @@ -75,14 +43,6 @@
    +
    + 75 + +
    +   + RunAssertsAfterMigrationDown(*testing.T, *sql.DB) +
    +
    + 76 + +
    +   + } +
    +
    + 77 + +
    +   +
    +
    +
    + 78 + +
    + - + type tableMetadata struct { +
    +
    + 79 + +
    + - + schema, name string +
    +
    + 80 + +
    + - + } +
    +
    + 81 + +
    + - +
    +
    +
    + 82 + +
    + - + type columnMetadata struct { +
    +
    + 83 + +
    + - + schema, tableName, name string +
    +
    + 84 + +
    + - + } +
    +
    + 85 + +
    + - +
    +
    +
    + 86 + +
    +   + var ( +
    +
    + 87 + +
    +   + stateDBCfg = dbutils.NewStateConfigFromEnv() +
    +
    + 88 + +
    +   + packrMigrations = map[string]*packr.Box{ +
    +
    +
    @@ -156,122 +116,3 @@
    +
    + 156 + +
    +   + } +
    +
    + 157 + +
    +   + return nil +
    +
    + 158 + +
    +   + } +
    +
    + 159 + +
    + - +
    +
    +
    + 160 + +
    + - + func checkColumnExists(db *sql.DB, column columnMetadata) (bool, error) { +
    +
    + 161 + +
    + - + const getColumn = `SELECT count(*) FROM information_schema.columns WHERE table_schema=$1 AND table_name=$2 AND column_name=$3` +
    +
    + 162 + +
    + - + var result int +
    +
    + 163 + +
    + - +
    +
    +
    + 164 + +
    + - + row := db.QueryRow(getColumn, column.schema, column.tableName, column.name) +
    +
    + 165 + +
    + - + err := row.Scan(&result) +
    +
    + 166 + +
    + - +
    +
    +
    + 167 + +
    + - + if errors.Is(err, pgx.ErrNoRows) { +
    +
    + 168 + +
    + - + return false, nil +
    +
    + 169 + +
    + - + } else if err != nil { +
    +
    + 170 + +
    + - + return false, err +
    +
    + 171 + +
    + - + } +
    +
    + 172 + +
    + - +
    +
    +
    + 173 + +
    + - + return (result == 1), nil +
    +
    + 174 + +
    + - + } +
    +
    + 175 + +
    + - +
    +
    +
    + 176 + +
    + - + func assertColumnExists(t *testing.T, db *sql.DB, column columnMetadata) { +
    +
    + 177 + +
    + - + exists, err := checkColumnExists(db, column) +
    +
    + 178 + +
    + - + assert.NoError(t, err) +
    +
    + 179 + +
    + - + assert.True(t, exists) +
    +
    + 180 + +
    + - + } +
    +
    + 181 + +
    + - +
    +
    +
    + 182 + +
    + - + func assertColumnNotExists(t *testing.T, db *sql.DB, column columnMetadata) { +
    +
    + 183 + +
    + - + exists, err := checkColumnExists(db, column) +
    +
    + 184 + +
    + - + assert.NoError(t, err) +
    +
    + 185 + +
    + - + assert.False(t, exists) +
    +
    + 186 + +
    + - + } +
    +
    + 187 + +
    + - +
    +
    +
    + 188 + +
    + - + func assertColumnsExist(t *testing.T, db *sql.DB, columns []columnMetadata) { +
    +
    + 189 + +
    + - + for _, column := range columns { +
    +
    + 190 + +
    + - + assertColumnExists(t, db, column) +
    +
    + 191 + +
    + - + } +
    +
    + 192 + +
    + - + } +
    +
    + 193 + +
    + - +
    +
    +
    + 194 + +
    + - + func assertColumnsNotExist(t *testing.T, db *sql.DB, columns []columnMetadata) { +
    +
    + 195 + +
    + - + for _, column := range columns { +
    +
    + 196 + +
    + - + assertColumnNotExists(t, db, column) +
    +
    + 197 + +
    + - + } +
    +
    + 198 + +
    + - + } +
    +
    + 199 + +
    + - +
    +
    +
    + 200 + +
    + - + func checkTableExists(db *sql.DB, table tableMetadata) (bool, error) { +
    +
    + 201 + +
    + - + const getTable = `SELECT count(*) FROM information_schema.tables WHERE table_schema=$1 AND table_name=$2` +
    +
    + 202 + +
    + - + var result int +
    +
    + 203 + +
    + - +
    +
    +
    + 204 + +
    + - + row := db.QueryRow(getTable, table.schema, table.name) +
    +
    + 205 + +
    + - + err := row.Scan(&result) +
    +
    + 206 + +
    + - +
    +
    +
    + 207 + +
    + - + if errors.Is(err, pgx.ErrNoRows) { +
    +
    + 208 + +
    + - + return false, nil +
    +
    + 209 + +
    + - + } else if err != nil { +
    +
    + 210 + +
    + - + return false, err +
    +
    + 211 + +
    + - + } +
    +
    + 212 + +
    + - +
    +
    +
    + 213 + +
    + - + return (result == 1), nil +
    +
    + 214 + +
    + - + } +
    +
    + 215 + +
    + - +
    +
    +
    + 216 + +
    + - + func assertTableExists(t *testing.T, db *sql.DB, table tableMetadata) { +
    +
    + 217 + +
    + - + exists, err := checkTableExists(db, table) +
    +
    + 218 + +
    + - + assert.NoError(t, err) +
    +
    + 219 + +
    + - + assert.True(t, exists) +
    +
    + 220 + +
    + - + } +
    +
    + 221 + +
    + - +
    +
    +
    + 222 + +
    + - + func assertTableNotExists(t *testing.T, db *sql.DB, table tableMetadata) { +
    +
    + 223 + +
    + - + exists, err := checkTableExists(db, table) +
    +
    + 224 + +
    + - + assert.NoError(t, err) +
    +
    + 225 + +
    + - + assert.False(t, exists) +
    +
    + 226 + +
    + - + } +
    +
    + 227 + +
    + - +
    +
    +
    + 228 + +
    + - + func assertTablesExist(t *testing.T, db *sql.DB, tables []tableMetadata) { +
    +
    + 229 + +
    + - + for _, table := range tables { +
    +
    + 230 + +
    + - + assertTableExists(t, db, table) +
    +
    + 231 + +
    + - + } +
    +
    + 232 + +
    + - + } +
    +
    + 233 + +
    + - +
    +
    +
    + 234 + +
    + - + func assertTablesNotExist(t *testing.T, db *sql.DB, tables []tableMetadata) { +
    +
    + 235 + +
    + - + for _, table := range tables { +
    +
    + 236 + +
    + - + assertTableNotExists(t, db, table) +
    +
    + 237 + +
    + - + } +
    +
    + 238 + +
    + - + } +
    +
    + 239 + +
    + - +
    +
    +
    + 240 + +
    + - + func checkIndexExists(db *sql.DB, index string) (bool, error) { +
    +
    + 241 + +
    + - + const getIndex = `SELECT count(*) FROM pg_indexes WHERE indexname = $1;` +
    +
    + 242 + +
    + - + row := db.QueryRow(getIndex, index) +
    +
    + 243 + +
    + - +
    +
    +
    + 244 + +
    + - + var result int +
    +
    + 245 + +
    + - + err := row.Scan(&result) +
    +
    + 246 + +
    + - + if errors.Is(err, pgx.ErrNoRows) { +
    +
    + 247 + +
    + - + return false, nil +
    +
    + 248 + +
    + - + } else if err != nil { +
    +
    + 249 + +
    + - + return false, err +
    +
    + 250 + +
    + - + } +
    +
    + 251 + +
    + - +
    +
    +
    + 252 + +
    + - + return (result == 1), nil +
    +
    + 253 + +
    + - + } +
    +
    + 254 + +
    + - +
    +
    +
    + 255 + +
    + - + func assertIndexExists(t *testing.T, db *sql.DB, index string) { +
    +
    + 256 + +
    + - + exists, err := checkIndexExists(db, index) +
    +
    + 257 + +
    + - + assert.NoError(t, err) +
    +
    + 258 + +
    + - + assert.True(t, exists) +
    +
    + 259 + +
    + - + } +
    +
    + 260 + +
    + - +
    +
    +
    + 261 + +
    + - + func assertIndexNotExists(t *testing.T, db *sql.DB, index string) { +
    +
    + 262 + +
    + - + exists, err := checkIndexExists(db, index) +
    +
    + 263 + +
    + - + assert.NoError(t, err) +
    +
    + 264 + +
    + - + assert.False(t, exists) +
    +
    + 265 + +
    + - + } +
    +
    + 266 + +
    + - +
    +
    +
    + 267 + +
    + - + func assertIndexesExist(t *testing.T, db *sql.DB, indexes []string) { +
    +
    + 268 + +
    + - + for _, index := range indexes { +
    +
    + 269 + +
    + - + assertIndexExists(t, db, index) +
    +
    + 270 + +
    + - + } +
    +
    + 271 + +
    + - + } +
    +
    + 272 + +
    + - +
    +
    +
    + 273 + +
    + - + func assertIndexesNotExist(t *testing.T, db *sql.DB, indexes []string) { +
    +
    + 274 + +
    + - + for _, index := range indexes { +
    +
    + 275 + +
    + - + assertIndexNotExists(t, db, index) +
    +
    + 276 + +
    + - + } +
    +
    + 277 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "database/sql" +
    +
    + + +
    +   +
    +
    +
    + 5 + +
    +   + "fmt" +
    +
    + 6 + +
    +   + "testing" +
    +
    + 7 + +
    +   +
    +
    +
    +
     
    +
    + 12 + +
    +   + "github.com/jackc/pgx/v4" +
    +
    + 13 + +
    +   + "github.com/jackc/pgx/v4/stdlib" +
    +
    + 14 + +
    +   + migrate "github.com/rubenv/sql-migrate" +
    +
    + + +
    +   +
    +
    +
    + 15 + +
    +   + "github.com/stretchr/testify/require" +
    +
    + 16 + +
    +   + ) +
    +
    + 17 + +
    +   +
    +
    +
    +
     
    +
    + 31 + +
    +   + }) +
    +
    + 32 + +
    +   + } +
    +
    + 33 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 34 + +
    +   + type migrationTester interface { +
    +
    + 35 + +
    +   + // InsertData used to insert data in the affected tables of the migration that is being tested +
    +
    + 36 + +
    +   + // data will be inserted with the schema as it was previous the migration that is being tested +
    +
    +
     
    +
    + 43 + +
    +   + RunAssertsAfterMigrationDown(*testing.T, *sql.DB) +
    +
    + 44 + +
    +   + } +
    +
    + 45 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 46 + +
    +   + var ( +
    +
    + 47 + +
    +   + stateDBCfg = dbutils.NewStateConfigFromEnv() +
    +
    + 48 + +
    +   + packrMigrations = map[string]*packr.Box{ +
    +
    +
     
    +
    + 116 + +
    +   + } +
    +
    + 117 + +
    +   + return nil +
    +
    + 118 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/validium-001.sql + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,32 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 1 +
    + - func New( + -- +migrate Up +
    +
    + 2 + +
    + + +
    +
    +
    + 3 + +
    + + + CREATE TABLE IF NOT EXISTS state.batch_data_backup +
    +
    + 4 + +
    + + + ( +
    +
    + 5 + +
    + + + batch_num BIGINT, +
    +
    + 6 + +
    + + + data BYTEA, +
    +
    + 7 + +
    + + + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, +
    +
    + 8 + +
    + + + PRIMARY KEY (batch_num, created_at) +
    +
    + 9 + +
    + + + ); +
    +
    + 10 + +
    + + +
    +
    +
    + 11 + +
    + + + -- +migrate StatementBegin +
    +
    + 12 + +
    + + + CREATE OR REPLACE FUNCTION backup_batch() RETURNS trigger AS $$ +
    +
    + 13 + +
    + + + BEGIN +
    +
    + 14 + +
    + + + INSERT INTO state.batch_data_backup (batch_num, data) +
    +
    + 15 + +
    + + + VALUES (OLD.batch_num, OLD.raw_txs_data) +
    +
    + 16 + +
    + + + ON CONFLICT (batch_num, created_at) DO UPDATE SET +
    +
    + 17 + +
    + + + data = EXCLUDED.data; +
    +
    + 18 + +
    + + + RETURN OLD; +
    +
    + 19 + +
    + + + END; +
    +
    + 20 + +
    + + + $$ +
    +
    + 21 + +
    + + + LANGUAGE plpgsql; +
    +
    + 22 + +
    + + + -- +migrate StatementEnd +
    +
    + 23 + +
    + + +
    +
    +
    + 24 + +
    + + + CREATE TRIGGER backup_batch +
    +
    + 25 + +
    + + + BEFORE DELETE ON state.batch FOR EACH ROW +
    +
    + 26 + +
    + + + EXECUTE PROCEDURE backup_batch(); +
    +
    + 27 + +
    + + +
    +
    +
    + 28 + +
    + + + -- +migrate Down +
    +
    + 29 + +
    + + +
    +
    +
    + 30 + +
    + + + DROP TRIGGER IF EXISTS backup_batch ON state.batch; +
    +
    + 31 + +
    + + + DROP FUNCTION IF EXISTS backup_batch(); +
    +
    + 32 + +
    + + + DROP TABLE IF EXISTS state.batch_data_backup; +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,47 @@
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 34 + + -
    - + - isTrustedSequencer bool, +
    +
    +   +
    - 35 + + -
    - + - backend DABackender, +
    +
    +   +
    - 36 + + -
    - + - state stateInterface, +
    +
    +   +
    - 37 + + -
    - + - zkEVMClient ZKEVMClientTrustedBatchesGetter, +
    +
    +   +
    - 38 + + -
    - + - ) (*DataAvailability, error) { +
    +
    +   +
    - 39 + + -
    - + - da := &DataAvailability{ +
    +
    +   +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    +
    - 40 + 1
    + - isTrustedSequencer: isTrustedSequencer, + PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/"
    - 41 + 2
    + - backend: backend, + diff -ruN \
    - 42 + 3
    + - state: state, + -I ".*github.com\/0x.*" \
    - 43 + 4
    + - zkEVMClient: zkEVMClient, + -x "*mock*" -x ".git" \
    - 44 + 5
    + - ctx: context.Background(), + -x ".github" \
    - 45 + 6
    + - } + -x ".gitignore" \
    - 46 + 7
    + - err := da.backend.Init() + -x ".vscode" \
    - 47 + 8
    + - return da, err + -x "ci" \
    - 48 + 9
    + - } + -x "environments" \
    - 49 + 10
    + -
    + -x "*.md" \
    - 50 + 11
    + - // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage + -x "*.html" \
    - 51 + 12
    + - // as expected by the contract + -x "*.html" \
    - 52 + 13
    + - func (d *DataAvailability) PostSequence(ctx context.Context, sequences []types.Sequence) ([]byte, error) { + -x "*.json" \
    - 53 + 14
    + - batchesData := [][]byte{} + -x "*.toml" \
    - 54 + 15
    + - for _, batch := range sequences { + -x "*.abi" \
    - 55 + 16
    + - // Do not send to the DA backend data that will be stored to L1 + -x "*.bin" \
    - 56 + 17
    + - if batch.ForcedBatchTimestamp == 0 { + -x "*.pb.go" \
    - 57 + 18
    + - batchesData = append(batchesData, batch.BatchL2Data) + -x "smartcontracts" \
    - 58 + 19
    + - } + -x "go.sum" \
    - 59 + 20
    + - } + -x "mock*.go" \
    - 60 + 21
    + - return d.backend.PostSequence(ctx, batchesData) + -x "*venv*" \
    - 61 + 22
    + - } + -x "/dist/" \
    - 62 + 23
    + -
    + -x "/test/e2e/keystore" \
    - 63 + 24
    + - // GetBatchL2Data tries to return the data from a batch, in the following priorities. batchNums should not include forced batches. + -x "/test/vectors/src/**/*md" \
    - 64 + 25
    + - // 1. From local DB + -x "/test/vectors/src/**/*js" \
    - 65 + 26
    + - // 2. From Trusted Sequencer (if not self) + -x "/test/vectors/src/**/*sol" \
    - 66 + 27
    + - // 3. From DA backend + -x "/test/vectors/src/**/*sh" \
    - 67 + 28
    + - func (d *DataAvailability) GetBatchL2Data(batchNums []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) { + -x "/test/vectors/src/package.json" \
    - 68 + 29
    + - if len(batchNums) != len(batchHashes) { + -x "/test/contracts/bin/**/*.bin" \
    - 69 + 30
    + - return nil, fmt.Errorf(invalidBatchRetrievalArgs, len(batchNums), len(batchHashes)) + -x "/test/contracts/bin/**/*.abi" \
    - 70 + 31
    + - } + -x "/tools/datastreamer/*.bin" \
    - 71 + 32
    + - localData, err := d.state.GetBatchL2DataByNumbers(d.ctx, batchNums, nil) + -x "/test/datastreamer/*.db/*" \
    - 72 + 33
    + - if err != nil { + -x "/test/*.bin" \
    - 73 + 34
    + - return nil, err + -x "/test/*.db/*" \
    - 74 + 35
    + - } + -x "**/.DS_Store" \
    - 75 + 36
    + -
    + -x ".vscode" \
    - 76 + 37
    + - data, err := checkBatches(batchNums, batchHashes, localData) + -x ".idea/" \
    - 77 + 38
    + - if err != nil { + -x ".env" \
    - 78 + 39
    + - log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error()) + -x "out.dat" \
    - 79 + 40
    + - } else { + -x "cmd/__debug_bin" \
    - 80 + 41
    + - return data, nil + -x ".venv" \
    - 81 + 42
    + - } + -x "*metrics.txt" \
    - 82 + 43
    + -
    + -x "coverage.out" \
    - 83 + 44
    + - if !d.isTrustedSequencer { + -x "*datastream.db*" \
    - 84 + 45
    + - data, err = d.rpcData(batchNums, batchHashes, d.zkEVMClient.BatchesByNumbers) + ${PATH_TO_ZKEVM_NODE_REPO} . | \
    - 85 + 46
    + - if err != nil { + diff2html -i stdin -s side -t "zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.6.0<h2/>" \
    - 86 + 47
    + - log.Warnf(failedDataRetrievalTemplate, batchNums, err.Error()) + -F ./docs/diff/diff.html +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/docker-compose.yml + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -107,7 +107,7 @@
    - 87 + + 107 +
    - + - } else { +   + zkevm-prover:
    - 88 + + 108 +
    - + - return data, nil +   + container_name: zkevm-prover
    - 89 + + 109 +
    - + - } +   + restart: unless-stopped
    - 90 + + 110 +
    - + - } + - + image: hermeznetwork/zkevm-prover:v6.0.2-RC2
    - 91 + + 111 +
    - + - return d.backend.GetSequence(d.ctx, batchHashes, dataAvailabilityMessage) +   + depends_on:
    - 92 + + 112 +
    - + - } +   + zkevm-state-db:
    - 93 + + 113 +
    - + -
    +   + condition: service_healthy +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - 94 + + 107 +
    - + - func checkBatches(batchNumbers []uint64, expectedHashes []common.Hash, batchData map[uint64][]byte) ([][]byte, error) { +   + zkevm-prover:
    - 95 + + 108 +
    - + - if len(batchNumbers) != len(expectedHashes) { +   + container_name: zkevm-prover
    - 96 + + 109 +
    - + - return nil, fmt.Errorf("invalid batch parameters") +   + restart: unless-stopped
    - 97 + + 110 +
    + - } + image: hermeznetwork/zkevm-prover:v6.0.0
    - 98 + + 111 +
    - + - result := make([][]byte, len(batchNumbers)) +   + depends_on:
    - 99 + + 112 +
    - + - for i := 0; i < len(batchNumbers); i++ { +   + zkevm-state-db:
    - 100 + + 113 +
    - + - batchNumber := batchNumbers[i] +   + condition: service_healthy
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -14,7 +14,6 @@
    +
    - 101 + + 14 +
    - + - expectedHash := expectedHashes[i] +   + # CONTAINER FOR RUNNING BINARY
    - 102 + + 15 +
    - + - bd, ok := batchData[batchNumber] +   + FROM alpine:3.18
    - 103 + + 16 +
    - + - if !ok { +   + COPY --from=build /src/dist/zkevm-node /app/zkevm-node
    - 104 + + 17 +
    - + - return nil, fmt.Errorf("missing batch data: [%d] %s", batchNumber, expectedHash.Hex()) + - + COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml
    - 105 + + 18 +
    - + - } +   + RUN apk update && apk add postgresql15-client
    - 106 + + 19 +
    - + - actualHash := crypto.Keccak256Hash(bd) +   + EXPOSE 8123
    - 107 + + 20 +
    - + - if actualHash != expectedHash { +   + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - 108 + + 14 +
    - + - err := fmt.Errorf(unexpectedHashTemplate, batchNumber, expectedHash, actualHash) +   + # CONTAINER FOR RUNNING BINARY
    - 109 + + 15 +
    - + - log.Warnf("wrong local data for hash: %s", err.Error()) +   + FROM alpine:3.18
    - 110 + + 16 +
    - + - return nil, err +   + COPY --from=build /src/dist/zkevm-node /app/zkevm-node
    - 111 + + -
    - + - } +
    +
    +   +
    - 112 + + 17 +
    - + - result[i] = bd +   + RUN apk update && apk add postgresql15-client
    - 113 + + 18 +
    - + - } +   + EXPOSE 8123
    - 114 + + 19 +
    - + - return result, nil +   + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -0,0 +1,15 @@
    +
    + + +
    +   +
    - 115 + + -
    - + - } +
    +
    +   +
    - 116 + + -
    - + +
    +
    +  
    - 117 + + -
    - + - type rpcBatchDataFunc func(ctx context.Context, numbers []*big.Int) ([]*jsontypes.BatchData, error) +
    +
    +   +
    - 118 + + -
    - + +
    +
    +  
    - 119 + + -
    - + - // rpcData retrieves batch data from rpcBatchDataFunc, returns an error unless all are found and correct +
    +
    +   +
    - 120 + + -
    - + - func (d *DataAvailability) rpcData(batchNums []uint64, expectedHashes []common.Hash, rpcFunc rpcBatchDataFunc) ([][]byte, error) { +
    +
    +   +
    - 121 + + -
    - + - if len(batchNums) != len(expectedHashes) { +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    - 122 + 1
    + - return nil, fmt.Errorf("invalid arguments, len of batch numbers does not equal length of expected hashes: %d != %d", + FROM alpine:3.18
    - 123 + 2
    + - len(batchNums), len(expectedHashes)) +
    - 124 + 3
    + - } + COPY zkevm-node /app/zkevm-node
    - 125 + 4
    + - nums := make([]*big.Int, 0, len(batchNums)) +
    - 126 + 5
    + - for _, n := range batchNums { + EXPOSE 8123
    - 127 + 6
    + - nums = append(nums, new(big.Int).SetUint64(n)) +
    - 128 + 7
    + - } + RUN addgroup -S zkevm-group \
    - 129 + 8
    + - batchData, err := rpcFunc(d.ctx, nums) + && adduser -S zkevm-user -G zkevm-group
    - 130 + 9
    + - if err != nil { +
    - 131 + 10
    + - return nil, err + RUN chown -R zkevm-user:zkevm-group /app
    - 132 + 11
    + - } +
    - 133 + 12
    + - if len(batchData) != len(batchNums) { + USER zkevm-user
    - 134 + 13
    + - return nil, fmt.Errorf("missing batch data, expected %d, got %d", len(batchNums), len(batchData)) +
    - 135 + 14
    + - } + CMD ["/app/zkevm-node"]
    - 136 + 15
    + - result := make(map[uint64][]byte) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/config.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + + +
    +
    @@ -6,8 +6,6 @@
    +
    - 137 + + 6 +
    - + - for i := 0; i < len(batchNums); i++ { +   + type Config struct {
    - 138 + + 7 +
    - + - number := batchNums[i] +   + // URL is the URL of the Ethereum node for L1
    - 139 + + 8 +
    - + - batch := batchData[i] +   + URL string `mapstructure:"URL"`
    - 140 + + 9 +
    - + - expectedTransactionsHash := expectedHashes[i] + - + // ConsensusL1URL is the URL of the consensus L1 RPC endpoint
    - 141 + + 10 +
    - + - actualTransactionsHash := crypto.Keccak256Hash(batch.BatchL2Data) + - + ConsensusL1URL string `mapstructure:"ConsensusL1URL"`
    - 142 + + 11 +
    - + - if expectedTransactionsHash != actualTransactionsHash { +   +
    - 143 + + 12 +
    - + - return nil, fmt.Errorf(unexpectedHashTemplate, number, expectedTransactionsHash, actualTransactionsHash) +   + // ForkIDChunkSize is the max interval for each call to L1 provider to get the forkIDs
    - 144 + + 13 +
    - + - } +   + ForkIDChunkSize uint64 `mapstructure:"ForkIDChunkSize"` +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - @@ -36725,12 +112000,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/eip4844/eip4844.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
    +
     
    - 145 + + 6 +
    - + - result[number] = batch.BatchL2Data +   + type Config struct {
    - 146 + + 7 +
    - + - } +   + // URL is the URL of the Ethereum node for L1
    - 147 + + 8 +
    - + - checked, err := checkBatches(batchNums, expectedHashes, result) +   + URL string `mapstructure:"URL"`
    - 148 + + -
    - + - if err != nil { +
    +
    +   +
    - 149 + + -
    - + - return nil, err +
    +
    +   +
    - 150 + + 9 +
    - + - } +   +
    - 151 + + 10 +
    - + - return checked, nil +   + // ForkIDChunkSize is the max interval for each call to L1 provider to get the forkIDs
    - 152 + + 11 +
    - + - } +   + ForkIDChunkSize uint64 `mapstructure:"ForkIDChunkSize"`
    -
    @@ -0,0 +1,309 @@
    +
    @@ -1,86 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package eip4844
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   -
    +
    +
    + - + "fmt"
    - + + 6 -
    -   +
    +
    + -
    - + + 7 -
    -   -
    +
    +
    + - + beaconclient "github.com/0xPolygonHermez/zkevm-node/beacon_client"
    - + + 8 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 9 -
    -   -
    +
    +
    + - + )
    - + + 10 -
    -   +
    +
    + -
    - + + 11 -
    -   -
    +
    +
    + - + // EthermanEIP4844 represents the EIP-4844 implementation
    - + + 12 -
    -   -
    +
    +
    + - + type EthermanEIP4844 struct {
    - + + 13 -
    -   -
    +
    +
    + - + beaconClient *beaconclient.BeaconAPIClient
    - + + 14 -
    -   -
    +
    +
    + - + initialized bool
    - + + 15 -
    -   -
    +
    +
    + - + genesisTime uint64
    - + + 16 -
    -   -
    +
    +
    + - + secondsPerSlot uint64
    - + + 17 -
    -   -
    +
    +
    + - + }
    - + + 18 -
    -   +
    +
    + -
    - + + 19 -
    -   -
    +
    +
    + - + // NewEthermanEIP4844 creates a new EthermanEIP4844
    - + + 20 -
    -   -
    +
    +
    + - + func NewEthermanEIP4844(beaconClient *beaconclient.BeaconAPIClient) *EthermanEIP4844 {
    - + + 21 -
    -   -
    +
    +
    + - + return &EthermanEIP4844{
    - + + 22 -
    -   -
    +
    +
    + - + beaconClient: beaconClient,
    - + + 23 -
    -   -
    +
    +
    + - + initialized: false,
    - + + 24 -
    -   -
    +
    +
    + - + }
    - + + 25 -
    -   -
    +
    +
    + - + }
    - + + 26 -
    -   +
    +
    + -
    - + + 27 -
    -   -
    +
    +
    + - + // IsInitialized returns if the EthermanEIP4844 is initialized
    - + + 28 -
    -   -
    +
    +
    + - + func (e *EthermanEIP4844) IsInitialized() bool {
    - + + 29 -
    -   -
    +
    +
    + - + return e.initialized && e.genesisTime != 0 && e.secondsPerSlot != 0
    - + + 30 -
    -   -
    +
    +
    + - + }
    - + + 31 -
    -   +
    +
    + -
    - + + 32 -
    -   -
    +
    +
    + - + // Initialize initializes the EthermanEIP4844
    - + + 33 -
    -   -
    +
    +
    + - + func (e *EthermanEIP4844) Initialize(ctx context.Context) error {
    - + + 34 -
    -   -
    +
    +
    + - + // You can initialize multiples times and will fetch again the data
    - + + 35 -
    -   +
    +
    + -
    - + + 36 -
    -   -
    +
    +
    + - + configSpec, err := e.beaconClient.ConfigSpec(ctx)
    - + + 37 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 38 -
    -   -
    +
    +
    + - + return fmt.Errorf("error fetching config spec: %v", err)
    - + + 39 -
    -   -
    +
    +
    + - + }
    - + + 40 -
    -   +
    +
    + -
    - + + 41 -
    -   -
    +
    +
    + - + e.secondsPerSlot = configSpec.SecondsPerSlot
    - + + 42 -
    -   +
    +
    + -
    - + + 43 -
    -   -
    +
    +
    + - + genesis, err := e.beaconClient.BeaconGenesis(ctx)
    - + + 44 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 45 -
    -   -
    +
    +
    + - + return fmt.Errorf("error fetching beacon genesis: %v", err)
    - + + 46 -
    -   -
    +
    +
    + - + }
    - + + 47 -
    -   -
    +
    +
    + - + e.genesisTime = genesis.GenesisTime
    - + + 48 -
    -   -
    +
    +
    + - + if e.secondsPerSlot == 0 || e.genesisTime == 0 {
    - + + 49 -
    -   -
    +
    +
    + - + return fmt.Errorf("genesisTime:%d or secondsPerSlot: %d is 0", e.genesisTime, e.secondsPerSlot)
    - + + 50 -
    -   -
    +
    +
    + - + }
    - + + 51 -
    -   -
    +
    +
    + - + e.initialized = true
    - + + 52 -
    -   +
    +
    + -
    - + + 53 -
    -   -
    +
    +
    + - + return nil
    - + + 54 -
    -   -
    +
    +
    + - + }
    - + + 55 -
    -   +
    +
    + -
    - + + 56 -
    -   -
    +
    +
    + - + // GetBlobSidecar returns the blob sidecar for a given blockTime and kzgCommitment
    - + + 57 -
    -   -
    +
    +
    + - + func (e *EthermanEIP4844) GetBlobSidecar(ctx context.Context, blockTime uint64, kzgCommitment string) ([]byte, error) {
    - + + 58 -
    -   -
    +
    +
    + - + slot, err := e.CalculateSlot(blockTime)
    - + + 59 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 60 -
    -   -
    +
    +
    + - + errComposed := fmt.Errorf("error calculating Slot blob sidecars: %v", err)
    - + + 61 -
    -   -
    +
    +
    + - + log.Error(errComposed.Error())
    - + + 62 -
    -   -
    +
    +
    + - + return nil, errComposed
    - + + 63 -
    -   -
    +
    +
    + - + }
    - + + 64 -
    -   -
    +
    +
    + - + sidecars, err := e.beaconClient.BeaconBlobSidecars(ctx, slot)
    - + + 65 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 66 -
    -   -
    +
    +
    + - + errComposed := fmt.Errorf("error fetching beacon blob sidecars: %v", err)
    - + + 67 -
    -   -
    +
    +
    + - + log.Error(errComposed.Error())
    - + + 68 -
    -   -
    +
    +
    + - + return nil, errComposed
    - + + 69 -
    -   -
    +
    +
    + - + }
    - + + 70 -
    -   -
    +
    +
    + - + for _, sidecar := range sidecars.Sidecars {
    - + + 71 -
    -   -
    +
    +
    + - + if sidecar.KzgCommitment == kzgCommitment {
    - + + 72 -
    -   -
    +
    +
    + - + return sidecar.Blob, nil
    - + + 73 -
    -   -
    +
    +
    + - + }
    - + + 74 -
    -   -
    +
    +
    + - + }
    - + + 75 -
    -   -
    +
    +
    + - + err = fmt.Errorf("sidecar not found")
    - + + 76 -
    -   -
    +
    +
    + - + log.Error(err.Error())
    - + + 77 -
    -   -
    +
    +
    + - + return nil, err
    - + + 78 -
    -   -
    +
    +
    + - + }
    - + + 79 -
    -   +
    +
    + -
    - + + 80 -
    -   -
    +
    +
    + - + // CalculateSlot calculates the slot for a given blockTime
    - + + 81 -
    -   -
    +
    +
    + - + func (e *EthermanEIP4844) CalculateSlot(blockTime uint64) (uint64, error) {
    - + + 82 -
    -   -
    +
    +
    + - + if !e.IsInitialized() { +
    +
    + 83 + +
    + - + return 0, fmt.Errorf("EIP-4844 not initialized,please call Initialize(..) function first") +
    +
    + 84 + +
    + - + } +
    +
    + 85 + +
    + - + return (blockTime - e.genesisTime) / e.secondsPerSlot, nil +
    +
    + 86 + +
    + - + } +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -38427,34 +113756,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -38468,321 +113826,336 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -39138,423 +114561,598 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - - - - - - - + + + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - @@ -39598,6040 +115196,6144 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -3,6 +3,7 @@
    +
    - + + 3 -
    +
    +
      -
    + import (
    - + + 4 -
    +
    +
      -
    + "bytes"
    - + + 5 -
    +
    +
      -
    + "context"
    - + + 6 -
    +
    +
      -
    + "encoding/json"
    - + + 7 -
    +
    +
      -
    + "errors"
    - + + 8 -
    +
    +
      -
    + "fmt"
    - + +
    @@ -43,13 +44,8 @@
    -
    +
    + 43 + +
      -
    + "golang.org/x/crypto/sha3"
    - + + 44 -
    +
    +
      -
    + )
    - + + 45 -
    +
    +
     
    - + + 46 -
    -   -
    +
    +
    + - + const (
    - + + 47 -
    -   -
    +
    +
    + - + // ETrogUpgradeVersion is the version of the LxLy upgrade
    - + + 48 -
    -   -
    +
    +
    + - + ETrogUpgradeVersion = 2
    - + + 49 -
    -   -
    +
    +
    + - + )
    - + + 50 -
    -   +
    +
    + -
    - + + 51 -
    +
    +
      -
    + var (
    - + + 52 -
    -   -
    +
    +
    + - + // Events EtrogRollupManager
    - + + 53 -
    +
    +
      -
    + setBatchFeeSignatureHash = crypto.Keccak256Hash([]byte("SetBatchFee(uint256)"))
    - + + 54 -
    +
    +
      -
    + setTrustedAggregatorSignatureHash = crypto.Keccak256Hash([]byte("SetTrustedAggregator(address)")) // Used in oldZkEvm as well
    - + + 55 -
    +
    +
      -
    + setVerifyBatchTimeTargetSignatureHash = crypto.Keccak256Hash([]byte("SetVerifyBatchTimeTarget(uint64)")) // Used in oldZkEvm as well
    - + +
    @@ -94,13 +90,13 @@
    -
    +
    + 94 + +
      -
    + updateL1InfoTreeSignatureHash = crypto.Keccak256Hash([]byte("UpdateL1InfoTree(bytes32,bytes32)"))
    - + + 95 -
    +
    +
     
    - + + 96 -
    +
    +
      -
    + // PreLxLy events
    - + + 97 -
    -   -
    +
    +
    + - + updateGlobalExitRootSignatureHash = crypto.Keccak256Hash([]byte("UpdateGlobalExitRoot(bytes32,bytes32)"))
    - + + 98 -
    -   -
    +
    +
    + - + preEtrogVerifyBatchesTrustedAggregatorSignatureHash = crypto.Keccak256Hash([]byte("VerifyBatchesTrustedAggregator(uint64,bytes32,address)"))
    - + + 99 -
    -   -
    +
    +
    + - + transferOwnershipSignatureHash = crypto.Keccak256Hash([]byte("OwnershipTransferred(address,address)"))
    - + + 100 -
    -   -
    +
    +
    + - + updateZkEVMVersionSignatureHash = crypto.Keccak256Hash([]byte("UpdateZkEVMVersion(uint64,uint64,string)"))
    - + + 101 -
    -   -
    +
    +
    + - + preEtrogConsolidatePendingStateSignatureHash = crypto.Keccak256Hash([]byte("ConsolidatePendingState(uint64,bytes32,uint64)"))
    - + + 102 -
    -   -
    +
    +
    + - + preEtrogOverridePendingStateSignatureHash = crypto.Keccak256Hash([]byte("OverridePendingState(uint64,bytes32,address)"))
    - + + 103 -
    -   -
    +
    +
    + - + sequenceBatchesPreEtrogSignatureHash = crypto.Keccak256Hash([]byte("SequenceBatches(uint64)"))
    - + + 104 -
    +
    +
     
    - + + 105 -
    +
    +
      -
    + // Proxy events
    - + + 106 -
    +
    +
      -
    + initializedProxySignatureHash = crypto.Keccak256Hash([]byte("Initialized(uint8)"))
    - + +
    @@ -113,6 +109,11 @@
    -
    +
    + 113 + +
      -
    + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
    - + + 114 -
    +
    +
      -
    + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
    - + + 115 -
    +
    +
     
    @@ -38838,293 +114211,343 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 116 -
    +
    +
      -
    + // ErrNotFound is used when the object is not found
    - + + 117 -
    +
    +
      -
    + ErrNotFound = errors.New("not found")
    - + + 118 -
    +
    +
      -
    + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    - + +
    @@ -163,7 +164,6 @@
    -
    +
    + 163 + +
      -
    + ethereum.LogFilterer
    - + + 164 -
    +
    +
      -
    + ethereum.TransactionReader
    - + + 165 -
    +
    +
      -
    + ethereum.TransactionSender
    - + + 166 -
    -   -
    +
    +
    + - + ethereum.PendingStateReader
    - + + 167 -
    +
    +
     
    - + + 168 -
    +
    +
      -
    + bind.DeployBackend
    - + + 169 -
    +
    +
      -
    + }
    - + +
    @@ -189,78 +189,66 @@
    -
    +
    + 189 + +
     
    - + + 190 -
    +
    +
      -
    + // Client is a simple implementation of EtherMan.
    - + + 191 -
    +
    +
      -
    + type Client struct {
    - + + 192 -
    -   -
    +
    +
    + - + EthClient ethereumClient
    - + + 193 -
    -   -
    +
    +
    + - + PreEtrogZkEVM *preetrogpolygonzkevm.Preetrogpolygonzkevm
    - + + 194 -
    -   -
    +
    +
    + - + ElderberryZKEVM *elderberrypolygonzkevm.Elderberrypolygonzkevm
    - + + 195 -
    -   -
    +
    +
    + - + EtrogZkEVM *etrogpolygonzkevm.Etrogpolygonzkevm
    - + + 196 -
    -   -
    +
    +
    + - + EtrogRollupManager *etrogpolygonrollupmanager.Etrogpolygonrollupmanager
    - + + 197 -
    -   -
    +
    +
    + - + EtrogGlobalExitRootManager *etrogpolygonzkevmglobalexitroot.Etrogpolygonzkevmglobalexitroot
    - + + 198 -
    -   -
    +
    +
    + - + PreEtrogGlobalExitRootManager *preetrogpolygonzkevmglobalexitroot.Preetrogpolygonzkevmglobalexitroot
    - + + 199 -
    -   -
    +
    +
    + - + FeijoaContracts *FeijoaContracts
    - + + 200 -
    -   -
    +
    +
    + - + Pol *pol.Pol
    - + + 201 -
    -   -
    +
    +
    + - + SCAddresses []common.Address
    - + + 202 -
    +
    +
     
    - + + 203 -
    +
    +
      -
    + RollupID uint32
    - + + 204 -
    +
    +
     
    - + + 205 -
    +
    +
      -
    + GasProviders externalGasProviders
    - + + 206 -
    +
    +
     
    - + + 207 -
    -   -
    +
    +
    + - + l1Cfg L1Config +
    +
    + 208 + +
    + - + cfg Config +
    +
    + 209 + +
    + - + auth map[common.Address]bind.TransactOpts // empty in case of read-only client +
    +
    + 210 + +
    + - + EIP4844 *eip4844.EthermanEIP4844 +
    +
    + 211 + +
    + - + eventFeijoaManager *EventManager
    - + + 212 -
    +
    +
      -
    + }
    - + + 213 -
    +
    +
     
    - + + 214 -
    +
    +
      -
    + // NewClient creates a new etherman.
    - + + 215 -
    +
    +
    + - + func NewClient(cfg Config, l1Config L1Config) (*Client, error) { +
    +
    + 216 + +
      -
    + // Connect to ethereum node
    - + + 217 -
    +
    +
      -
    + ethClient, err := ethclient.Dial(cfg.URL)
    - + + 218 -
    +
    +
      -
    + if err != nil {
    - + + 219 -
    +
    +
      -
    + log.Errorf("error connecting to %s: %+v", cfg.URL, err)
    - + + 220 -
    +
    +
      -
    + return nil, err
    - + + 221 -
    +
    +
      -
    + }
    - + + 222 -
    +
    +
    + - + if cfg.ConsensusL1URL == "" { +
    +
    + 223 + +
    + - + log.Warn("ConsensusL1URL is not set, so Feijoa is not going to work") +
    +
    + 224 + +
    + - + } +
    +
    + 225 + +
    + - + feijoaEnabled := true +
    +
    + 226 + +
    + - + beaconClient := beaconclient.NewBeaconAPIClient(cfg.ConsensusL1URL) +
    +
    + 227 + +
    + - + eip4844 := eip4844.NewEthermanEIP4844(beaconClient) +
    +
    + 228 + +
    + - + if err := eip4844.Initialize(context.Background()); err != nil { +
    +
    + 229 + +
    + - + // TODO: Must be mandatory to have a consensusL1URL configured, but +
    +
    + 230 + +
    + - + // for maintain compatibility allow to disable Feijoa +
    +
    + 231 + +
    + - + // so the log.Warnf must be an Errorf and must return nil, err +
    +
    + 232 + +
    + - + log.Warnf("error initializing EIP-4844,Feijoa is going to be disabled. URL:%s : %+v", cfg.ConsensusL1URL, err) +
    +
    + 233 + +
    + - + feijoaEnabled = false +
    +
    + 234 + +
    + - + } +
    +
    + 235 + +
      -
    + // Create smc clients
    - + + 236 -
    +
    +
    + - + etrogZkevm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(l1Config.ZkEVMAddr, ethClient) +
    +
    + 237 + +
      -
    + if err != nil {
    - + + 238 -
    +
    +
      -
    + log.Errorf("error creating Polygonzkevm client (%s). Error: %w", l1Config.ZkEVMAddr.String(), err)
    - + + 239 -
    +
    +
      -
    + return nil, err
    - + + 240 -
    +
    +
      -
    + }
    - + + 241 -
    +
    +
    + - + elderberryZkevm, err := elderberrypolygonzkevm.NewElderberrypolygonzkevm(l1Config.RollupManagerAddr, ethClient) +
    +
    + 242 + +
      -
    + if err != nil {
    - + + 243 -
    +
    +
    + - + log.Errorf("error creating NewElderberryPolygonzkevm client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err) +
    +
    + 244 + +
      -
    + return nil, err
    - + + 245 -
    +
    +
      -
    + }
    - + + 246 -
    -   -
    +
    +
    + - + preEtrogZkevm, err := preetrogpolygonzkevm.NewPreetrogpolygonzkevm(l1Config.RollupManagerAddr, ethClient)
    - + + 247 -
    +
    +
      -
    + if err != nil {
    - + + 248 -
    -   -
    +
    +
    + - + log.Errorf("error creating Newpreetrogpolygonzkevm client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 249 -
    +
    +
      -
    + return nil, err
    - + + 250 -
    +
    +
      -
    + }
    - + + 251 -
    -   -
    +
    +
    + - + etrogRollupManager, err := etrogpolygonrollupmanager.NewEtrogpolygonrollupmanager(l1Config.RollupManagerAddr, ethClient)
    - + + 252 -
    +
    +
      -
    + if err != nil {
    - + + 253 -
    +
    +
      -
    + log.Errorf("error creating NewPolygonrollupmanager client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 254 -
    +
    +
      -
    + return nil, err
    - + + 255 -
    +
    +
      -
    + }
    - + + 256 -
    -   -
    +
    +
    + - + etrogGlobalExitRoot, err := etrogpolygonzkevmglobalexitroot.NewEtrogpolygonzkevmglobalexitroot(l1Config.GlobalExitRootManagerAddr, ethClient)
    - + + 257 -
    +
    +
      -
    + if err != nil {
    - + + 258 -
    +
    +
      -
    + log.Errorf("error creating NewPolygonzkevmglobalexitroot client (%s). Error: %w", l1Config.GlobalExitRootManagerAddr.String(), err)
    - + + 259 -
    +
    +
      -
    + return nil, err
    - + + 260 -
    +
    +
      -
    + }
    - + + 261 -
    -   -
    +
    +
    + - + preEtrogGlobalExitRoot, err := preetrogpolygonzkevmglobalexitroot.NewPreetrogpolygonzkevmglobalexitroot(l1Config.GlobalExitRootManagerAddr, ethClient)
    - + + 262 -
    +
    +
      -
    + if err != nil {
    - + + 263 -
    -   -
    +
    +
    + - + log.Errorf("error creating Newpreetrogpolygonzkevmglobalexitroot client (%s). Error: %w", l1Config.GlobalExitRootManagerAddr.String(), err)
    - + + 264 -
    +
    +
      -
    + return nil, err
    - + + 265 -
    +
    +
      -
    + }
    - + + 266 -
    +
    +
      -
    + pol, err := pol.NewPol(l1Config.PolAddr, ethClient)
    - + +
    @@ -268,12 +256,15 @@
    -
    +
    + 268 + +
      -
    + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - + + 269 -
    +
    +
      -
    + return nil, err
    - + + 270 -
    +
    +
      -
    + }
    - + + 271 -
    -   -
    +
    +
    + - + feijoaContracts, err := NewFeijoaContracts(ethClient, l1Config)
    - + + 272 -
    +
    +
      -
    + if err != nil {
    - + + 273 -
    -   -
    +
    +
    + - + log.Errorf("error creating NewFeijoaContracts client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 274 -
    +
    +
      -
    + return nil, err
    - + + 275 -
    +
    +
      -
    + }
    - + + 276 -
    -   -
    +
    +
    + - + scAddresses := feijoaContracts.GetAddresses()
    - + + 277 -
    +
    +
      -
    + scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
    - + + 278 -
    +
    +
     
    - + + 279 -
    +
    +
      -
    + gProviders := []ethereum.GasPricer{ethClient}
    - + +
    @@ -288,43 +279,40 @@
    -
    +
    + 288 + +
      -
    + }
    - + + 289 -
    +
    +
      -
    + metrics.Register()
    - + + 290 -
    +
    +
      -
    + // Get RollupID
    - + + 291 -
    -   -
    +
    +
    + - + rollupID, err := etrogRollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr)
    - + + 292 -
    +
    +
      -
    + if err != nil {
    - + + 293 -
    +
    +
      -
    + log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
    - + + 294 -
    +
    +
      -
    + return nil, err
    - + + 295 -
    +
    +
      -
    + }
    - + + 296 -
    +
    +
      -
    + log.Debug("rollupID: ", rollupID)
    - + + 297 -
    +
    +
     
    - + + 298 -
    -   -
    +
    +
    + - + client := &Client{
    - + + 299 -
    -   -
    +
    +
    + - + EthClient: ethClient,
    - + + 300 -
    -   -
    +
    +
    + - + EtrogZkEVM: etrogZkevm,
    - + + 301 -
    -   -
    +
    +
    + - + ElderberryZKEVM: elderberryZkevm,
    - + + 302 -
    -   -
    +
    +
    + - + PreEtrogZkEVM: preEtrogZkevm,
    - + + 303 -
    -   -
    +
    +
    + - + EtrogRollupManager: etrogRollupManager,
    -
    + + + 304 + + +
    + - + Pol: pol,
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - -
    -
     
    - 1 + + 305 +
    - + - package datacommittee + - + EtrogGlobalExitRootManager: etrogGlobalExitRoot,
    - 2 + + 306 +
    - + -
    + - + PreEtrogGlobalExitRootManager: preEtrogGlobalExitRoot,
    - 3 + + 307 +
    - + - import ( + - + SCAddresses: scAddresses,
    - 4 + + 308 +
    - + - "crypto/ecdsa" + - + RollupID: rollupID,
    - 5 + + -
    - + - "errors" +
    +
    +   +
    - 6 + + 309 +
    - + - "fmt" +   + GasProviders: externalGasProviders{
    - 7 + + 310 +
    - + - "math/big" +   + MultiGasProvider: cfg.MultiGasProvider,
    - 8 + + 311 +
    - + - "math/rand" +   + Providers: gProviders,
    - 9 + + 312 +
    - + - "sort" +   + },
    - 10 + + 313 +
    - + - "strings" + - + l1Cfg: l1Config,
    - 11 + + 314 +
    - + -
    + - + cfg: cfg,
    - 12 + + 315 +
    - + - "github.com/0xPolygon/cdk-data-availability/client" + - + auth: map[common.Address]bind.TransactOpts{},
    - 13 + + 316 +
    - + - daTypes "github.com/0xPolygon/cdk-data-availability/types" + - + EIP4844: eip4844,
    - 14 + + 317 +
    - + - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" + - + }
    - 15 + + 318 +
    - + - "github.com/0xPolygonHermez/zkevm-node/log" + - + if feijoaEnabled {
    - 16 + + 319 +
    - + - "github.com/ethereum/go-ethereum/accounts/abi/bind" + - + eventFeijoaManager := NewEventManager(client, NewCallDataExtratorGeth(ethClient))
    - 17 + + 320 +
    - + - "github.com/ethereum/go-ethereum/common" + - + eventFeijoaManager.AddProcessor(NewEventFeijoaSequenceBlobsProcessor(feijoaContracts))
    - 18 + + 321 +
    - + - "github.com/ethereum/go-ethereum/crypto" + - + client.eventFeijoaManager = eventFeijoaManager
    - 19 + + 322 +
    - + - "github.com/ethereum/go-ethereum/ethclient" + - + }
    - 20 + + 323 +
    - + - "golang.org/x/net/context" + - + return client, nil
    - 21 + + 324 +
    - + - ) +   + }
    - 22 + + 325 +
    - + +  
    - 23 + + 326 +
    - + - const unexpectedHashTemplate = "missmatch on transaction data. Expected hash %s, actual hash: %s" +   + // VerifyGenBlockNumber verifies if the genesis Block Number is valid
    - 24 + + 327 +
    - + +   + func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { +
    +
    + + +
    +  
    - 25 + + 328 +
    - + - // DataCommitteeMember represents a member of the Data Committee +   + start := time.Now()
    - 26 + + 329 +
    - + - type DataCommitteeMember struct { +   + log.Info("Verifying genesis blockNumber: ", genBlockNumber)
    - 27 + + 330 +
    - + - Addr common.Address +   + // Filter query
    - 28 + +
    @@ -342,11 +330,11 @@
    +
    + 342 +
    - + - URL string +   + if len(logs) == 0 {
    - 29 + + 343 +
    - + - } +   + return false, fmt.Errorf("the specified genBlockNumber in config file does not contain any forkID event. Please use the proper blockNumber.")
    - 30 + + 344 +
    - + -
    +   + }
    - 31 + + 345 +
    - + - // DataCommittee represents a specific committee + - + var zkevmVersion preetrogpolygonzkevm.PreetrogpolygonzkevmUpdateZkEVMVersion
    - 32 + + 346 +
    - + - type DataCommittee struct { +   + switch logs[0].Topics[0] {
    - 33 + + 347 +
    - + - AddressesHash common.Hash +   + case updateZkEVMVersionSignatureHash:
    - 34 + + 348 +
    - + - Members []DataCommitteeMember +   + log.Debug("UpdateZkEVMVersion event detected during the Verification of the GenBlockNumber")
    - 35 + + 349 +
    - + - RequiredSignatures uint64 + - + zkevmV, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(logs[0])
    - 36 + + 350 +
    - + - } +   + if err != nil {
    - 37 + + 351 +
    - + -
    +   + return false, err
    - 38 + + 352 +
    - + - // DataCommitteeBackend implements the DAC integration +   + }
    - 39 + +
    @@ -355,12 +343,12 @@
    +
    + 355 +
    - + - type DataCommitteeBackend struct { +   + }
    - 40 + + 356 +
    - + - dataCommitteeContract *polygondatacommittee.Polygondatacommittee +   + case createNewRollupSignatureHash:
    - 41 + + 357 +
    - + - privKey *ecdsa.PrivateKey +   + log.Debug("CreateNewRollup event detected during the Verification of the GenBlockNumber")
    - 42 + + 358 +
    - + - dataCommitteeClientFactory client.Factory + - + createNewRollupEvent, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(logs[0])
    - 43 + + 359 +
    - + -
    +   + if err != nil {
    - 44 + + 360 +
    - + - committeeMembers []DataCommitteeMember +   + return false, err
    - 45 + + 361 +
    - + - selectedCommitteeMember int +   + }
    - 46 + + 362 +
    - + - ctx context.Context +   + // Query to get the forkID
    - 47 + + 363 +
    - + - } + - + rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID)
    - 48 + + 364 +
    - + -
    +   + if err != nil {
    - 49 + + 365 +
    - + - // New creates an instance of DataCommitteeBackend +   + log.Error(err)
    - 50 + + 366 +
    - + - func New( +   + return false, err
    - 51 + +
    @@ -375,36 +363,16 @@
    +
    + 375 +
    - + - l1RPCURL string, +   + return true, nil
    - 52 + + 376 +
    - + - dataCommitteeAddr common.Address, +   + }
    - 53 + + 377 +
    - + - privKey *ecdsa.PrivateKey, +   +
    - 54 + + 378 +
    - + - dataCommitteeClientFactory client.Factory, + - + // GetL1BlockUpgradeLxLy It returns the block genesis for LxLy before genesisBlock or error
    - 55 + + 379 +
    - + - ) (*DataCommitteeBackend, error) { + - + // TODO: Check if all RPC providers support this range of blocks
    - 56 + + 380 +
    - + - ethClient, err := ethclient.Dial(l1RPCURL) + - + func (etherMan *Client) GetL1BlockUpgradeLxLy(ctx context.Context, genesisBlock uint64) (uint64, error) {
    - 57 + + 381 +
    - + - if err != nil { + - + it, err := etherMan.EtrogRollupManager.FilterInitialized(&bind.FilterOpts{
    - 58 + + 382 +
    - + - log.Errorf("error connecting to %s: %+v", l1RPCURL, err) + - + Start: 1,
    - 59 + + 383 +
    - + - return nil, err + - + End: &genesisBlock,
    - 60 + + 384 +
    - + - } + - + Context: ctx,
    - 61 + + 385 +
    - + - dataCommittee, err := polygondatacommittee.NewPolygondatacommittee(dataCommitteeAddr, ethClient) + - + })
    - 62 + + 386 +
    - + + - if err != nil {
    - 63 + + 387 +
    - + - return nil, err + - + return uint64(0), err
    - 64 + + 388 +
    - + + - }
    - 65 + + 389 +
    - + - return &DataCommitteeBackend{ + - + for it.Next() {
    - 66 + + 390 +
    - + - dataCommitteeContract: dataCommittee, + - + log.Debugf("BlockNumber: %d Topics:Initialized(%d)", it.Event.Raw.BlockNumber, it.Event.Version)
    - 67 + + 391 +
    - + - privKey: privKey, + - + if it.Event.Version == ETrogUpgradeVersion { // 2 is ETROG (LxLy upgrade)
    - 68 + + 392 +
    - + - dataCommitteeClientFactory: dataCommitteeClientFactory, + - + log.Infof("LxLy upgrade found at blockNumber: %d", it.Event.Raw.BlockNumber)
    - 69 + + 393 +
    - + - ctx: context.Background(), + - + return it.Event.Raw.BlockNumber, nil
    - 70 + + 394 +
    - + - }, nil + - + }
    - 71 + + 395 +
    - + - } + - + }
    - 72 + + 396 +
    - + -
    + - + return uint64(0), ErrNotFound
    - 73 + + 397 +
    - + - // Init loads the DAC to be cached when needed + - + }
    - 74 + + 398 +
    - + - func (d *DataCommitteeBackend) Init() error { + - +
    - 75 + + 399 +
    - + - committee, err := d.getCurrentDataCommittee() +   + // GetForks returns fork information
    - 76 + + 400 +
    - + - if err != nil { +   + func (etherMan *Client) GetForks(ctx context.Context, genBlockNumber uint64, lastL1BlockSynced uint64) ([]state.ForkIDInterval, error) {
    - 77 + + 401 +
    - + - return err +   + log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
    - 78 + + 402 +
    - + - } +   + start := time.Now()
    - 79 + + 403 +
    - + - selectedCommitteeMember := -1 +   + var logs []types.Log
    - 80 + + 404 +
    - + - if committee != nil { + - + // At minimum it checks the GenesisBlock
    - 81 + + 405 +
    - + - d.committeeMembers = committee.Members +   + if lastL1BlockSynced < genBlockNumber {
    - 82 + + 406 +
    - + - if len(committee.Members) > 0 { +   + lastL1BlockSynced = genBlockNumber
    - 83 + + 407 +
    - + - selectedCommitteeMember = rand.Intn(len(committee.Members)) //nolint:gosec +   + }
    - 84 + + -
    - + - } +
    +
    +   +
    - 85 + + 408 +
    - + - } +   + log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
    - 86 + + 409 +
    - + - d.selectedCommitteeMember = selectedCommitteeMember +   + for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
    - 87 + + 410 +
    - + - return nil +   + final := i + etherMan.cfg.ForkIDChunkSize
    - 88 + +
    @@ -429,11 +397,11 @@
    +
    + 429 +
    - + - } +   +
    - 89 + + 430 +
    - + -
    +   + var forks []state.ForkIDInterval
    - 90 + + 431 +
    - + - // GetSequence gets backend data one hash at a time. This should be optimized on the DAC side to get them all at once. +   + for i, l := range logs {
    - 91 + + 432 +
    - + - func (d *DataCommitteeBackend) GetSequence(ctx context.Context, hashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) { + - + var zkevmVersion preetrogpolygonzkevm.PreetrogpolygonzkevmUpdateZkEVMVersion
    - 92 + + 433 +
    - + - // TODO: optimize this on the DAC side by implementing a multi batch retrieve api +   + switch l.Topics[0] {
    - 93 + + 434 +
    - + - var batchData [][]byte +   + case updateZkEVMVersionSignatureHash:
    - 94 + + 435 +
    - + - for _, h := range hashes { +   + log.Debug("updateZkEVMVersion Event received")
    - 95 + + 436 +
    - + - data, err := d.GetBatchL2Data(h) + - + zkevmV, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(l)
    - 96 + + 437 +
    - + - if err != nil { +   + if err != nil {
    - 97 + + 438 +
    - + - return nil, err +   + return []state.ForkIDInterval{}, err
    - 98 + + 439 +
    - + - } +   + }
    - 99 + +
    @@ -442,7 +410,7 @@
    +
    + 442 +
    - + - batchData = append(batchData, data) +   + }
    - 100 + + 443 +
    - + - } +   + case updateRollupSignatureHash:
    - 101 + + 444 +
    - + - return batchData, nil +   + log.Debug("updateRollup Event received")
    - 102 + + 445 +
    - + - } + - + updateRollupEvent, err := etherMan.EtrogRollupManager.ParseUpdateRollup(l)
    - 103 + + 446 +
    - + -
    +   + if err != nil {
    - 104 + + 447 +
    - + - // GetBatchL2Data returns the data from the DAC. It checks that it matches with the expected hash +   + return []state.ForkIDInterval{}, err
    - 105 + + 448 +
    - + - func (d *DataCommitteeBackend) GetBatchL2Data(hash common.Hash) ([]byte, error) { +   + }
    - 106 + +
    @@ -450,7 +418,7 @@
    +
    + 450 +
    - + - intialMember := d.selectedCommitteeMember +   + continue
    - 107 + + 451 +
    - + - found := false +   + }
    - 108 + + 452 +
    - + - for !found && intialMember != -1 { +   + // Query to get the forkID
    - 109 + + 453 +
    - + - member := d.committeeMembers[d.selectedCommitteeMember] + - + rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollupEvent.NewRollupTypeID)
    - 110 + + 454 +
    - + - log.Infof("trying to get data from %s at %s", member.Addr.Hex(), member.URL) +   + if err != nil {
    - 111 + + 455 +
    - + - c := d.dataCommitteeClientFactory.New(member.URL) +   + return []state.ForkIDInterval{}, err
    - 112 + + 456 +
    - + - data, err := c.GetOffChainData(d.ctx, hash) +   + }
    - 113 + +
    @@ -459,7 +427,7 @@
    +
    + 459 +
    - + - if err != nil { +   +
    - 114 + + 460 +
    - + - log.Warnf( +   + case addExistingRollupSignatureHash:
    - 115 + + 461 +
    - + - "error getting data from DAC node %s at %s: %s", +   + log.Debug("addExistingRollup Event received")
    - 116 + + 462 +
    - + - member.Addr.Hex(), member.URL, err, + - + addExistingRollupEvent, err := etherMan.EtrogRollupManager.ParseAddExistingRollup(l)
    - 117 + + 463 +
    - + - ) +   + if err != nil {
    - 118 + + 464 +
    - + - d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers) +   + return []state.ForkIDInterval{}, err
    - 119 + + 465 +
    - + - if d.selectedCommitteeMember == intialMember { +   + }
    - 120 + +
    @@ -471,7 +439,7 @@
    +
    + 471 +
    - + - break +   +
    - 121 + + 472 +
    - + - } +   + case createNewRollupSignatureHash:
    - 122 + + 473 +
    - + - continue +   + log.Debug("createNewRollup Event received")
    - 123 + + 474 +
    - + - } + - + createNewRollupEvent, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(l)
    - 124 + + 475 +
    - + - actualTransactionsHash := crypto.Keccak256Hash(data) +   + if err != nil {
    - 125 + + 476 +
    - + - if actualTransactionsHash != hash { +   + return []state.ForkIDInterval{}, err
    - 126 + + 477 +
    - + - unexpectedHash := fmt.Errorf( +   + }
    - 127 + +
    @@ -479,7 +447,7 @@
    +
    + 479 +
    - + - unexpectedHashTemplate, hash, actualTransactionsHash, +   + continue
    - 128 + + 480 +
    - + - ) +   + }
    - 129 + + 481 +
    - + - log.Warnf( +   + // Query to get the forkID
    - 130 + + 482 +
    - + - "error getting data from DAC node %s at %s: %s", + - + rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID)
    - 131 + + 483 +
    - + - member.Addr.Hex(), member.URL, unexpectedHash, +   + if err != nil {
    - 132 + + 484 +
    - + - ) +   + log.Error(err)
    - 133 + + 485 +
    - + - d.selectedCommitteeMember = (d.selectedCommitteeMember + 1) % len(d.committeeMembers) +   + return []state.ForkIDInterval{}, err
    - 134 + +
    @@ -531,25 +499,6 @@
    +
    + 531 +
    - + - if d.selectedCommitteeMember == intialMember { +   + return blocks, blocksOrder, nil
    - 135 + + 532 +
    - + - break +   + }
    - 136 + + 533 +
    - + - } +   +
    - 137 + + 534 +
    - + - continue + - + // GetRollupInfoByBlockRangePreviousRollupGenesis function retrieves the Rollup information that are included in all this ethereum blocks
    - 138 + + 535 +
    - + - } + - + // but it only retrieves the information from the previous rollup genesis block to the current block.
    - 139 + + 536 +
    - + - return data, nil + - + func (etherMan *Client) GetRollupInfoByBlockRangePreviousRollupGenesis(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]Block, map[common.Hash][]Order, error) {
    - 140 + + 537 +
    - + - } + - + // Filter query
    - 141 + + 538 +
    - + - if err := d.Init(); err != nil { + - + query := ethereum.FilterQuery{
    - 142 + + 539 +
    - + - return nil, fmt.Errorf("error loading data committee: %s", err) + - + FromBlock: new(big.Int).SetUint64(fromBlock),
    - 143 + + 540 +
    - + - } + - + Addresses: []common.Address{etherMan.l1Cfg.GlobalExitRootManagerAddr},
    - 144 + + 541 +
    - + - return nil, fmt.Errorf("couldn't get the data from any committee member") + - + Topics: [][]common.Hash{{updateL1InfoTreeSignatureHash}},
    - 145 + + 542 +
    - + - } + - + }
    - 146 + + 543 +
    - + -
    + - + if toBlock != nil {
    - 147 + + 544 +
    - + - type signatureMsg struct { + - + query.ToBlock = new(big.Int).SetUint64(*toBlock)
    - 148 + + 545 +
    - + - addr common.Address + - + }
    - 149 + + 546 +
    - + - signature []byte + - + blocks, blocksOrder, err := etherMan.readEvents(ctx, query)
    - 150 + + 547 +
    - + - err error + - + if err != nil {
    - 151 + + 548 +
    - + - } + - + return nil, nil, err
    - 152 + + 549 +
    - + -
    + - + }
    - 153 + + 550 +
    - + - // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage + - + return blocks, blocksOrder, nil
    - 154 + + 551 +
    - + - // as expected by the contract + - + }
    - 155 + + 552 +
    - + - func (s *DataCommitteeBackend) PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) { + - +
    - 156 + + 553 +
    - + - // Get current committee +   + // Order contains the event order to let the synchronizer store the information following this order.
    - 157 + + 554 +
    - + - committee, err := s.getCurrentDataCommittee() +   + type Order struct {
    - 158 + + 555 +
    - + - if err != nil { +   + Name EventOrder
    - 159 + +
    @@ -580,17 +529,8 @@
    +
    + 580 +
    - + - return nil, err +   + metrics.ReadAndProcessAllEventsTime(time.Since(start))
    - 160 + + 581 +
    - + - } +   + return blocks, blocksOrder, nil
    - 161 + + 582 +
    - + -
    +   + }
    - 162 + + 583 +
    - + - // Authenticate as trusted sequencer by signing the sequences + - + func (etherMan *Client) processEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 163 + + 584 +
    - + - sequence := daTypes.Sequence{} + - + if etherMan.eventFeijoaManager != nil {
    - 164 + + 585 +
    - + - for _, seq := range batchesData { + - + processed, err := etherMan.eventFeijoaManager.ProcessEvent(ctx, vLog, blocks, blocksOrder)
    - 165 + + 586 +
    - + - sequence = append(sequence, seq) + - + if processed || err != nil {
    - 166 + + 587 +
    - + - } + - + return err
    - 167 + + 588 +
    - + - signedSequence, err := sequence.Sign(s.privKey) + - + }
    - 168 + + 589 +
    - + - if err != nil { + - + }
    - 169 + + 590 +
    - + - return nil, err + - + return etherMan.processEventLegacy(ctx, vLog, blocks, blocksOrder)
    - 170 + + 591 +
    - + - } + - + }
    - 171 + + 592 +
    - + +  
    - 172 + + 593 +
    - + - // Request signatures to all members in parallel + - + func (etherMan *Client) processEventLegacy(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 173 + + 594 +
    - + - ch := make(chan signatureMsg, len(committee.Members)) +   + switch vLog.Topics[0] {
    - 174 + + 595 +
    - + - signatureCtx, cancelSignatureCollection := context.WithCancel(ctx) +   + case sequenceBatchesSignatureHash:
    - 175 + + 596 +
    - + - for _, member := range committee.Members { +   + return etherMan.sequencedBatchesEvent(ctx, vLog, blocks, blocksOrder)
    - 176 + +
    @@ -612,8 +552,8 @@
    +
    + 612 +
    - + - go requestSignatureFromMember(signatureCtx, *signedSequence, member, ch) +   + case rollupManagerVerifyBatchesSignatureHash:
    - 177 + + 613 +
    - + - } +   + log.Debug("RollupManagerVerifyBatches event detected. Ignoring...")
    - 178 + + 614 +
    - + -
    +   + return nil
    - 179 + + 615 +
    - + - // Collect signatures + - + case preEtrogVerifyBatchesTrustedAggregatorSignatureHash:
    - 180 + + 616 +
    - + - msgs := []signatureMsg{} + - + return etherMan.preEtrogVerifyBatchesTrustedAggregatorEvent(ctx, vLog, blocks, blocksOrder)
    - 181 + + 617 +
    - + - var ( +   + case verifyBatchesSignatureHash:
    - 182 + + 618 +
    - + - collectedSignatures uint64 +   + return etherMan.verifyBatchesEvent(ctx, vLog, blocks, blocksOrder)
    - 183 + + 619 +
    - + - failedToCollect uint64 +   + case sequenceForceBatchesSignatureHash:
    - 184 + +
    @@ -653,8 +593,8 @@
    +
    + 653 +
    - + - ) +   + case consolidatePendingStateSignatureHash:
    - 185 + + 654 +
    - + - for collectedSignatures < committee.RequiredSignatures { +   + log.Debug("ConsolidatePendingState event detected. Ignoring...")
    - 186 + + 655 +
    - + - msg := <-ch +   + return nil
    - 187 + + 656 +
    - + - if msg.err != nil { + - + case preEtrogConsolidatePendingStateSignatureHash:
    - 188 + + 657 +
    - + - log.Errorf("error when trying to get signature from %s: %s", msg.addr, msg.err) + - + log.Debug("PreEtrogConsolidatePendingState event detected. Ignoring...")
    - 189 + + 658 +
    - + - failedToCollect++ +   + return nil
    - 190 + + 659 +
    - + - if len(committee.Members)-int(failedToCollect) < int(committee.RequiredSignatures) { +   + case setTrustedAggregatorTimeoutSignatureHash:
    - 191 + + 660 +
    - + - cancelSignatureCollection() +   + log.Debug("SetTrustedAggregatorTimeout event detected. Ignoring...")
    - 192 + +
    @@ -689,8 +629,8 @@
    +
    + 689 +
    - + - return nil, errors.New("too many members failed to send their signature") +   + case overridePendingStateSignatureHash:
    - 193 + + 690 +
    - + - } +   + log.Debug("OverridePendingState event detected. Ignoring...")
    - 194 + + 691 +
    - + - } else { +   + return nil
    - 195 + + 692 +
    - + - log.Infof("received signature from %s", msg.addr) + - + case preEtrogOverridePendingStateSignatureHash:
    - 196 + + 693 +
    - + - collectedSignatures++ + - + log.Debug("PreEtrogOverridePendingState event detected. Ignoring...")
    - 197 + + 694 +
    - + - } +   + return nil
    - 198 + + 695 +
    - + - msgs = append(msgs, msg) +   + case roleAdminChangedSignatureHash:
    - 199 + + 696 +
    - + - } +   + log.Debug("RoleAdminChanged event detected. Ignoring...")
    - 200 + +
    @@ -726,7 +666,7 @@
    +
    + 726 +
    - + +  
    - 201 + + 727 +
    - + - // Stop requesting as soon as we have N valid signatures +   + func (etherMan *Client) updateZkevmVersion(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 202 + + 728 +
    - + - cancelSignatureCollection() +   + log.Debug("UpdateZkEVMVersion event detected")
    - 203 + + 729 +
    - + -
    + - + zkevmVersion, err := etherMan.PreEtrogZkEVM.ParseUpdateZkEVMVersion(vLog)
    - 204 + + 730 +
    - + - return buildSignaturesAndAddrs(signatureMsgs(msgs), committee.Members), nil +   + if err != nil {
    - 205 + + 731 +
    - + - } +   + log.Error("error parsing UpdateZkEVMVersion event. Error: ", err)
    - 206 + + 732 +
    - + -
    +   + return err
    - 207 - -
    - + - func requestSignatureFromMember(ctx context.Context, signedSequence daTypes.SignedSequence, member DataCommitteeMember, ch chan signatureMsg) { -
    +
    +
    @@ -736,12 +676,12 @@
    - 208 + + 736 +
    - + - // request +   +
    - 209 + + 737 +
    - + - c := client.New(member.URL) +   + func (etherMan *Client) updateRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 210 + + 738 +
    - + - log.Infof("sending request to sign the sequence to %s at %s", member.Addr.Hex(), member.URL) +   + log.Debug("UpdateRollup event detected")
    - 211 + + 739 +
    - + - signature, err := c.SignSequence(signedSequence) + - + updateRollup, err := etherMan.EtrogRollupManager.ParseUpdateRollup(vLog)
    - 212 + + 740 +
    - + +   if err != nil {
    - 213 + + 741 +
    - + - ch <- signatureMsg{ +   + log.Error("error parsing UpdateRollup event. Error: ", err)
    - 214 + + 742 +
    - + - addr: member.Addr, +   + return err
    - 215 + + 743 +
    - + - err: err, +   + }
    - 216 + + 744 +
    - + - } + - + rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollup.NewRollupTypeID)
    - 217 + + 745 +
    - + - return +   + if err != nil {
    - 218 + + 746 +
    - + - } +   + return err
    - 219 + + 747 +
    - + - // verify returned signature +   + }
    - 220 - -
    - + - signedSequence.Signature = signature -
    +
    +
    @@ -750,12 +690,12 @@
    - 221 + + 750 +
    - + - signer, err := signedSequence.Signer() +   +
    - 222 + + 751 +
    - + - if err != nil { +   + func (etherMan *Client) createNewRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 223 + + 752 +
    - + - ch <- signatureMsg{ +   + log.Debug("createNewRollup event detected")
    - 224 + + 753 +
    - + - addr: member.Addr, + - + createRollup, err := etherMan.EtrogRollupManager.ParseCreateNewRollup(vLog)
    - 225 + + 754 +
    - + - err: err, +   + if err != nil {
    - 226 + + 755 +
    - + - } +   + log.Error("error parsing createNewRollup event. Error: ", err)
    - 227 + + 756 +
    - + - return +   + return err
    - 228 + + 757 +
    - + +   }
    - 229 + + 758 +
    - + - if signer != member.Addr { + - + rollupType, err := etherMan.EtrogRollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createRollup.RollupTypeID)
    - 230 + + 759 +
    - + - ch <- signatureMsg{ +   + if err != nil {
    - 231 + + 760 +
    - + - addr: member.Addr, +   + return err
    - 232 + + 761 +
    - + - err: fmt.Errorf("invalid signer. Expected %s, actual %s", member.Addr.Hex(), signer.Hex()), +   + }
    - 233 - -
    - + - } -
    +
    +
    @@ -764,7 +704,7 @@
    - 234 + + 764 +
    - + - return +   +
    - 235 + + 765 +
    - + - } +   + func (etherMan *Client) addExistingRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 236 + + 766 +
    - + - ch <- signatureMsg{ +   + log.Debug("addExistingRollup event detected")
    - 237 + + 767 +
    - + - addr: member.Addr, + - + addExistingRollup, err := etherMan.EtrogRollupManager.ParseAddExistingRollup(vLog)
    - 238 + + 768 +
    - + - signature: signature, +   + if err != nil {
    - 239 + + 769 +
    - + - } +   + log.Error("error parsing createNewRollup event. Error: ", err)
    - 240 + + 770 +
    - + - } +   + return err
    - 241 + +
    @@ -773,66 +713,13 @@
    +
    + 773 +
    - + -
    +   + return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
    - 242 + + 774 +
    - + - func buildSignaturesAndAddrs(sigs signatureMsgs, members []DataCommitteeMember) []byte { +   + }
    - 243 + + 775 +
    - + - const ( +   +
    - 244 + + 776 +
    - + - sigLen = 65 + - + func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 245 + + 777 +
    - + - addrLen = 20 + - + log.Debug("updateEtrogSequence event detected")
    - 246 + + 778 +
    - + - ) + - + updateEtrogSequence, err := etherMan.ElderberryZKEVM.ParseUpdateEtrogSequence(vLog)
    - 247 + + 779 +
    - + - res := make([]byte, 0, len(sigs)*sigLen+len(members)*addrLen) + - + if err != nil {
    - 248 + + 780 +
    - + - sort.Sort(sigs) + - + log.Error("error parsing updateEtrogSequence event. Error: ", err)
    - 249 + + 781 +
    - + - for _, msg := range sigs { + - + return err
    - 250 + + 782 +
    - + - log.Debugf("adding signature %s from %s", common.Bytes2Hex(msg.signature), msg.addr.Hex()) + - + }
    - 251 + + 783 +
    - + - res = append(res, msg.signature...) + - +
    - 252 + + 784 +
    - + - } + - + // Read the tx for this event.
    - 253 + + 785 +
    - + - for _, member := range members { + - + tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex)
    - 254 + + 786 +
    - + - log.Debugf("adding addr %s", common.Bytes2Hex(member.Addr.Bytes())) + - + if err != nil {
    - 255 + + 787 +
    - + - res = append(res, member.Addr.Bytes()...) + - + return err
    - 256 + + 788 +
    - + + - }
    - 257 + + 789 +
    - + - log.Debugf("full res %s", common.Bytes2Hex(res)) + - + if tx.Hash() != vLog.TxHash {
    - 258 + + 790 +
    - + - return res + - + return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String())
    - 259 + + 791 +
    - + - } + - + }
    - 260 + + 792 +
    - + -
    + - + msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0))
    - 261 + + 793 +
    - + - type signatureMsgs []signatureMsg + - + if err != nil {
    - 262 + + 794 +
    - + -
    + - + return err
    - 263 + + 795 +
    - + - func (s signatureMsgs) Len() int { return len(s) } + - + }
    - 264 + + 796 +
    - + - func (s signatureMsgs) Less(i, j int) bool { + - + fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash)
    - 265 + + 797 +
    - + - return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex()) + - + if err != nil {
    - 266 + + 798 +
    - + - } + - + return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err)
    - 267 + + 799 +
    - + - func (s signatureMsgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + - + }
    - 268 + + 800 +
    - + + -
    - 269 + + 801 +
    - + - // getCurrentDataCommittee return the currently registered data committee + - + log.Info("update Etrog transaction sequence...")
    - 270 + + 802 +
    - + - func (d *DataCommitteeBackend) getCurrentDataCommittee() (*DataCommittee, error) { + - + sequence := UpdateEtrogSequence{
    - 271 + + 803 +
    - + - addrsHash, err := d.dataCommitteeContract.CommitteeHash(&bind.CallOpts{Pending: false}) + - + BatchNumber: updateEtrogSequence.NumBatch,
    - 272 + + 804 +
    - + - if err != nil { + - + SequencerAddr: updateEtrogSequence.Sequencer,
    - 273 + + 805 +
    - + - return nil, fmt.Errorf("error getting CommitteeHash from L1 SC: %w", err) + - + TxHash: vLog.TxHash,
    - 274 + + 806 +
    - + - } + - + Nonce: msg.Nonce,
    - 275 + + 807 +
    - + - reqSign, err := d.dataCommitteeContract.RequiredAmountOfSignatures(&bind.CallOpts{Pending: false}) + - + PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 276 + + 808 +
    - + - if err != nil { + - + Transactions: updateEtrogSequence.Transactions,
    - 277 + + 809 +
    - + - return nil, fmt.Errorf("error getting RequiredAmountOfSignatures from L1 SC: %w", err) + - + ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot,
    - 278 + + 810 +
    - + - } + - + ForcedTimestamp: fullBlock.Time(),
    - 279 + + 811 +
    - + - members, err := d.getCurrentDataCommitteeMembers() + - + ForcedBlockHashL1: fullBlock.ParentHash(),
    - 280 + + 812 +
    - + - if err != nil { + - + },
    - 281 + + 813 +
    - + - return nil, err + - + }
    - 282 + + 814 +
    - + - } + - +
    - 283 + + 815 +
    - + -
    + - + if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) {
    - 284 + + 816 +
    - + - return &DataCommittee{ + - + block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock)
    - 285 + + 817 +
    - + - AddressesHash: common.Hash(addrsHash), + - + block.UpdateEtrogSequence = sequence
    - 286 + + 818 +
    - + - RequiredSignatures: reqSign.Uint64(), + - + *blocks = append(*blocks, block)
    - 287 + + 819 +
    - + - Members: members, + - + } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber {
    - 288 + + 820 +
    - + - }, nil + - + (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence
    - 289 + + 821 +
    - + - } + - + } else {
    - 290 + + 822 +
    - + -
    + - + log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber)
    - 291 + + 823 +
    - + - // getCurrentDataCommitteeMembers return the currently registered data committee members + - + return fmt.Errorf("error processing UpdateEtrogSequence event")
    - 292 + + 824 +
    - + - func (d *DataCommitteeBackend) getCurrentDataCommitteeMembers() ([]DataCommitteeMember, error) { + - + }
    - 293 + + 825 +
    - + - nMembers, err := d.dataCommitteeContract.GetAmountOfMembers(&bind.CallOpts{Pending: false}) + - + or := Order{
    - 294 + + 826 +
    - + - if err != nil { + - + Name: UpdateEtrogSequenceOrder,
    - 295 + + 827 +
    - + - return nil, fmt.Errorf("error getting GetAmountOfMembers from L1 SC: %w", err) + - + Pos: 0,
    - 296 + + 828 +
    - + + - }
    - 297 + + 829 +
    - + - members := make([]DataCommitteeMember, 0, nMembers.Int64()) + - + (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or)
    - 298 + + 830 +
    - + - for i := int64(0); i < nMembers.Int64(); i++ { + - + return nil
    - 299 + + 831 +
    - + - member, err := d.dataCommitteeContract.Members(&bind.CallOpts{Pending: false}, big.NewInt(i)) +   + }
    - 300 + + 832 +
    - + - if err != nil { +   +
    - 301 + + 833 +
    - + - return nil, fmt.Errorf("error getting Members %d from L1 SC: %w", i, err) +   + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 302 + + 834 +
    - + - } +   + log.Debug("initialSequenceBatches event detected")
    - 303 + + 835 +
    - + - members = append(members, DataCommitteeMember{ + - + initialSequenceBatches, err := etherMan.EtrogZkEVM.ParseInitialSequenceBatches(vLog)
    - 304 + + 836 +
    - + - Addr: member.Addr, +   + if err != nil {
    - 305 + + 837 +
    - + - URL: member.Url, +   + log.Error("error parsing initialSequenceBatches event. Error: ", err)
    - 306 + + 838 +
    - + - }) +   + return err
    - 307 + +
    @@ -862,7 +749,7 @@
    +
    + 862 +
    - + - } +   + SequencerAddr: initialSequenceBatches.Sequencer,
    - 308 + + 863 +
    - + - return members, nil +   + TxHash: vLog.TxHash,
    - 309 + + 864 +
    - + - } +   + Nonce: msg.Nonce,
    -
    + + + 865 + + +
    + - + PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/datacommittee/datacommittee_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,131 @@
    - + + 866 -
    +
    +
      -
    + Transactions: initialSequenceBatches.Transactions,
    - + + 867 -
    +
    +
      -
    + ForcedGlobalExitRoot: initialSequenceBatches.LastGlobalExitRoot,
    - + + 868 -
    +
    +
      -
    + ForcedTimestamp: fullBlock.Time(),
    - + +
    @@ -922,20 +809,20 @@
    -
    +
    + 922 + +
     
    - + + 923 -
    +
    +
      -
    + func (etherMan *Client) updateL1InfoTreeEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 924 -
    +
    +
      -
    + log.Debug("UpdateL1InfoTree event detected")
    - + + 925 -
    -   -
    +
    +
    + - + etrogGlobalExitRootL1InfoTree, err := etherMan.EtrogGlobalExitRootManager.ParseUpdateL1InfoTree(vLog)
    - + + 926 -
    +
    +
      -
    + if err != nil {
    - + + 927 -
    +
    +
      -
    + return err
    - + + 928 -
    +
    +
      -
    + }
    - + + 929 -
    +
    +
     
    - + + 930 -
    +
    +
      -
    + var gExitRoot GlobalExitRoot
    - + + 931 -
    -   -
    +
    +
    + - + gExitRoot.MainnetExitRoot = etrogGlobalExitRootL1InfoTree.MainnetExitRoot
    - + + 932 -
    -   -
    +
    +
    + - + gExitRoot.RollupExitRoot = etrogGlobalExitRootL1InfoTree.RollupExitRoot
    - + + 933 -
    +
    +
      -
    + gExitRoot.BlockNumber = vLog.BlockNumber
    - + + 934 -
    -   -
    +
    +
    + - + gExitRoot.GlobalExitRoot = hash(etrogGlobalExitRootL1InfoTree.MainnetExitRoot, etrogGlobalExitRootL1InfoTree.RollupExitRoot)
    - + + 935 -
    +
    +
      -
    + var block *Block
    - + + 936 -
    +
    +
      -
    + if !isheadBlockInArray(blocks, vLog.BlockHash, vLog.BlockNumber) {
    - + + 937 -
    +
    +
      -
    + // Need to add the block, doesnt mind if inside the blocks because I have to respect the order so insert at end
    - + + 938 -
    -   -
    +
    +
    + - + block, err = etherMan.RetrieveFullBlockForEvent(ctx, vLog)
    - + + 939 -
    +
    +
      -
    + if err != nil {
    - + + 940 -
    +
    +
      -
    + return err
    - + + 941 -
    +
    +
      -
    + }
    - + +
    @@ -955,8 +842,7 @@
    -
    +
    + 955 + +
      -
    + return nil
    - + + 956 -
    +
    +
      -
    + }
    - + + 957 -
    +
    +
     
    - + + 958 -
    -   -
    +
    +
    + - + // RetrieveFullBlockForEvent retrieves the full block for a given event
    - + + 959 -
    -   -
    +
    +
    + - + func (etherMan *Client) RetrieveFullBlockForEvent(ctx context.Context, vLog types.Log) (*Block, error) {
    - + + 960 -
    +
    +
      -
    + fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash)
    - + + 961 -
    +
    +
      -
    + if err != nil {
    - + + 962 -
    +
    +
      -
    + return nil, fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %w", vLog.BlockNumber, err)
    - + +
    @@ -975,11 +861,11 @@
    -
    +
    + 975 + +
     
    - + + 976 -
    +
    +
      -
    + func (etherMan *Client) updateGlobalExitRootEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 977 -
    +
    +
      -
    + log.Debug("UpdateGlobalExitRoot event detected")
    - + + 978 -
    -   -
    +
    +
    + - + preEtrogGlobalExitRoot, err := etherMan.PreEtrogGlobalExitRootManager.ParseUpdateGlobalExitRoot(vLog)
    - + + 979 -
    +
    +
      -
    + if err != nil {
    - + + 980 -
    +
    +
      -
    + return err
    - + + 981 -
    +
    +
      -
    + }
    - + + 982 -
    -   -
    +
    +
    + - + return etherMan.processUpdateGlobalExitRootEvent(ctx, preEtrogGlobalExitRoot.MainnetExitRoot, preEtrogGlobalExitRoot.RollupExitRoot, vLog, blocks, blocksOrder)
    - + + 983 -
    +
    +
      -
    + }
    - + + 984 -
    +
    +
     
    - + + 985 -
    +
    +
      -
    + func (etherMan *Client) processUpdateGlobalExitRootEvent(ctx context.Context, mainnetExitRoot, rollupExitRoot common.Hash, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + +
    @@ -1027,14 +913,14 @@
    -
    +
    + 1027 + +
      -
    + }
    - + + 1028 -
    +
    +
     
    - + + 1029 -
    +
    +
      -
    + // EstimateGasSequenceBatches estimates gas for sending batches
    - + + 1030 -
    -   -
    +
    +
    + - + func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
    - + + 1031 -
    +
    +
      -
    + opts, err := etherMan.getAuthByAddress(sender)
    - + + 1032 -
    +
    +
      -
    + if err == ErrNotFound {
    - + + 1033 -
    +
    +
      -
    + return nil, ErrPrivateKeyNotFound
    - + + 1034 -
    +
    +
      -
    + }
    - + + 1035 -
    +
    +
      -
    + opts.NoSend = true
    - + + 1036 -
    +
    +
     
    - + + 1037 -
    -   -
    +
    +
    + - + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - + + 1038 -
    +
    +
      -
    + if err != nil {
    - + + 1039 -
    +
    +
      -
    + return nil, err
    - + + 1040 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -1043,7 +929,7 @@
    - + + 1043 -
    +
    +
      -
    + }
    - + + 1044 -
    +
    +
     
    - + + 1045 -
    +
    +
      -
    + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - + + 1046 -
    -   -
    +
    +
    + - + func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) {
    - + + 1047 -
    +
    +
      -
    + opts, err := etherMan.getAuthByAddress(sender)
    - + + 1048 -
    +
    +
      -
    + if err == ErrNotFound {
    - + + 1049 -
    +
    +
      -
    + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    - + +
    @@ -1054,7 +940,7 @@
    -
    +
    + 1054 + +
      -
    + opts.GasLimit = uint64(1)
    - + + 1055 -
    +
    +
      -
    + opts.GasPrice = big.NewInt(1)
    - + + 1056 -
    +
    +
     
    - + + 1057 -
    -   -
    +
    +
    + - + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - + + 1058 -
    +
    +
      -
    + if err != nil {
    - + + 1059 -
    +
    +
      -
    + return nil, nil, err
    - + + 1060 -
    +
    +
      -
    + }
    - + +
    @@ -1062,15 +948,15 @@
    -
    +
    + 1062 + +
      -
    + return tx.To(), tx.Data(), nil
    - + + 1063 -
    +
    +
      -
    + }
    - + + 1064 -
    +
    +
     
    - + + 1065 -
    -   -
    +
    +
    + - + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) {
    - + + 1066 -
    -   -
    +
    +
    + - + var batches []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - + + 1067 -
    +
    +
      -
    + for _, seq := range sequences {
    - + + 1068 -
    +
    +
      -
    + var ger common.Hash
    - + + 1069 -
    +
    +
      -
    + if seq.ForcedBatchTimestamp > 0 {
    - + + 1070 -
    +
    +
      -
    + ger = seq.GlobalExitRoot
    - + + 1071 -
    +
    +
      -
    + }
    - + + 1072 -
    -   -
    +
    +
    + - + batch := etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 1073 -
    -   -
    +
    +
    + - + Transactions: seq.BatchL2Data,
    - + + 1074 -
    +
    +
      -
    + ForcedGlobalExitRoot: ger,
    - + + 1075 -
    +
    +
      -
    + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - + + 1076 -
    +
    +
      -
    + ForcedBlockHashL1: seq.PrevBlockHash,
    - + +
    @@ -1079,12 +965,12 @@
    -
    +
    + 1079 + +
      -
    + batches = append(batches, batch)
    - + + 1080 -
    +
    +
      -
    + }
    - + + 1081 -
    +
    +
     
    - + + 1082 -
    -   -
    +
    +
    + - + tx, err := etherMan.EtrogZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase)
    - + + 1083 -
    +
    +
      -
    + if err != nil {
    - + + 1084 -
    +
    +
      -
    + log.Debugf("Batches to send: %+v", batches)
    - + + 1085 -
    +
    +
      -
    + log.Debug("l2CoinBase: ", l2Coinbase)
    - + + 1086 -
    +
    +
      -
    + log.Debug("Sequencer address: ", opts.From)
    - + + 1087 -
    -   -
    +
    +
    + - + a, err2 := etrogpolygonzkevm.EtrogpolygonzkevmMetaData.GetAbi()
    - + + 1088 -
    +
    +
      -
    + if err2 != nil {
    - + + 1089 -
    +
    +
      -
    + log.Error("error getting abi. Error: ", err2)
    - + + 1090 -
    +
    +
      -
    + }
    - + +
    @@ -1144,7 +1030,7 @@
    -
    +
    + 1144 + +
     
    - + + 1145 -
    +
    +
      -
    + const pendStateNum = 0 // TODO hardcoded for now until we implement the pending state feature
    - + + 1146 -
    +
    +
     
    - + + 1147 -
    -   -
    +
    +
    + - + tx, err := etherMan.EtrogRollupManager.VerifyBatchesTrustedAggregator(
    - + + 1148 -
    +
    +
      -
    + &opts,
    - + + 1149 -
    +
    +
      -
    + etherMan.RollupID,
    - + + 1150 -
    +
    +
      -
    + pendStateNum,
    - + +
    @@ -1186,7 +1072,7 @@
    -
    +
    + 1186 + +
     
    - + + 1187 -
    +
    +
      -
    + // GetSendSequenceFee get super/trusted sequencer fee
    - + + 1188 -
    +
    +
      -
    + func (etherMan *Client) GetSendSequenceFee(numBatches uint64) (*big.Int, error) {
    - + + 1189 -
    -   -
    +
    +
    + - + f, err := etherMan.EtrogRollupManager.GetBatchFee(&bind.CallOpts{Pending: false})
    - + + 1190 -
    +
    +
      -
    + if err != nil {
    - + + 1191 -
    +
    +
      -
    + return nil, err
    - + + 1192 -
    +
    +
      -
    + }
    - + +
    @@ -1196,12 +1082,12 @@
    -
    +
    + 1196 + +
     
    - + + 1197 -
    +
    +
      -
    + // TrustedSequencer gets trusted sequencer address
    - + + 1198 -
    +
    +
      -
    + func (etherMan *Client) TrustedSequencer() (common.Address, error) {
    - + + 1199 -
    -   -
    +
    +
    + - + return etherMan.EtrogZkEVM.TrustedSequencer(&bind.CallOpts{Pending: false})
    - + + 1200 -
    +
    +
      -
    + }
    - + + 1201 -
    +
    +
     
    - + + 1202 -
    +
    +
      -
    + func (etherMan *Client) forcedBatchEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 1203 -
    +
    +
      -
    + log.Debug("ForceBatch event detected")
    - + + 1204 -
    -   -
    +
    +
    + - + fb, err := etherMan.EtrogZkEVM.ParseForceBatch(vLog)
    - + + 1205 -
    +
    +
      -
    + if err != nil {
    - + + 1206 -
    +
    +
      -
    + return err
    - + + 1207 -
    +
    +
      -
    + }
    - + +
    @@ -1227,7 +1113,7 @@
    -
    +
    + 1227 + +
      -
    + txData := tx.Data()
    - + + 1228 -
    +
    +
      -
    + // Extract coded txs.
    - + + 1229 -
    +
    +
      -
    + // Load contract ABI
    - + + 1230 -
    -   -
    +
    +
    + - + abi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - + + 1231 -
    +
    +
      -
    + if err != nil {
    - + + 1232 -
    +
    +
      -
    + return err
    - + + 1233 -
    +
    +
      -
    + }
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -1276,7 +1162,7 @@
    - 1 + + 1276 +
    - + - package datacommittee +   + func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 2 + + 1277 +
    - + -
    +   + log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:]))
    - 3 + + 1278 +
    - + - import ( +   +
    - 4 + + 1279 +
    - + - "math/big" + - + sb, err := etherMan.EtrogZkEVM.ParseSequenceBatches(vLog)
    - 5 + + 1280 +
    - + - "testing" +   + if err != nil {
    - 6 + + 1281 +
    - + -
    +   + return err
    - 7 + + 1282 +
    - + - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +   + }
    - 8 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/log" -
    +
    +
    @@ -1289,7 +1175,7 @@
    - 9 + + 1289 +
    - + - "github.com/ethereum/go-ethereum/accounts/abi/bind" +   + if tx.Hash() != vLog.TxHash {
    - 10 + + 1290 +
    - + - "github.com/ethereum/go-ethereum/common" +   + return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String())
    - 11 + + 1291 +
    - + - "github.com/ethereum/go-ethereum/core" +   + }
    - 12 + + 1292 +
    - + - "github.com/ethereum/go-ethereum/crypto" + - + msg, err := core.TransactionToMessage(tx, types.NewCancunSigner(tx.ChainId()), big.NewInt(0))
    - 13 + + 1293 +
    - + - "github.com/ethereum/go-ethereum/ethclient/simulated" +   + if err != nil {
    - 14 + + 1294 +
    - + - "github.com/stretchr/testify/assert" +   + return err
    - 15 + + 1295 +
    - + - "github.com/stretchr/testify/require" +   + }
    - 16 - -
    - + - ) -
    +
    +
    @@ -1298,13 +1184,15 @@
    - 17 + + 1298 +
    - + -
    +   + if sb.NumBatch != 1 {
    - 18 + + 1299 +
    - + - func TestUpdateDataCommitteeEvent(t *testing.T) { +   + methodId := tx.Data()[:4]
    - 19 + + 1300 +
    - + - // Set up testing environment +   + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - 20 + + 1301 +
    - + - dac, ethBackend, auth, da := newTestingEnv(t) + - + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) {
    - 21 + + 1302 +
    - + -
    + - + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 22 + + -
    - + - // Update the committee +
    +
    +   +
    - 23 + + 1303 +
    - + - requiredAmountOfSignatures := big.NewInt(2) +   + if err != nil {
    - 24 + + 1304 +
    - + - URLs := []string{"1", "2", "3"} +   + return fmt.Errorf("error decoding the sequences (etrog): %v", err)
    - 25 + + 1305 +
    - + - addrs := []common.Address{ +   + }
    - 26 + + 1306 +
    - + - common.HexToAddress("0x1"), + - + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) {
    - 27 + + 1307 +
    - + - common.HexToAddress("0x2"), + - + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot)
    - 28 + + -
    - + - common.HexToAddress("0x3"), +
    +
    +   +
    - 29 + + 1308 +
    - + - } +   + if err != nil {
    - 30 + + 1309 +
    - + - addrsBytes := []byte{} +   + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 31 + + 1310 +
    - + - for _, addr := range addrs { +   + }
    - 32 + +
    @@ -1345,7 +1233,7 @@
    +
    + 1345 +
    - + - addrsBytes = append(addrsBytes, addr.Bytes()...) +   +
    - 33 + + 1346 +
    - + - } +   + func (etherMan *Client) sequencedBatchesPreEtrogEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 34 + + 1347 +
    - + - _, err := da.SetupCommittee(auth, requiredAmountOfSignatures, URLs, addrsBytes) +   + log.Debug("Pre etrog SequenceBatches event detected")
    - 35 + + 1348 +
    - + - require.NoError(t, err) + - + sb, err := etherMan.PreEtrogZkEVM.ParseSequenceBatches(vLog)
    - 36 + + 1349 +
    - + - ethBackend.Commit() +   + if err != nil {
    - 37 + + 1350 +
    - + -
    +   + return err
    - 38 + + 1351 +
    - + - // Assert the committee update +   + }
    - 39 + +
    @@ -1390,7 +1278,20 @@
    +
    + 1390 +
    - + - actualSetup, err := dac.getCurrentDataCommittee() +   + return nil
    - 40 + + 1391 +
    - + - require.NoError(t, err) +   + }
    - 41 + + 1392 +
    - + - expectedMembers := []DataCommitteeMember{} +   +
    - 42 + + 1393 +
    - + - expectedSetup := DataCommittee{ + - + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 43 + + -
    - + - RequiredSignatures: uint64(len(URLs) - 1), +
    +
    +   +
    - 44 + + -
    - + - AddressesHash: crypto.Keccak256Hash(addrsBytes), +
    +
    +   +
    - 45 + + -
    - + - } +
    +
    +   +
    - 46 + + -
    - + - for i, url := range URLs { +
    +
    +   +
    - 47 + + -
    - + - expectedMembers = append(expectedMembers, DataCommitteeMember{ +
    +
    +   +
    - 48 + + -
    - + - URL: url, +
    +
    +   +
    - 49 + + -
    - + - Addr: addrs[i], +
    +
    +   +
    - 50 + + -
    - + - }) +
    +
    +   +
    - 51 + + -
    - + - } +
    +
    +   +
    - 52 + + -
    - + - expectedSetup.Members = expectedMembers +
    +
    +   +
    - 53 + + -
    - + - assert.Equal(t, expectedSetup, *actualSetup) +
    +
    +   +
    - 54 + + -
    - + - } +
    +
    +   +
    - 55 + + -
    - + +
    +
    +  
    - 56 + + 1394 +
    - + - func init() { +   + // Extract coded txs.
    - 57 + + 1395 +
    - + - log.Init(log.Config{ +   + // Load contract ABI
    - 58 + + 1396 +
    - + - Level: "debug", +   + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - 59 + +
    @@ -1398,6 +1299,13 @@
    +
    + 1398 +
    - + - Outputs: []string{"stderr"}, +   + return nil, err
    - 60 + + 1399 +
    - + - }) +   + }
    - 61 + + 1400 +
    - + - } +   +
    - 62 + + -
    - + +
    +
    +  
    - 63 + + -
    - + - // This function prepare the blockchain, the wallet with funds and deploy the smc +
    +
    +   +
    - 64 + + -
    - + - func newTestingEnv(t *testing.T) ( +
    +
    +   +
    - 65 + + -
    - + - dac *DataCommitteeBackend, +
    +
    +   +
    - 66 + + -
    - + - ethBackend *simulated.Backend, +
    +
    +   +
    - 67 + + -
    - + - auth *bind.TransactOpts, +
    +
    +   +
    - 68 + + -
    - + - da *polygondatacommittee.Polygondatacommittee, +
    +
    +   +
    - 69 + + 1401 +
    - + - ) { +   + // Recover Method from signature and ABI
    - 70 + + 1402 +
    - + - t.Helper() +   + method, err := smcAbi.MethodById(txData[:4])
    - 71 + + 1403 +
    - + - privateKey, err := crypto.GenerateKey() +   + if err != nil {
    - 72 + +
    @@ -1409,93 +1317,218 @@
    +
    + 1409 +
    - + +   if err != nil {
    - 73 + + 1410 +
    - + - log.Fatal(err) +   + return nil, err
    - 74 + + 1411 +
    - + +   }
    - 75 + + 1412 +
    - + - auth, err = bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1337)) + - + var sequences []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - 76 + + 1413 +
    - + +   + bytedata, err := json.Marshal(data[0]) +
    +
    + 1414 + +
    +   if err != nil {
    - 77 + + 1415 +
    - + - log.Fatal(err) +   + return nil, err
    - 78 + + 1416 +
    - + +   }
    - 79 + + 1417 +
    - + - dac, ethBackend, da, err = newSimulatedDacman(t, auth) + - + err = json.Unmarshal(bytedata, &sequences)
    - 80 + + 1418 +
    - + + - if err != nil {
    - 81 + + 1419 +
    - + - log.Fatal(err) + - + return nil, err
    - 82 + + 1420 +
    - + + - }
    - 83 + + 1421 +
    - + - return dac, ethBackend, auth, da + - + maxSequenceTimestamp := data[1].(uint64)
    - 84 + + 1422 +
    - + - } + - + initSequencedBatchNumber := data[2].(uint64)
    - 85 + + 1423 +
    - + -
    + - + coinbase := (data[3]).(common.Address)
    - 86 + + 1424 +
    - + - // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth + - + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 87 + + 1425 +
    - + - // must be 1337. The address that holds the auth will have an initial balance of 10 ETH +   +
    - 88 + + 1426 +
    - + - func newSimulatedDacman(t *testing.T, auth *bind.TransactOpts) ( + - + for i, seq := range sequences {
    - 89 + + 1427 +
    - + - dacman *DataCommitteeBackend, + - + elderberry := SequencedBatchElderberryData{
    - 90 + + 1428 +
    - + - ethBackend *simulated.Backend, + - + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 91 + + 1429 +
    - + - da *polygondatacommittee.Polygondatacommittee, + - + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 92 + + -
    - + - err error, +
    +
    +   +
    - 93 + + -
    - + - ) { +
    +
    +   +
    - 94 + + -
    - + - t.Helper() +
    +
    +   +
    - 95 + + -
    - + - if auth == nil { +
    +
    +   +
    - 96 + + -
    - + - // read only client +
    +
    +   +
    - 97 + + -
    - + - return &DataCommitteeBackend{}, nil, nil, nil +
    +
    +   +
    - 98 + + -
    - + - } +
    +
    +   +
    - 99 + + -
    - + - // 10000000 ETH in wei +
    +
    +   +
    - 100 + + 1430 +
    - + - balance, _ := new(big.Int).SetString("10000000000000000000000000", 10) //nolint:gomnd +   + }
    - 101 + + 1431 +
    - + - address := auth.From + - + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 102 + + 1432 +
    - + - genesisAlloc := map[common.Address]core.GenesisAccount{ + - + s := seq
    - 103 + + 1433 +
    - + - address: { + - + sequencedBatches[i] = SequencedBatch{
    - 104 + + 1434 +
    - + - Balance: balance, + - + BatchNumber: bn,
    - 105 + + 1435 +
    - + - }, + - + L1InfoRoot: &l1InfoRoot,
    - 106 + + 1436 +
    - + - } + - + SequencerAddr: sequencer,
    - 107 + + 1437 +
    - + - blockGasLimit := uint64(999999999999999999) //nolint:gomnd + - + TxHash: txHash,
    - 108 + + 1438 +
    - + - client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) + - + Nonce: nonce,
    - 109 + + 1439 +
    - + -
    + - + Coinbase: coinbase,
    - 110 + + 1440 +
    - + - // DAC Setup + - + PolygonRollupBaseEtrogBatchData: &s,
    - 111 + + 1441 +
    - + - _, _, da, err = polygondatacommittee.DeployPolygondatacommittee(auth, client.Client()) + - + SequencedBatchElderberryData: &elderberry,
    - 112 + + -
    - + - if err != nil { +
    +
    +   +
    - 113 + + -
    - + - return &DataCommitteeBackend{}, nil, nil, err +
    +
    +   +
    - 114 + + -
    - + - } +
    +
    +   +
    - 115 + + -
    - + - client.Commit() +
    +
    +   +
    - 116 + + -
    - + - _, err = da.Initialize(auth) +
    +
    +   +
    - 117 + + -
    - + - if err != nil { +
    +
    +   +
    +
    +
    + + +
    +   +
    - 118 + + -
    - + - return &DataCommitteeBackend{}, nil, nil, err +
    +
    +   +
    - 119 + + -
    - + - } +
    +
    +   +
    - 120 + + -
    - + - client.Commit() +
    +
    +   +
    - 121 + + -
    - + - _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{}) +
    +
    +   +
    - 122 + + -
    - + - if err != nil { +
    +
    +   +
    - 123 + + -
    - + - return &DataCommitteeBackend{}, nil, nil, err +
    +
    +   +
    - 124 + + -
    - + - } +
    +
    +   +
    - 125 + + -
    - + - client.Commit() +
    +
    +   +
    - 126 + + -
    - + +
    +
    +  
    - 127 + + -
    - + - c := &DataCommitteeBackend{ +
    +
    +   +
    - 128 + + -
    - + - dataCommitteeContract: da, +
    +
    +   +
    - 129 + + -
    - + - } +
    +
    +   +
    - 130 + + -
    - + - return c, client, da, nil +
    +
    +   +
    - 131 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/dataavailability/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,60 @@
    @@ -46233,648 +121935,625 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + -
    - + - package dataavailability +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import ( +
    +
    +   +
    - 4 + + -
    - + - "context" +
    +
    +   +
    - 5 + + 1442 +
    - + - "math/big" +   + }
    - 6 + + -
    - + +
    +
    +  
    - 7 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    +   +
    - 8 + + 1443 +
    - + - "github.com/0xPolygonHermez/zkevm-node/state" +   + }
    - 9 + + 1444 +
    - + - "github.com/ethereum/go-ethereum/common" +   +
    - 10 + + 1445 +
    - + - "github.com/jackc/pgx/v4" + - + return sequencedBatches, nil
    - 11 + + 1446 +
    - + - ) +   + }
    - 12 + + 1447 +
    - + +  
    - 13 + + 1448 +
    - + - // DABackender is an interface for components that store and retrieve batch data + - + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) {
    - 14 + + 1449 +
    - + - type DABackender interface { + - + // Extract coded txs.
    - 15 + + 1450 +
    - + - SequenceRetriever + - + // Load contract ABI
    - 16 + + 1451 +
    - + - SequenceSender + - + smcAbi, err := abi.JSON(strings.NewReader(elderberrypolygonzkevm.ElderberrypolygonzkevmABI))
    - 17 + + -
    - + - // Init initializes the DABackend +
    +
    +   +
    - 18 + + -
    - + - Init() error +
    +
    +   +
    - 19 + + -
    - + - } +
    +
    +   +
    - 20 + + -
    - + +
    +
    +  
    - 21 + + 1452 +
    - + - // SequenceSender is used to send provided sequence of batches +   + if err != nil {
    - 22 + + 1453 +
    - + - type SequenceSender interface { +   + return nil, err
    - 23 + + 1454 +
    - + - // PostSequence sends the sequence data to the data availability backend, and returns the dataAvailabilityMessage +   + }
    - 24 + + 1455 +
    - + - // as expected by the contract + - +
    - 25 + + 1456 +
    - + - PostSequence(ctx context.Context, batchesData [][]byte) ([]byte, error) + - + // Recover Method from signature and ABI
    - 26 + + 1457 +
    - + - } + - + method, err := smcAbi.MethodById(txData[:4])
    - 27 + + 1458 +
    - + -
    +   + if err != nil {
    - 28 + + 1459 +
    - + - // SequenceRetriever is used to retrieve batch data +   + return nil, err
    - 29 + + 1460 +
    - + - type SequenceRetriever interface { +   + }
    - 30 + + -
    - + - // GetSequence retrieves the sequence data from the data availability backend +
    +
    +   +
    - 31 + + -
    - + - GetSequence(ctx context.Context, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) +
    +
    +   +
    - 32 + + -
    - + - } +
    +
    +   +
    - 33 + + -
    - + +
    +
    +  
    - 34 + + -
    - + - // === Internal interfaces === +
    +
    +   +
    - 35 + + -
    - + +
    +
    +  
    - 36 + + -
    - + - type stateInterface interface { +
    +
    +   +
    - 37 + + -
    - + - GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) +
    +
    +   +
    - 38 + + -
    - + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    +
    +   +
    - 39 + + -
    - + - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    +   +
    - 40 + + -
    - + - GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    +
    +   +
    - 41 + + 1461 +
    - + - } +   +
    - 42 + + 1462 +
    - + -
    + - + // Unpack method inputs
    - 43 + + 1463 +
    - + - // BatchDataProvider is used to retrieve batch data + - + data, err := method.Inputs.Unpack(txData[4:])
    - 44 + + 1464 +
    - + - type BatchDataProvider interface { + - + if err != nil {
    - 45 + + 1465 +
    - + - // GetBatchL2Data retrieve the data of a batch from the DA backend. The returned data must be the pre-image of the hash + - + return nil, err
    - 46 + + -
    - + - GetBatchL2Data(batchNum []uint64, batchHashes []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) +
    +
    +   +
    - 47 + + -
    - + - } +
    +
    +   +
    - 48 + + -
    - + +
    +
    +  
    - 49 + + -
    - + - // DataManager is an interface for components that send and retrieve batch data +
    +
    +   +
    - 50 + + 1466 +
    - + - type DataManager interface { +   + }
    - 51 + + 1467 +
    - + - BatchDataProvider + - + var sequences []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - 52 + + 1468 +
    - + - SequenceSender + - + bytedata, err := json.Marshal(data[0])
    - 53 + + -
    - + - } +
    +
    +   +
    - 54 + + -
    - + +
    +
    +  
    - 55 + + 1469 +
    - + - // ZKEVMClientTrustedBatchesGetter contains the methods required to interact with zkEVM-RPC +   + if err != nil {
    - 56 + + 1470 +
    - + - type ZKEVMClientTrustedBatchesGetter interface { +   + return nil, err
    - 57 + + 1471 +
    - + - BatchByNumber(ctx context.Context, number *big.Int) (*types.Batch, error) +   + }
    - 58 + + 1472 +
    - + - BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) + - + err = json.Unmarshal(bytedata, &sequences)
    - 59 + + -
    - + - ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) +
    +
    +   +
    - 60 + + -
    - + - } +
    +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/pool/validium-001.sql - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,20 @@
    @@ -47076,760 +122755,819 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + 1473 + + +
    +   + if err != nil {
    -
    -
    - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + 1474 +
    - + - -- +migrate Down +   + return nil, err
    - 2 + + 1475 +
    - + - DROP TABLE IF EXISTS pool.acl CASCADE; +   + }
    - 3 + + 1476 +
    - + - DROP TABLE IF EXISTS pool.policy CASCADE; + - + coinbase := (data[1]).(common.Address)
    - 4 + + 1477 +
    - + -
    + - + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 5 + + 1478 + +
    + - + for i, seq := range sequences { +
    +
    + 1479 + +
    + - + bn := lastBatchNumber - uint64(len(sequences)-(i+1)) +
    +
    + 1480 + +
    + - + s := seq +
    +
    + 1481 + +
    + - + sequencedBatches[i] = SequencedBatch{ +
    +
    + 1482 + +
    + - + BatchNumber: bn, +
    +
    + 1483 + +
    + - + L1InfoRoot: &l1InfoRoot, +
    +
    + 1484 + +
    + - + SequencerAddr: sequencer, +
    +
    + 1485 +
    - + - -- +migrate Up + - + TxHash: txHash,
    - 6 + + 1486 +
    - + - CREATE TABLE pool.policy + - + Nonce: nonce,
    - 7 + + 1487 +
    - + - ( + - + Coinbase: coinbase,
    - 8 + + 1488 +
    - + - name VARCHAR PRIMARY KEY, + - + PolygonRollupBaseEtrogBatchData: &s,
    - 9 + + 1489 +
    - + - allow BOOLEAN NOT NULL DEFAULT false +   + }
    - 10 + + 1490 +
    - + - ); +   + }
    - 11 + + 1491 +
    - + + -
    - 12 + + 1492 +
    - + - INSERT INTO pool.policy (name, allow) VALUES ('send_tx', false); + - + return sequencedBatches, nil
    - 13 + + 1493 +
    - + - INSERT INTO pool.policy (name, allow) VALUES ('deploy', false); +   + }
    - 14 + + 1494 +
    - + +  
    - 15 + + 1495 +
    - + - CREATE TABLE pool.acl +   + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
    - 16 + + 1496 +
    - + - ( +   + // Extract coded txs.
    - 17 + + 1497 +
    - + - address VARCHAR, +   + // Load contract ABI
    - 18 + + 1498 +
    - + - policy VARCHAR, + - + smcAbi, err := abi.JSON(strings.NewReader(preetrogpolygonzkevm.PreetrogpolygonzkevmABI))
    - 19 + + 1499 +
    - + - PRIMARY KEY (address, policy) +   + if err != nil {
    - 20 + + 1500 +
    - + - ); +   + return nil, err
    -
    + + + 1501 + + +
    +   + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0018.sql - RENAMED - -
    -
    -
    -
    - - - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - -
    -
    @@ -0,0 +1,11 @@
    +
    @@ -1511,7 +1544,7 @@
    - + + 1511 -
    +
    +
      -
    + if err != nil {
    - + + 1512 -
    +
    +
      -
    + return nil, err
    - + + 1513 -
    +
    +
      -
    + }
    - + + 1514 -
    -   -
    +
    +
    + - + var sequences []preetrogpolygonzkevm.PolygonZkEVMBatchData
    - + + 1515 -
    +
    +
      -
    + bytedata, err := json.Marshal(data[0])
    - + + 1516 -
    +
    +
      -
    + if err != nil {
    - + + 1517 -
    +
    +
      -
    + return nil, err
    - + +
    @@ -1538,10 +1571,10 @@
    -
    +
    + 1538 + +
      -
    + return sequencedBatches, nil
    - + + 1539 -
    +
    +
      -
    + }
    - + + 1540 -
    +
    +
     
    - + + 1541 -
    -   -
    +
    +
    + - + func (etherMan *Client) preEtrogVerifyBatchesTrustedAggregatorEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    -
    + + + 1542 + + +
    +   + log.Debug("TrustedVerifyBatches event detected")
    -
    -
    - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - -
    -
     
    - 1 + + 1543 +
    - + - -- +migrate Up + - + var vb *preetrogpolygonzkevm.PreetrogpolygonzkevmVerifyBatchesTrustedAggregator
    - 2 + + 1544 +
    - + - ALTER TABLE state.block + - + vb, err := etherMan.PreEtrogZkEVM.ParseVerifyBatchesTrustedAggregator(vLog)
    - 3 + + 1545 +
    - + - ADD COLUMN IF NOT EXISTS checked BOOL NOT NULL DEFAULT FALSE; +   + if err != nil {
    - 4 + + 1546 +
    - + -
    +   + log.Error("error parsing TrustedVerifyBatches event. Error: ", err)
    - 5 + + 1547 +
    - + - -- set block.checked to true for all blocks below max - 100 +   + return err
    - 6 + +
    @@ -1551,7 +1584,7 @@
    +
    + 1551 +
    - + - UPDATE state.block SET checked = true WHERE block_num <= (SELECT MAX(block_num) - 1000 FROM state.block); +   +
    - 7 + + 1552 +
    - + -
    +   + func (etherMan *Client) verifyBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 8 + + 1553 +
    - + - -- +migrate Down +   + log.Debug("VerifyBatches event detected")
    - 9 + + 1554 +
    - + - ALTER TABLE state.block + - + vb, err := etherMan.EtrogZkEVM.ParseVerifyBatches(vLog)
    - 10 + + 1555 +
    - + - DROP COLUMN IF EXISTS checked; +   + if err != nil {
    - 11 + + 1556 +
    - + -
    +   + log.Error("error parsing VerifyBatches event. Error: ", err)
    -
    + + + 1557 + + +
    +   + return err
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0018_test.go - RENAMED - -
    -
    -
    -
    - - - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - @@ -47843,23 +123581,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -47923,93 +123661,98 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - + - + + - - - - - - @@ -48023,23 +123766,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -48103,93 +123846,98 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - + - + + - - - - - - @@ -48272,738 +124020,740 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -0,0 +1,69 @@
    +
    @@ -1598,7 +1631,7 @@
    - + + 1598 -
    +
    +
     
    - + + 1599 -
    +
    +
      -
    + func (etherMan *Client) forceSequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 1600 -
    +
    +
      -
    + log.Debug("SequenceForceBatches event detect")
    - + + 1601 -
    -   -
    +
    +
    + - + fsb, err := etherMan.EtrogZkEVM.ParseSequenceForceBatches(vLog)
    - + + 1602 -
    +
    +
      -
    + if err != nil {
    - + + 1603 -
    +
    +
      -
    + return err
    - + + 1604 -
    +
    +
      -
    + }
    - + +
    @@ -1647,7 +1680,7 @@
    -
    +
    + 1647 + +
      -
    + func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, block *types.Block, nonce uint64) ([]SequencedForceBatch, error) {
    - + + 1648 -
    +
    +
      -
    + // Extract coded txs.
    - + + 1649 -
    +
    +
      -
    + // Load contract ABI
    - + + 1650 -
    -   -
    +
    +
    + - + abi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - + + 1651 -
    +
    +
      -
    + if err != nil {
    - + + 1652 -
    +
    +
      -
    + return nil, err
    - + + 1653 -
    +
    +
      -
    + }
    - + +
    @@ -1664,7 +1697,7 @@
    -
    +
    + 1664 + +
      -
    + return nil, err
    - + + 1665 -
    +
    +
      -
    + }
    - + + 1666 -
    +
    +
     
    - + + 1667 -
    -   -
    +
    +
    + - + var forceBatches []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - + + 1668 -
    +
    +
      -
    + bytedata, err := json.Marshal(data[0])
    - + + 1669 -
    +
    +
      -
    + if err != nil {
    - + + 1670 -
    +
    +
      -
    + return nil, err
    - + +
    @@ -1728,11 +1761,18 @@
    -
    +
    + 1728 + +
     
    - + + 1729 -
    +
    +
      -
    + // GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc
    - + + 1730 -
    +
    +
      -
    + func (etherMan *Client) GetLatestBatchNumber() (uint64, error) {
    - + + 1731 -
    -   -
    +
    +
    + - + rollupData, err := etherMan.EtrogRollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
    - + + 1732 -
    +
    +
      -
    + if err != nil {
    - + + 1733 -
    -   -
    +
    +
    + - + return 0, err
    - + + 1734 -
    +
    +
      -
    + }
    - + + 1735 -
    -   -
    +
    +
    + - + return rollupData.LastBatchSequenced, nil
    - + + 1736 -
    +
    +
      -
    + }
    - + + 1737 -
    +
    +
     
    - + + 1738 -
    +
    +
      -
    + // GetLatestBlockHeader gets the latest block header from the ethereum
    - + +
    @@ -1779,11 +1819,18 @@
    -
    +
    + 1779 + +
     
    - + + 1780 -
    +
    +
      -
    + // GetLatestVerifiedBatchNum gets latest verified batch from ethereum
    - + + 1781 -
    +
    +
      -
    + func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error) {
    - + + 1782 -
    -   -
    +
    +
    + - + rollupData, err := etherMan.EtrogRollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
    - + + 1783 -
    +
    +
      -
    + if err != nil {
    - + + 1784 -
    -   -
    +
    +
    + - + return 0, err
    - + + 1785 -
    +
    +
      -
    + }
    - + + 1786 -
    -   -
    +
    +
    + - + return rollupData.LastVerifiedBatch, nil
    - + + 1787 -
    +
    +
      -
    + }
    - + + 1788 -
    +
    +
     
    - + + 1789 -
    +
    +
      -
    + // GetTx function get ethereum tx
    - + +
    @@ -1818,19 +1865,27 @@
    -
    +
    + 1818 + +
     
    - + + 1819 -
    +
    +
      -
    + // GetTrustedSequencerURL Gets the trusted sequencer url from rollup smc
    - + + 1820 -
    +
    +
      -
    + func (etherMan *Client) GetTrustedSequencerURL() (string, error) {
    - + + 1821 -
    -   -
    +
    +
    + - + return etherMan.EtrogZkEVM.TrustedSequencerURL(&bind.CallOpts{Pending: false})
    -
    + + + 1822 + + +
    +   + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - -
    -
     
    - 1 + + 1823 +
    - + - package migrations_test +   +
    - 2 + + 1824 +
    - + -
    +   + // GetL2ChainID returns L2 Chain ID
    - 3 + + 1825 +
    - + - import ( +   + func (etherMan *Client) GetL2ChainID() (uint64, error) {
    - 4 + + 1826 +
    - + - "database/sql" + - + chainID, err := etherMan.PreEtrogZkEVM.ChainID(&bind.CallOpts{Pending: false})
    - 5 + + 1827 +
    - + - "testing" + - + log.Debug("chainID read from preEtrogZkevm: ", chainID)
    - 6 + + 1828 +
    - + - "time" +   + if err != nil || chainID == 0 {
    - 7 + + 1829 +
    - + -
    + - + log.Debug("error from preEtrogZkevm: ", err)
    - 8 + + 1830 +
    - + - "github.com/stretchr/testify/assert" + - + rollupData, err := etherMan.EtrogRollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
    - 9 + + 1831 +
    - + - ) + - + log.Debugf("ChainID read from EtrogRollupManager: %d using rollupID: %d", rollupData.ChainID, etherMan.RollupID)
    - 10 + + 1832 +
    - + -
    +   + if err != nil {
    - 11 + + 1833 +
    - + - type migrationTest0018 struct{} + - + log.Debug("error from EtrogRollupManager: ", err)
    - 12 + + 1834 +
    - + -
    +   + return 0, err
    - 13 + + 1835 +
    - + - func (m migrationTest0018) InsertData(db *sql.DB) error { +   + } else if rollupData.ChainID == 0 {
    - 14 + + 1836 +
    - + - const addBlock = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES ($1, $2, $3)" +   + return rollupData.ChainID, fmt.Errorf("error: chainID received is 0!!")
    - 15 + +
    @@ -1861,11 +1916,6 @@
    +
    + 1861 +
    - + - if _, err := db.Exec(addBlock, 1, time.Now(), "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1"); err != nil { +   + return etherMan.EthClient.SendTransaction(ctx, tx)
    - 16 + + 1862 +
    - + - return err +   + }
    - 17 + + 1863 +
    - + - } +   +
    - 18 + + 1864 +
    - + - if _, err := db.Exec(addBlock, 50, time.Now(), "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1"); err != nil { + - + // PendingNonce returns the pending nonce for the provided account
    - 19 + + 1865 +
    - + - return err + - + func (etherMan *Client) PendingNonce(ctx context.Context, account common.Address) (uint64, error) {
    - 20 + + 1866 +
    - + - } + - + return etherMan.EthClient.PendingNonceAt(ctx, account)
    - 21 + + 1867 +
    - + - if _, err := db.Exec(addBlock, 1050, time.Now(), "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1"); err != nil { + - + }
    - 22 + + 1868 +
    - + - return err + - +
    - 23 + + 1869 +
    - + - } +   + // CurrentNonce returns the current nonce for the provided account
    - 24 + + 1870 +
    - + - return nil +   + func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error) {
    - 25 + + 1871 +
    - + - } +   + return etherMan.EthClient.NonceAt(ctx, account, nil)
    - 26 + +
    @@ -1898,7 +1948,7 @@
    +
    + 1898 +
    - + -
    +   + opts.BlockNumber = new(big.Int).SetUint64(*blockNumber)
    - 27 + + 1899 +
    - + - func (m migrationTest0018) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +   + }
    - 28 + + 1900 +
    - + - var checked bool +   +
    - 29 + + 1901 +
    - + - row := db.QueryRow("SELECT checked FROM state.block WHERE block_num = $1", 1) + - + return etherman.EtrogGlobalExitRootManager.DepositCount(opts)
    - 30 + + 1902 +
    - + - assert.NoError(t, row.Scan(&checked)) +   + }
    - 31 + + 1903 +
    - + - assert.Equal(t, true, checked) +   +
    - 32 + + 1904 +
    - + - row = db.QueryRow("SELECT checked FROM state.block WHERE block_num = $1", 50) +   + // CheckTxWasMined check if a tx was already mined
    - 33 + +
    @@ -1955,15 +2005,15 @@
    +
    + 1955 +
    - + - assert.NoError(t, row.Scan(&checked)) +   + }
    - 34 + + 1956 +
    - + - assert.Equal(t, true, checked) +   +
    - 35 + + 1957 +
    - + - row = db.QueryRow("SELECT checked FROM state.block WHERE block_num = $1", 1050) +   + // LoadAuthFromKeyStore loads an authorization from a key store file
    - 36 + + 1958 +
    - + - assert.NoError(t, row.Scan(&checked)) + - + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) {
    - 37 + + 1959 +
    - + - assert.Equal(t, false, checked) + - + auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 38 + + 1960 +
    - + -
    +   + if err != nil {
    - 39 + + 1961 +
    - + - const addBlock = "INSERT INTO state.block (block_num, received_at, block_hash, checked) VALUES ($1, $2, $3, $4)" + - + return nil, err
    - 40 + + 1962 +
    - + - _, err := db.Exec(addBlock, 2, time.Now(), "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1", true) +   + }
    - 41 + + 1963 +
    - + - assert.NoError(t, err) +   +
    - 42 + + 1964 +
    - + - _, err = db.Exec(addBlock, 3, time.Now(), "0x29e885edaf8e4b51e1d2e05f9da28161d2fb4f6b1d53827d9b80a23cf2d7d9f1", false) +   + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 43 + + 1965 +
    - + - assert.NoError(t, err) +   + etherMan.auth[auth.From] = auth
    - 44 + + 1966 +
    - + - const sql = `SELECT count(*) FROM state.block WHERE checked = true` + - + return &auth, nil
    - 45 + + 1967 +
    - + - row = db.QueryRow(sql) +   + }
    - 46 + + 1968 +
    - + - var result int +   +
    - 47 + + 1969 +
    - + - assert.NoError(t, row.Scan(&result)) +   + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    - 48 + +
    @@ -1984,20 +2034,20 @@
    +
    + 1984 +
    - + - assert.Equal(t, 3, result, "must be 1,50 per migration and 2 by insert") +   + }
    - 49 + + 1985 +
    - + +  
    - 50 + + 1986 +
    - + - const sqlCheckedFalse = `SELECT count(*) FROM state.block WHERE checked = false` +   + // newAuthFromKeystore an authorization instance from a keystore file
    - 51 + + 1987 +
    - + - row = db.QueryRow(sqlCheckedFalse) + - + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) {
    - 52 + + 1988 +
    - + -
    +   + log.Infof("reading key from: %v", path)
    - 53 + + 1989 +
    - + - assert.NoError(t, row.Scan(&result)) +   + key, err := newKeyFromKeystore(path, password)
    - 54 + + 1990 +
    - + - assert.Equal(t, 2, result, "must be 150 by migration, and 3 by insert") +   + if err != nil {
    - 55 + + 1991 +
    - + - } + - + return bind.TransactOpts{}, err
    - 56 + + 1992 +
    - + -
    +   + }
    - 57 + + 1993 +
    - + - func (m migrationTest0018) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +   + if key == nil {
    - 58 + + 1994 +
    - + - var result int + - + return bind.TransactOpts{}, nil
    - 59 + + 1995 +
    - + -
    +   + }
    - 60 + + 1996 +
    - + - // Check column wip doesn't exists in state.batch table +   + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    - 61 + + 1997 +
    - + - const sql = `SELECT count(*) FROM state.block` +   + if err != nil {
    - 62 + + 1998 +
    - + - row := db.QueryRow(sql) + - + return bind.TransactOpts{}, err
    - 63 + + 1999 +
    - + - assert.NoError(t, row.Scan(&result)) +   + }
    - 64 + + 2000 +
    - + - assert.Equal(t, 5, result) + - + return *auth, nil
    - 65 + + 2001 +
    - + +   }
    - 66 + + 2002 +
    - + +  
    - 67 + + 2003 +
    - + - func TestMigration0018(t *testing.T) { +   + // getAuthByAddress tries to get an authorization from the authorizations map
    - 68 + +
    @@ -2025,3 +2075,28 @@
    +
    + 2025 +
    - + - runMigrationTest(t, 18, migrationTest0018{}) +   +
    - 69 + + 2026 +
    - + - } +   + return *auth, nil
    -
    + + + 2027 + + +
    +   + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019.sql - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - @@ -49326,228 +125056,74 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,25 @@
    @@ -49270,53 +125020,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - 1 - -
    - + - -- +migrate Up -
    -
    - 2 - -
    - + -
    -
    -
    + 3 +
    - + - -- the update below fix the wrong receipt TX indexes +   + import (
    + 4 +
    - + - WITH map_fix_tx_index AS ( +   + "bytes"
    + 5 +
    - + - SELECT t.l2_block_num AS block_num +   + "context"
    + - , t.hash AS tx_hash + "crypto/ecdsa"
    + 7 +
    - + - , r.tx_index AS current_index +   + "encoding/json"
    + 8 +
    - + - , (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index +   + "errors"
    + 9 +
    - + - FROM state.receipt r +   + "fmt"
    - 10 - -
    - + - INNER JOIN state."transaction" t -
    +
    +
     
    - 11 + + 44 +
    - + - ON t.hash = r.tx_hash +   + "golang.org/x/crypto/sha3"
    - 12 + + 45 +
    - + +   )
    - 13 - -
    - + - UPDATE state.receipt AS r -
    -
    - 14 - -
    - + - SET tx_index = m.correct_index -
    -
    - 15 - -
    - + - FROM map_fix_tx_index m -
    -
    - 16 - -
    - + - WHERE m.block_num = r.block_num -
    -
    - 17 - -
    - + - AND m.tx_hash = r.tx_hash -
    -
    - 18 - -
    - + - AND m.current_index = r.tx_index -
    -
    - 19 - -
    - + - AND m.current_index != m.correct_index; -
    -
    - 20 - -
    - + -
    -
    -
    - 21 - -
    - + -
    -
    -
    - 22 - -
    - + - -- +migrate Down -
    -
    - 23 + + 46 +
    - + +  
    - 24 - -
    - + - -- no action is needed, the data fixed by the -
    -
    - 25 - -
    - + - -- migrate up must remain fixed -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0019_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -49939,373 +125520,378 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -50439,413 +126025,418 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - @@ -50859,1637 +126450,1659 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,145 @@
    -
    @@ -49599,333 +125175,338 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 47 -
    +
    +
      -
    + var (
    - + + 48 -
    -   -
    +
    +
    + + + // Events RollupManager
    - + + 49 -
    +
    +
      -
    + setBatchFeeSignatureHash = crypto.Keccak256Hash([]byte("SetBatchFee(uint256)"))
    - + + 50 -
    +
    +
      -
    + setTrustedAggregatorSignatureHash = crypto.Keccak256Hash([]byte("SetTrustedAggregator(address)")) // Used in oldZkEvm as well
    - + + 51 -
    +
    +
      -
    + setVerifyBatchTimeTargetSignatureHash = crypto.Keccak256Hash([]byte("SetVerifyBatchTimeTarget(uint64)")) // Used in oldZkEvm as well
    - - -
    -   -
    -
    +
    +
     
    - + + 90 -
    +
    +
      -
    + updateL1InfoTreeSignatureHash = crypto.Keccak256Hash([]byte("UpdateL1InfoTree(bytes32,bytes32)"))
    - + + 91 -
    +
    +
     
    - + + 92 -
    +
    +
      -
    + // PreLxLy events
    - + + 93 -
    -   -
    +
    +
    + + + updateGlobalExitRootSignatureHash = crypto.Keccak256Hash([]byte("UpdateGlobalExitRoot(bytes32,bytes32)"))
    - + + 94 -
    -   -
    +
    +
    + + + oldVerifyBatchesTrustedAggregatorSignatureHash = crypto.Keccak256Hash([]byte("VerifyBatchesTrustedAggregator(uint64,bytes32,address)"))
    - + + 95 -
    -   -
    +
    +
    + + + transferOwnershipSignatureHash = crypto.Keccak256Hash([]byte("OwnershipTransferred(address,address)"))
    - + + 96 -
    -   -
    +
    +
    + + + updateZkEVMVersionSignatureHash = crypto.Keccak256Hash([]byte("UpdateZkEVMVersion(uint64,uint64,string)"))
    - + + 97 -
    -   -
    +
    +
    + + + oldConsolidatePendingStateSignatureHash = crypto.Keccak256Hash([]byte("ConsolidatePendingState(uint64,bytes32,uint64)"))
    - + + 98 -
    -   -
    +
    +
    + + + oldOverridePendingStateSignatureHash = crypto.Keccak256Hash([]byte("OverridePendingState(uint64,bytes32,address)"))
    - + + 99 -
    -   -
    +
    +
    + + + sequenceBatchesPreEtrogSignatureHash = crypto.Keccak256Hash([]byte("SequenceBatches(uint64)"))
    - + + 100 -
    +
    +
     
    - + + 101 -
    +
    +
      -
    + // Proxy events
    - + + 102 -
    +
    +
      -
    + initializedProxySignatureHash = crypto.Keccak256Hash([]byte("Initialized(uint8)"))
    - + +
     
    -
    +
    + 109 + +
      -
    + // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry
    - + + 110 -
    +
    +
      -
    + methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address)
    - + + 111 -
    +
    +
     
    - + + 112 -
    -   -
    +
    +
    + + + // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog
    - + + 113 -
    -   -
    +
    +
    + + + methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes)
    - + + 114 -
    -   -
    +
    +
    + + + // methodIDSequenceBatchesValidiumElderberry: MethodID for sequenceBatchesValidium in Elderberry
    - + + 115 -
    -   -
    +
    +
    + + + methodIDSequenceBatchesValidiumElderberry = []byte{0xdb, 0x5b, 0x0e, 0xd7} // 0xdb5b0ed7 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes)
    - + + 116 -
    -   +
    +
    + +
    - + + 117 -
    +
    +
      -
    + // ErrNotFound is used when the object is not found
    - + + 118 -
    +
    +
      -
    + ErrNotFound = errors.New("not found")
    - + + 119 -
    +
    +
      -
    + // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode.
    - + +
     
    -
    +
    + 164 + +
      -
    + ethereum.LogFilterer
    - + + 165 -
    +
    +
      -
    + ethereum.TransactionReader
    - + + 166 -
    +
    +
      -
    + ethereum.TransactionSender
    - + + 167 -
    +
    +
     
    - + + 168 -
    +
    +
      -
    + bind.DeployBackend
    - + + 169 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 189 + +
     
    - + + 190 -
    +
    +
      -
    + // Client is a simple implementation of EtherMan.
    - + + 191 -
    +
    +
      -
    + type Client struct {
    - + + 192 -
    -   -
    +
    +
    + + + EthClient ethereumClient
    - + + 193 -
    -   -
    +
    +
    + + + OldZkEVM *oldpolygonzkevm.Oldpolygonzkevm
    - + + 194 -
    -   -
    +
    +
    + + + EtrogZKEVM *etrogpolygonzkevm.Etrogpolygonzkevm
    - + + 195 -
    -   -
    +
    +
    + + + ZkEVM *polygonzkevm.Polygonzkevm
    - + + 196 -
    -   -
    +
    +
    + + + RollupManager *polygonrollupmanager.Polygonrollupmanager
    - + + 197 -
    -   -
    +
    +
    + + + GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot
    - + + 198 -
    -   -
    +
    +
    + + + OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot
    - + + 199 -
    -   -
    +
    +
    + + + Pol *pol.Pol
    - + + 200 -
    -   -
    +
    +
    + + + DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol
    - + + 201 -
    -   -
    +
    +
    + + + SCAddresses []common.Address
    - + + 202 -
    +
    +
     
    - + + 203 -
    +
    +
      -
    + RollupID uint32
    - + + 204 -
    +
    +
     
    - + + 205 -
    +
    +
      -
    + GasProviders externalGasProviders
    - + + 206 -
    +
    +
     
    - + + 207 -
    -   -
    +
    +
    + + + l1Cfg L1Config
    - + + 208 -
    -   -
    +
    +
    + + + cfg Config
    - + + 209 -
    -   -
    +
    +
    + + + auth map[common.Address]bind.TransactOpts // empty in case of read-only client
    - + + 210 -
    -   +
    +
    + +
    - + + 211 -
    -   -
    +
    +
    + + + da dataavailability.BatchDataProvider
    - + + 212 -
    -   -
    +
    +
    + + + state stateProvider
    - + + 213 -
    +
    +
      -
    + }
    - + + 214 -
    +
    +
     
    - + + 215 -
    +
    +
      -
    + // NewClient creates a new etherman.
    - + + 216 -
    -   -
    +
    +
    + + + func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider, st stateProvider) (*Client, error) {
    - + + 217 -
    +
    +
      -
    + // Connect to ethereum node
    - + + 218 -
    +
    +
      -
    + ethClient, err := ethclient.Dial(cfg.URL)
    - + + 219 -
    +
    +
      -
    + if err != nil {
    - + + 220 -
    +
    +
      -
    + log.Errorf("error connecting to %s: %+v", cfg.URL, err)
    - + + 221 -
    +
    +
      -
    + return nil, err
    - + + 222 -
    +
    +
      -
    + }
    - + + 223 -
    +
    +
      -
    + // Create smc clients
    - + + 224 -
    -   -
    +
    +
    + + + zkevm, err := polygonzkevm.NewPolygonzkevm(l1Config.ZkEVMAddr, ethClient)
    - + + 225 -
    +
    +
      -
    + if err != nil {
    - + + 226 -
    +
    +
      -
    + log.Errorf("error creating Polygonzkevm client (%s). Error: %w", l1Config.ZkEVMAddr.String(), err)
    - + + 227 -
    +
    +
      -
    + return nil, err
    - + + 228 -
    +
    +
      -
    + }
    - + + 229 -
    -   -
    +
    +
    + + + etrogZkevm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(l1Config.RollupManagerAddr, ethClient)
    - + + 230 -
    +
    +
      -
    + if err != nil {
    - + + 231 -
    -   -
    +
    +
    + + + log.Errorf("error creating NewEtrogPolygonzkevm client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 232 -
    +
    +
      -
    + return nil, err
    - + + 233 -
    +
    +
      -
    + }
    - + + 234 -
    -   -
    +
    +
    + + + oldZkevm, err := oldpolygonzkevm.NewOldpolygonzkevm(l1Config.RollupManagerAddr, ethClient)
    - + + 235 -
    +
    +
      -
    + if err != nil {
    - + + 236 -
    -   -
    +
    +
    + + + log.Errorf("error creating NewOldpolygonzkevm client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 237 -
    +
    +
      -
    + return nil, err
    - + + 238 -
    +
    +
      -
    + }
    - + + 239 -
    -   -
    +
    +
    + + + rollupManager, err := polygonrollupmanager.NewPolygonrollupmanager(l1Config.RollupManagerAddr, ethClient)
    - + + 240 -
    +
    +
      -
    + if err != nil {
    - + + 241 -
    +
    +
      -
    + log.Errorf("error creating NewPolygonrollupmanager client (%s). Error: %w", l1Config.RollupManagerAddr.String(), err)
    - + + 242 -
    +
    +
      -
    + return nil, err
    - + + 243 -
    +
    +
      -
    + }
    - + + 244 -
    -   -
    +
    +
    + + + globalExitRoot, err := polygonzkevmglobalexitroot.NewPolygonzkevmglobalexitroot(l1Config.GlobalExitRootManagerAddr, ethClient)
    - + + 245 -
    +
    +
      -
    + if err != nil {
    - + + 246 -
    +
    +
      -
    + log.Errorf("error creating NewPolygonzkevmglobalexitroot client (%s). Error: %w", l1Config.GlobalExitRootManagerAddr.String(), err)
    - + + 247 -
    +
    +
      -
    + return nil, err
    - + + 248 -
    +
    +
      -
    + }
    - + + 249 -
    -   -
    +
    +
    + + + oldGlobalExitRoot, err := oldpolygonzkevmglobalexitroot.NewOldpolygonzkevmglobalexitroot(l1Config.GlobalExitRootManagerAddr, ethClient)
    - + + 250 -
    +
    +
      -
    + if err != nil {
    - + + 251 -
    -   -
    +
    +
    + + + log.Errorf("error creating NewOldpolygonzkevmglobalexitroot client (%s). Error: %w", l1Config.GlobalExitRootManagerAddr.String(), err)
    - + + 252 -
    +
    +
      -
    + return nil, err
    - + + 253 -
    +
    +
      -
    + }
    - + + 254 -
    +
    +
      -
    + pol, err := pol.NewPol(l1Config.PolAddr, ethClient)
    - + +
     
    -
    +
    + 256 + +
      -
    + log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err)
    - + + 257 -
    +
    +
      -
    + return nil, err
    - + + 258 -
    +
    +
      -
    + }
    - + + 259 -
    -   -
    +
    +
    + + + dapAddr, err := zkevm.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
    - + + 260 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 261 -
    -   -
    +
    +
    + + + return nil, err
    - + + 262 -
    -   -
    +
    +
    + + + }
    - + + 263 -
    -   -
    +
    +
    + + + dap, err := dataavailabilityprotocol.NewDataavailabilityprotocol(dapAddr, ethClient)
    - + + 264 -
    +
    +
      -
    + if err != nil {
    - + + 265 -
    +
    +
      -
    + return nil, err
    - + + 266 -
    +
    +
      -
    + }
    - + + 267 -
    -   -
    +
    +
    + + + var scAddresses []common.Address
    - + + 268 -
    +
    +
      -
    + scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr)
    - + + 269 -
    +
    +
     
    - + + 270 -
    +
    +
      -
    + gProviders := []ethereum.GasPricer{ethClient}
    - + +
     
    -
    +
    + 279 + +
      -
    + }
    - + + 280 -
    +
    +
      -
    + metrics.Register()
    - + + 281 -
    +
    +
      -
    + // Get RollupID
    - + + 282 -
    -   -
    +
    +
    + + + rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr)
    - + + 283 -
    +
    +
      -
    + if err != nil {
    - + + 284 -
    +
    +
      -
    + log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err)
    - + + 285 -
    +
    +
      -
    + return nil, err
    - + + 286 -
    +
    +
      -
    -
    -
    -
    + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - -
    -
     
    - 1 + + 287 +
    - + - package migrations_test +   + log.Debug("rollupID: ", rollupID)
    - 2 + + 288 +
    - + +  
    - 3 + + 289 +
    + - import ( + return &Client{
    - 4 + + 290 +
    + - "database/sql" + EthClient: ethClient,
    - 5 + + 291 +
    + - "testing" + ZkEVM: zkevm,
    - 6 + + 292 +
    + -
    + EtrogZKEVM: etrogZkevm,
    - 7 + + 293 +
    + - "github.com/0xPolygonHermez/zkevm-node/hex" + OldZkEVM: oldZkevm,
    - 8 + + 294 +
    + - "github.com/ethereum/go-ethereum/common" + RollupManager: rollupManager,
    - 9 + + 295 +
    + - "github.com/stretchr/testify/require" + Pol: pol,
    - 10 + + 296 +
    + - ) + GlobalExitRootManager: globalExitRoot,
    - 11 + + 297 +
    + -
    + DAProtocol: dap,
    - 12 + + 298 +
    + - type migrationTest0019TestCase struct { + OldGlobalExitRootManager: oldGlobalExitRoot,
    - 13 + + 299 +
    + - Name string + SCAddresses: scAddresses,
    - 14 + 300
    + - Block migrationTest0019TestCaseBlock + RollupID: rollupID,
    - 15 + + 301 +
    - + - } +   + GasProviders: externalGasProviders{
    - 16 + + 302 +
    - + -
    +   + MultiGasProvider: cfg.MultiGasProvider,
    - 17 + + 303 +
    - + - type migrationTest0019TestCaseBlock struct { +   + Providers: gProviders,
    - 18 + + 304 +
    - + - Transactions []migrationTest0019TestCaseTransaction +   + },
    - 19 + + 305 +
    + - } + l1Cfg: l1Config,
    - 20 + + 306 +
    + -
    + cfg: cfg,
    - 21 + + 307 +
    + - type migrationTest0019TestCaseTransaction struct { + auth: map[common.Address]bind.TransactOpts{},
    - 22 + + 308 +
    + - CurrentIndex uint + da: da,
    - 23 + + 309 +
    + - } + state: st,
    - 24 + + 310 +
    + -
    + }, nil
    - 25 + + -
    - + - type migrationTest0019 struct { +
    +
    +   +
    - 26 + + -
    - + - TestCases []migrationTest0019TestCase +
    +
    +   +
    - 27 + + -
    - + - } +
    +
    +   +
    - 28 + + -
    - + +
    +
    +  
    - 29 + + -
    - + - func (m migrationTest0019) InsertData(db *sql.DB) error { +
    +
    +   +
    - 30 + + 311 +
    - + - const addBlock0 = "INSERT INTO state.block (block_num, received_at, block_hash) VALUES (0, now(), '0x0')" +   + }
    - 31 + + 312 +
    - + - if _, err := db.Exec(addBlock0); err != nil { +   +
    - 32 + + 313 +
    - + - return err +   + // VerifyGenBlockNumber verifies if the genesis Block Number is valid
    - 33 + + 314 +
    - + - } +   + func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) {
    - 34 + 315
    + -
    + // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block
    - 35 + + 316 +
    - + - const addBatch0 = ` +   + start := time.Now()
    - 36 + + 317 +
    - + - 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) +   + log.Info("Verifying genesis blockNumber: ", genBlockNumber)
    - 37 + + 318 +
    - + - VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)` +   + // Filter query
    - 38 + +
     
    +
    + 330 +
    - + - if _, err := db.Exec(addBatch0); err != nil { +   + if len(logs) == 0 {
    - 39 + + 331 +
    - + - return err +   + return false, fmt.Errorf("the specified genBlockNumber in config file does not contain any forkID event. Please use the proper blockNumber.")
    - 40 + + 332 +
    - + +   }
    - 41 + + 333 +
    + -
    + var zkevmVersion oldpolygonzkevm.OldpolygonzkevmUpdateZkEVMVersion
    - 42 + + 334 +
    - + - const addL2Block = "INSERT INTO state.l2block (block_num, block_hash, header, uncles, parent_hash, state_root, received_at, batch_num, created_at) VALUES ($1, $2, '{}', '{}', '0x0', '0x0', now(), 0, now())" +   + switch logs[0].Topics[0] {
    - 43 + + 335 +
    - + - const addTransaction = "INSERT INTO state.transaction (hash, encoded, decoded, l2_block_num, effective_percentage, l2_hash) VALUES ($1, 'ABCDEF', '{}', $2, 255, $1)" +   + case updateZkEVMVersionSignatureHash:
    - 44 + + 336 +
    - + - const addReceipt = "INSERT INTO state.receipt (tx_hash, type, post_state, status, cumulative_gas_used, gas_used, effective_gas_price, block_num, tx_index, contract_address) VALUES ($1, 1, null, 1, 1234, 1234, 1, $2, $3, '')" +   + log.Debug("UpdateZkEVMVersion event detected during the Verification of the GenBlockNumber")
    - 45 + + 337 +
    + -
    + zkevmV, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(logs[0])
    - 46 + + 338 +
    - + - txUnique := 0 +   + if err != nil {
    - 47 + + 339 +
    - + - for tci, testCase := range m.TestCases { +   + return false, err
    - 48 + + 340 +
    - + - blockNum := uint64(tci + 1) +   + }
    - 49 + +
     
    +
    + 343 +
    - + - blockHash := common.HexToHash(hex.EncodeUint64(blockNum)).String() +   + }
    - 50 + + 344 +
    - + - if _, err := db.Exec(addL2Block, blockNum, blockHash); err != nil { +   + case createNewRollupSignatureHash:
    - 51 + + 345 +
    - + - return err +   + log.Debug("CreateNewRollup event detected during the Verification of the GenBlockNumber")
    - 52 + + 346 +
    + - } + createNewRollupEvent, err := etherMan.RollupManager.ParseCreateNewRollup(logs[0])
    - 53 + + 347 +
    - + - for _, tx := range testCase.Block.Transactions { +   + if err != nil {
    - 54 + + 348 +
    - + - txUnique++ +   + return false, err
    - 55 + + 349 +
    - + - txHash := common.HexToHash(hex.EncodeUint64(uint64(txUnique))).String() +   + }
    - 56 + + 350 +
    - + - if _, err := db.Exec(addTransaction, txHash, blockNum); err != nil { +   + // Query to get the forkID
    - 57 + + 351 +
    + - return err + rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID)
    - 58 + + 352 +
    - + - } +   + if err != nil {
    - 59 + + 353 +
    - + - if _, err := db.Exec(addReceipt, txHash, blockNum, tx.CurrentIndex); err != nil { +   + log.Error(err)
    - 60 + + 354 +
    - + - return err +   + return false, err
    - 61 + +
     
    +
    + 363 +
    - + - } +   + return true, nil
    - 62 + + 364 +
    - + - } +   + }
    - 63 + + 365 +
    - + - } +   +
    - 64 + + -
    - + +
    +
    +  
    - 65 + + -
    - + - return nil +
    +
    +   +
    - 66 + + -
    - + - } +
    +
    +   +
    - 67 + + -
    - + +
    +
    +  
    - 68 + + -
    - + - func (m migrationTest0019) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +
    +
    +   +
    - 69 + + -
    - + - const getReceiptsByBlock = "SELECT r.tx_index FROM state.receipt r WHERE r.block_num = $1 ORDER BY r.tx_index" +
    +
    +   +
    - 70 + + -
    - + +
    +
    +  
    - 71 + + -
    - + - for tci := range m.TestCases { +
    +
    +   +
    - 72 + + -
    - + - blockNum := uint64(tci + 1) +
    +
    +   +
    - 73 + + -
    - + +
    +
    +  
    - 74 + + -
    - + - rows, err := db.Query(getReceiptsByBlock, blockNum) +
    +
    +   +
    - 75 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 76 + + -
    - + +
    +
    +  
    - 77 + + -
    - + - var expectedIndex = uint(0) +
    +
    +   +
    - 78 + + -
    - + - var txIndex uint +
    +
    +   +
    - 79 + + -
    - + - for rows.Next() { +
    +
    +   +
    - 80 + + -
    - + - err := rows.Scan(&txIndex) +
    +
    +   +
    - 81 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 82 + + -
    - + - require.Equal(t, expectedIndex, txIndex) +
    +
    +   +
    - 83 + + -
    - + - expectedIndex++ +
    +
    +   +
    - 84 + + -
    - + - } +
    +
    +   +
    - 85 + + 366 +
    - + - } +   + // GetForks returns fork information
    - 86 + + 367 +
    - + - } +   + func (etherMan *Client) GetForks(ctx context.Context, genBlockNumber uint64, lastL1BlockSynced uint64) ([]state.ForkIDInterval, error) {
    - 87 + + 368 +
    - + -
    +   + log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber)
    - 88 + + 369 +
    - + - func (m migrationTest0019) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { +   + start := time.Now()
    - 89 + + 370 +
    - + - m.RunAssertsAfterMigrationUp(t, db) +   + var logs []types.Log
    - 90 + + 371 +
    + - } +
    - 91 + + 372 +
    - + -
    +   + if lastL1BlockSynced < genBlockNumber {
    - 92 + + 373 +
    - + - func TestMigration0019(t *testing.T) { +   + lastL1BlockSynced = genBlockNumber
    - 93 + + 374 +
    - + - runMigrationTest(t, 19, migrationTest0019{ +   + }
    - 94 + 375
    + - TestCases: []migrationTest0019TestCase{ +
    - 95 + + 376 +
    - + - { +   + log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize)
    - 96 + + 377 +
    - + - Name: "single tx with correct index", +   + for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 {
    - 97 + + 378 +
    - + - Block: migrationTest0019TestCaseBlock{ +   + final := i + etherMan.cfg.ForkIDChunkSize
    - 98 + +
     
    +
    + 397 +
    - + - Transactions: []migrationTest0019TestCaseTransaction{ +   +
    - 99 + + 398 +
    - + - {CurrentIndex: 0}, +   + var forks []state.ForkIDInterval
    - 100 + + 399 +
    - + - }, +   + for i, l := range logs {
    - 101 + + 400 +
    + - }, + var zkevmVersion oldpolygonzkevm.OldpolygonzkevmUpdateZkEVMVersion
    - 102 + + 401 +
    - + - }, +   + switch l.Topics[0] {
    - 103 + + 402 +
    - + - { +   + case updateZkEVMVersionSignatureHash:
    - 104 + + 403 +
    - + - Name: "multiple txs indexes are correct", +   + log.Debug("updateZkEVMVersion Event received")
    - 105 + + 404 +
    + - Block: migrationTest0019TestCaseBlock{ + zkevmV, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(l)
    - 106 + + 405 +
    - + - Transactions: []migrationTest0019TestCaseTransaction{ +   + if err != nil {
    - 107 + + 406 +
    - + - {CurrentIndex: 0}, +   + return []state.ForkIDInterval{}, err
    - 108 + + 407 +
    - + - {CurrentIndex: 1}, +   + }
    - 109 + +
     
    +
    + 410 +
    - + - {CurrentIndex: 2}, +   + }
    - 110 + + 411 +
    - + - }, +   + case updateRollupSignatureHash:
    - 111 + + 412 +
    - + - }, +   + log.Debug("updateRollup Event received")
    - 112 + + 413 +
    + - }, + updateRollupEvent, err := etherMan.RollupManager.ParseUpdateRollup(l)
    - 113 + + 414 +
    - + - { +   + if err != nil {
    - 114 + + 415 +
    - + - Name: "single tx with wrong tx index", +   + return []state.ForkIDInterval{}, err
    - 115 + + 416 +
    - + - Block: migrationTest0019TestCaseBlock{ +   + }
    - 116 + +
     
    +
    + 418 +
    - + - Transactions: []migrationTest0019TestCaseTransaction{ +   + continue
    - 117 + + 419 +
    - + - {CurrentIndex: 3}, +   + }
    - 118 + + 420 +
    - + - }, +   + // Query to get the forkID
    - 119 + + 421 +
    + - }, + rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollupEvent.NewRollupTypeID)
    - 120 + + 422 +
    - + - }, +   + if err != nil {
    - 121 + + 423 +
    - + - { +   + return []state.ForkIDInterval{}, err
    - 122 + + 424 +
    - + - Name: "multiple txs missing 0 index", +   + }
    - 123 + +
     
    +
    + 427 +
    - + - Block: migrationTest0019TestCaseBlock{ +   +
    - 124 + + 428 +
    - + - Transactions: []migrationTest0019TestCaseTransaction{ +   + case addExistingRollupSignatureHash:
    - 125 + + 429 +
    - + - {CurrentIndex: 1}, +   + log.Debug("addExistingRollup Event received")
    - 126 + + 430 +
    + - {CurrentIndex: 2}, + addExistingRollupEvent, err := etherMan.RollupManager.ParseAddExistingRollup(l)
    - 127 + + 431 +
    - + - {CurrentIndex: 3}, +   + if err != nil {
    - 128 + + 432 +
    - + - {CurrentIndex: 4}, +   + return []state.ForkIDInterval{}, err
    - 129 + + 433 +
    - + - }, +   + }
    - 130 + +
     
    +
    + 439 +
    - + - }, +   +
    - 131 + + 440 +
    - + - }, +   + case createNewRollupSignatureHash:
    - 132 + + 441 +
    - + - { +   + log.Debug("createNewRollup Event received")
    - 133 + + 442 +
    + - Name: "multiple has index 0 but also txs index gap", + createNewRollupEvent, err := etherMan.RollupManager.ParseCreateNewRollup(l)
    - 134 + + 443 +
    - + - Block: migrationTest0019TestCaseBlock{ +   + if err != nil {
    - 135 + + 444 +
    - + - Transactions: []migrationTest0019TestCaseTransaction{ +   + return []state.ForkIDInterval{}, err
    - 136 + + 445 +
    - + - {CurrentIndex: 0}, +   + }
    - 137 + +
     
    +
    + 447 +
    - + - {CurrentIndex: 2}, +   + continue
    - 138 + + 448 +
    - + - {CurrentIndex: 4}, +   + }
    - 139 + + 449 +
    - + - {CurrentIndex: 6}, +   + // Query to get the forkID
    - 140 + + 450 +
    + - }, + rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createNewRollupEvent.RollupTypeID)
    - 141 + + 451 +
    - + - }, +   + if err != nil {
    - 142 + + 452 +
    - + - }, +   + log.Error(err)
    - 143 + + 453 +
    - + - }, +   + return []state.ForkIDInterval{}, err
    - 144 + +
     
    +
    + 499 +
    - + - }) +   + return blocks, blocksOrder, nil
    - 145 + + 500 +
    - + +   }
    -
    + + + 501 + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020.sql - RENAMED - -
    -
    -
    -
    - - - - - + + + + + + + + + + + + + + + + + + + + + - - -
    -
    @@ -0,0 +1,28 @@
    @@ -52681,6 +128294,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 502 + +
    +   + // Order contains the event order to let the synchronizer store the information following this order. +
    +
    + 503 + +
    +   + type Order struct { +
    +
    + 504 + +
    +   + Name EventOrder +
    +
    +
     
    +
    + 529 + +
    +   + metrics.ReadAndProcessAllEventsTime(time.Since(start)) +
    +
    + 530 + +
    +   + return blocks, blocksOrder, nil +
    +
    + 531 + +
    +   + } +
    +
    @@ -52771,447 +128449,764 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + 532 + + +
    +   +
    -
    -
    - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + - + + - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - -
    + 533 + +
    + + + func (etherMan *Client) processEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { +
    +
    + 534 + +
    +   + switch vLog.Topics[0] { +
    +
    + 535 + +
    +   + case sequenceBatchesSignatureHash: +
    +
    + 536 + +
    +   + return etherMan.sequencedBatchesEvent(ctx, vLog, blocks, blocksOrder) +
    +
     
    - 1 + + 552 +
    - + - -- +migrate Up +   + case rollupManagerVerifyBatchesSignatureHash:
    - 2 + + 553 +
    - + -
    +   + log.Debug("RollupManagerVerifyBatches event detected. Ignoring...")
    - 3 + + 554 +
    - + - -- This migration will delete all empty blocks +   + return nil
    - 4 + + 555 +
    + - DELETE FROM state.block + case oldVerifyBatchesTrustedAggregatorSignatureHash:
    - 5 + + 556 +
    + - WHERE NOT EXISTS (SELECT * + return etherMan.oldVerifyBatchesTrustedAggregatorEvent(ctx, vLog, blocks, blocksOrder)
    - 6 + + 557 +
    - + - FROM state.virtual_batch +   + case verifyBatchesSignatureHash:
    - 7 + + 558 +
    - + - WHERE state.virtual_batch.block_num = state.block.block_num) +   + return etherMan.verifyBatchesEvent(ctx, vLog, blocks, blocksOrder)
    - 8 + + 559 +
    - + - AND NOT EXISTS (SELECT * +   + case sequenceForceBatchesSignatureHash:
    - 9 + +
     
    +
    + 593 +
    - + - FROM state.verified_batch +   + case consolidatePendingStateSignatureHash:
    - 10 + + 594 + +
    +   + log.Debug("ConsolidatePendingState event detected. Ignoring...") +
    +
    + 595 + +
    +   + return nil +
    +
    + 596 +
    + - WHERE state.verified_batch.block_num = state.block.block_num) + case oldConsolidatePendingStateSignatureHash:
    - 11 + + 597 +
    + - AND NOT EXISTS (SELECT * + log.Debug("OldConsolidatePendingState event detected. Ignoring...")
    - 12 + + 598 + +
    +   + return nil +
    +
    + 599 + +
    +   + case setTrustedAggregatorTimeoutSignatureHash: +
    +
    + 600 + +
    +   + log.Debug("SetTrustedAggregatorTimeout event detected. Ignoring...") +
    +
    +
     
    +
    + 629 + +
    +   + case overridePendingStateSignatureHash: +
    +
    + 630 + +
    +   + log.Debug("OverridePendingState event detected. Ignoring...") +
    +
    + 631 + +
    +   + return nil +
    +
    + 632 +
    + - FROM state.forced_batch + case oldOverridePendingStateSignatureHash:
    - 13 + + 633 +
    + - WHERE state.forced_batch.block_num = state.block.block_num) + log.Debug("OldOverridePendingState event detected. Ignoring...")
    - 14 + + 634 + +
    +   + return nil +
    +
    + 635 + +
    +   + case roleAdminChangedSignatureHash: +
    +
    + 636 + +
    +   + log.Debug("RoleAdminChanged event detected. Ignoring...") +
    +
    +
     
    +
    + 666 + +
    +   +
    +
    +
    + 667 + +
    +   + func (etherMan *Client) updateZkevmVersion(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { +
    +
    + 668 + +
    +   + log.Debug("UpdateZkEVMVersion event detected") +
    +
    + 669 +
    + - AND NOT EXISTS (SELECT * + zkevmVersion, err := etherMan.OldZkEVM.ParseUpdateZkEVMVersion(vLog)
    - 15 + + 670 + +
    +   + if err != nil { +
    +
    + 671 + +
    +   + log.Error("error parsing UpdateZkEVMVersion event. Error: ", err) +
    +
    + 672 + +
    +   + return err +
    +
    +
     
    +
    + 676 + +
    +   +
    +
    +
    + 677 + +
    +   + func (etherMan *Client) updateRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { +
    +
    + 678 + +
    +   + log.Debug("UpdateRollup event detected") +
    +
    + 679 +
    + - FROM state.exit_root + updateRollup, err := etherMan.RollupManager.ParseUpdateRollup(vLog)
    - 16 + + 680 + +
    +   + if err != nil { +
    +
    + 681 + +
    +   + log.Error("error parsing UpdateRollup event. Error: ", err) +
    +
    + 682 + +
    +   + return err +
    +
    + 683 + +
    +   + } +
    +
    + 684 +
    + - WHERE state.exit_root.block_num = state.block.block_num) + rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, updateRollup.NewRollupTypeID)
    - 17 + + 685 + +
    +   + if err != nil { +
    +
    + 686 + +
    +   + return err +
    +
    + 687 + +
    +   + } +
    +
    +
     
    +
    + 690 +
    - + - AND NOT EXISTS (SELECT * +   +
    - 18 + + 691 +
    - + - FROM state.monitored_txs +   + func (etherMan *Client) createNewRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 19 + + 692 +
    - + - WHERE state.monitored_txs.block_num = state.block.block_num) +   + log.Debug("createNewRollup event detected")
    - 20 + + 693 +
    + - AND NOT EXISTS (SELECT * + createRollup, err := etherMan.RollupManager.ParseCreateNewRollup(vLog)
    - 21 + + 694 +
    - + - FROM state.fork_id +   + if err != nil {
    - 22 + + 695 +
    - + - WHERE state.fork_id.block_num = state.block.block_num); +   + log.Error("error parsing createNewRollup event. Error: ", err)
    - 23 + + 696 +
    - + - +   + return err
    - 24 + + 697 +
    - + -
    +   + }
    - 25 + + 698 +
    + -
    + rollupType, err := etherMan.RollupManager.RollupTypeMap(&bind.CallOpts{Pending: false}, createRollup.RollupTypeID)
    - 26 + + 699 +
    - + - -- +migrate Down +   + if err != nil {
    - 27 + + 700 +
    - + -
    +   + return err
    - 28 + + 701 +
    - + - -- no action is needed, the data must remain deleted as it is useless +   + }
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/0020_test.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - @@ -53745,1995 +129740,1988 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,99 @@
    +
     
    - + + 704 -
    +
    +
     
    - + + 705 -
    +
    +
      -
    + func (etherMan *Client) addExistingRollup(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 706 -
    +
    +
      -
    + log.Debug("addExistingRollup event detected")
    - + + 707 -
    -   -
    +
    +
    + + + addExistingRollup, err := etherMan.RollupManager.ParseAddExistingRollup(vLog)
    - + + 708 -
    +
    +
      -
    + if err != nil {
    - + + 709 -
    +
    +
      -
    + log.Error("error parsing createNewRollup event. Error: ", err)
    - + + 710 -
    +
    +
      -
    + return err
    - + +
     
    -
    +
    + 713 + +
      -
    + return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID)
    - + + 714 -
    +
    +
      -
    + }
    - + + 715 -
    +
    +
     
    - + + 716 -
    -   -
    +
    +
    + + + func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error {
    - + + 717 -
    -   -
    +
    +
    + + + return errors.New("upgrading validiums to etrog not supported")
    - + + 718 -
    +
    +
      -
    + }
    - + + 719 -
    +
    +
     
    - + + 720 -
    +
    +
      -
    + func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 721 -
    +
    +
      -
    + log.Debug("initialSequenceBatches event detected")
    - + + 722 -
    -   -
    +
    +
    + + + initialSequenceBatches, err := etherMan.ZkEVM.ParseInitialSequenceBatches(vLog)
    - + + 723 -
    +
    +
      -
    + if err != nil {
    - + + 724 -
    +
    +
      -
    + log.Error("error parsing initialSequenceBatches event. Error: ", err)
    - + + 725 -
    +
    +
      -
    + return err
    - + +
     
    -
    +
    + 749 + +
      -
    + SequencerAddr: initialSequenceBatches.Sequencer,
    - + + 750 -
    +
    +
      -
    + TxHash: vLog.TxHash,
    - + + 751 -
    +
    +
      -
    + Nonce: msg.Nonce,
    - + + 752 -
    -   -
    +
    +
    + + + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 753 -
    +
    +
      -
    + Transactions: initialSequenceBatches.Transactions,
    - + + 754 -
    +
    +
      -
    + ForcedGlobalExitRoot: initialSequenceBatches.LastGlobalExitRoot,
    - + + 755 -
    +
    +
      -
    + ForcedTimestamp: fullBlock.Time(),
    - + +
     
    -
    +
    + 809 + +
     
    - + + 810 -
    +
    +
      -
    + func (etherMan *Client) updateL1InfoTreeEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 811 -
    +
    +
      -
    + log.Debug("UpdateL1InfoTree event detected")
    - + + 812 -
    -   -
    +
    +
    + + + globalExitRootL1InfoTree, err := etherMan.GlobalExitRootManager.ParseUpdateL1InfoTree(vLog)
    - + + 813 -
    +
    +
      -
    + if err != nil {
    - + + 814 -
    +
    +
      -
    + return err
    - + + 815 -
    +
    +
      -
    + }
    - + + 816 -
    +
    +
     
    - + + 817 -
    +
    +
      -
    + var gExitRoot GlobalExitRoot
    - + + 818 -
    -   -
    +
    +
    + + + gExitRoot.MainnetExitRoot = globalExitRootL1InfoTree.MainnetExitRoot
    - + + 819 -
    -   -
    +
    +
    + + + gExitRoot.RollupExitRoot = globalExitRootL1InfoTree.RollupExitRoot
    - + + 820 -
    +
    +
      -
    + gExitRoot.BlockNumber = vLog.BlockNumber
    - + + 821 -
    -   -
    +
    +
    + + + gExitRoot.GlobalExitRoot = hash(globalExitRootL1InfoTree.MainnetExitRoot, globalExitRootL1InfoTree.RollupExitRoot)
    - + + 822 -
    +
    +
      -
    + var block *Block
    - + + 823 -
    +
    +
      -
    + if !isheadBlockInArray(blocks, vLog.BlockHash, vLog.BlockNumber) {
    - + + 824 -
    +
    +
      -
    + // Need to add the block, doesnt mind if inside the blocks because I have to respect the order so insert at end
    - + + 825 -
    -   -
    +
    +
    + + + block, err = etherMan.retrieveFullBlockForEvent(ctx, vLog)
    - + + 826 -
    +
    +
      -
    + if err != nil {
    - + + 827 -
    +
    +
      -
    + return err
    -
    + + + 828 + + +
    +   + }
    -
    -
    - - - + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - -
     
    - 1 + + 842 +
    - + - package migrations_test +   + return nil
    - 2 + + 843 +
    - + -
    +   + }
    - 3 + + 844 +
    - + - import ( +   +
    - 4 + + 845 +
    + - "database/sql" + func (etherMan *Client) retrieveFullBlockForEvent(ctx context.Context, vLog types.Log) (*Block, error) {
    - 5 + + -
    - + - "fmt" +
    +
    +   +
    - 6 + + 846 +
    - + - "testing" +   + fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash)
    - 7 + + 847 +
    - + -
    +   + if err != nil {
    - 8 + + 848 +
    - + - "github.com/stretchr/testify/assert" +   + return nil, fmt.Errorf("error getting hashParent. BlockNumber: %d. Error: %w", vLog.BlockNumber, err)
    - 9 - -
    - + - ) -
    +
    +
     
    - 10 + + 861 +
    - + +  
    - 11 + + 862 +
    - + - // this migration changes length of the token name +   + func (etherMan *Client) updateGlobalExitRootEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 12 + + 863 +
    - + - type migrationTest0020 struct{} +   + log.Debug("UpdateGlobalExitRoot event detected")
    - 13 + + 864 +
    + -
    + oldglobalExitRoot, err := etherMan.OldGlobalExitRootManager.ParseUpdateGlobalExitRoot(vLog)
    - 14 + + 865 +
    - + - func (m migrationTest0020) InsertData(db *sql.DB) error { +   + if err != nil {
    - 15 + + 866 +
    - + - addBlocks := ` +   + return err
    - 16 + + 867 +
    - + - INSERT INTO state.block +   + }
    - 17 + + 868 +
    + - (block_num, block_hash, parent_hash, received_at, checked) + return etherMan.processUpdateGlobalExitRootEvent(ctx, oldglobalExitRoot.MainnetExitRoot, oldglobalExitRoot.RollupExitRoot, vLog, blocks, blocksOrder)
    - 18 + + 869 +
    - + - VALUES(1, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b20', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fe', '2024-03-11 02:52:23.000', true); +   + }
    - 19 + + 870 +
    - + - INSERT INTO state.block +   +
    - 20 + + 871 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + func (etherMan *Client) processUpdateGlobalExitRootEvent(ctx context.Context, mainnetExitRoot, rollupExitRoot common.Hash, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 21 + +
     
    +
    + 913 +
    - + - VALUES(2, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b21', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f1', '2024-03-11 02:52:24.000', true); +   + }
    - 22 + + 914 +
    - + - INSERT INTO state.block +   +
    - 23 + + 915 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + // EstimateGasSequenceBatches estimates gas for sending batches
    - 24 + + 916 +
    + - VALUES(3, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b22', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f2', '2024-03-11 02:52:25.000', false); + func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 25 + + 917 +
    - + - INSERT INTO state.block +   + opts, err := etherMan.getAuthByAddress(sender)
    - 26 + + 918 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + if err == ErrNotFound {
    - 27 + + 919 +
    - + - VALUES(4, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b23', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f3', '2024-03-11 02:52:26.000', false); +   + return nil, ErrPrivateKeyNotFound
    - 28 + + 920 +
    - + - INSERT INTO state.block +   + }
    - 29 + + 921 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + opts.NoSend = true
    - 30 + + 922 +
    - + - VALUES(5, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b24', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f4', '2024-03-11 02:52:27.000', true); +   +
    - 31 + + 923 +
    + - INSERT INTO state.block + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 32 + + 924 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + if err != nil {
    - 33 + + 925 +
    - + - VALUES(6, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b25', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f5', '2024-03-11 02:52:28.000', true); +   + return nil, err
    - 34 + + 926 +
    - + - INSERT INTO state.block +   + }
    - 35 + +
     
    +
    + 929 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + }
    - 36 + + 930 +
    - + - VALUES(7, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b26', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f6', '2024-03-11 02:52:29.000', true); +   +
    - 37 + + 931 +
    - + - INSERT INTO state.block +   + // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches.
    - 38 + + 932 +
    + - (block_num, block_hash, parent_hash, received_at, checked) + func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (to *common.Address, data []byte, err error) {
    - 39 + + 933 +
    - + - VALUES(8, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b27', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f7', '2024-03-11 02:52:30.000', true); +   + opts, err := etherMan.getAuthByAddress(sender)
    - 40 + + 934 +
    - + - INSERT INTO state.block +   + if err == ErrNotFound {
    - 41 + + 935 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound)
    - 42 + +
     
    +
    + 940 +
    - + - VALUES(9, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b28', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f8', '2024-03-11 02:52:31.000', true); +   + opts.GasLimit = uint64(1)
    - 43 + + 941 +
    - + - INSERT INTO state.block +   + opts.GasPrice = big.NewInt(1)
    - 44 + + 942 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   +
    - 45 + + 943 +
    + - VALUES(10, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b29', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50f9', '2024-03-11 02:52:32.000', true); + tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 46 + + 944 +
    - + - INSERT INTO state.block +   + if err != nil {
    - 47 + + 945 +
    - + - (block_num, block_hash, parent_hash, received_at, checked) +   + return nil, nil, err
    - 48 + + 946 +
    - + - VALUES(11, '0x013be63487a53c874614dd1ae0434cf211e393b2e386c8fde74da203b5469b2a', '0x0328698ebeda498df8c63040e2a4771d24722ab2c1e8291226b9215c7eec50fa', '2024-03-11 02:52:33.000', true); +   + }
    - 49 - -
    - + - INSERT INTO state.batch -
    +
    +
     
    - 50 + + 948 +
    - + - (batch_num, global_exit_root, local_exit_root, state_root, acc_input_hash, "timestamp", coinbase, raw_txs_data, forced_batch_num, batch_resources, closing_reason, wip, checked) +   + return tx.To(), tx.Data(), nil
    - 51 + + 949 +
    - + - VALUES(1, '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9', '0xa5bd7311fe00707809dd3aa718be2ea0cb363626b9db44172098515f07acf940', '2023-03-24 16:35:27.000', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', decode('','hex'), NULL, '{"Bytes": 0, "ZKCounters": {"GasUsed": 0, "UsedSteps": 0, "UsedBinaries": 0, "UsedMemAligns": 0, "UsedArithmetics": 0, "UsedKeccakHashes": 0, "UsedPoseidonHashes": 0, "UsedSha256Hashes_V2": 0, "UsedPoseidonPaddings": 0}}'::jsonb, '', false, true); +   + }
    - 52 + + 950 +
    - + - INSERT INTO state.virtual_batch +   +
    - 53 + + 951 +
    + - (batch_num, tx_hash, coinbase, block_num, sequencer_addr, timestamp_batch_etrog, l1_info_root) + func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) {
    - 54 + + 952 +
    + - VALUES(1, '0x4314ed5d8ad4812e88895942b2b4642af176d80a97c5489a16a7a5aeb08b51a6', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', 2, '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '2024-04-09 16:26:45.000', '0xcdb4258d7ccd8fd41c4a26fd8d9d1fadbc9c506e64d489170525a65e2ad3580b'); + var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - 55 + + 953 +
    - + - INSERT INTO state.verified_batch +   + for _, seq := range sequences {
    - 56 + + 954 +
    - + - (batch_num, tx_hash, aggregator, state_root, block_num, is_trusted) +   + var ger common.Hash
    - 57 + + 955 +
    - + - VALUES(1, '0x28e82f15ab7bac043598623c65a838c315d00ecb5d6e013c406d6bb889680592', '0x6329Fe417621925C81c16F9F9a18c203C21Af7ab', '0x80bd488b1e150b9b42611d038c7fdfa43a3e95b3a02e5c2d57074e73b583f8fd', 3, true); +   + if seq.ForcedBatchTimestamp > 0 {
    - 58 + + 956 +
    - + - INSERT INTO state.fork_id +   + ger = seq.GlobalExitRoot
    - 59 + + 957 +
    - + - (fork_id, from_batch_num, to_batch_num, "version", block_num) +   + }
    - 60 + + 958 +
    + - VALUES(5, 813267, 1228916, 'v2.0.0-RC1-fork.5', 5); + batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - 61 + + 959 +
    + - INSERT INTO state.monitored_txs + TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data),
    - 62 + + 960 +
    - + - ("owner", id, from_addr, to_addr, nonce, value, "data", gas, gas_price, status, history, block_num, created_at, updated_at, gas_offset) +   + ForcedGlobalExitRoot: ger,
    - 63 + + 961 +
    - + - VALUES('sequencer', 'sequence-from-2006249-to-2006252', '0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800', '0x519E42c24163192Dca44CD3fBDCEBF6be9130987', 58056, NULL, 'def57e540000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000006614ec3100000000000000000000000000000000000000000000000000000000001e9ce8000000000000000000000000148ee7da0000000300000000ee8306089a84ae0baa0082520894417a7ba2d8d0060ae6c54fd098590db854b9c1d58609184e72a0008082044d80802787e068e6fe23cda64eb868cefb7231a17449d508a77919f6c5408814aaab5f259d43a62eb50df0b2d5740552d3f95176a1f0e31cade590facf70b01c1129151bab0b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000000000000000000000000000000', 1474265, 25212431373, 'done', '{0x44423d538d6fc2f2e882fcd0d1952a735d81c824827b83936e6a5e52268a7d8e}', 7, '2024-04-09 09:26:36.235', '2024-04-09 09:38:24.377', 150000); +   + ForcedTimestamp: uint64(seq.ForcedBatchTimestamp),
    - 64 + + 962 +
    - + - INSERT INTO state.exit_root +   + ForcedBlockHashL1: seq.PrevBlockHash,
    - 65 + +
     
    +
    + 965 +
    - + - (id, block_num, "timestamp", mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index) +   + batches = append(batches, batch)
    - 66 + + 966 +
    - + - VALUES(379599, 8, '2024-04-09 09:43:59.000', decode('C90DCBC69719971625800AD619E5EEEFD0378317E26F0DDE9B30B3C7C84DBD78','hex'), decode('514D72BBF7C2AD8E4D15EC1186EBF077E98208479651B1C30C5AC7DA11BAB209','hex'), decode('B20FACBED4A2774CE33A0F68D9B6F9B4D9AD553DACD73705503910B141D2102E','hex'), decode('845E01F723E5C77DBE5A4889F299860FBECD8353BFD423D366851F3A90496334','hex'), decode('EDB0EF9C80E947C411FD9B8B23318708132F8A3BD15CD366499866EF91748FC8','hex'), 8032); +   + }
    - 67 + + 967 +
    - + - INSERT INTO state.forced_batch +   +
    - 68 + + 968 +
    + - (block_num, forced_batch_num, global_exit_root, timestamp, raw_txs_data, coinbase) + tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage)
    - 69 + + 969 +
    - + - VALUES(10, 1, '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5ca', '2024-04-09 09:26:36.235', '0x3f86b09b', '0x3f86b09b43e3e49a41fc20a07579b79eba044253367817d5c241d23c0e2bc5c9'); +   + if err != nil {
    - 70 + + 970 +
    - + - ` +   + log.Debugf("Batches to send: %+v", batches)
    - 71 + + 971 +
    - + - if _, err := db.Exec(addBlocks); err != nil { +   + log.Debug("l2CoinBase: ", l2Coinbase)
    - 72 + + 972 +
    - + - return err +   + log.Debug("Sequencer address: ", opts.From)
    - 73 + + 973 +
    + - } + a, err2 := polygonzkevm.PolygonzkevmMetaData.GetAbi()
    - 74 + + 974 +
    - + - blockCount := `SELECT count(*) FROM state.block` +   + if err2 != nil {
    - 75 + + 975 +
    - + - var count int +   + log.Error("error getting abi. Error: ", err2)
    - 76 + + 976 +
    - + - err := db.QueryRow(blockCount).Scan(&count) +   + }
    - 77 + +
     
    +
    + 1030 +
    - + - if err != nil { +   +
    - 78 + + 1031 +
    - + - return err +   + const pendStateNum = 0 // TODO hardcoded for now until we implement the pending state feature
    - 79 + + 1032 +
    - + - } +   +
    - 80 + + 1033 +
    + - if count != 11 { + tx, err := etherMan.RollupManager.VerifyBatchesTrustedAggregator(
    - 81 + + 1034 +
    - + - return fmt.Errorf("error: initial wrong number of blocks") +   + &opts,
    - 82 + + 1035 +
    - + - } +   + etherMan.RollupID,
    - 83 + + 1036 +
    - + - return nil +   + pendStateNum,
    - 84 + +
     
    +
    + 1072 +
    - + - } +   +
    - 85 + + 1073 +
    - + -
    +   + // GetSendSequenceFee get super/trusted sequencer fee
    - 86 + + 1074 +
    - + - func (m migrationTest0020) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { +   + func (etherMan *Client) GetSendSequenceFee(numBatches uint64) (*big.Int, error) {
    - 87 + + 1075 +
    + - blockCount := `SELECT count(*) FROM state.block` + f, err := etherMan.RollupManager.GetBatchFee(&bind.CallOpts{Pending: false})
    - 88 + + 1076 +
    - + - var count int +   + if err != nil {
    - 89 + + 1077 +
    - + - err := db.QueryRow(blockCount).Scan(&count) +   + return nil, err
    - 90 + + 1078 +
    - + - assert.NoError(t, err) +   + }
    - 91 + +
     
    +
    + 1082 +
    - + - assert.Equal(t, 6, count) +   +
    - 92 + + 1083 +
    - + - } +   + // TrustedSequencer gets trusted sequencer address
    - 93 + + 1084 +
    - + -
    +   + func (etherMan *Client) TrustedSequencer() (common.Address, error) {
    - 94 + + 1085 +
    + - func (m migrationTest0020) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { + return etherMan.ZkEVM.TrustedSequencer(&bind.CallOpts{Pending: false})
    - 95 + + 1086 +
    - + +   }
    - 96 + + 1087 +
    - + +  
    - 97 + + 1088 +
    - + - func TestMigration0020(t *testing.T) { +   + func (etherMan *Client) forcedBatchEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 98 + + 1089 +
    - + - runMigrationTest(t, 20, migrationTest0020{}) +   + log.Debug("ForceBatch event detected")
    - 99 + + 1090 +
    + - } -
    -
    -
    + fb, err := etherMan.ZkEVM.ParseForceBatch(vLog)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/db/migrations/state/validium-001.sql - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - -
    -
    @@ -0,0 +1,32 @@
    - + + 1091 -
    +
    +
      -
    + if err != nil {
    - + + 1092 -
    +
    +
      -
    + return err
    - + + 1093 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 1113 -
    +
    +
      -
    + txData := tx.Data()
    - + + 1114 -
    +
    +
      -
    + // Extract coded txs.
    - + + 1115 -
    +
    +
      -
    + // Load contract ABI
    - + + 1116 -
    -   -
    +
    +
    + + + abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    - + + 1117 -
    +
    +
      -
    + if err != nil {
    - + + 1118 -
    +
    +
      -
    + return err
    - + + 1119 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 1162 -
    +
    +
      -
    + func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - + + 1163 -
    +
    +
      -
    + log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:]))
    - + + 1164 -
    +
    +
     
    - + + 1165 -
    -   -
    +
    +
    + + + sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog)
    - + + 1166 -
    +
    +
      -
    + if err != nil {
    - + + 1167 -
    +
    +
      -
    + return err
    - + + 1168 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 1175 -
    +
    +
      -
    + if tx.Hash() != vLog.TxHash {
    - + + 1176 -
    +
    +
      -
    + return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String())
    - + + 1177 -
    +
    +
      -
    + }
    - + + 1178 -
    -   -
    +
    +
    + + + msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0))
    - + + 1179 -
    +
    +
      -
    + if err != nil {
    - + + 1180 -
    +
    +
      -
    + return err
    - + + 1181 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 1184 -
    +
    +
      -
    + if sb.NumBatch != 1 {
    - + + 1185 -
    +
    +
      -
    + methodId := tx.Data()[:4]
    - + + 1186 -
    +
    +
      -
    + log.Debugf("MethodId: %s", common.Bytes2Hex(methodId))
    - + + 1187 -
    -   -
    +
    +
    + + + if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) ||
    -
    + + + 1188 + + +
    + + + bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) {
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - -
    -
     
    - 1 + 1189
    + - -- +migrate Up + sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 2 + + 1190 +
    - + -
    +   + if err != nil {
    - 3 + + 1191 +
    - + - CREATE TABLE IF NOT EXISTS state.batch_data_backup +   + return fmt.Errorf("error decoding the sequences (etrog): %v", err)
    - 4 + + 1192 +
    - + - ( +   + }
    - 5 + + 1193 +
    + - batch_num BIGINT, + } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) ||
    - 6 + + 1194 +
    + - data BYTEA, + bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) {
    - 7 + 1195
    + - created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state)
    - 8 + + 1196 +
    - + - PRIMARY KEY (batch_num, created_at) +   + if err != nil {
    - 9 + + 1197 +
    - + - ); +   + return fmt.Errorf("error decoding the sequences (elderberry): %v", err)
    - 10 + + 1198 +
    - + -
    +   + }
    - 11 + +
     
    +
    + 1233 +
    - + - -- +migrate StatementBegin +   +
    - 12 + + 1234 +
    - + - CREATE OR REPLACE FUNCTION backup_batch() RETURNS trigger AS $$ +   + func (etherMan *Client) sequencedBatchesPreEtrogEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 13 + + 1235 +
    - + - BEGIN +   + log.Debug("Pre etrog SequenceBatches event detected")
    - 14 + + 1236 +
    + - INSERT INTO state.batch_data_backup (batch_num, data) + sb, err := etherMan.OldZkEVM.ParseSequenceBatches(vLog)
    - 15 + + 1237 +
    - + - VALUES (OLD.batch_num, OLD.raw_txs_data) +   + if err != nil {
    - 16 + + 1238 +
    - + - ON CONFLICT (batch_num, created_at) DO UPDATE SET +   + return err
    - 17 + + 1239 +
    - + - data = EXCLUDED.data; +   + }
    - 18 + +
     
    +
    + 1278 +
    - + - RETURN OLD; +   + return nil
    - 19 + + 1279 +
    - + - END; +   + }
    - 20 + + 1280 +
    - + - $$ +   +
    - 21 + + 1281 +
    + - LANGUAGE plpgsql; + func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64,
    - 22 + 1282
    + - -- +migrate StatementEnd + l1InfoRoot common.Hash, da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - 23 + 1283
    + -
    + // Extract coded txs.
    - 24 + 1284
    + - CREATE TRIGGER backup_batch + // Load contract ABI
    - 25 + 1285
    + - BEFORE DELETE ON state.batch FOR EACH ROW + smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    - 26 + 1286
    + - EXECUTE PROCEDURE backup_batch(); + if err != nil {
    - 27 + 1287
    + -
    + return nil, err
    - 28 + 1288
    + - -- +migrate Down + }
    - 29 + 1289
    @@ -55743,351 +131731,252 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 30 + 1290
    + - DROP TRIGGER IF EXISTS backup_batch ON state.batch; + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st)
    - 31 + 1291
    + - DROP FUNCTION IF EXISTS backup_batch(); + }
    - 32 + 1292
    + - DROP TABLE IF EXISTS state.batch_data_backup; -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/diffgen.sh - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -56101,43 +131990,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -56221,948 +132110,628 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - -
    -
    @@ -0,0 +1,47 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -  
    - + + 1293 -
    -   -
    +
    +
    + + + func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
    - + + 1294 -
    -   -
    +
    +
    + + + da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - + + 1295 -
    +
    +
      -
    + // Extract coded txs.
    - + + 1296 -
    +
    +
      -
    + // Load contract ABI
    - + + 1297 -
    +
    +
      -
    + smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - - -
    -   -
    -
    +
    +
     
    - + + 1299 -
    +
    +
      -
    + return nil, err
    - + + 1300 -
    +
    +
      -
    + }
    - + + 1301 -
    +
    +
     
    - + + 1302 -
    -   -
    +
    +
    + + + return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st)
    - + + 1303 -
    -   -
    +
    +
    + + + }
    - + + 1304 -
    -   +
    +
    + +
    - + + 1305 -
    -   -
    +
    +
    + + + // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches
    - + + 1306 -
    -   -
    +
    +
    + + + func decodeSequencedBatches(smcAbi abi.ABI, txData []byte, forkID uint64, lastBatchNumber uint64,
    - + + 1307 -
    -   -
    +
    +
    + + + sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash,
    - + + 1308 -
    -   -
    +
    +
    + + + da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) {
    - + + 1309 -
    +
    +
      -
    + // Recover Method from signature and ABI
    - + + 1310 -
    +
    +
      -
    + method, err := smcAbi.MethodById(txData[:4])
    - + + 1311 -
    +
    +
      -
    + if err != nil {
    - - -
    -   -
    -
    +
    +
     
    - + + 1317 -
    +
    +
      -
    + if err != nil {
    - + + 1318 -
    +
    +
      -
    + return nil, err
    - + + 1319 -
    +
    +
      -
    + }
    - + + 1320 -
    +
    +
      -
    + bytedata, err := json.Marshal(data[0])
    - + + 1321 -
    +
    +
      -
    + if err != nil {
    - + + 1322 -
    +
    +
      -
    + return nil, err
    - + + 1323 -
    +
    +
      -
    + }
    - + + 1324 -
    +
    +
     
    - + + 1325 -
    -   -
    +
    +
    + + + var (
    - + + 1326 -
    -   -
    +
    +
    + + + maxSequenceTimestamp uint64
    - + + 1327 -
    -   -
    +
    +
    + + + initSequencedBatchNumber uint64
    - - -
    -   -
    -
    +
    + 1328
    -
    + +
    + + + coinbase common.Address
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + 1329
    + - PATH_TO_ZKEVM_NODE_REPO="/home/stefan/go/src/Polygon/zkevm-node/" + )
    - 2 + 1330
    + - diff -ruN \ +
    - 3 + 1331
    + - -I ".*github.com\/0x.*" \ + switch method.Name {
    - 4 + 1332
    + - -x "*mock*" -x ".git" \ + case "sequenceBatches":
    - 5 + 1333
    + - -x ".github" \ + var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 6 + 1334
    + - -x ".gitignore" \ + err := json.Unmarshal(bytedata, &sequences)
    - 7 + 1335
    + - -x ".vscode" \ + if err != nil {
    - 8 + 1336
    + - -x "ci" \ + return nil, err
    - 9 + + 1337 +
    - + - -x "environments" \ +   + }
    - 10 + + 1338 +
    + - -x "*.md" \ +
    - 11 + + 1339 +
    + - -x "*.html" \ + switch forkID {
    - 12 + + 1340 +
    + - -x "*.html" \ + case state.FORKID_ETROG:
    - 13 + + 1341 +
    + - -x "*.json" \ + coinbase = data[1].(common.Address)
    - 14 + + 1342 +
    + - -x "*.toml" \ +
    - 15 + + 1343 +
    + - -x "*.abi" \ + case state.FORKID_ELDERBERRY:
    - 16 + + 1344 +
    + - -x "*.bin" \ + maxSequenceTimestamp = data[1].(uint64)
    - 17 + + 1345 +
    + - -x "*.pb.go" \ + initSequencedBatchNumber = data[2].(uint64)
    - 18 + + 1346 +
    + - -x "smartcontracts" \ + coinbase = data[3].(common.Address)
    - 19 + + 1347 +
    + - -x "go.sum" \ + }
    - 20 + + 1348 +
    + - -x "mock*.go" \ +
    - 21 + 1349
    + - -x "*venv*" \ + sequencedBatches := make([]SequencedBatch, len(sequences))
    - 22 + 1350
    + - -x "/dist/" \ + for i, seq := range sequences {
    - 23 + 1351
    + - -x "/test/e2e/keystore" \ + bn := lastBatchNumber - uint64(len(sequences)-(i+1))
    - 24 + 1352
    + - -x "/test/vectors/src/**/*md" \ + s := seq
    - 25 + 1353
    + - -x "/test/vectors/src/**/*js" \ + batch := SequencedBatch{
    - 26 + 1354
    + - -x "/test/vectors/src/**/*sol" \ + BatchNumber: bn,
    - 27 + 1355
    + - -x "/test/vectors/src/**/*sh" \ + L1InfoRoot: &l1InfoRoot,
    - 28 + 1356
    + - -x "/test/vectors/src/package.json" \ + SequencerAddr: sequencer,
    - 29 + 1357
    + - -x "/test/contracts/bin/**/*.bin" \ + TxHash: txHash,
    - 30 + 1358
    + - -x "/test/contracts/bin/**/*.abi" \ + Nonce: nonce,
    - 31 + 1359
    + - -x "/tools/datastreamer/*.bin" \ + Coinbase: coinbase,
    - 32 + 1360
    + - -x "/test/datastreamer/*.db/*" \ + PolygonRollupBaseEtrogBatchData: &s,
    - 33 + 1361
    + - -x "/test/*.bin" \ + }
    - 34 + 1362
    + - -x "/test/*.db/*" \ + if forkID >= state.FORKID_ELDERBERRY {
    - 35 + 1363
    + - -x "**/.DS_Store" \ + batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{
    - 36 + 1364
    + - -x ".vscode" \ + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 37 + 1365
    + - -x ".idea/" \ + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 38 + 1366
    + - -x ".env" \ + }
    - 39 + 1367
    + - -x "out.dat" \ + }
    - 40 + 1368
    + - -x "cmd/__debug_bin" \ + sequencedBatches[i] = batch
    - 41 + 1369
    + - -x ".venv" \ + }
    - 42 + 1370
    + - -x "*metrics.txt" \ +
    - 43 + 1371
    + - -x "coverage.out" \ + return sequencedBatches, nil
    - 44 + 1372
    + - -x "*datastream.db*" \ + case "sequenceBatchesValidium":
    - 45 + 1373
    + - ${PATH_TO_ZKEVM_NODE_REPO} . | \ + var (
    - 46 + 1374
    + - diff2html -i stdin -s side -t "zkEVM node vs CDK validium node</br><h2>zkevm-node version: v0.6.0<h2/>" \ + sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData
    - 47 + 1375
    + - -F ./docs/diff/diff.html -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -14,7 +14,6 @@
    -
    - 14 - -
    -   - # CONTAINER FOR RUNNING BINARY -
    -
    - 15 - -
    -   - FROM alpine:3.18 -
    -
    - 16 - -
    -   - COPY --from=build /src/dist/zkevm-node /app/zkevm-node -
    -
    - 17 - -
    - - - COPY --from=build /src/config/environments/testnet/node.config.toml /app/example.config.toml -
    -
    - 18 - -
    -   - RUN apk update && apk add postgresql15-client -
    -
    - 19 - -
    -   - EXPOSE 8123 -
    -
    - 20 - -
    -   - CMD ["/bin/sh", "-c", "/app/zkevm-node run"] -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 14 - -
    -   - # CONTAINER FOR RUNNING BINARY -
    -
    - 15 - -
    -   - FROM alpine:3.18 -
    -
    - 16 - -
    -   - COPY --from=build /src/dist/zkevm-node /app/zkevm-node -
    -
    - - -
    -   -
    -
    -
    - 17 - -
    -   - RUN apk update && apk add postgresql15-client -
    -
    - 18 - -
    -   - EXPOSE 8123 -
    -
    - 19 - -
    -   - CMD ["/bin/sh", "-c", "/app/zkevm-node run"] -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/Dockerfile.release - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,15 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + dataAvailabilityMsg []byte
    - + + 1376 -
    -   -
    +
    +
    + + + )
    - + + 1377 -
    -   -
    +
    +
    + + + err := json.Unmarshal(bytedata, &sequencesValidium)
    - + + 1378 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 1379 -
    -   -
    +
    +
    + + + return nil, err
    - + + 1380 -
    -   -
    +
    +
    + + + }
    - + + 1381 -
    -   +
    +
    + +
    -
    + + + 1382 + + +
    + + + switch forkID {
    -
    -
    - - - - - - - -
    -
     
    - 1 + 1383
    + - FROM alpine:3.18 + case state.FORKID_ETROG:
    - 2 + 1384
    + -
    + coinbase = data[1].(common.Address)
    - 3 + 1385
    + - COPY zkevm-node /app/zkevm-node + dataAvailabilityMsg = data[2].([]byte)
    - 4 + 1386
    @@ -57172,67 +132741,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 5 + 1387
    + - EXPOSE 8123 + case state.FORKID_ELDERBERRY:
    - 6 + 1388
    + -
    + maxSequenceTimestamp = data[1].(uint64)
    - 7 + 1389
    + - RUN addgroup -S zkevm-group \ + initSequencedBatchNumber = data[2].(uint64)
    - 8 + 1390
    + - && adduser -S zkevm-user -G zkevm-group + coinbase = data[3].(common.Address)
    - 9 + 1391
    + -
    + dataAvailabilityMsg = data[4].([]byte)
    - 10 + 1392
    + - RUN chown -R zkevm-user:zkevm-group /app + }
    - 11 + 1393
    @@ -57242,496 +132811,447 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 12 + 1394
    + - USER zkevm-user + // Pair the batch number, hash, and if it is forced. This will allow
    - 13 + 1395
    + -
    + // retrieval from different sources, and keep them in original order.
    - 14 + 1396
    + - CMD ["/app/zkevm-node"] + var batchInfos []batchInfo
    - 15 + 1397
    + -
    -
    -
    -
    + for i, d := range sequencesValidium {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + + + + - - + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + - - + + + - - - - - - + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -3,6 +3,7 @@
    - 3 + + 1398 +
    -   - import ( + + + bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1))
    - 4 + + 1399 +
    -   - "bytes" + + + forced := d.ForcedTimestamp > 0
    - 5 + + 1400 +
    -   - "context" + + + h := d.TransactionsHash
    - + + 1401 -
    -   -
    +
    +
    + + + batchInfos = append(batchInfos, batchInfo{num: bn, hash: h, isForced: forced})
    - 6 + + 1402 +
    -   - "encoding/json" + + + }
    - 7 + + 1403 +
    -   - "errors" + + +
    - 8 + + 1404 +
    -   - "fmt" + + + batchData, err := retrieveBatchData(da, st, batchInfos, dataAvailabilityMsg)
    -
    @@ -106,6 +109,11 @@
    -
    - 106 + + 1405 +
    -   - // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry + + + if err != nil {
    - 107 + + 1406 +
    -   - methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address) + + + return nil, err
    - 108 + + 1407 +
    -   -
    + + + }
    - + + 1408 -
    -   +
    +
    + +
    - + + 1409 -
    -   -
    +
    +
    + + + sequencedBatches := make([]SequencedBatch, len(sequencesValidium))
    - + + 1410 -
    -   -
    +
    +
    + + + for i, info := range batchInfos {
    - + + 1411 -
    -   -
    +
    +
    + + + bn := info.num
    - + + 1412 -
    -   -
    +
    +
    + + + s := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 109 + + 1413 +
    -   - // ErrNotFound is used when the object is not found + + + Transactions: batchData[i],
    - 110 + + 1414 +
    -   - ErrNotFound = errors.New("not found") + + + ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot,
    - 111 + + 1415 +
    -   - // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode. + + + ForcedTimestamp: sequencesValidium[i].ForcedTimestamp,
    -
    @@ -189,6 +197,7 @@
    -
    - 189 + + 1416 +
    -   - GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot + + + ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1,
    - 190 + + 1417 +
    -   - OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot + + + }
    - 191 + + 1418 +
    -   - Pol *pol.Pol + + + batch := SequencedBatch{
    - + + 1419 -
    -   -
    +
    +
    + + + BatchNumber: bn,
    - 192 + + 1420 +
    -   - SCAddresses []common.Address + + + L1InfoRoot: &l1InfoRoot,
    - 193 + + 1421 +
    -   -
    + + + SequencerAddr: sequencer,
    - 194 + + 1422 +
    -   - RollupID uint32 + + + TxHash: txHash,
    -
    @@ -198,10 +207,13 @@
    -
    - 198 + + 1423 +
    -   - l1Cfg L1Config + + + Nonce: nonce,
    - 199 + + 1424 +
    -   - cfg Config + + + Coinbase: coinbase,
    - 200 + + 1425 +
    -   - auth map[common.Address]bind.TransactOpts // empty in case of read-only client + + + PolygonRollupBaseEtrogBatchData: &s,
    - + + 1426 -
    -   -
    +
    +
    + + + }
    - + + 1427 -
    -   -
    +
    +
    + + + if forkID >= state.FORKID_ELDERBERRY {
    - + + 1428 -
    -   -
    +
    +
    + + + elderberry := &SequencedBatchElderberryData{
    - 201 + + 1429 +
    -   - } + + + MaxSequenceTimestamp: maxSequenceTimestamp,
    - 202 + + 1430 +
    -   -
    + + + InitSequencedBatchNumber: initSequencedBatchNumber,
    - 203 + + 1431 +
    -   - // NewClient creates a new etherman. + + + }
    - 204 + + 1432 +
    - - - func NewClient(cfg Config, l1Config L1Config) (*Client, error) { + + + batch.SequencedBatchElderberryData = elderberry
    - 205 + + 1433 +
    -   - // Connect to ethereum node + + + }
    - 206 + + 1434 +
    -   - ethClient, err := ethclient.Dial(cfg.URL) + + + sequencedBatches[i] = batch
    - 207 + 1435
      - if err != nil { + }
    -
    @@ -244,6 +256,14 @@
    -
    - 244 + + 1436 +
    -   - log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err) + + +
    - 245 + + 1437 +
    -   - return nil, err + + + return sequencedBatches, nil
    - 246 + 1438
    @@ -57740,133 +133260,128 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 1439 -
    +
    +
     
    - + + 1440 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName)
    - + + 1441 -
    +
    +
      -
    + }
    - + + 1442 -
    +
    +
     
    - + + 1443 -
    -   -
    +
    +
    + + + type batchInfo struct {
    - + + 1444 -
    -   -
    +
    +
    + + + num uint64
    - + + 1445 -
    -   -
    +
    +
    + + + hash common.Hash
    - + + 1446 -
    -   -
    +
    +
    + + + isForced bool
    - 247 + + 1447 +
    -   - var scAddresses []common.Address + + + }
    - 248 + + 1448 +
    -   - scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr) + + +
    - 249 + + 1449 +
    -   -
    + + + func retrieveBatchData(da dataavailability.BatchDataProvider, st stateProvider, batchInfos []batchInfo, daMessage []byte) ([][]byte, error) {
    -
    @@ -262,7 +282,7 @@
    -
    - 262 + + 1450 +
    -   - rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr) + + + validiumData, err := getBatchL2Data(da, batchInfos, daMessage)
    - 263 + 1451
    @@ -57876,27 +133391,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 264 + 1452
      - log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err) -
    -
    - 265 - -
    - - - // TODO return error after the upgrade + return nil, err
    - 266 + 1453
    @@ -57905,178 +133410,178 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 267 + + 1454 +
    -   - log.Debug("rollupID: ", rollupID) + + + forcedData, err := getForcedBatchData(st, batchInfos)
    - 268 + + -
    +
    +
     
    -
    @@ -274,6 +294,7 @@
    +
    + + +
    +   +
    +
    - 274 + 1455
      - RollupManager: rollupManager, + if err != nil {
    - 275 + 1456
      - Pol: pol, + return nil, err
    - 276 + 1457
      - GlobalExitRootManager: globalExitRoot, + }
    - + + 1458 -
    -   -
    +
    +
    + + + data := make([][]byte, len(batchInfos))
    - 277 + + 1459 +
    -   - OldGlobalExitRootManager: oldGlobalExitRoot, + + + for i, info := range batchInfos {
    - 278 + + 1460 +
    -   - SCAddresses: scAddresses, + + + bn := info.num
    - 279 + + 1461 +
    -   - RollupID: rollupID, + + + if info.isForced {
    -
    @@ -284,11 +305,14 @@
    -
    - 284 + + 1462 +
    -   - l1Cfg: l1Config, + + + data[i] = forcedData[bn]
    - 285 + + 1463 +
    -   - cfg: cfg, + + + } else {
    - 286 + + 1464 +
    -   - auth: map[common.Address]bind.TransactOpts{}, + + + data[i] = validiumData[bn]
    - + + 1465 -
    -   -
    +
    +
    + + + }
    - + + 1466 -
    -   -
    +
    +
    + + + }
    - 287 + + 1467 +
    -   - }, nil + + + return data, nil
    - 288 + + 1468 +
    -   + + }
    - 289 + 1469
    @@ -58085,803 +133590,788 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 290 + + 1470 +
    -   - // VerifyGenBlockNumber verifies if the genesis Block Number is valid + + + func getBatchL2Data(da dataavailability.BatchDataProvider, batchInfos []batchInfo, daMessage []byte) (map[uint64][]byte, error) {
    - 291 + + 1471 +
    -   - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { + + + var batchNums []uint64
    - + + 1472 -
    -   -
    +
    +
    + + + var batchHashes []common.Hash
    - 292 + + 1473 +
    -   - start := time.Now() + + + for _, info := range batchInfos {
    - 293 + + 1474 +
    -   - log.Info("Verifying genesis blockNumber: ", genBlockNumber) + + + if !info.isForced {
    - 294 + + 1475 +
    -   - // Filter query + + + batchNums = append(batchNums, info.num)
    -
    @@ -344,6 +368,11 @@
    -
    - 344 + + 1476 +
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) + + + batchHashes = append(batchHashes, info.hash)
    - 345 + + 1477 +
    -   - start := time.Now() + + + }
    - 346 + 1478
      - var logs []types.Log -
    -
    - - -
    -   -
    + }
    - + + 1479 -
    -   -
    +
    +
    + + + if len(batchNums) == 0 {
    - + + 1480 -
    -   -
    +
    +
    + + + return nil, nil
    - + + 1481 -
    -   -
    +
    +
    + + + }
    - + + 1482 -
    -   -
    +
    +
    + + + batchL2Data, err := da.GetBatchL2Data(batchNums, batchHashes, daMessage)
    - 347 + 1483
      - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) + if err != nil {
    - 348 + 1484
      - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { + return nil, err
    - 349 + 1485
      - final := i + etherMan.cfg.ForkIDChunkSize + }
    -
    @@ -684,61 +713,8 @@
    -
    - 684 + + 1486 +
    -   - return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID) + + + if len(batchL2Data) != len(batchNums) {
    - 685 + + 1487 +
    -   - } + + + return nil,
    - 686 + + 1488 +
    -   -
    + + + fmt.Errorf("failed to retrieve all batch data. Expected %d, got %d", len(batchNums), len(batchL2Data))
    - 687 + + 1489 +
    - - - func (etherMan *Client) updateEtrogSequence(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + + }
    - 688 + + 1490 +
    - - - log.Debug("updateEtrogSequence event detected") + + + data := make(map[uint64][]byte)
    - 689 + + 1491 +
    - - - updateEtrogSequence, err := etherMan.EtrogZKEVM.ParseUpdateEtrogSequence(vLog) + + + for i, bn := range batchNums {
    - 690 + + 1492 +
    - - - if err != nil { + + + data[bn] = batchL2Data[i]
    - 691 + + 1493 +
    - - - log.Error("error parsing updateEtrogSequence event. Error: ", err) + + + }
    - 692 + + 1494 +
    - - - return err + + + return data, nil
    - 693 + + 1495 +
    - - - } + + + }
    - 694 + + 1496 +
    - - + +
    - 695 + + 1497 +
    - - - // Read the tx for this event. + + + func getForcedBatchData(st stateProvider, batchInfos []batchInfo) (map[uint64][]byte, error) {
    - 696 + + 1498 +
    - - - tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) + + + var batchNums []uint64
    - 697 + + 1499 +
    - - - if err != nil { + + + var batchHashes []common.Hash
    - 698 + + 1500 +
    - - - return err + + + for _, info := range batchInfos {
    - 699 + + 1501 +
    - - - } + + + if info.isForced {
    - 700 + + 1502 +
    - - - if tx.Hash() != vLog.TxHash { + + + batchNums = append(batchNums, info.num)
    - 701 + + 1503 +
    - - - return fmt.Errorf("error: tx hash mismatch. want: %s have: %s", vLog.TxHash, tx.Hash().String()) + + + batchHashes = append(batchHashes, info.hash)
    - 702 + + 1504 +
    - - - } + + + }
    - 703 + + 1505 +
    - - - msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0)) + + + }
    - 704 + + 1506 +
    - - - if err != nil { + + + if len(batchNums) == 0 {
    - 705 + + 1507 +
    - - - return err + + + return nil, nil
    - 706 + + 1508 +
    - - + + }
    - 707 + + 1509 +
    - - - fullBlock, err := etherMan.EthClient.BlockByHash(ctx, vLog.BlockHash) + + + data, err := st.GetForcedBatchDataByNumbers(context.Background(), batchNums, nil)
    - 708 + + 1510 +
    - - +   if err != nil {
    - 709 + + 1511 +
    - - - return fmt.Errorf("error getting fullBlockInfo. BlockNumber: %d. Error: %w", vLog.BlockNumber, err) +   + return nil, err
    - 710 + + 1512 +
    - - +   }
    - 711 + + 1513 +
    - - + +
    - 712 + + 1514 +
    - - - log.Info("update Etrog transaction sequence...") + + + for i, bn := range batchNums {
    - 713 + + 1515 +
    - - - sequence := UpdateEtrogSequence{ + + + expectedHash := batchHashes[i]
    - 714 + + 1516 +
    - - - BatchNumber: updateEtrogSequence.NumBatch, + + + d, ok := data[bn]
    - 715 + + 1517 +
    - - - SequencerAddr: updateEtrogSequence.Sequencer, + + + if !ok {
    - 716 + + 1518 +
    - - - TxHash: vLog.TxHash, + + + return nil, fmt.Errorf("missing forced batch data for number %d", bn)
    - 717 + + 1519 +
    - - - Nonce: msg.Nonce, + + + }
    - 718 + + 1520 +
    - - - PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + actualHash := crypto.Keccak256Hash(d)
    - 719 + + 1521 +
    - - - Transactions: updateEtrogSequence.Transactions, + + + if actualHash != expectedHash {
    - 720 + + 1522 +
    - - - ForcedGlobalExitRoot: updateEtrogSequence.LastGlobalExitRoot, + + + return nil, fmt.Errorf("got wrong hash for forced batch data number %d", bn)
    - 721 + + -
    - - - ForcedTimestamp: fullBlock.Time(), +
    +
    +   +
    - 722 + + -
    - - - ForcedBlockHashL1: fullBlock.ParentHash(), +
    +
    +   +
    - 723 + + -
    - - - }, +
    +
    +   +
    - 724 + + 1523 +
    - - - } +   + }
    - 725 + + 1524 +
    - - -
    +   + }
    - 726 + + 1525 +
    - - - if len(*blocks) == 0 || ((*blocks)[len(*blocks)-1].BlockHash != vLog.BlockHash || (*blocks)[len(*blocks)-1].BlockNumber != vLog.BlockNumber) { + + + return data, nil
    - 727 + + -
    - - - block := prepareBlock(vLog, time.Unix(int64(fullBlock.Time()), 0), fullBlock) +
    +
    +   +
    - 728 + + 1526 +
    - - - block.UpdateEtrogSequence = sequence +   + }
    - 729 + + 1527 +
    - - - *blocks = append(*blocks, block) +   +
    - 730 + + 1528 +
    - - - } else if (*blocks)[len(*blocks)-1].BlockHash == vLog.BlockHash && (*blocks)[len(*blocks)-1].BlockNumber == vLog.BlockNumber { +   + func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) {
    - 731 + + 1529 +
    - - - (*blocks)[len(*blocks)-1].UpdateEtrogSequence = sequence +   + // Extract coded txs.
    - 732 + + 1530 +
    - - - } else { +   + // Load contract ABI
    - 733 + + 1531 +
    - - - log.Error("Error processing UpdateEtrogSequence event. BlockHash:", vLog.BlockHash, ". BlockNumber: ", vLog.BlockNumber) + + + smcAbi, err := abi.JSON(strings.NewReader(oldpolygonzkevm.OldpolygonzkevmABI))
    - 734 + + 1532 +
    - - - return fmt.Errorf("error processing UpdateEtrogSequence event") +   + if err != nil {
    - 735 + + 1533 +
    - - - } +   + return nil, err
    - 736 + + 1534 +
    - - - or := Order{ +   + }
    - 737 - -
    - - - Name: UpdateEtrogSequenceOrder, -
    +
    +
     
    - 738 + + 1544 +
    - - - Pos: 0, +   + if err != nil {
    - 739 + + 1545 +
    - - - } +   + return nil, err
    - 740 + + 1546 +
    - - - (*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash] = append((*blocksOrder)[(*blocks)[len(*blocks)-1].BlockHash], or) +   + }
    - 741 + + 1547 +
    - - - return nil + + + var sequences []oldpolygonzkevm.PolygonZkEVMBatchData
    - 742 + 1548
      - } + bytedata, err := json.Marshal(data[0])
    - 743 + 1549
      -
    + if err != nil {
    - 744 + 1550
      - func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + return nil, err
    -
    @@ -937,14 +913,14 @@
    +
     
    - 937 + 1571 + +
    +   + return sequencedBatches, nil +
    +
    + 1572
    @@ -58891,7 +134381,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 938 + 1573
    @@ -58899,99 +134389,124 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 1574 + +
    + + + func (etherMan *Client) oldVerifyBatchesTrustedAggregatorEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { +
    +
    - 939 + 1575
      - // EstimateGasSequenceBatches estimates gas for sending batches + log.Debug("TrustedVerifyBatches event detected")
    - 940 + + 1576 +
    - - - func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) { + + + var vb *oldpolygonzkevm.OldpolygonzkevmVerifyBatchesTrustedAggregator +
    +
    + 1577 + +
    + + + vb, err := etherMan.OldZkEVM.ParseVerifyBatchesTrustedAggregator(vLog)
    - 941 + 1578
      - opts, err := etherMan.getAuthByAddress(sender) + if err != nil {
    - 942 + 1579
      - if err == ErrNotFound { + log.Error("error parsing TrustedVerifyBatches event. Error: ", err)
    - 943 + 1580
      - return nil, ErrPrivateKeyNotFound + return err
    +
     
    +
    - 944 + 1584
      - } +
    - 945 + 1585
      - opts.NoSend = true + func (etherMan *Client) verifyBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 946 + 1586
      -
    + log.Debug("VerifyBatches event detected")
    - 947 + + 1587 +
    - - - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) + + + vb, err := etherMan.ZkEVM.ParseVerifyBatches(vLog)
    - 948 + 1588
    @@ -59001,147 +134516,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 949 + 1589
      - return nil, err + log.Error("error parsing VerifyBatches event. Error: ", err)
    - 950 + 1590
      - } + return err
    -
    @@ -953,7 +929,7 @@
    +
     
    - 953 + 1631
      - } +
    - 954 + 1632
      -
    + func (etherMan *Client) forceSequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error {
    - 955 + 1633
      - // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches. + log.Debug("SequenceForceBatches event detect")
    - 956 + + 1634 +
    - - - func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) { + + + fsb, err := etherMan.ZkEVM.ParseSequenceForceBatches(vLog)
    - 957 + 1635
      - opts, err := etherMan.getAuthByAddress(sender) + if err != nil {
    - 958 + 1636
      - if err == ErrNotFound { + return err
    - 959 + 1637
      - return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound) + }
    -
    @@ -964,7 +940,7 @@
    +
     
    - 964 + 1680
      - opts.GasLimit = uint64(1) + func decodeSequencedForceBatches(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, block *types.Block, nonce uint64) ([]SequencedForceBatch, error) {
    - 965 + 1681
      - opts.GasPrice = big.NewInt(1) + // Extract coded txs.
    - 966 + 1682
      -
    + // Load contract ABI
    - 967 + + 1683 +
    - - - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) + + + abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    - 968 + 1684
    @@ -59151,17 +134666,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 969 + 1685
      - return nil, nil, err + return nil, err
    - 970 + 1686
    @@ -59172,31 +134687,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -972,15 +948,15 @@
    +
     
    - 972 + 1697
      - return tx.To(), tx.Data(), nil + return nil, err
    - 973 + 1698
      - } + }
    - 974 + 1699
    @@ -59205,173 +134720,288 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 975 + + 1700 +
    - - - func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) { + + + var forceBatches []polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 976 + + 1701 +
    - - - var batches []polygonzkevm.PolygonRollupBaseEtrogBatchData +   + bytedata, err := json.Marshal(data[0])
    - 977 + 1702
      - for _, seq := range sequences { + if err != nil {
    - 978 + 1703
      - var ger common.Hash + return nil, err
    +
     
    +
    - 979 + 1761
      - if seq.ForcedBatchTimestamp > 0 { +
    - 980 + 1762
      - ger = seq.GlobalExitRoot + // GetLatestBatchNumber function allows to retrieve the latest proposed batch in the smc
    - 981 + 1763 + +
    +   + func (etherMan *Client) GetLatestBatchNumber() (uint64, error) { +
    +
    + 1764 + +
    + + + var latestBatchNum uint64 +
    +
    + 1765 + +
    + + + rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID) +
    +
    + 1766
      + if err != nil { +
    +
    + 1767 + +
    + + + log.Debug("error getting latestBatchNum from rollupManager. Trying old zkevm smc... Error: ", err) +
    +
    + 1768 + +
    + + + latestBatchNum, err = etherMan.OldZkEVM.LastBatchSequenced(&bind.CallOpts{Pending: false}) +
    +
    + 1769 + +
    + + + if err != nil { +
    +
    + 1770 + +
    + + + return latestBatchNum, err +
    +
    + 1771 + +
    + + }
    - 982 + + 1772 +
    - - - batch := polygonzkevm.PolygonRollupBaseEtrogBatchData{ + + + } else {
    - 983 + + 1773 +
    - - - Transactions: seq.BatchL2Data, + + + latestBatchNum = rollupData.LastBatchSequenced
    - 984 + 1774
      - ForcedGlobalExitRoot: ger, + } +
    +
    + 1775 + +
    + + + return latestBatchNum, nil
    - 985 + 1776
      - ForcedTimestamp: uint64(seq.ForcedBatchTimestamp), + }
    - 986 + 1777
      - ForcedBlockHashL1: seq.PrevBlockHash, +
    +
    +
    + 1778 + +
    +   + // GetLatestBlockHeader gets the latest block header from the ethereum
    -
    @@ -989,7 +965,7 @@
    +
     
    - 989 + 1819
      - batches = append(batches, batch) +
    - 990 + 1820
      - } + // GetLatestVerifiedBatchNum gets latest verified batch from ethereum
    - 991 + 1821
      -
    + func (etherMan *Client) GetLatestVerifiedBatchNum() (uint64, error) {
    - 992 + + 1822 +
    - - - tx, err := etherMan.ZkEVM.SequenceBatches(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase) + + + var lastVerifiedBatchNum uint64 +
    +
    + 1823 + +
    + + + rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
    - 993 + 1824
    @@ -59380,511 +135010,431 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 994 + + 1825 +
    -   - log.Debugf("Batches to send: %+v", batches) + + + log.Debug("error getting lastVerifiedBatchNum from rollupManager. Trying old zkevm smc... Error: ", err)
    - 995 + + 1826 +
    -   - log.Debug("l2CoinBase: ", l2Coinbase) + + + lastVerifiedBatchNum, err = etherMan.OldZkEVM.LastVerifiedBatch(&bind.CallOpts{Pending: false})
    -
    @@ -1185,7 +1161,6 @@
    +
    + 1827 + +
    + + + if err != nil { +
    - 1185 + + 1828 + +
    + + + return lastVerifiedBatchNum, err +
    +
    + 1829 + +
    + + + } +
    +
    + 1830 +
    -   -
    + + + } else {
    - 1186 + + 1831 +
    -   - func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + + + lastVerifiedBatchNum = rollupData.LastVerifiedBatch
    - 1187 + 1832
      - log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:])) + }
    - 1188 + + 1833 +
    - - - //tx,isPending, err:=etherMan.EthClient.TransactionByHash(ctx, vLog.TxHash) + + + return lastVerifiedBatchNum, nil
    - 1189 + 1834
      -
    + }
    - 1190 + 1835
      - sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog) +
    - 1191 + 1836
      - if err != nil { + // GetTx function get ethereum tx
    -
    @@ -1209,13 +1184,15 @@
    +
     
    - 1209 + 1865
      - if sb.NumBatch != 1 { +
    - 1210 + 1866
      - methodId := tx.Data()[:4] + // GetTrustedSequencerURL Gets the trusted sequencer url from rollup smc
    - 1211 + 1867
      - log.Debugf("MethodId: %s", common.Bytes2Hex(methodId)) + func (etherMan *Client) GetTrustedSequencerURL() (string, error) {
    - 1212 + + 1868 +
    - - - if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) { + + + url, err := etherMan.ZkEVM.TrustedSequencerURL(&bind.CallOpts{Pending: false})
    - 1213 + + 1869 +
    - - - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) + + + //TODO: remove this code because is for compatibility with oldZkEVM
    - + + 1870 -
    -   -
    +
    +
    + + + if err != nil || url == "" {
    - 1214 + + 1871 +
    -   - if err != nil { + + + // Getting from oldZkEVM Contract
    - 1215 + + 1872 +
    -   - return fmt.Errorf("error decoding the sequences (etrog): %v", err) + + + log.Debug("getting trusted sequencer URL from oldZkevm smc")
    - 1216 + + 1873 +
    -   - } + + + return etherMan.OldZkEVM.TrustedSequencerURL(&bind.CallOpts{Pending: false})
    - 1217 + + 1874 +
    - - - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) { + + + }
    - 1218 + + 1875 +
    - - - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot) + + + // err is always nil
    - + + 1876 -
    -   -
    +
    +
    + + + return url, nil
    - 1219 + 1877
      - if err != nil { + }
    - 1220 + 1878
      - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) +
    - 1221 + 1879
      - } + // GetL2ChainID returns L2 Chain ID
    -
    @@ -1301,7 +1278,8 @@
    -
    - 1301 + 1880
      - return nil + func (etherMan *Client) GetL2ChainID() (uint64, error) {
    - 1302 + + 1881 +
    -   - } + + + chainID, err := etherMan.OldZkEVM.ChainID(&bind.CallOpts{Pending: false}) +
    +
    + 1882 + +
    + + + log.Debug("chainID read from oldZkevm: ", chainID)
    - 1303 + 1883
      -
    + if err != nil || chainID == 0 {
    - 1304 + + 1884 +
    - - - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { + + + log.Debug("error from oldZkevm: ", err)
    - + + 1885 -
    -   -
    +
    +
    + + + rollupData, err := etherMan.RollupManager.RollupIDToRollupData(&bind.CallOpts{Pending: false}, etherMan.RollupID)
    - 1305 + + 1886 +
    -   - // Extract coded txs. + + + log.Debugf("ChainID read from rollupManager: %d using rollupID: %d", rollupData.ChainID, etherMan.RollupID)
    - 1306 + 1887
      - // Load contract ABI + if err != nil {
    - 1307 + + 1888 +
    -   - smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) + + + log.Debug("error from rollupManager: ", err)
    -
    @@ -1309,6 +1287,25 @@
    -
    - 1309 + 1889
      - return nil, err + return 0, err
    - 1310 + 1890
      - } + } else if rollupData.ChainID == 0 {
    - 1311 + 1891
      -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + return rollupData.ChainID, fmt.Errorf("error: chainID received is 0!!")
    - - -
    -   -
    -
    +
    +
     
    - + + 1916 -
    +
    +
      -
    + return etherMan.EthClient.SendTransaction(ctx, tx)
    - + + 1917 -
    +
    +
      -
    + }
    - + + 1918 -
    +
    +
     
    @@ -59941,202 +135491,197 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1312 + 1919
      - // Recover Method from signature and ABI + // CurrentNonce returns the current nonce for the provided account
    - 1313 + 1920
      - method, err := smcAbi.MethodById(txData[:4]) + func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error) {
    - 1314 + 1921
      - if err != nil { + return etherMan.EthClient.NonceAt(ctx, account, nil)
    -
    @@ -1320,87 +1317,212 @@
    +
     
    - 1320 + 1948
      - if err != nil { + opts.BlockNumber = new(big.Int).SetUint64(*blockNumber)
    - 1321 + 1949
      - return nil, err + }
    - 1322 + 1950
      - } +
    - 1323 + + 1951 +
    - - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData + + + return etherman.GlobalExitRootManager.DepositCount(opts)
    - 1324 + 1952
      - bytedata, err := json.Marshal(data[0]) + }
    - 1325 + 1953
      - if err != nil { +
    - 1326 + 1954
      - return nil, err + // CheckTxWasMined check if a tx was already mined
    +
     
    +
    - 1327 + 2005
      - } -
    -
    - 1328 - -
    - - - err = json.Unmarshal(bytedata, &sequences) + }
    - 1329 + + 2006 +
    - - - if err != nil { +   +
    - 1330 + + 2007 +
    - - - return nil, err +   + // LoadAuthFromKeyStore loads an authorization from a key store file
    - 1331 + + 2008 +
    - - - } + + + func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 1332 + + 2009 +
    - - - maxSequenceTimestamp := data[1].(uint64) + + + auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID)
    - 1333 + + 2010 +
    - - - initSequencedBatchNumber := data[2].(uint64) +   + if err != nil {
    - 1334 + + 2011 +
    - - - coinbase := (data[3]).(common.Address) + + + return nil, nil, err
    - 1335 + + 2012 +
    - - - sequencedBatches := make([]SequencedBatch, len(sequences)) +   + }
    - 1336 + 2013
    @@ -60145,813 +135690,697 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1337 + + 2014 +
    - - - for i, seq := range sequences { +   + log.Infof("loaded authorization for address: %v", auth.From.String())
    - 1338 + + 2015 +
    - - - elderberry := SequencedBatchElderberryData{ +   + etherMan.auth[auth.From] = auth
    - 1339 + + 2016 +
    - - - MaxSequenceTimestamp: maxSequenceTimestamp, + + + return &auth, pk, nil
    - 1340 + + 2017 +
    - - - InitSequencedBatchNumber: initSequencedBatchNumber, -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
      -
    + }
    - + + 2018 -
    +
    +
     
    - + + 2019 -
    +
    +
      -
    + // newKeyFromKeystore creates an instance of a keystore key from a keystore file
    - - -
    -   -
    -
    +
    +
     
    - + + 2034 -
    +
    +
      -
    + }
    - + + 2035 -
    +
    +
     
    - 1341 + 2036
      - } -
    -
    - 1342 - -
    - - - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) -
    -
    - 1343 - -
    - - - s := seq + // newAuthFromKeystore an authorization instance from a keystore file
    - 1344 + + 2037 +
    - - - sequencedBatches[i] = SequencedBatch{ + + + func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) {
    - 1345 + + 2038 +
    - - - BatchNumber: bn, +   + log.Infof("reading key from: %v", path)
    - 1346 + + 2039 +
    - - - L1InfoRoot: &l1InfoRoot, +   + key, err := newKeyFromKeystore(path, password)
    - 1347 + + 2040 +
    - - - SequencerAddr: sequencer, +   + if err != nil {
    - 1348 + + 2041 +
    - - - TxHash: txHash, + + + return bind.TransactOpts{}, nil, err
    - 1349 + + 2042 +
    - - - Nonce: nonce, +   + }
    - 1350 + + 2043 +
    - - - Coinbase: coinbase, +   + if key == nil {
    - 1351 + + 2044 +
    - - - PolygonRollupBaseEtrogBatchData: &s, + + + return bind.TransactOpts{}, nil, nil
    - 1352 + + 2045 +
    - - - SequencedBatchElderberryData: &elderberry, -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
      -
    + }
    - + + 2046 -
    +
    +
      -
    + auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID))
    - + + 2047 -
    +
    +
      -
    + if err != nil {
    - + + 2048 -
    -   -
    +
    +
    + + + return bind.TransactOpts{}, nil, err
    - + + 2049 -
    +
    +
      -
    + }
    - + + 2050 -
    -   -
    +
    +
    + + + return *auth, key.PrivateKey, nil
    - + + 2051 -
    +
    +
      -
    + }
    - + + 2052 -
    +
    +
     
    - + + 2053 -
    +
    +
      -
    + // getAuthByAddress tries to get an authorization from the authorizations map
    - - -
    -   -
    -
    +
    +
     
    - + + 2075 -
    +
    +
     
    - + + 2076 -
    +
    +
      -
    + return *auth, nil
    - + + 2077 -
    +
    +
      -
    + }
    - + + 2078 -
    -   +
    +
    + +
    - 1353 + + 2079 +
    -   - } -
    -
    - - -
    -   -
    + + + // GetDAProtocolAddr returns the address of the data availability protocol
    - + + 2080 -
    -   -
    +
    +
    + + + func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) {
    - + + 2081 -
    -   -
    +
    +
    + + + return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false})
    - + + 2082 -
    -   -
    +
    +
    + + + }
    - + + 2083 -
    -   +
    +
    + +
    - + + 2084 -
    -   -
    +
    +
    + + + // GetDAProtocolName returns the name of the data availability protocol
    - + + 2085 -
    -   -
    +
    +
    + + + func (etherMan *Client) GetDAProtocolName() (string, error) {
    - + + 2086 -
    -   -
    +
    +
    + + + return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false})
    - + + 2087 -
    -   -
    +
    +
    + + + }
    - + + 2088 -
    -   +
    +
    + +
    - + + 2089 -
    -   -
    +
    +
    + + + // SetDataAvailabilityProtocol sets the address for the new data availability protocol
    - + + 2090 -
    -   -
    +
    +
    + + + func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) {
    - + + 2091 -
    -   -
    +
    +
    + + + auth, err := etherMan.getAuthByAddress(from)
    - + + 2092 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 2093 -
    -   -
    +
    +
    + + + return nil, err
    - + + 2094 -
    -   -
    +
    +
    + + + }
    - + + 2095 -
    -   +
    +
    + +
    - + + 2096 -
    -   -
    +
    +
    + + + return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress)
    - + + 2097 -
    -   -
    +
    +
    + + + }
    - + + 2098 -
    -   +
    +
    + +
    - + + 2099 -
    -   -
    +
    +
    + + + // GetRollupId returns the rollup id
    - + + 2100 -
    -   -
    +
    +
    + + + func (etherMan *Client) GetRollupId() uint32 {
    - + + 2101 -
    -   -
    +
    +
    + + + return etherMan.RollupID
    - + + 2102 -
    -   -
    +
    +
    + + + }
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - @@ -60975,318 +136404,328 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - @@ -61835,23 +137204,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -61905,393 +137274,418 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - + + + - - - - - - + + + - - - - + + + - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + - - - - - - - + + + - + - + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - @@ -63155,72 +138639,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -63230,187 +138714,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + - - + + + + - - + + + @@ -63420,67 +138934,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - @@ -63700,72 +139199,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + @@ -63775,72 +139284,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -63850,257 +139359,317 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + - - + + + - - + - - - - + + + + + + + + + + + + @@ -64110,612 +139679,662 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - - - - - - - - - + + + - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - - - - - - @@ -64725,142 +140344,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + @@ -64870,72 +140494,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + @@ -64945,72 +140629,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -65020,152 +140704,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - @@ -65175,72 +140849,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -65250,7 +140924,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - + + +
    +
    @@ -38,7 +38,7 @@
    - + + 38 -
    +
    +
      -
    + }
    - + + 39 -
    +
    +
     
    - + + 40 -
    +
    +
      -
    + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - + + 41 -
    -   -
    +
    +
    + - + func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *etrogpolygonzkevmbridge.Etrogpolygonzkevmbridge) {
    - + + 42 -
    +
    +
      -
    + privateKey, err := crypto.GenerateKey()
    - + + 43 -
    +
    +
      -
    + if err != nil {
    - + + 44 -
    +
    +
      -
    + log.Fatal(err)
    - + +
    @@ -47,7 +47,9 @@
    -
    +
    + 47 + +
      -
    + if err != nil {
    - + + 48 -
    +
    +
      -
    + log.Fatal(err)
    - + + 49 -
    +
    +
      -
    + }
    - + + 50 -
    -   -
    +
    +
    + - + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth)
    - + + 51 -
    +
    +
      -
    + if err != nil {
    - + + 52 -
    +
    +
      -
    + log.Fatal(err)
    - + + 53 -
    +
    +
      -
    + }
    - + +
    @@ -55,12 +57,12 @@
    -
    +
    + 55 + +
      -
    + if err != nil {
    - + + 56 -
    +
    +
      -
    + log.Fatal(err)
    - + + 57 -
    +
    +
      -
    + }
    - + + 58 -
    -   -
    +
    +
    + - + return ethman, ethBackend, auth, polAddr, br
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    +
    +
     
    - + + 61 -
    +
    +
      -
    + func TestGEREvent(t *testing.T) {
    - + + 62 -
    +
    +
      -
    + // Set up testing environment
    - + + 63 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, br := newTestingEnv()
    - + + 64 -
    +
    +
     
    - + + 65 -
    +
    +
      -
    + // Read currentBlock
    - + + 66 -
    +
    +
      -
    + ctx := context.Background()
    - + +
    @@ -82,26 +84,26 @@
    -
    +
    + 82 + +
      -
    + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 83 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 84 -
    +
    +
      -
    + t.Logf("Blocks: %+v", blocks)
    - + + 85 -
    -   -
    +
    +
    + - + assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber)
    - + + 86 -
    +
    +
      -
    + assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
    - + + 87 -
    +
    +
      -
    + assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
    - + + 88 -
    +
    +
      -
    + }
    - + + 89 -
    +
    +
     
    - + + 90 -
    +
    +
      -
    + func TestForcedBatchEvent(t *testing.T) {
    - + + 91 -
    +
    +
      -
    + // Set up testing environment
    - + + 92 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - + + 93 -
    +
    +
     
    - + + 94 -
    +
    +
      -
    + // Read currentBlock
    - + + 95 -
    +
    +
      -
    + ctx := context.Background()
    - + + 96 -
    +
    +
      -
    + initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil)
    - 1354 + 97
      - } + require.NoError(t, err)
    - 1355 + 98
    @@ -61296,317 +136735,282 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1356 + 99
    - - return sequencedBatches, nil + amount, err := etherman.EtrogRollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false})
    - 1357 + 100
      - } + require.NoError(t, err)
    - 1358 + 101
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - 1359 + + 102 +
    - - - func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash) ([]SequencedBatch, error) { +   + data, err := hex.DecodeString(rawTxs)
    - 1360 + + 103 +
    - - - // Extract coded txs. +   + require.NoError(t, err)
    - 1361 + 104
    - - // Load contract ABI + _, err = etherman.EtrogZkEVM.ForceBatch(auth, data, amount)
    - 1362 + + 105 +
    - - - smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) -
    -
    - - -
      -
    + require.NoError(t, err)
    - + + 106 -
    +
    +
     
    - + + 107 -
    +
    +
      -
    + // Mine the tx in a block
    - - -
    -   -
    -
    +
    +
    @@ -114,8 +116,8 @@
    - 1363 + 114
      - if err != nil { + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 1364 + 115
      - return nil, err + require.NoError(t, err)
    - 1365 + 116
      - } + t.Logf("Blocks: %+v", blocks)
    - 1366 + 117
    - -
    -
    -
    - 1367 - -
    - - - // Recover Method from signature and ABI + assert.Equal(t, uint64(8), blocks[0].BlockNumber)
    - 1368 + + 118 +
    - - method, err := smcAbi.MethodById(txData[:4]) + assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber)
    - 1369 + 119
      - if err != nil { + assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
    - 1370 + 120
      - return nil, err + assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
    - 1371 + 121
      - } + assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
    - - -
    -   -
    -
    +
    +
    @@ -125,7 +127,7 @@
    - + + 125 -
    +
    +
     
    - + + 126 -
    +
    +
      -
    + func TestSequencedBatchesEvent(t *testing.T) {
    - + + 127 -
    +
    +
      -
    + // Set up testing environment
    - + + 128 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, br := newTestingEnv()
    - + + 129 -
    +
    +
     
    - + + 130 -
    +
    +
      -
    + // Read currentBlock
    - + + 131 -
    +
    +
      -
    + ctx := context.Background()
    - - -
    -   -
    -
    +
    +
    @@ -139,12 +141,12 @@
    - + + 139 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 140 -
    +
    +
      -
    + auth.Value = big.NewInt(0)
    - 1372 + 141
    @@ -61616,212 +137020,177 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1373 - -
    - - - // Unpack method inputs -
    -
    - 1374 - -
    - - - data, err := method.Inputs.Unpack(txData[4:]) -
    -
    - 1375 + 142
    - - if err != nil { + amount, err := etherman.EtrogRollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false})
    - 1376 + + 143 +
    - - - return nil, err -
    -
    - - -
    -   -
    -
    -
    - - -
      -
    + require.NoError(t, err)
    - + + 144 -
    +
    +
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - + + 145 -
    +
    +
      -
    + data, err := hex.DecodeString(rawTxs)
    - 1377 + 146
      - } + require.NoError(t, err)
    - 1378 + 147
    - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData + _, err = etherman.EtrogZkEVM.ForceBatch(auth, data, amount)
    - 1379 + + 148 +
    - - - bytedata, err := json.Marshal(data[0]) +   + require.NoError(t, err)
    - + + 149 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 150 -
    +
    +
      -
    + ethBackend.Commit()
    +
    @@ -156,13 +158,19 @@
    +
    - 1380 + 156
      - if err != nil { + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
    - 1381 + 157
      - return nil, err + require.NoError(t, err)
    - 1382 + 158
      - } + t.Log("Blocks: ", blocks)
    - 1383 + 159
    - - err = json.Unmarshal(bytedata, &sequences) + var sequences []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - + + 160 -
    -   -
    +
    +
    + - + sequences = append(sequences, etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 161 -
    -   -
    +
    +
    + - + Transactions: common.Hex2Bytes(rawTxs),
    - + + 162 -
    -   -
    +
    +
    + - + }, etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 163 -
    -   -
    +
    +
    + - + Transactions: common.Hex2Bytes(rawTxs),
    - + + 164 -
    +
    +
      -
    + })
    - + + 165 -
    -   -
    +
    +
    + - + _, err = etherman.EtrogZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From)
    - + + 166 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 167 -
    +
    +
     
    - + + 168 -
    +
    +
      -
    + // Mine the tx in a block
    - - -
    -   -
    -
    +
    +
    @@ -188,7 +196,7 @@
    - + + 188 -
    +
    +
     
    - + + 189 -
    +
    +
      -
    + func TestVerifyBatchEvent(t *testing.T) {
    - + + 190 -
    +
    +
      -
    + // Set up testing environment
    - + + 191 -
    -   -
    +
    +
    + - + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - + + 192 -
    +
    +
     
    - + + 193 -
    +
    +
      -
    + // Read currentBlock
    - + + 194 -
    +
    +
      -
    + ctx := context.Background()
    +
    @@ -197,17 +205,18 @@
    +
    - 1384 + 197
      - if err != nil { + require.NoError(t, err)
    - 1385 + 198
      - return nil, err +
    - 1386 + 199
      - } + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - 1387 + 200
    - - coinbase := (data[1]).(common.Address) + tx := etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1388 + 201
    - - sequencedBatches := make([]SequencedBatch, len(sequences)) + Transactions: common.Hex2Bytes(rawTxs),
    - 1389 + + 202 +
    - - - for i, seq := range sequences { +   + }
    - 1390 + 203
    - - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) + //TODO: Fix params
    - 1391 + 204
    - - s := seq + _, err = etherman.EtrogZkEVM.SequenceBatches(auth, []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From)
    - 1392 + + 205 +
    - - - sequencedBatches[i] = SequencedBatch{ +   + require.NoError(t, err)
    - 1393 + + + +
    +   +
    +
    +
    + 206 +
    - - - BatchNumber: bn, +   +
    - 1394 + + 207 +
    - - - L1InfoRoot: &l1InfoRoot, +   + // Mine the tx in a block
    - 1395 + + 208 +
    - - - SequencerAddr: sequencer, +   + ethBackend.Commit() +
    +
    + 209 + +
    +   +
    - 1396 + 210
    - - TxHash: txHash, + _, err = etherman.EtrogRollupManager.VerifyBatchesTrustedAggregator(auth, 1, uint64(0), uint64(0), uint64(1), [32]byte{}, [32]byte{}, auth.From, [24][32]byte{})
    - 1397 + + 211 +
    - - - Nonce: nonce, +   + require.NoError(t, err)
    - 1398 + + 212 +
    - - - Coinbase: coinbase, +   +
    - 1399 + + 213 +
    - - - PolygonRollupBaseEtrogBatchData: &s, +   + // Mine the tx in a block
    +
    @@ -220,7 +229,7 @@
    +
    - 1400 + 220
      - } + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 1401 + 221
      - } + require.NoError(t, err)
    - 1402 + + 222 +
    - - -
    +   + t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
    - 1403 + + 223 +
    - - return sequencedBatches, nil + assert.Equal(t, uint64(9), blocks[1].BlockNumber)
    - 1404 + 224
      - } + assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
    - 1405 + 225
      -
    + assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
    - 1406 + 226
      - func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { + assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
    -
    @@ -1513,7 +1635,7 @@
    +
    @@ -232,19 +241,19 @@
    - 1513 + 232
      - if err != nil { +
    - 1514 + 233
      - return err + func TestSequenceForceBatchesEvent(t *testing.T) {
    - 1515 + 234
      - } + // Set up testing environment
    - 1516 + 235
    - - // TODO completar los datos de forcedBlockHas, forcedGer y forcedTimestamp + etherman, ethBackend, auth, _, _ := newTestingEnv()
    - 1517 + 236
    @@ -62301,52 +137695,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1518 + 237
      - // Read the tx for this batch. + // Read currentBlock
    - 1519 + 238
      - tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) + ctx := context.Background()
    -
    @@ -1818,6 +1940,17 @@
    -
    - 1818 + 239
      - }) + initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil)
    - 1819 + 240
      - } + require.NoError(t, err)
    - 1820 + 241
    @@ -62355,388 +137744,408 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 242 -
    -   -
    +
    +
    + - + amount, err := etherman.EtrogRollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false})
    - + + 243 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 244 -
    +
    +
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - + + 245 -
    +
    +
      -
    + data, err := hex.DecodeString(rawTxs)
    - + + 246 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 247 -
    -   -
    +
    +
    + - + _, err = etherman.EtrogZkEVM.ForceBatch(auth, data, amount)
    - + + 248 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 249 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 250 -
    +
    +
      -
    + ethBackend.Commit()
    - - -
    -   -
    -
    +
    +
    @@ -266,13 +275,13 @@
    - + + 266 -
    +
    +
      -
    + prevBlock, err := etherman.EthClient.BlockByNumber(ctx, big.NewInt(0).SetUint64(blocks[0].BlockNumber-1))
    - 1821 + 267
      - // CheckTxWasMined check if a tx was already mined + require.NoError(t, err)
    - 1822 + 268
      - func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error) { + forcedBlockHashL1 := prevBlock.Hash() +
    +
    + 269 + +
    + - + forceBatchData := etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1823 + 270
      - receipt, err := etherMan.EthClient.TransactionReceipt(ctx, txHash) + Transactions: blocks[0].ForcedBatches[0].RawTxsData,
    -
    @@ -1872,15 +2005,15 @@
    -
    - 1872 + 271
      - } + ForcedGlobalExitRoot: forcedGer,
    - 1873 + 272
      -
    + ForcedTimestamp: forcedTimestamp,
    - 1874 + 273
      - // LoadAuthFromKeyStore loads an authorization from a key store file + ForcedBlockHashL1: forcedBlockHashL1,
    - 1875 + + 274 +
    - - - func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, error) { +   + }
    - 1876 + 275
    - - auth, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID) + _, err = etherman.EtrogZkEVM.SequenceForceBatches(auth, []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{forceBatchData})
    - 1877 + 276
      - if err != nil { + require.NoError(t, err)
    - 1878 + + 277 +
    - - - return nil, err +   + ethBackend.Commit()
    - 1879 + 278
      - } +
    +
    @@ -283,7 +292,7 @@
    +
    - 1880 + 283
      -
    + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 1881 + 284
      - log.Infof("loaded authorization for address: %v", auth.From.String()) + require.NoError(t, err)
    - 1882 + 285
      - etherMan.auth[auth.From] = auth + t.Logf("Blocks: %+v", blocks)
    - 1883 + 286
    - - return &auth, nil + assert.Equal(t, uint64(12), blocks[1].BlockNumber)
    - 1884 + 287
      - } + assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
    - 1885 + 288
      -
    + assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
    - 1886 + 289
      - // newKeyFromKeystore creates an instance of a keystore key from a keystore file + assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
    -
    @@ -1901,20 +2034,20 @@
    +
    @@ -293,7 +302,7 @@
    - 1901 + 293
      - } +
    - 1902 + 294
      -
    + func TestSendSequences(t *testing.T) {
    - 1903 + 295
      - // newAuthFromKeystore an authorization instance from a keystore file + // Set up testing environment
    - 1904 + 296
    - - func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, error) { + etherman, ethBackend, auth, _, br := newTestingEnv()
    - 1905 + 297
      - log.Infof("reading key from: %v", path) +
    - 1906 + 298
      - key, err := newKeyFromKeystore(path, password) + // Read currentBlock
    - 1907 + 299
      - if err != nil { + ctx := context.Background()
    - 1908 + +
    @@ -315,10 +324,12 @@
    +
    + 315 +
    - - - return bind.TransactOpts{}, err +   + BatchL2Data: batchL2Data, +
    +
    + 316 + +
    +   + LastL2BLockTimestamp: time.Now().Unix(),
    - 1909 + 317
    @@ -62744,124 +138153,189 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    + + +
    +   +
    +
    +
    - 1910 + 318
      - if key == nil { + lastL2BlockTStamp := tx1.Time().Unix()
    - 1911 + 319
    - - return bind.TransactOpts{}, nil + // TODO: fix params +
    +
    + 320 + +
    + - + tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From)
    - 1912 + 321
      - } + require.NoError(t, err) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 1913 + 322
      - auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID)) + log.Debug("TX: ", tx.Hash())
    - 1914 + 323
      - if err != nil { + ethBackend.Commit()
    - 1915 + + 324 +
    - - - return bind.TransactOpts{}, err +   +
    +
    @@ -341,7 +352,7 @@
    +
    - 1916 + 341
      - } +
    +
    +
    + 342 + +
    +   + func TestGasPrice(t *testing.T) { +
    +
    + 343 + +
    +   + // Set up testing environment
    - 1917 + 344
    - - return *auth, nil + etherman, _, _, _, _ := newTestingEnv()
    - 1918 + 345
      - } + etherscanM := new(etherscanMock)
    - 1919 + 346
      -
    + ethGasStationM := new(ethGasStationMock)
    - 1920 + 347
      - // getAuthByAddress tries to get an authorization from the authorizations map + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    -
    @@ -1942,3 +2075,28 @@
    +
    @@ -360,14 +371,14 @@
    - 1942 + 360
    @@ -62871,272 +138345,282 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1943 + 361
      - return *auth, nil + func TestErrorEthGasStationPrice(t *testing.T) {
    - 1944 + 362
      - } + // Set up testing environment
    - + + 363 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 364 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 365 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
    - + + 366 -
    +
    +
      -
    + ctx := context.Background()
    - + + 367 -
    +
    +
     
    - + + 368 -
    +
    +
      -
    + ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
    - + + 369 -
    +
    +
      -
    + gp := etherman.GetL1GasPrice(ctx)
    - + + 370 -
    -   -
    +
    +
    + - + assert.Equal(t, big.NewInt(1392695906), gp)
    - + + 371 -
    +
    +
     
    - + + 372 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 373 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
    @@ -379,7 +390,7 @@
    -
    +
    + 379 + +
     
    - + + 380 -
    +
    +
      -
    + func TestErrorEtherScanPrice(t *testing.T) {
    - + + 381 -
    +
    +
      -
    + // Set up testing environment
    - + + 382 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 383 -
    +
    +
      -
    + etherscanM := new(etherscanMock)
    - + + 384 -
    +
    +
      -
    + ethGasStationM := new(ethGasStationMock)
    - + + 385 -
    +
    +
      -
    + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - + +
    @@ -393,7 +404,7 @@
    -
    +
    + 393 + +
     
    - + + 394 -
    +
    +
      -
    + func TestGetForks(t *testing.T) {
    - + + 395 -
    +
    +
      -
    + // Set up testing environment
    - + + 396 -
    -   -
    +
    +
    + - + etherman, _, _, _, _ := newTestingEnv()
    - + + 397 -
    +
    +
      -
    + ctx := context.Background()
    - + + 398 -
    +
    +
      -
    + forks, err := etherman.GetForks(ctx, 0, 132)
    - + + 399 -
    +
    +
      -
    + require.NoError(t, err)
    - 3 + 38
      - import ( + }
    - 4 + 39
      - "bytes" +
    - 5 + 40
      - "context" + // This function prepare the blockchain, the wallet with funds and deploy the smc
    - 6 + + 41 +
    + - "crypto/ecdsa" + func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock, st *stateMock) {
    - 7 + 42
      - "encoding/json" + privateKey, err := crypto.GenerateKey()
    - 8 + 43
      - "errors" + if err != nil {
    - 9 + 44
      - "fmt" + log.Fatal(err)
    - 109 + 47
      - // methodIDSequenceBatchesElderberry: MethodID for sequenceBatches in Elderberry + if err != nil {
    - 110 + 48
      - methodIDSequenceBatchesElderberry = []byte{0xde, 0xf5, 0x7e, 0x54} // 0xdef57e54 sequenceBatches((bytes,bytes32,uint64,bytes32)[],uint64,uint64,address) + log.Fatal(err)
    - 111 + 49
      -
    + }
    - 112 + + 50 +
    + - // methodIDSequenceBatchesValidiumEtrog: MethodID for sequenceBatchesValidium in Etrog + da = newDaMock(t)
    - 113 + 51
    + - methodIDSequenceBatchesValidiumEtrog = []byte{0x2d, 0x72, 0xc2, 0x48} // 0x2d72c248 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],address,bytes) + st = newStateMock(t)
    - 114 + 52
    + - // methodIDSequenceBatchesValidiumElderberry: MethodID for sequenceBatchesValidium in Elderberry + ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da, st)
    - 115 + + 53 +
    - + - methodIDSequenceBatchesValidiumElderberry = []byte{0xdb, 0x5b, 0x0e, 0xd7} // 0xdb5b0ed7 sequenceBatchesValidium((bytes32,bytes32,uint64,bytes32)[],uint64,uint64,address,bytes) +   + if err != nil {
    - 116 + + 54 +
    - + -
    +   + log.Fatal(err)
    - 117 + 55
      - // ErrNotFound is used when the object is not found + }
    +
     
    +
    - 118 + 57
      - ErrNotFound = errors.New("not found") + if err != nil {
    - 119 + 58
      - // ErrIsReadOnlyMode is used when the EtherMan client is in read-only mode. + log.Fatal(err)
    -
     
    +
    + 59 + +
    +   + } +
    +
    + 60 + +
    + + + return ethman, ethBackend, auth, polAddr, br, da, st +
    - 197 + 61
      - GlobalExitRootManager *polygonzkevmglobalexitroot.Polygonzkevmglobalexitroot + }
    - 198 + 62
      - OldGlobalExitRootManager *oldpolygonzkevmglobalexitroot.Oldpolygonzkevmglobalexitroot +
    - 199 + 63
      - Pol *pol.Pol + func TestGEREvent(t *testing.T) {
    - 200 + + 64 + +
    +   + // Set up testing environment +
    +
    + 65 +
    + - DAProtocol *dataavailabilityprotocol.Dataavailabilityprotocol + etherman, ethBackend, auth, _, br, _, _ := newTestingEnv(t)
    - 201 + 66
      - SCAddresses []common.Address +
    - 202 + 67
      -
    + // Read currentBlock
    - 203 + 68
      - RollupID uint32 + ctx := context.Background()
    - 207 + 84
      - l1Cfg L1Config + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 208 + 85
      - cfg Config + require.NoError(t, err)
    - 209 + 86
      - auth map[common.Address]bind.TransactOpts // empty in case of read-only client + t.Logf("Blocks: %+v", blocks)
    - 210 + + 87 +
    + -
    + assert.Equal(t, uint64(11), blocks[0].L1InfoTree[0].BlockNumber)
    - 211 + + 88 +
    - + - da dataavailability.BatchDataProvider +   + assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot)
    - 212 + + 89 +
    - + - state stateProvider +   + assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot)
    - 213 + 90
    @@ -63490,7 +139004,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 214 + 91
    @@ -63500,197 +139014,182 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 215 + 92
      - // NewClient creates a new etherman. + func TestForcedBatchEvent(t *testing.T) { +
    +
    + 93 + +
    +   + // Set up testing environment
    - 216 + 94
    + - func NewClient(cfg Config, l1Config L1Config, da dataavailability.BatchDataProvider, st stateProvider) (*Client, error) { + etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t)
    - 217 + 95
      - // Connect to ethereum node +
    - 218 + 96
      - ethClient, err := ethclient.Dial(cfg.URL) + // Read currentBlock
    - 219 + 97
      - if err != nil { + ctx := context.Background()
    -
     
    -
    - 256 + 98
      - log.Errorf("error creating NewPol client (%s). Error: %w", l1Config.PolAddr.String(), err) + initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil)
    - 257 + 99
      - return nil, err + require.NoError(t, err)
    - 258 + 100
      - } -
    -
    - 259 - -
    - + - dapAddr, err := zkevm.DataAvailabilityProtocol(&bind.CallOpts{Pending: false}) -
    -
    - 260 - -
    - + - if err != nil { +
    - 261 + + 101 +
    + - return nil, err + amount, err := etherman.RollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false})
    - 262 + + 102 +
    - + - } +   + require.NoError(t, err)
    - 263 + + 103 +
    - + - dap, err := dataavailabilityprotocol.NewDataavailabilityprotocol(dapAddr, ethClient) +   + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - 264 + + 104 +
    - + - if err != nil { +   + data, err := hex.DecodeString(rawTxs)
    - 265 + + 105 +
    - + - return nil, err +   + require.NoError(t, err)
    - 266 + + 106 +
    + - } + _, err = etherman.ZkEVM.ForceBatch(auth, data, amount)
    - 267 + 107
      - var scAddresses []common.Address + require.NoError(t, err)
    - 268 + 108
      - scAddresses = append(scAddresses, l1Config.ZkEVMAddr, l1Config.RollupManagerAddr, l1Config.GlobalExitRootManagerAddr) +
    - 269 + 109
      -
    + // Mine the tx in a block
    - 282 + 116
      - rollupID, err := rollupManager.RollupAddressToID(&bind.CallOpts{Pending: false}, l1Config.ZkEVMAddr) + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 283 + 117
      - if err != nil { + require.NoError(t, err)
    - 284 + 118
      - log.Debugf("error rollupManager.RollupAddressToID(%s). Error: %w", l1Config.RollupManagerAddr, err) + t.Logf("Blocks: %+v", blocks)
    - 285 + 119
    + - return nil, err + assert.Equal(t, uint64(11), blocks[0].BlockNumber) +
    +
    + 120 + +
    + + + assert.Equal(t, uint64(11), blocks[0].ForcedBatches[0].BlockNumber)
    - 286 + 121
      - } + assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot)
    - 287 + 122
      - log.Debug("rollupID: ", rollupID) + assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt)
    - 288 + 123
      -
    + assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber)
    - 294 + 127
      - RollupManager: rollupManager, +
    - 295 + 128
      - Pol: pol, + func TestSequencedBatchesEvent(t *testing.T) {
    - 296 + 129
      - GlobalExitRootManager: globalExitRoot, + // Set up testing environment
    - 297 + + 130 +
    + - DAProtocol: dap, + etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t)
    - 298 + 131
      - OldGlobalExitRootManager: oldGlobalExitRoot, +
    - 299 + 132
      - SCAddresses: scAddresses, + // Read currentBlock
    - 300 + 133
      - RollupID: rollupID, + ctx := context.Background()
    - 305 + 141
      - l1Cfg: l1Config, + ethBackend.Commit()
    - 306 + 142
      - cfg: cfg, + auth.Value = big.NewInt(0)
    - 307 + 143
      - auth: map[common.Address]bind.TransactOpts{}, +
    - 308 + + 144 +
    + - da: da, + amount, err := etherman.RollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false})
    - 309 + + 145 +
    - + - state: st, +   + require.NoError(t, err)
    - 310 + 146
      - }, nil + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - 311 + 147
      - } + data, err := hex.DecodeString(rawTxs)
    - 312 + 148
      -
    + require.NoError(t, err) +
    +
    + 149 + +
    + + + _, err = etherman.ZkEVM.ForceBatch(auth, data, amount)
    - 313 + 150
      - // VerifyGenBlockNumber verifies if the genesis Block Number is valid + require.NoError(t, err)
    - 314 + 151
      - func (etherMan *Client) VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) { + require.NoError(t, err)
    - 315 + + 152 +
    - + - // TODO: do not assume that only one rollup will be attached to the rollup manager in the same L1 block +   + ethBackend.Commit()
    +
     
    +
    - 316 + 158
      - start := time.Now() + blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber)
    - 317 + 159
      - log.Info("Verifying genesis blockNumber: ", genBlockNumber) + require.NoError(t, err)
    - 318 + 160
      - // Filter query + t.Log("Blocks: ", blocks)
    -
     
    +
    + 161 + +
    + + + var sequences []polygonzkevm.PolygonValidiumEtrogValidiumBatchData +
    - 368 + + 162 +
    -   - log.Debug("Getting forkIDs from blockNumber: ", genBlockNumber) + + + txsHash := crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))
    - 369 + + 163 +
    -   - start := time.Now() + + + sequences = append(sequences, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    + 164 + +
    + + + TransactionsHash: txsHash, +
    +
    + 165 + +
    + + + }, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    + 166 + +
    + + + TransactionsHash: txsHash,
    - 370 + 167
      - var logs []types.Log + }) +
    +
    + 168 + +
    + + + batchNums := []uint64{2, 3}
    - 371 + 169
    + -
    + batchHashes := []common.Hash{txsHash, txsHash}
    - 372 + 170
    + - if lastL1BlockSynced < genBlockNumber { + batchData := [][]byte{data, data}
    - 373 + 171
    + - lastL1BlockSynced = genBlockNumber + daMessage, _ := hex.DecodeString("0x123456789123456789")
    - 374 + 172
    + - } + da.Mock.On("GetBatchL2Data", batchNums, batchHashes, daMessage).Return(batchData, nil)
    - 375 + 173
    + -
    + _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
    - 376 + 174
      - log.Debug("Using ForkIDChunkSize: ", etherMan.cfg.ForkIDChunkSize) + require.NoError(t, err)
    - 377 + 175
      - for i := genBlockNumber; i <= lastL1BlockSynced; i = i + etherMan.cfg.ForkIDChunkSize + 1 { +
    - 378 + 176
      - final := i + etherMan.cfg.ForkIDChunkSize + // Mine the tx in a block
    - 713 + 196
      - return etherMan.updateForkId(ctx, vLog, blocks, blocksOrder, addExistingRollup.LastVerifiedBatchBeforeUpgrade, addExistingRollup.ForkID, "", addExistingRollup.RollupID) +
    - 714 + 197
      - } + func TestVerifyBatchEvent(t *testing.T) {
    - 715 + 198
      -
    + // Set up testing environment
    - 716 + 199
    + - func (etherMan *Client) updateEtrogSequence(_ context.Context, _ types.Log, _ *[]Block, _ *map[common.Hash][]Order) error { + etherman, ethBackend, auth, _, _, da, _ := newTestingEnv(t)
    - 717 + + 200 +
    - + - return errors.New("upgrading validiums to etrog not supported") +   +
    - + + 201 -
    +
    +
      -
    + // Read currentBlock
    - + + 202 -
    +
    +
      -
    + ctx := context.Background()
    - + +
     
    -
    +
    + 205 + +
      -
    + require.NoError(t, err)
    - + + 206 -
    +
    +
     
    - + + 207 -
    +
    +
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - + + 208 -
    -   -
    +
    +
    + + + tx := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{
    - + + 209 -
    -   -
    +
    +
    + + + TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)),
    - + + 210 -
    +
    +
      -
    + }
    - + + 211 -
    -   -
    +
    +
    + + + daMessage, _ := hex.DecodeString("0x1234")
    - + + 212 -
    -   -
    +
    +
    + + + _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, []polygonzkevm.PolygonValidiumEtrogValidiumBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage)
    - + + 213 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 214 -
    -   -
    +
    +
    + + + da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))}, daMessage).Return([][]byte{common.Hex2Bytes(rawTxs)}, nil)
    - + + 215 -
    +
    +
     
    - + + 216 -
    +
    +
      -
    + // Mine the tx in a block
    - + + 217 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 218 -
    +
    +
     
    - + + 219 -
    -   -
    +
    +
    + + + _, err = etherman.RollupManager.VerifyBatchesTrustedAggregator(auth, 1, uint64(0), uint64(0), uint64(1), [32]byte{}, [32]byte{}, auth.From, [24][32]byte{})
    - + + 220 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 221 -
    +
    +
     
    - + + 222 -
    +
    +
      -
    + // Mine the tx in a block
    - + +
     
    -
    +
    + 229 + +
      -
    + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - + + 230 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 231 -
    +
    +
      -
    + t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order)
    - + + 232 -
    -   -
    +
    +
    + + + assert.Equal(t, uint64(12), blocks[1].BlockNumber)
    - + + 233 -
    +
    +
      -
    + assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber)
    - + + 234 -
    +
    +
      -
    + assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator)
    - + + 235 -
    +
    +
      -
    + assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash)
    - + +
     
    -
    +
    + 241 + +
     
    - + + 242 -
    +
    +
      -
    + func TestSequenceForceBatchesEvent(t *testing.T) {
    - + + 243 -
    +
    +
      -
    + // Set up testing environment
    - + + 244 -
    +
    +
    + + + etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t) +
    +
    + 245 + +
     
    - + + 246 -
    +
    +
      -
    + // Read currentBlock
    - + + 247 -
    +
    +
      -
    + ctx := context.Background()
    - + + 248 -
    +
    +
      -
    + initBlock, err := etherman.EthClient.BlockByNumber(ctx, nil)
    - + + 249 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 250 -
    +
    +
     
    - + + 251 -
    +
    +
    + + + amount, err := etherman.RollupManager.GetForcedBatchFee(&bind.CallOpts{Pending: false}) +
    +
    + 252 + +
      -
    + require.NoError(t, err)
    - + + 253 -
    +
    +
      -
    + rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c"
    - + + 254 -
    +
    +
      -
    + data, err := hex.DecodeString(rawTxs)
    - + + 255 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 256 -
    +
    +
    + + + _, err = etherman.ZkEVM.ForceBatch(auth, data, amount) +
    +
    + 257 + +
      -
    + require.NoError(t, err)
    - + + 258 -
    +
    +
      -
    + ethBackend.Commit()
    - + + 259 -
    +
    +
      -
    + ethBackend.Commit()
    - + +
     
    -
    +
    + 275 + +
      -
    + prevBlock, err := etherman.EthClient.BlockByNumber(ctx, big.NewInt(0).SetUint64(blocks[0].BlockNumber-1))
    - + + 276 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 277 -
    +
    +
      -
    + forcedBlockHashL1 := prevBlock.Hash()
    - + + 278 -
    -   -
    +
    +
    + + + forceBatchData := polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 279 -
    +
    +
      -
    + Transactions: blocks[0].ForcedBatches[0].RawTxsData,
    - + + 280 -
    +
    +
      -
    + ForcedGlobalExitRoot: forcedGer,
    - + + 281 -
    +
    +
      -
    + ForcedTimestamp: forcedTimestamp,
    - + + 282 -
    +
    +
      -
    + ForcedBlockHashL1: forcedBlockHashL1,
    - + + 283 -
    +
    +
      -
    + }
    - + + 284 -
    -   -
    +
    +
    + + + _, err = etherman.ZkEVM.SequenceForceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{forceBatchData})
    - 718 + 285
      - } + require.NoError(t, err)
    - 719 + 286
      -
    + ethBackend.Commit()
    - 720 + 287
      - func (etherMan *Client) initialSequenceBatches(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { +
    - 913 + 292
      - } + blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber)
    - 914 + 293
      -
    + require.NoError(t, err)
    - 915 + 294
      - // EstimateGasSequenceBatches estimates gas for sending batches + t.Logf("Blocks: %+v", blocks)
    - 916 + 295
    + - func (etherMan *Client) EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) { + assert.Equal(t, uint64(15), blocks[1].BlockNumber)
    - 917 + 296
      - opts, err := etherMan.getAuthByAddress(sender) + assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber)
    - 918 + 297
      - if err == ErrNotFound { + assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:]))
    - 919 + 298
      - return nil, ErrPrivateKeyNotFound + assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp)
    +
     
    +
    - 920 + 302
      - } +
    - 921 + 303
      - opts.NoSend = true + func TestSendSequences(t *testing.T) {
    - 922 + 304
      -
    + // Set up testing environment
    - 923 + 305
    + - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) + etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t)
    - 924 + 306
      - if err != nil { +
    - 925 + 307
      - return nil, err + // Read currentBlock
    - 926 + 308
      - } + ctx := context.Background()
    - 929 + 324
      - } + BatchL2Data: batchL2Data,
    - 930 + 325
      -
    + LastL2BLockTimestamp: time.Now().Unix(),
    - 931 + 326
      - // BuildSequenceBatchesTxData builds a []bytes to be sent to the PoE SC method SequenceBatches. + } +
    +
    + 327 + +
    + + + daMessage, _ := hex.DecodeString("0x1234") +
    +
    + 328 + +
    +   + lastL2BlockTStamp := tx1.Time().Unix()
    - 932 + 329
    + - func (etherMan *Client) BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (to *common.Address, data []byte, err error) { + tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From, daMessage) +
    +
    + + +
    +   +
    - 933 + 330
      - opts, err := etherMan.getAuthByAddress(sender) + require.NoError(t, err) +
    +
    + 331 + +
    + + + da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(batchL2Data)}, daMessage).Return([][]byte{batchL2Data}, nil) +
    +
    + 332 + +
    + + +
    - 934 + 333
      - if err == ErrNotFound { + log.Debug("TX: ", tx.Hash())
    - 935 + 334
      - return nil, nil, fmt.Errorf("failed to build sequence batches, err: %w", ErrPrivateKeyNotFound) + ethBackend.Commit() +
    +
    + 335 + +
    +   +
    - 940 + 352
      - opts.GasLimit = uint64(1) +
    - 941 + 353
      - opts.GasPrice = big.NewInt(1) + func TestGasPrice(t *testing.T) {
    - 942 + 354
      -
    + // Set up testing environment
    - 943 + 355
    + - tx, err := etherMan.sequenceBatches(opts, sequences, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) + etherman, _, _, _, _, _, _ := newTestingEnv(t)
    - 944 + 356
      - if err != nil { + etherscanM := new(etherscanMock)
    - 945 + 357
      - return nil, nil, err + ethGasStationM := new(ethGasStationMock)
    - 946 + 358
      - } + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 948 + 371
      - return tx.To(), tx.Data(), nil +
    - 949 + 372
      - } + func TestErrorEthGasStationPrice(t *testing.T) {
    - 950 + 373
      -
    -
    -
    - 951 - -
    - + - func (etherMan *Client) sequenceBatches(opts bind.TransactOpts, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, lastSequencedBatchNumber uint64, l2Coinbase common.Address, dataAvailabilityMessage []byte) (*types.Transaction, error) { + // Set up testing environment
    - 952 + 374
    + - var batches []polygonzkevm.PolygonValidiumEtrogValidiumBatchData + etherman, _, _, _, _, _, _ := newTestingEnv(t)
    - 953 + 375
      - for _, seq := range sequences { + ethGasStationM := new(ethGasStationMock)
    - 954 + 376
      - var ger common.Hash + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM}
    - 955 + 377
      - if seq.ForcedBatchTimestamp > 0 { + ctx := context.Background()
    - 956 + 378
      - ger = seq.GlobalExitRoot +
    - 957 + 379
      - } + ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation"))
    - 958 + + 380 +
    - + - batch := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +   + gp := etherman.GetL1GasPrice(ctx)
    - 959 + 381
    + - TransactionsHash: crypto.Keccak256Hash(seq.BatchL2Data), + assert.Equal(t, big.NewInt(1263075579), gp)
    - 960 + 382
      - ForcedGlobalExitRoot: ger, +
    - 961 + 383
      - ForcedTimestamp: uint64(seq.ForcedBatchTimestamp), + etherscanM := new(etherscanMock)
    - 962 + 384
      - ForcedBlockHashL1: seq.PrevBlockHash, + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 965 + 390
      - batches = append(batches, batch) +
    - 966 + 391
      - } + func TestErrorEtherScanPrice(t *testing.T) {
    - 967 + 392
      -
    + // Set up testing environment
    - 968 + 393
    + - tx, err := etherMan.ZkEVM.SequenceBatchesValidium(&opts, batches, maxSequenceTimestamp, lastSequencedBatchNumber, l2Coinbase, dataAvailabilityMessage) + etherman, _, _, _, _, _, _ := newTestingEnv(t)
    - 969 + 394
      - if err != nil { + etherscanM := new(etherscanMock)
    - 970 + 395
      - log.Debugf("Batches to send: %+v", batches) + ethGasStationM := new(ethGasStationMock)
    - 971 + 396
      - log.Debug("l2CoinBase: ", l2Coinbase) + etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM}
    - 1161 + 404
    @@ -65260,2032 +140934,2205 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1162 + 405
      - func (etherMan *Client) sequencedBatchesEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) error { + func TestGetForks(t *testing.T) {
    - 1163 + 406
      - log.Debugf("SequenceBatches event detected: txHash: %s", common.Bytes2Hex(vLog.TxHash[:])) + // Set up testing environment
    - + + 407 -
    -   -
    +
    +
    + + + etherman, _, _, _, _, _, _ := newTestingEnv(t)
    - 1164 + 408
      -
    + ctx := context.Background()
    - 1165 + 409
      - sb, err := etherMan.ZkEVM.ParseSequenceBatches(vLog) + forks, err := etherman.GetForks(ctx, 0, 132)
    - 1166 + 410
      - if err != nil { + require.NoError(t, err)
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/events_helper.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -1,191 +0,0 @@
    - 1184 + + 1 +
    -   - if sb.NumBatch != 1 { + - + package etherman
    - 1185 + + 2 +
    -   - methodId := tx.Data()[:4] + - +
    - 1186 + + 3 +
    -   - log.Debugf("MethodId: %s", common.Bytes2Hex(methodId)) + - + import (
    - 1187 + + 4 +
    - + - if bytes.Equal(methodId, methodIDSequenceBatchesEtrog) || + - + "bytes"
    - 1188 + + 5 +
    - + - bytes.Equal(methodId, methodIDSequenceBatchesValidiumEtrog) { + - + "context"
    - 1189 + + 6 +
    - + - sequences, err = decodeSequencesEtrog(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state) + - + "fmt"
    - 1190 + + 7 +
    -   - if err != nil { + - + "math/big"
    - 1191 + + 8 +
    -   - return fmt.Errorf("error decoding the sequences (etrog): %v", err) + - +
    - 1192 + + 9 +
    -   - } + - + "github.com/ethereum/go-ethereum"
    - 1193 + + 10 +
    - + - } else if bytes.Equal(methodId, methodIDSequenceBatchesElderberry) || + - + "github.com/ethereum/go-ethereum/common"
    - 1194 + + 11 +
    - + - bytes.Equal(methodId, methodIDSequenceBatchesValidiumElderberry) { + - + "github.com/ethereum/go-ethereum/core"
    - 1195 + + 12 +
    - + - sequences, err = decodeSequencesElderberry(tx.Data(), sb.NumBatch, msg.From, vLog.TxHash, msg.Nonce, sb.L1InfoRoot, etherMan.da, etherMan.state) + - + "github.com/ethereum/go-ethereum/core/types"
    - 1196 + + 13 +
    -   - if err != nil { + - + )
    - 1197 + + 14 +
    -   - return fmt.Errorf("error decoding the sequences (elderberry): %v", err) + - +
    - 1198 + + 15 +
    -   - } + - + // BlockRetriever is the interface required from etherman main object
    -
     
    +
    + 16 + +
    + - + type BlockRetriever interface { +
    - 1278 + + 17 +
    -   - return nil + - + RetrieveFullBlockForEvent(ctx context.Context, vLog types.Log) (*Block, error)
    - 1279 + + 18 +
    -   + - }
    - 1280 + + 19 +
    -   + -
    - 1281 + + 20 +
    - + - func decodeSequencesElderberry(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, + - + // GenericEventProcessor is the interface that a processor must implement
    - 1282 + + 21 +
    - + - l1InfoRoot common.Hash, da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) { + - + type GenericEventProcessor interface {
    - 1283 + + 22 +
    -   - // Extract coded txs. + - + // EventSignature returns the signature of the event supported
    - 1284 + + 23 +
    -   - // Load contract ABI + - + // evaluate if make sens to support multiples signatures
    - 1285 + + 24 +
    -   - smcAbi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI)) + - + EventSignature() common.Hash
    -
     
    +
    + 25 + +
    + - + AddEventDataToBlock(ctx context.Context, vLog types.Log, block *Block, callData *CallData) (*Order, error) +
    - 1287 + + 26 +
    -   - return nil, err + - + }
    - 1288 + + 27 +
    -   - } + - +
    - 1289 + + 28 +
    -   -
    + - + // CallDataExtractor is the interface required to extract the call data from a transaction
    - 1290 + + 29 +
    - + - return decodeSequencedBatches(smcAbi, txData, state.FORKID_ELDERBERRY, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st) + - + type CallDataExtractor interface {
    - 1291 + + 30 +
    - + + - + ExtractCallData(ctx context.Context, blockHash, txHash common.Hash, txIndex uint) (*CallData, error) +
    +
    + 31 + +
    + - }
    - 1292 + + 32 +
    - + + -
    - 1293 + + 33 +
    - + - func decodeSequencesEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, + - + // EventManager is a struct that manages the L1 events
    - 1294 + + 34 +
    - + - da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) { + - + // The way of using this is create and add Processor
    - 1295 + + 35 +
    - + - // Extract coded txs. + - + // A processor only need to code the specific part of adding specific data
    - 1296 + + 36 +
    - + - // Load contract ABI + - + // to the block
    - 1297 + + 37 +
    - + - smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI)) + - + type EventManager struct {
    - 1298 + + 38 +
    - + - if err != nil { + - + blockRetriever BlockRetriever
    - 1299 + + 39 +
    - + - return nil, err + - + callDataExtractor CallDataExtractor
    - 1300 + + 40 +
    - + - } + - +
    - 1301 + + 41 +
    - + + - + processors []GenericEventProcessor +
    +
    + 42 + +
    + - + } +
    +
    + 43 + +
    + -
    - 1302 + + 44 +
    - + - return decodeSequencedBatches(smcAbi, txData, state.FORKID_ETROG, lastBatchNumber, sequencer, txHash, nonce, l1InfoRoot, da, st) + - + // NewEventManager creates a new EventManager
    - 1303 + + 45 +
    - + + - + func NewEventManager(blockRetriever BlockRetriever, callDataExtractor CallDataExtractor) *EventManager { +
    +
    + 46 + +
    + - + return &EventManager{ +
    +
    + 47 + +
    + - + blockRetriever: blockRetriever, +
    +
    + 48 + +
    + - + callDataExtractor: callDataExtractor, +
    +
    + 49 + +
    + - + processors: []GenericEventProcessor{}, +
    +
    + 50 + +
    + - + } +
    +
    + 51 + +
    + - }
    - 1304 + + 52 +
    - + + -
    - 1305 + + 53 +
    - + - // decodeSequencedBatches decodes provided data, based on the funcName, whether it is rollup or validium data and returns sequenced batches + - + // AddProcessor adds a new processor to the EventManager
    - 1306 + + 54 +
    - + - func decodeSequencedBatches(smcAbi abi.ABI, txData []byte, forkID uint64, lastBatchNumber uint64, + - + func (e *EventManager) AddProcessor(processor GenericEventProcessor) {
    - 1307 + + 55 +
    - + - sequencer common.Address, txHash common.Hash, nonce uint64, l1InfoRoot common.Hash, + - + e.processors = append(e.processors, processor)
    - 1308 + + 56 +
    - + - da dataavailability.BatchDataProvider, st stateProvider) ([]SequencedBatch, error) { + - + } +
    +
    + 57 + +
    + - +
    +
    +
    + 58 + +
    + - + // ProcessEvent processes an event +
    +
    + 59 + +
    + - + // this is the interface with etherman +
    +
    + 60 + +
    + - + // it returns true if this event belong to this processor
    - 1309 + + 61 +
    -   - // Recover Method from signature and ABI + - + func (e *EventManager) ProcessEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) (bool, error) {
    - 1310 + + 62 +
    -   - method, err := smcAbi.MethodById(txData[:4]) + - + for idx := range e.processors {
    - 1311 + + 63 +
    -   - if err != nil { + - + processor := e.processors[idx]
    -
     
    -
    - 1317 + + 64 +
    -   - if err != nil { + - + if len(vLog.Topics) > 0 && vLog.Topics[0] == processor.EventSignature() {
    - 1318 + + 65 +
    -   - return nil, err + - + return true, e.processGenericEvent(ctx, vLog, blocks, blocksOrder, processor)
    - 1319 + + 66 +
    -   - } + - + }
    - + + 67 -
    -   -
    +
    +
    + - + }
    - 1320 + + 68 +
    -   - bytedata, err := json.Marshal(data[0]) + - + return false, nil
    - 1321 + + 69 +
    -   - if err != nil { + - + }
    - 1322 + + 70 +
    -   - return nil, err + - +
    - 1323 + + 71 +
    -   - } + - + func (e *EventManager) processGenericEvent(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order, processor GenericEventProcessor) error {
    - + + 72 -
    -   -
    +
    +
    + - + callData, err := e.callDataExtractor.ExtractCallData(ctx, vLog.BlockHash, vLog.TxHash, vLog.TxIndex)
    - + + 73 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 74 -
    -   -
    +
    +
    + - + return err
    - + + 75 -
    -   -
    +
    +
    + - + }
    - + + 76 -
    -   -
    +
    +
    + - + block, err := e.addNewBlockToResult(ctx, vLog, blocks, blocksOrder)
    - + + 77 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 78 -
    -   -
    +
    +
    + - + return err
    - + + 79 -
    -   -
    +
    +
    + - + }
    - 1324 + + 80 +
    -   -
    + - + order, err := processor.AddEventDataToBlock(ctx, vLog, block, callData)
    - 1325 + + 81 +
    - + - var ( + - + if err != nil {
    - 1326 + + 82 +
    - + - maxSequenceTimestamp uint64 + - + return err
    - 1327 + + 83 +
    - + - initSequencedBatchNumber uint64 + - + }
    - 1328 + + 84 +
    - + - coinbase common.Address + - + addNewOrder(order, block.BlockHash, blocksOrder)
    - 1329 + + 85 +
    - + - ) + - + return nil
    - 1330 + + 86 +
    - + -
    + - + }
    - 1331 + + 87 +
    - + - switch method.Name { + - +
    - 1332 + + 88 +
    - + - case "sequenceBatches": + - + func addNewOrder(order *Order, blockHash common.Hash, blocksOrder *map[common.Hash][]Order) {
    - 1333 + + 89 +
    - + - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData + - + (*blocksOrder)[blockHash] = append((*blocksOrder)[blockHash], *order)
    - 1334 + + 90 +
    - + - err := json.Unmarshal(bytedata, &sequences) + - + }
    - 1335 + + 91 +
    - + - if err != nil { + - +
    - 1336 + + 92 +
    - + - return nil, err + - + // addNewEvent adds a new event to the blocks array and order array.
    - 1337 + + 93 +
    -   - } + - + // it returns the block that must be filled with event data
    - 1338 + + 94 +
    - + -
    + - + func (e *EventManager) addNewBlockToResult(ctx context.Context, vLog types.Log, blocks *[]Block, blocksOrder *map[common.Hash][]Order) (*Block, error) {
    - 1339 + + 95 +
    - + - switch forkID { + - + var block *Block
    - 1340 + + 96 +
    - + - case state.FORKID_ETROG: + - + var err error
    - 1341 + + 97 +
    - + - coinbase = data[1].(common.Address) + - + if !isheadBlockInArray(blocks, vLog.BlockHash, vLog.BlockNumber) {
    - 1342 + + 98 +
    - + -
    + - + // Need to add the block, doesnt mind if inside the blocks because I have to respect the order so insert at end
    - 1343 + + 99 +
    - + - case state.FORKID_ELDERBERRY: + - + //TODO: Check if the block is already in the blocks array and copy it instead of retrieve it again
    - 1344 + + 100 +
    - + - maxSequenceTimestamp = data[1].(uint64) + - + block, err = e.blockRetriever.RetrieveFullBlockForEvent(ctx, vLog)
    - 1345 + + 101 +
    - + - initSequencedBatchNumber = data[2].(uint64) + - + if err != nil {
    - 1346 + + 102 +
    - + - coinbase = data[3].(common.Address) + - + return nil, err
    - 1347 + + 103 +
    - + - } + - + }
    - 1348 + + 104 +
    - + -
    + - + *blocks = append(*blocks, *block)
    - 1349 + + 105 +
    - + - sequencedBatches := make([]SequencedBatch, len(sequences)) + - + }
    - 1350 + + 106 +
    - + - for i, seq := range sequences { + - + block = &(*blocks)[len(*blocks)-1]
    - 1351 + + 107 +
    - + - bn := lastBatchNumber - uint64(len(sequences)-(i+1)) + - + return block, nil
    - 1352 + + 108 +
    - + - s := seq + - + }
    - 1353 + + 109 +
    - + - batch := SequencedBatch{ + - +
    - 1354 + + 110 +
    - + - BatchNumber: bn, + - + // CallData is a struct that contains the calldata of a transaction
    - 1355 + + 111 +
    - + - L1InfoRoot: &l1InfoRoot, + - + type CallData struct {
    - 1356 + + 112 +
    - + - SequencerAddr: sequencer, + - + data []byte
    - 1357 + + 113 +
    - + - TxHash: txHash, + - + nonce uint64
    - 1358 + + 114 +
    - + - Nonce: nonce, + - + from common.Address
    - 1359 + + 115 +
    - + - Coinbase: coinbase, + - + }
    - 1360 + + 116 +
    - + - PolygonRollupBaseEtrogBatchData: &s, + - +
    - 1361 + + 117 +
    - + - } + - + // NewCallData creates a new CallData struct
    - 1362 + + 118 +
    - + - if forkID >= state.FORKID_ELDERBERRY { + - + func NewCallData(data []byte, nonce uint64, from common.Address) *CallData {
    - 1363 + + 119 +
    - + - batch.SequencedBatchElderberryData = &SequencedBatchElderberryData{ + - + return &CallData{
    - 1364 + + 120 +
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, + - + data: data,
    - 1365 + + 121 +
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, + - + nonce: nonce,
    - 1366 + + 122 +
    - + - } + - + from: from,
    - 1367 + + 123 +
    - + - } + - + }
    - 1368 + + 124 +
    - + - sequencedBatches[i] = batch + - + }
    - 1369 + + 125 +
    -   - } + - +
    - 1370 + + 126 +
    - + -
    + - + // MethodID returns the method ID of the transaction
    - 1371 + + 127 +
    - + - return sequencedBatches, nil + - + func (c *CallData) MethodID() []byte {
    - 1372 + + 128 +
    - + - case "sequenceBatchesValidium": + - + return c.data[:4]
    - 1373 + + 129 +
    - + - var ( + - + }
    - 1374 + + 130 +
    - + - sequencesValidium []polygonzkevm.PolygonValidiumEtrogValidiumBatchData + - +
    - 1375 + + 131 +
    - + - dataAvailabilityMsg []byte + - + // InputData returns the input data of the transaction
    - 1376 + + 132 +
    - + - ) + - + func (c *CallData) InputData() []byte {
    - 1377 + + 133 +
    - + - err := json.Unmarshal(bytedata, &sequencesValidium) + - + return c.data[4:]
    - 1378 + + 134 +
    - + - if err != nil { + - + }
    - 1379 + + 135 +
    - + - return nil, err + - +
    - 1380 + + 136 +
    - + - } + - + // Nonce returns the nonce of the transaction
    - 1381 + + 137 +
    - + -
    + - + func (c *CallData) Nonce() uint64 {
    - 1382 + + 138 +
    - + - switch forkID { + - + return c.nonce
    - 1383 + + 139 +
    - + - case state.FORKID_ETROG: + - + }
    - 1384 + + 140 +
    - + - coinbase = data[1].(common.Address) + - +
    - 1385 + + 141 +
    - + - dataAvailabilityMsg = data[2].([]byte) + - + // From returns the address of the sender of the transaction
    - 1386 + + 142 +
    - + -
    + - + func (c *CallData) From() common.Address {
    - 1387 + + 143 +
    - + - case state.FORKID_ELDERBERRY: + - + return c.from
    - 1388 + + 144 +
    - + - maxSequenceTimestamp = data[1].(uint64) + - + }
    - 1389 + + 145 +
    - + - initSequencedBatchNumber = data[2].(uint64) + - +
    - 1390 + + 146 +
    - + - coinbase = data[3].(common.Address) + - + // CallDataExtratorGeth is a CallDataExtractor based on Geth
    - 1391 + + 147 +
    - + - dataAvailabilityMsg = data[4].([]byte) + - + type CallDataExtratorGeth struct {
    - 1392 + + 148 +
    - + - } + - + ethClient ethereum.ChainReader
    - 1393 + + 149 +
    - + -
    + - + }
    - 1394 + + 150 +
    - + - // Pair the batch number, hash, and if it is forced. This will allow + - +
    - 1395 + + 151 +
    - + - // retrieval from different sources, and keep them in original order. + - + // NewCallDataExtratorGeth creates a new CallDataExtrator based on Geth
    - 1396 + + 152 +
    - + - var batchInfos []batchInfo + - + func NewCallDataExtratorGeth(ethClient ethereum.ChainReader) *CallDataExtratorGeth {
    - 1397 + + 153 +
    - + - for i, d := range sequencesValidium { + - + return &CallDataExtratorGeth{
    - 1398 + + 154 +
    - + - bn := lastBatchNumber - uint64(len(sequencesValidium)-(i+1)) + - + ethClient: ethClient,
    - 1399 + + 155 +
    - + - forced := d.ForcedTimestamp > 0 + - + }
    - 1400 + + 156 +
    - + - h := d.TransactionsHash + - + }
    - 1401 + + 157 +
    - + - batchInfos = append(batchInfos, batchInfo{num: bn, hash: h, isForced: forced}) + - +
    - 1402 + + 158 +
    - + - } + - + // ExtractCallData get the call data from a transaction
    - 1403 + + 159 +
    - + -
    + - + func (e *CallDataExtratorGeth) ExtractCallData(ctx context.Context, blockHash, txHash common.Hash, txIndex uint) (*CallData, error) {
    - 1404 + + 160 +
    - + - batchData, err := retrieveBatchData(da, st, batchInfos, dataAvailabilityMsg) + - + // Read the tx for this event.
    - 1405 + + 161 +
    - + - if err != nil { + - + tx, err := e.ethClient.TransactionInBlock(ctx, blockHash, txIndex)
    - 1406 + + 162 +
    - + - return nil, err + - + if err != nil {
    - 1407 + + 163 +
    - + - } + - + return nil, err
    - 1408 + + 164 +
    - + -
    + - + }
    - 1409 + + 165 +
    - + - sequencedBatches := make([]SequencedBatch, len(sequencesValidium)) + - + if tx == nil {
    - 1410 + + 166 +
    - + - for i, info := range batchInfos { + - + return nil, fmt.Errorf("error: tx not found in block %s at index %d", blockHash.String(), txIndex)
    - 1411 + + 167 +
    - + - bn := info.num + - + }
    - 1412 + + 168 +
    - + - s := polygonzkevm.PolygonRollupBaseEtrogBatchData{ + - + //log.Debug("tx: ", tx2string(tx))
    - 1413 + + 169 +
    - + - Transactions: batchData[i], + - + if tx.Hash() != txHash {
    - 1414 + + 170 +
    - + - ForcedGlobalExitRoot: sequencesValidium[i].ForcedGlobalExitRoot, + - + return nil, fmt.Errorf("error: tx hash mismatch. want: %s have: %s", txHash, tx.Hash().String())
    - 1415 + + 171 +
    - + - ForcedTimestamp: sequencesValidium[i].ForcedTimestamp, + - + }
    - 1416 + + 172 +
    - + - ForcedBlockHashL1: sequencesValidium[i].ForcedBlockHashL1, + - + msg, err := core.TransactionToMessage(tx, types.NewLondonSigner(tx.ChainId()), big.NewInt(0))
    - 1417 + + 173 +
    - + - } + - + if err != nil {
    - 1418 + + 174 +
    - + - batch := SequencedBatch{ + - + return nil, err
    - 1419 + + 175 +
    - + - BatchNumber: bn, + - + }
    - 1420 + + 176 +
    - + - L1InfoRoot: &l1InfoRoot, + - + return &CallData{
    - 1421 + + 177 +
    - + - SequencerAddr: sequencer, + - + data: tx.Data(),
    - 1422 + + 178 +
    - + - TxHash: txHash, + - + nonce: msg.Nonce,
    - 1423 + + 179 +
    - + - Nonce: nonce, + - + from: msg.From,
    - 1424 + + 180 +
    - + - Coinbase: coinbase, + - + }, nil
    - 1425 + + 181 +
    - + - PolygonRollupBaseEtrogBatchData: &s, + - + }
    - 1426 + + 182 +
    - + - } + - +
    - 1427 + + 183 +
    - + - if forkID >= state.FORKID_ELDERBERRY { + - + // Function used to convert a transaction to a string to used as input data for unittest
    - 1428 + + 184 +
    - + - elderberry := &SequencedBatchElderberryData{ + - + func tx2string(tx *types.Transaction) string { //nolint:unused
    - 1429 + + 185 +
    - + - MaxSequenceTimestamp: maxSequenceTimestamp, + - + writer := new(bytes.Buffer)
    - 1430 + + 186 +
    - + - InitSequencedBatchNumber: initSequencedBatchNumber, + - + err := tx.EncodeRLP(writer)
    - 1431 + + 187 +
    - + - } + - + if err != nil {
    - 1432 + + 188 +
    - + - batch.SequencedBatchElderberryData = elderberry + - + return "error:" + err.Error()
    - 1433 + + 189 +
    - + - } + - + }
    - 1434 + + 190 +
    - + - sequencedBatches[i] = batch + - + return common.Bytes2Hex(writer.Bytes())
    - 1435 + + 191 +
    - + - } + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -67309,683 +143156,683 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -68019,33 +143866,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -68059,928 +143906,953 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -68990,12 +144862,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/etherman_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/events_helper_test.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    +
     
    - 1436 + + -
    - + +
    +
    +  
    - 1437 + + -
    - + - return sequencedBatches, nil +
    +
    +   +
    - 1438 + + -
    +
    +
      - } +
    - 1439 + + -
    +
    +
     
    - 1440 + + -
    - + - return nil, fmt.Errorf("unexpected method called in sequence batches transaction: %s", method.RawName) +
    +
    +   +
    - 1441 + + -
    +
    +
      - } +
    - 1442 + + -
    +
    +
     
    - 1443 + + -
    - + - type batchInfo struct { +
    +
    +   +
    - 1444 + + -
    - + - num uint64 +
    +
    +   +
    - 1445 + + -
    - + - hash common.Hash +
    +
    +   +
    - 1446 + + -
    - + - isForced bool +
    +
    +   +
    - 1447 + + -
    - + - } +
    +
    +   +
    - 1448 + + -
    - + +
    +
    +  
    - 1449 + + -
    - + - func retrieveBatchData(da dataavailability.BatchDataProvider, st stateProvider, batchInfos []batchInfo, daMessage []byte) ([][]byte, error) { +
    +
    +   +
    - 1450 + + -
    - + - validiumData, err := getBatchL2Data(da, batchInfos, daMessage) +
    +
    +   +
    - 1451 + + -
    +
    +
      - if err != nil { +
    - 1452 + + -
    +
    +
      - return nil, err +
    - 1453 + + -
    +
    +
      - } +
    - 1454 + + -
    - + - forcedData, err := getForcedBatchData(st, batchInfos) +
    +
    +   +
    - 1455 + + -
    +
    +
      - if err != nil { +
    - 1456 + + -
    +
    +
      - return nil, err +
    - 1457 + + -
    +
    +
      - } +
    - 1458 + + -
    - + - data := make([][]byte, len(batchInfos)) +
    +
    +   +
    - 1459 + + -
    - + - for i, info := range batchInfos { +
    +
    +   +
    - 1460 + + -
    - + - bn := info.num +
    +
    +   +
    - 1461 + + -
    - + - if info.isForced { +
    +
    +   +
    - 1462 + + -
    - + - data[i] = forcedData[bn] +
    +
    +   +
    - 1463 + + -
    - + - } else { +
    +
    +   +
    - 1464 + + -
    - + - data[i] = validiumData[bn] +
    +
    +   +
    - 1465 + + -
    - + - } +
    +
    +   +
    - 1466 + + -
    - + - } +
    +
    +   +
    - 1467 + + -
    - + - return data, nil +
    +
    +   +
    - 1468 + + -
    - + - } +
    +
    +   +
    - 1469 + + -
    +
    +
     
    - 1470 + + -
    - + - func getBatchL2Data(da dataavailability.BatchDataProvider, batchInfos []batchInfo, daMessage []byte) (map[uint64][]byte, error) { +
    +
    +   +
    - 1471 + + -
    - + - var batchNums []uint64 +
    +
    +   +
    - 1472 + + -
    - + - var batchHashes []common.Hash +
    +
    +   +
    - 1473 + + -
    - + - for _, info := range batchInfos { +
    +
    +   +
    - 1474 + + -
    - + - if !info.isForced { +
    +
    +   +
    - 1475 + + -
    - + - batchNums = append(batchNums, info.num) +
    +
    +   +
    - 1476 + + -
    - + - batchHashes = append(batchHashes, info.hash) +
    +
    +   +
    - 1477 + + -
    - + - } +
    +
    +   +
    - 1478 + + -
    +
    +
      - } +
    - 1479 + + -
    - + - if len(batchNums) == 0 { +
    +
    +   +
    - 1480 + + -
    - + - return nil, nil +
    +
    +   +
    - 1481 + + -
    - + - } +
    +
    +   +
    - 1482 + + -
    - + - batchL2Data, err := da.GetBatchL2Data(batchNums, batchHashes, daMessage) +
    +
    +   +
    - 1483 + + -
    +
    +
      - if err != nil { +
    - 1484 + + -
    +
    +
      - return nil, err +
    - 1485 + + -
    +
    +
      - } +
    - 1486 + + -
    - + - if len(batchL2Data) != len(batchNums) { +
    +
    +   +
    - 1487 + + -
    - + - return nil, +
    +
    +   +
    - 1488 + + -
    - + - fmt.Errorf("failed to retrieve all batch data. Expected %d, got %d", len(batchNums), len(batchL2Data)) +
    +
    +   +
    - 1489 + + -
    - + - } +
    +
    +   +
    - 1490 + + -
    - + - data := make(map[uint64][]byte) +
    +
    +   +
    - 1491 + + -
    - + - for i, bn := range batchNums { +
    +
    +   +
    - 1492 + + -
    - + - data[bn] = batchL2Data[i] +
    +
    +   +
    - 1493 + + -
    - + - } +
    +
    +   +
    - 1494 + + -
    - + - return data, nil +
    +
    +   +
    - 1495 + + -
    - + - } +
    +
    +   +
    - 1496 + + -
    - + +
    +
    +  
    - 1497 + + -
    - + - func getForcedBatchData(st stateProvider, batchInfos []batchInfo) (map[uint64][]byte, error) { +
    +
    +   +
    - 1498 + + -
    - + - var batchNums []uint64 +
    +
    +   +
    - 1499 + + -
    - + - var batchHashes []common.Hash +
    +
    +   +
    - 1500 + + -
    - + - for _, info := range batchInfos { +
    +
    +   +
    - 1501 + + -
    - + - if info.isForced { +
    +
    +   +
    - 1502 + + -
    - + - batchNums = append(batchNums, info.num) +
    +
    +   +
    - 1503 + + -
    - + - batchHashes = append(batchHashes, info.hash) +
    +
    +   +
    - 1504 + + -
    - + - } +
    +
    +   +
    - 1505 + + -
    - + - } +
    +
    +   +
    - 1506 + + -
    - + - if len(batchNums) == 0 { +
    +
    +   +
    - 1507 + + -
    - + - return nil, nil +
    +
    +   +
    - 1508 + + -
    - + - } +
    +
    +   +
    - 1509 + + -
    - + - data, err := st.GetForcedBatchDataByNumbers(context.Background(), batchNums, nil) +
    +
    +   +
    - 1510 + + -
    +
    +
      - if err != nil { +
    - 1511 + + -
    +
    +
      - return nil, err +
    - 1512 + + -
    +
    +
      - } +
    - 1513 + + -
    - + +
    +
    +  
    - 1514 + + -
    - + - for i, bn := range batchNums { +
    +
    +   +
    - 1515 + + -
    - + - expectedHash := batchHashes[i] +
    +
    +   +
    - 1516 + + -
    - + - d, ok := data[bn] +
    +
    +   +
    - 1517 + + -
    - + - if !ok { +
    +
    +   +
    - 1518 + + -
    - + - return nil, fmt.Errorf("missing forced batch data for number %d", bn) +
    +
    +   +
    - 1519 + + -
    - + - } +
    +
    +   +
    - 1520 + + -
    - + - actualHash := crypto.Keccak256Hash(d) +
    +
    +   +
    - 1521 + + -
    - + - if actualHash != expectedHash { +
    +
    +   +
    - 1522 + + -
    - + - return nil, fmt.Errorf("got wrong hash for forced batch data number %d", bn) +
    +
    +   +
    - 1523 + + -
    +
    +
      - } +
    - 1524 + + -
    +
    +
      - } +
    - 1525 + + -
    - + - return data, nil +
    +
    +   +
    - 1526 + + -
    +
    +
      - } +
    - 1527 + + -
    +
    +
     
    - 1528 + + -
    +
    +
      - func decodeSequencesPreEtrog(txData []byte, lastBatchNumber uint64, sequencer common.Address, txHash common.Hash, nonce uint64) ([]SequencedBatch, error) { +
    -
     
    +
    + + +
    +   +
    +
    - 1635 + + -
    +
    +
      - if err != nil { +
    - 1636 + + -
    +
    +
      - return err +
    - 1637 + + -
    +
    +
      - } +
    - 1638 + + -
    - + - // TODO complete data forcedBlockHash, forcedGer y forcedTimestamp +
    +
    +   +
    - 1639 + + -
    +
    +
     
    - 1640 + + -
    +
    +
      - // Read the tx for this batch. +
    - 1641 + + -
    +
    +
      - tx, err := etherMan.EthClient.TransactionInBlock(ctx, vLog.BlockHash, vLog.TxIndex) +
    -
     
    +
    + + +
    +   +
    +
    - 1940 + + -
    +
    +
      - }) +
    - 1941 + + -
    +
    +
      - } +
    - 1942 + + -
    +
    +
     
    - 1943 + + -
    - + - // DepositCount returns deposits count +
    +
    +   +
    - 1944 + + -
    - + - func (etherman *Client) DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) { +
    +
    +   +
    - 1945 + + -
    - + - var opts *bind.CallOpts +
    +
    +   +
    - 1946 + + -
    - + - if blockNumber != nil { +
    +
    +   +
    - 1947 + + -
    - + - opts = new(bind.CallOpts) +
    +
    +   +
    - 1948 + + -
    - + - opts.BlockNumber = new(big.Int).SetUint64(*blockNumber) +
    +
    +   +
    - 1949 + + -
    - + - } +
    +
    +   +
    - 1950 + + -
    - + +
    +
    +  
    - 1951 + + -
    - + - return etherman.GlobalExitRootManager.DepositCount(opts) +
    +
    +   +
    - 1952 + + -
    - + - } +
    +
    +   +
    - 1953 + + -
    - + +
    +
    +  
    - 1954 + + -
    +
    +
      - // CheckTxWasMined check if a tx was already mined +
    - 1955 + + -
    +
    +
      - func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error) { +
    - 1956 + + -
    +
    +
      - receipt, err := etherMan.EthClient.TransactionReceipt(ctx, txHash) +
    -
     
    +
    + + +
    +   +
    +
    - 2005 + + -
    +
    +
      - } +
    - 2006 + + -
    +
    +
     
    - 2007 + + -
    +
    +
      - // LoadAuthFromKeyStore loads an authorization from a key store file +
    - 2008 + + -
    - + - func (etherMan *Client) LoadAuthFromKeyStore(path, password string) (*bind.TransactOpts, *ecdsa.PrivateKey, error) { +
    +
    +   +
    - 2009 + + -
    - + - auth, pk, err := newAuthFromKeystore(path, password, etherMan.l1Cfg.L1ChainID) +
    +
    +   +
    - 2010 + + -
    +
    +
      - if err != nil { +
    - 2011 + + -
    - + - return nil, nil, err +
    +
    +   +
    - 2012 + + -
    +
    +
      - } +
    - 2013 + + -
    +
    +
     
    - 2014 + + -
    +
    +
      - log.Infof("loaded authorization for address: %v", auth.From.String()) +
    - 2015 + + -
    +
    +
      - etherMan.auth[auth.From] = auth +
    - 2016 + + -
    - + - return &auth, pk, nil +
    +
    +   +
    - 2017 + + -
    +
    +
      - } +
    - 2018 + + -
    +
    +
     
    - 2019 + + -
    +
    +
      - // newKeyFromKeystore creates an instance of a keystore key from a keystore file +
    -
     
    +
    + + +
    +   +
    +
    - 2034 + + -
    +
    +
      - } +
    - 2035 + + -
    +
    +
     
    - 2036 + + -
    +
    +
      - // newAuthFromKeystore an authorization instance from a keystore file +
    - 2037 + + -
    - + - func newAuthFromKeystore(path, password string, chainID uint64) (bind.TransactOpts, *ecdsa.PrivateKey, error) { +
    +
    +   +
    - 2038 + + -
    +
    +
      - log.Infof("reading key from: %v", path) +
    - 2039 + + -
    +
    +
      - key, err := newKeyFromKeystore(path, password) +
    - 2040 + + -
    +
    +
      - if err != nil { +
    - 2041 + + -
    - + - return bind.TransactOpts{}, nil, err +
    +
    +   +
    - 2042 + + -
    +
    +
      - } +
    - 2043 + + -
    +
    +
      - if key == nil { +
    - 2044 + + -
    - + - return bind.TransactOpts{}, nil, nil +
    +
    +   +
    - 2045 + + -
    +
    +
      - } +
    - 2046 + + -
    +
    +
      - auth, err := bind.NewKeyedTransactorWithChainID(key.PrivateKey, new(big.Int).SetUint64(chainID)) +
    - 2047 + + -
    +
    +
      - if err != nil { +
    - 2048 + + -
    - + - return bind.TransactOpts{}, nil, err +
    +
    +   +
    - 2049 + + -
    +
    +
      - } +
    - 2050 + + -
    - + - return *auth, key.PrivateKey, nil +
    +
    +   +
    - 2051 + + -
    +
    +
      - } +
    - 2052 + + -
    +
    +
     
    - 2053 + + -
    +
    +
      - // getAuthByAddress tries to get an authorization from the authorizations map +
    -
     
    +
    + + +
    +   +
    +
    - 2075 + + -
    +
    +
     
    - 2076 + + -
    +
    +
      - return *auth, nil +
    - 2077 + + -
    +
    +
      - } +
    - 2078 + + -
    - + +
    +
    +  
    - 2079 + + -
    - + - // GetDAProtocolAddr returns the address of the data availability protocol +
    +
    +   +
    - 2080 + + -
    - + - func (etherMan *Client) GetDAProtocolAddr() (common.Address, error) { +
    +
    +   +
    - 2081 + + -
    - + - return etherMan.ZkEVM.DataAvailabilityProtocol(&bind.CallOpts{Pending: false}) +
    +
    +   +
    - 2082 + + -
    - + - } +
    +
    +   +
    - 2083 + + -
    - + +
    +
    +  
    - 2084 + + -
    - + - // GetDAProtocolName returns the name of the data availability protocol +
    +
    +   +
    - 2085 + + -
    - + - func (etherMan *Client) GetDAProtocolName() (string, error) { +
    +
    +   +
    - 2086 + + -
    - + - return etherMan.DAProtocol.GetProcotolName(&bind.CallOpts{Pending: false}) +
    +
    +   +
    - 2087 + + -
    - + - } +
    +
    +   +
    - 2088 + + -
    - + +
    +
    +  
    - 2089 + + -
    - + - // SetDataAvailabilityProtocol sets the address for the new data availability protocol +
    +
    +   +
    - 2090 + + -
    - + - func (etherMan *Client) SetDataAvailabilityProtocol(from, daAddress common.Address) (*types.Transaction, error) { +
    +
    +   +
    - 2091 + + -
    - + - auth, err := etherMan.getAuthByAddress(from) +
    +
    +   +
    - 2092 + + -
    - + - if err != nil { +
    +
    +   +
    - 2093 + + -
    - + - return nil, err +
    +
    +   +
    - 2094 + + -
    - + - } +
    +
    +   +
    - 2095 + + -
    - + +
    +
    +  
    - 2096 + + -
    - + - return etherMan.ZkEVM.SetDataAvailabilityProtocol(&auth, daAddress) +
    +
    +   +
    - 2097 + + -
    - + - } +
    +
    +   +
    - 2098 + + -
    - + +
    +
    +  
    - 2099 + + -
    - + - // GetRollupId returns the rollup id +
    +
    +   +
    - 2100 + + -
    - + - func (etherMan *Client) GetRollupId() uint32 { +
    +
    +   +
    - 2101 + + -
    - + - return etherMan.RollupID +
    +
    +   +
    - 2102 + + -
    - + - } +
    +
    +   +
    -
    @@ -38,7 +38,7 @@
    +
    @@ -1,180 +0,0 @@
    - 38 + + 1 +
    -   - } + - + package etherman_test
    - 39 + + 2 +
    -   + -
    - 40 + + 3 +
    -   - // This function prepare the blockchain, the wallet with funds and deploy the smc + - + import (
    - 41 + + 4 +
    - - func newTestingEnv() (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge) { + "bytes"
    - 42 + + 5 +
    -   - privateKey, err := crypto.GenerateKey() + - + "context"
    - 43 + + 6 +
    -   - if err != nil { + - + "fmt"
    - 44 + + 7 +
    -   - log.Fatal(err) + - + "math/big"
    -
    @@ -47,7 +47,9 @@
    -
    - 47 + + 8 +
    -   - if err != nil { + - + "testing"
    - 48 + + 9 +
    -   - log.Fatal(err) + - +
    - 49 + + 10 +
    -   - } + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 50 + + 11 +
    - - ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth) -
    -
    - - -
    -   -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/mockseth"
    - + + 12 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/common"
    - 51 + + 13 +
    -   - if err != nil { + - + "github.com/ethereum/go-ethereum/core/types"
    - 52 + + 14 +
    -   - log.Fatal(err) + - + "github.com/ethereum/go-ethereum/rlp"
    - 53 + + 15 +
    -   - } + - + "github.com/stretchr/testify/mock"
    -
    @@ -55,12 +57,12 @@
    -
    - 55 + + 16 +
    -   - if err != nil { + - + "github.com/stretchr/testify/require"
    - 56 + + 17 +
    -   - log.Fatal(err) + - + )
    - 57 + + 18 +
    -   - } + - +
    - 58 + + 19 +
    - - return ethman, ethBackend, auth, polAddr, br + type EventManagerTestData struct {
    - 59 + + 20 +
    -   - } + - + mockBlockRetiever *mockseth.BlockRetriever
    - 60 + + 21 +
    -   + -
    - 61 + + 22 +
    -   - func TestGEREvent(t *testing.T) { + - + mockProcessor *mockseth.GenericEventProcessor
    - 62 + + 23 +
    -   - // Set up testing environment + - + mockCallDataExtractor *mockseth.CallDataExtractor
    - 63 + + 24 +
    - - etherman, ethBackend, auth, _, br := newTestingEnv() + sut *etherman.EventManager
    - 64 + + 25 +
    -   -
    + - + ctx context.Context
    - 65 + + 26 +
    -   - // Read currentBlock + - + }
    - 66 + + 27 +
    -   - ctx := context.Background() + - +
    -
    @@ -82,14 +84,14 @@
    -
    - 82 + + 28 +
    -   - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + - + func NewEventManagerTestData(t *testing.T) *EventManagerTestData {
    - 83 + + 29 +
    -   - require.NoError(t, err) + - + mockBlockRetriever := mockseth.NewBlockRetriever(t)
    - 84 + + 30 +
    -   - t.Logf("Blocks: %+v", blocks) + - + mockCallDataExtractor := mockseth.NewCallDataExtractor(t)
    - 85 + + 31 +
    - - assert.Equal(t, uint64(8), blocks[0].L1InfoTree[0].BlockNumber) + return &EventManagerTestData{
    - 86 + + 32 +
    -   - assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot) + - + mockBlockRetiever: mockBlockRetriever,
    - 87 + + 33 +
    -   - assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot) + - + mockCallDataExtractor: mockCallDataExtractor,
    - 88 + + 34 +
    -   - } + - + mockProcessor: mockseth.NewGenericEventProcessor(t),
    - 89 + + 35 +
    -   -
    + - + sut: etherman.NewEventManager(mockBlockRetriever, mockCallDataExtractor),
    - 90 + + 36 +
    -   - func TestForcedBatchEvent(t *testing.T) { + - + ctx: context.TODO(),
    - 91 + + 37 +
    -   - // Set up testing environment + - + }
    - 92 + + 38 +
    - - etherman, ethBackend, auth, _, _ := newTestingEnv() + }
    - 93 + + 39 +
    -   + -
    - 94 + + 40 +
    -   - // Read currentBlock + - + func TestEventManagerNoEventToProcess(t *testing.T) {
    - 95 + + 41 +
    -   - ctx := context.Background() + - + data := NewEventManagerTestData(t)
    -
    @@ -114,8 +116,8 @@
    -
    - 114 + + 42 +
    -   - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + - + vLog := types.Log{}
    - 115 + + 43 +
    -   - require.NoError(t, err) + - +
    - 116 + + 44 +
    -   - t.Logf("Blocks: %+v", blocks) + - + processed, err := data.sut.ProcessEvent(context.TODO(), vLog, nil, nil)
    - 117 + + 45 +
    - - assert.Equal(t, uint64(8), blocks[0].BlockNumber) + require.False(t, processed)
    - 118 + + 46 +
    - - assert.Equal(t, uint64(8), blocks[0].ForcedBatches[0].BlockNumber) + require.NoError(t, err)
    - 119 + + 47 +
    -   - assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot) + - + }
    - 120 + + 48 +
    -   - assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt) + - +
    - 121 + + 49 +
    -   - assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber) + - + func TestEventManagerEventToProcessHappyPathIntegratedWithSequenceBlobs(t *testing.T) {
    -
    @@ -125,7 +127,7 @@
    -
    - 125 + + 50 +
    -   -
    + - + data := NewEventManagerTestData(t)
    - 126 + + 51 +
    -   - func TestSequencedBatchesEvent(t *testing.T) { + - + mockChainReader := etherman.NewChainReaderMock(t)
    - 127 + + 52 +
    -   - // Set up testing environment + - + data.sut = etherman.NewEventManager(data.mockBlockRetiever, etherman.NewCallDataExtratorGeth(mockChainReader))
    - 128 + + 53 +
    - - etherman, ethBackend, auth, _, br := newTestingEnv() + contracts, err := etherman.NewFeijoaContracts(nil, etherman.L1Config{})
    - 129 + + 54 +
    -   -
    + - + require.NoError(t, err)
    - 130 + + 55 +
    -   - // Read currentBlock + - + processor := etherman.NewEventFeijoaSequenceBlobsProcessor(contracts)
    - 131 + + 56 +
    -   - ctx := context.Background() + - + data.sut.AddProcessor(processor)
    -
    @@ -156,13 +158,19 @@
    -
    - 156 + + 57 +
    -   - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber) + - + block := etherman.Block{
    - 157 + + 58 +
    -   - require.NoError(t, err) + - + BlockHash: common.HexToHash("0x1"),
    - 158 + + 59 +
    -   - t.Log("Blocks: ", blocks) + - + BlockNumber: 1234,
    - 159 + + 60 +
    - - var sequences []polygonzkevm.PolygonRollupBaseEtrogBatchData + }
    - 160 + + 61 +
    - - sequences = append(sequences, polygonzkevm.PolygonRollupBaseEtrogBatchData{ +
    - 161 + + 62 +
    - - Transactions: common.Hex2Bytes(rawTxs), + tx := txExample()
    - 162 + + 63 +
    - - }, polygonzkevm.PolygonRollupBaseEtrogBatchData{ + vLog := types.Log{
    - 163 + + 64 +
    - - Transactions: common.Hex2Bytes(rawTxs), -
    -
    - - -
    -   -
    + Topics: []common.Hash{processor.EventSignature(),
    - 164 + + 65 +
    -   - }) + - + common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000074")},
    - 165 + + 66 +
    - - _, err = etherman.ZkEVM.SequenceBatches(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From) + BlockNumber: block.BlockNumber,
    - + + 67 -
    -   -
    +
    +
    + - + BlockHash: block.BlockHash,
    - + + 68 -
    -   -
    +
    +
    + - + TxHash: tx.Hash(),
    - + + 69 -
    -   -
    +
    +
    + - + }
    - + + 70 -
    -   -
    +
    +
    + - + blocks := []etherman.Block{}
    - + + 71 -
    -   +
    +
    + -
    - 166 + + 72 +
    -   - require.NoError(t, err) + - + data.mockBlockRetiever.EXPECT().RetrieveFullBlockForEvent(data.ctx, vLog).Return(&block, nil).Once()
    - 167 + + 73 +
    -   -
    + - + mockChainReader.EXPECT().TransactionInBlock(data.ctx, block.BlockHash, uint(0)).Return(tx, nil).Once()
    - 168 + + 74 +
    -   - // Mine the tx in a block + - + blocksOrder := map[common.Hash][]etherman.Order{}
    -
    @@ -188,7 +196,7 @@
    -
    - 188 + + 75 +
    -   + -
    - 189 + + 76 +
    -   - func TestVerifyBatchEvent(t *testing.T) { + - + processed, err := data.sut.ProcessEvent(data.ctx, vLog, &blocks, &blocksOrder)
    - 190 + + 77 +
    -   - // Set up testing environment + - +
    - 191 + + 78 +
    - - etherman, ethBackend, auth, _, _ := newTestingEnv() + require.True(t, processed)
    - 192 + + 79 +
    -   -
    + - + require.NoError(t, err)
    - 193 + + 80 +
    -   - // Read currentBlock + - + }
    - 194 + + 81 +
    -   - ctx := context.Background() + - +
    -
    @@ -197,12 +205,13 @@
    -
    - 197 + + 82 +
    -   - require.NoError(t, err) + - + func TestEventManagerEventToProcessHappyPath(t *testing.T) {
    - 198 + + 83 +
    -   -
    + - + data := NewEventManagerTestData(t)
    - 199 + + 84 +
    -   - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" + - + block := etherman.Block{
    - 200 + + 85 +
    - - tx := polygonzkevm.PolygonRollupBaseEtrogBatchData{ + BlockHash: common.HexToHash("0x1"),
    - 201 + + 86 +
    - - Transactions: common.Hex2Bytes(rawTxs), + BlockNumber: 1234,
    - 202 + + 87 +
    -   + - }
    - 203 + + 88 +
    - - //TODO: Fix params + eventSignature := common.HexToHash("0x2")
    - 204 + + 89 +
    - - _, err = etherman.ZkEVM.SequenceBatches(auth, []polygonzkevm.PolygonRollupBaseEtrogBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From) + tx := txExample()
    - 205 + + 90 +
    -   - require.NoError(t, err) + - + vLog := types.Log{
    - + + 91 -
    -   -
    +
    +
    + - + Topics: []common.Hash{eventSignature},
    - 206 + + 92 +
    -   -
    + - + BlockNumber: block.BlockNumber,
    - 207 + + 93 +
    -   - // Mine the tx in a block + - + BlockHash: block.BlockHash,
    - 208 + + 94 +
    -   - ethBackend.Commit() + - + TxHash: tx.Hash(),
    -
    @@ -220,7 +229,7 @@
    -
    - 220 + + 95 +
    -   - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + - + }
    - 221 + + 96 +
    -   - require.NoError(t, err) + - + blocks := []etherman.Block{}
    - 222 + + 97 +
    -   - t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order) + - + data.mockProcessor.EXPECT().EventSignature().Return(eventSignature).Once()
    - 223 + + 98 +
    - - assert.Equal(t, uint64(9), blocks[1].BlockNumber) +
    - 224 + + 99 +
    -   - assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber) + - + data.mockBlockRetiever.EXPECT().RetrieveFullBlockForEvent(data.ctx, vLog).Return(&block, nil).Once()
    - 225 + + 100 +
    -   - assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator) + - + data.mockCallDataExtractor.EXPECT().ExtractCallData(data.ctx, block.BlockHash, tx.Hash(), uint(0)).Return(&etherman.CallData{}, nil)
    - 226 + + 101 +
    -   - assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash) + - + data.mockProcessor.EXPECT().AddEventDataToBlock(data.ctx, vLog, &block, mock.Anything).Return(&etherman.Order{}, nil).Once()
    -
    @@ -232,7 +241,7 @@
    +
    + 102 + +
    + - + data.sut.AddProcessor(data.mockProcessor) +
    - 232 + + 103 +
    -   + -
    - 233 + + 104 +
    -   - func TestSequenceForceBatchesEvent(t *testing.T) { + - + blocksOrder := map[common.Hash][]etherman.Order{}
    - 234 + + 105 +
    -   - // Set up testing environment + - +
    - 235 + + 106 +
    - - etherman, ethBackend, auth, _, _ := newTestingEnv() + processed, err := data.sut.ProcessEvent(data.ctx, vLog, &blocks, &blocksOrder)
    - 236 + + 107 +
    -   + -
    - 237 + + 108 +
    -   - // Read currentBlock + - + require.True(t, processed)
    - 238 + + 109 +
    -   - ctx := context.Background() + - + require.NoError(t, err)
    -
    @@ -283,7 +292,7 @@
    -
    - 283 + + 110 +
    -   - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) + - + }
    - 284 + + 111 +
    -   - require.NoError(t, err) + - +
    - 285 + + 112 +
    -   - t.Logf("Blocks: %+v", blocks) + - + func TestCallDataExtractorExtarctCallDataHappyPath(t *testing.T) {
    - 286 + + 113 +
    - - assert.Equal(t, uint64(12), blocks[1].BlockNumber) + mockChainRetriever := etherman.NewChainReaderMock(t)
    - 287 + + 114 +
    -   - assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber) + - + blockHash := common.HexToHash("0x1")
    - 288 + + 115 +
    -   - assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:])) + - + indexTx := uint(12)
    - 289 + + 116 +
    -   - assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp) + - + tx := txExample()
    -
    @@ -293,7 +302,7 @@
    -
    - 293 + + 117 +
    -   -
    + - + mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once()
    - 294 + + 118 +
    -   - func TestSendSequences(t *testing.T) { + - + callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever)
    - 295 + + 119 +
    -   - // Set up testing environment + - + _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, tx.Hash(), indexTx)
    - 296 + + 120 +
    - - etherman, ethBackend, auth, _, br := newTestingEnv() + require.NoError(t, err)
    - 297 + + 121 +
    -   -
    + - + }
    - 298 + + 122 +
    -   - // Read currentBlock + - +
    - 299 + + 123 +
    -   - ctx := context.Background() + - + func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnsErr(t *testing.T) {
    -
    @@ -315,10 +324,12 @@
    -
    - 315 + + 124 +
    -   - BatchL2Data: batchL2Data, + - + mockChainRetriever := etherman.NewChainReaderMock(t)
    - 316 + + 125 +
    -   - LastL2BLockTimestamp: time.Now().Unix(), + - + blockHash := common.HexToHash("0x1")
    - 317 + + 126 +
    -   - } + - + indexTx := uint(12)
    - + + 127 -
    -   -
    +
    +
    + - + errReturned := fmt.Errorf("mock error")
    - 318 + + 128 +
    -   - lastL2BlockTStamp := tx1.Time().Unix() + - + mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(nil, errReturned).Once()
    - 319 + + 129 +
    - - // TODO: fix params + callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever)
    - 320 + 130
    - - tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From) + _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx)
    - 321 + + 131 +
    -   - require.NoError(t, err) + - + require.ErrorIs(t, err, errReturned)
    - + + 132 -
    -   -
    +
    +
    + - + }
    - + + 133 -
    -   +
    +
    + -
    - 322 + + 134 +
    -   - log.Debug("TX: ", tx.Hash()) + - + func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnsNilTx(t *testing.T) {
    - 323 + + 135 +
    -   - ethBackend.Commit() + - + mockChainRetriever := etherman.NewChainReaderMock(t)
    - 324 + + 136 +
    -   -
    + - + blockHash := common.HexToHash("0x1")
    -
    @@ -341,7 +352,7 @@
    -
    - 341 + + 137 +
    -   -
    + - + indexTx := uint(12)
    - 342 + + 138 +
    -   - func TestGasPrice(t *testing.T) { + - +
    - 343 + + 139 +
    -   - // Set up testing environment + - + mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(nil, nil).Once()
    - 344 + + 140 +
    - - etherman, _, _, _, _ := newTestingEnv() + callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever)
    - 345 + + 141 +
    -   - etherscanM := new(etherscanMock) + - + _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx)
    - 346 + + 142 +
    -   - ethGasStationM := new(ethGasStationMock) + - + require.Error(t, err)
    - 347 + + 143 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + - + }
    -
    @@ -360,14 +371,14 @@
    -
    - 360 + + 144 +
    -   + -
    - 361 + + 145 +
    -   - func TestErrorEthGasStationPrice(t *testing.T) { + - + func TestCallDataExtractorExtarctCallDataTransactionInBlockReturnTxHashNotMatch(t *testing.T) {
    - 362 + + 146 +
    -   - // Set up testing environment + - + mockChainRetriever := etherman.NewChainReaderMock(t)
    - 363 + + 147 +
    - - etherman, _, _, _, _ := newTestingEnv() + blockHash := common.HexToHash("0x1")
    - 364 + + 148 +
    -   - ethGasStationM := new(ethGasStationMock) + - + indexTx := uint(12)
    - 365 + + 149 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM} + - + tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil)
    - 366 + + 150 +
    -   - ctx := context.Background() + - + mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once()
    - 367 + + 151 +
    -   -
    + - + callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever)
    - 368 + + 152 +
    -   - ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation")) + - + _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, common.Hash{}, indexTx)
    - 369 + + 153 +
    -   - gp := etherman.GetL1GasPrice(ctx) + - + require.Error(t, err)
    - 370 + + 154 +
    - - assert.Equal(t, big.NewInt(1392695906), gp) + }
    - 371 + + 155 +
    -   + -
    - 372 + + 156 +
    -   - etherscanM := new(etherscanMock) + - + func TestCallDataExtractorExtarctCallDataWrongTxData(t *testing.T) {
    - 373 + + 157 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + - + mockChainRetriever := etherman.NewChainReaderMock(t)
    -
    @@ -379,7 +390,7 @@
    -
    - 379 + + 158 +
    -   -
    + - + blockHash := common.HexToHash("0x1")
    - 380 + + 159 +
    -   - func TestErrorEtherScanPrice(t *testing.T) { + - + indexTx := uint(12)
    - 381 + + 160 +
    -   - // Set up testing environment + - + tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil)
    - 382 + + 161 +
    - - etherman, _, _, _, _ := newTestingEnv() + mockChainRetriever.EXPECT().TransactionInBlock(context.TODO(), blockHash, indexTx).Return(tx, nil).Once()
    - 383 + + 162 +
    -   - etherscanM := new(etherscanMock) + - + callDataExtractor := etherman.NewCallDataExtratorGeth(mockChainRetriever)
    - 384 + + 163 +
    -   - ethGasStationM := new(ethGasStationMock) + - + _, err := callDataExtractor.ExtractCallData(context.TODO(), blockHash, tx.Hash(), indexTx)
    - 385 + + 164 +
    -   - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} + - + require.Error(t, err)
    -
    @@ -393,7 +404,7 @@
    +
    + 165 + +
    + - + } +
    - 393 + + 166 +
    -   + -
    - 394 + + 167 +
    -   - func TestGetForks(t *testing.T) { + - + func txExample() *types.Transaction {
    - 395 + + 168 +
    -   - // Set up testing environment + - + var tx types.Transaction
    - 396 + + 169 +
    - - etherman, _, _, _, _ := newTestingEnv() + reader := bytes.NewBuffer(common.Hex2Bytes(txExampleRLP))
    - 397 + + 170 +
    -   - ctx := context.Background() + - + stream := rlp.NewStream(reader, 0)
    - 398 + + 171 +
    -   - forks, err := etherman.GetForks(ctx, 0, 132) + - + err := tx.DecodeRLP(stream)
    - 399 + + 172 +
    -   - require.NoError(t, err) + - + if err != nil {
    -
    + + + 173 + + +
    + - + panic(err)
    -
    -
    - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    - 38 + + 174 +
    -   - } + - + }
    - 39 + + 175 +
    -   -
    + - + return &tx
    - 40 + + 176 +
    -   - // This function prepare the blockchain, the wallet with funds and deploy the smc + - + }
    - 41 + + 177 +
    - + - func newTestingEnv(t *testing.T) (ethman *Client, ethBackend *simulated.Backend, auth *bind.TransactOpts, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, da *daMock, st *stateMock) { + - +
    - 42 + + 178 +
    -   - privateKey, err := crypto.GenerateKey() + - + const (
    - 43 + + 179 +
    -   - if err != nil { + - + txExampleRLP = "fa01cc3181c28501699d83808310360194d23c761025306cf5038d74feeb077cf66de134da80ba01cbc438793b4f00000000000000000000000000000000000000000000000000000000000000600000000000000000000000006c50a878df81d7e49424968dfac5e1409bccb68fde08efdeb2225f233039b7f5fa2bb0dc95bcf9c884b2f388092e3db6ff3484770000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000001cac00000000000000000000000000000000000000000000000000000000065f3006b00000000000000000000000000000000000000000000000000000001836e210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000001ca1a000001ca15000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007110b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b0000000300000000000007080b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000b00000003000000000000000000008401546d72a04a4304c05e4033d414115b3ad1f652e9da459614f84e7ac2eec2ed6c07660023a013aa534e2b3544baadeb9b82b368d3587b50495086318f0d8289f77912180d18"
    - 44 + + 180 +
    -   - log.Fatal(err) + - + )
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -72207,463 +147929,414 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
    - 47 + + -
    +
    +
      - if err != nil { +
    - 48 + + -
    +
    +
      - log.Fatal(err) +
    - 49 + + -
    +
    +
      - } -
    -
    - 50 - -
    - + - da = newDaMock(t) -
    -
    - 51 - -
    - + - st = newStateMock(t) +
    - 52 + + -
    - + - ethman, ethBackend, polAddr, br, err = NewSimulatedEtherman(Config{ForkIDChunkSize: 10}, auth, da, st) +
    +
    +   +
    - 53 + + -
    +
    +
      - if err != nil { +
    - 54 + + -
    +
    +
      - log.Fatal(err) +
    - 55 + + -
    +
    +
      - } -
    -
    -
     
    +
    +
    - 57 + + -
    +
    +
      - if err != nil { +
    - 58 + + -
    +
    +
      - log.Fatal(err) +
    - 59 + + -
    +
    +
      - } +
    - 60 + + -
    - + - return ethman, ethBackend, auth, polAddr, br, da, st +
    +
    +   +
    - 61 + + -
    +
    +
      - } +
    - 62 + + -
    +
    +
     
    - 63 + + -
    +
    +
      - func TestGEREvent(t *testing.T) { +
    - 64 + + -
    +
    +
      - // Set up testing environment +
    - 65 + + -
    - + - etherman, ethBackend, auth, _, br, _, _ := newTestingEnv(t) +
    +
    +   +
    - 66 + + -
    +
    +
     
    - 67 + + -
    +
    +
      - // Read currentBlock +
    - 68 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 84 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 85 + + -
    +
    +
      - require.NoError(t, err) +
    - 86 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) +
    - 87 + + -
    - + - assert.Equal(t, uint64(11), blocks[0].L1InfoTree[0].BlockNumber) +
    +
    +   +
    - 88 + + -
    +
    +
      - assert.NotEqual(t, common.Hash{}, blocks[0].L1InfoTree[0].MainnetExitRoot) +
    - 89 + + -
    +
    +
      - assert.Equal(t, common.Hash{}, blocks[0].L1InfoTree[0].RollupExitRoot) +
    - 90 + + -
    +
    +
      - } +
    - 91 + + -
    +
    +
     
    - 92 + + -
    +
    +
      - func TestForcedBatchEvent(t *testing.T) { +
    - 93 + + -
    +
    +
      - // Set up testing environment +
    - 94 + + -
    - + - etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 95 + + -
    +
    +
     
    - 96 + + -
    +
    +
      - // Read currentBlock +
    - 97 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 116 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 117 + + -
    +
    +
      - require.NoError(t, err) +
    - 118 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) +
    - 119 + + -
    - + - assert.Equal(t, uint64(11), blocks[0].BlockNumber) +
    +
    +   +
    - 120 + + -
    - + - assert.Equal(t, uint64(11), blocks[0].ForcedBatches[0].BlockNumber) +
    +
    +   +
    - 121 + + -
    +
    +
      - assert.NotEqual(t, common.Hash{}, blocks[0].ForcedBatches[0].GlobalExitRoot) +
    - 122 + + -
    +
    +
      - assert.NotEqual(t, time.Time{}, blocks[0].ForcedBatches[0].ForcedAt) +
    - 123 + + -
    +
    +
      - assert.Equal(t, uint64(1), blocks[0].ForcedBatches[0].ForcedBatchNumber) +
    -
     
    -
    - 127 + + -
    +
    +
     
    - 128 + + -
    +
    +
      - func TestSequencedBatchesEvent(t *testing.T) { +
    - 129 + + -
    +
    +
      - // Set up testing environment +
    - 130 + + -
    - + - etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t) +
    +
    +   +
    - 131 + + -
    +
    +
     
    - 132 + + -
    +
    +
      - // Read currentBlock +
    - 133 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 158 + + -
    +
    +
      - blocks, _, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &currentBlockNumber) +
    - 159 + + -
    +
    +
      - require.NoError(t, err) +
    - 160 + + -
    +
    +
      - t.Log("Blocks: ", blocks) +
    - 161 + + -
    - + - var sequences []polygonzkevm.PolygonValidiumEtrogValidiumBatchData +
    +
    +   +
    - 162 + + -
    - + - txsHash := crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)) +
    +
    +   +
    - 163 + + -
    - + - sequences = append(sequences, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    +   +
    - 164 + + -
    - + - TransactionsHash: txsHash, +
    +
    +   +
    - 165 + + -
    - + - }, polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    +   +
    - 166 + + -
    - + - TransactionsHash: txsHash, +
    +
    +   +
    - 167 + + -
    +
    +
      - }) +
    - 168 + + -
    - + - batchNums := []uint64{2, 3} +
    +
    +   +
    - 169 + + -
    - + - batchHashes := []common.Hash{txsHash, txsHash} +
    +
    +   +
    - 170 + + -
    - + - batchData := [][]byte{data, data} +
    +
    +   +
    - 171 + + -
    - + - daMessage, _ := hex.DecodeString("0x123456789123456789") +
    +
    +   +
    - 172 + + -
    - + - da.Mock.On("GetBatchL2Data", batchNums, batchHashes, daMessage).Return(batchData, nil) +
    +
    +   +
    - 173 + + -
    - + - _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, sequences, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage) +
    +
    +   +
    - 174 + + -
    +
    +
      - require.NoError(t, err) +
    - 175 + + -
    +
    +
     
    - 176 + + -
    +
    +
      - // Mine the tx in a block +
    -
     
    -
    - 196 + + -
    +
    +
     
    - 197 + + -
    +
    +
      - func TestVerifyBatchEvent(t *testing.T) { +
    - 198 + + -
    +
    +
      - // Set up testing environment +
    - 199 + + -
    - + - etherman, ethBackend, auth, _, _, da, _ := newTestingEnv(t) +
    +
    +   +
    - 200 + + -
    +
    +
     
    - 201 + + -
    +
    +
      - // Read currentBlock +
    - 202 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 205 + + -
    +
    +
      - require.NoError(t, err) +
    - 206 + + -
    +
    +
     
    - 207 + + -
    +
    +
      - rawTxs := "f84901843b9aca00827b0c945fbdb2315678afecb367f032d93f642f64180aa380a46057361d00000000000000000000000000000000000000000000000000000000000000048203e9808073efe1fa2d3e27f26f32208550ea9b0274d49050b816cadab05a771f4275d0242fd5d92b3fb89575c070e6c930587c520ee65a3aa8cfe382fcad20421bf51d621c" +
    - 208 + + -
    - + - tx := polygonzkevm.PolygonValidiumEtrogValidiumBatchData{ +
    +
    +   +
    - 209 + + -
    - + - TransactionsHash: crypto.Keccak256Hash(common.Hex2Bytes(rawTxs)), +
    +
    +   +
    - 210 + + -
    +
    +
      - } +
    - 211 + + -
    - + - daMessage, _ := hex.DecodeString("0x1234") +
    +
    +   +
    - 212 + + -
    - + - _, err = etherman.ZkEVM.SequenceBatchesValidium(auth, []polygonzkevm.PolygonValidiumEtrogValidiumBatchData{tx}, uint64(time.Now().Unix()), uint64(1), auth.From, daMessage) +
    +
    +   +
    - 213 + + -
    +
    +
      - require.NoError(t, err) +
    - 214 + + -
    - + - da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(common.Hex2Bytes(rawTxs))}, daMessage).Return([][]byte{common.Hex2Bytes(rawTxs)}, nil) +
    +
    +   +
    - 215 + + -
    +
    +
     
    - 216 + + -
    +
    +
      - // Mine the tx in a block +
    - 217 + + -
    +
    +
      - ethBackend.Commit() +
    -
     
    -
    - 229 + + -
    +
    +
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 230 + + -
    +
    +
      - require.NoError(t, err) +
    - 231 + + -
    +
    +
      - t.Logf("Blocks: %+v, \nOrder: %+v", blocks, order) +
    - 232 + + -
    - + - assert.Equal(t, uint64(12), blocks[1].BlockNumber) +
    +
    +   +
    - 233 + + -
    +
    +
      - assert.Equal(t, uint64(1), blocks[1].VerifiedBatches[0].BatchNumber) +
    - 234 + + -
    +
    +
      - assert.NotEqual(t, common.Address{}, blocks[1].VerifiedBatches[0].Aggregator) +
    - 235 + + -
    +
    +
      - assert.NotEqual(t, common.Hash{}, blocks[1].VerifiedBatches[0].TxHash) +
    -
     
    -
    - 241 + + -
    +
    +
     
    - 242 + + -
    +
    +
      - func TestSequenceForceBatchesEvent(t *testing.T) { +
    - 243 + + -
    +
    +
      - // Set up testing environment +
    - 244 + + -
    - + - etherman, ethBackend, auth, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 245 + + -
    +
    +
     
    - 246 + + -
    +
    +
      - // Read currentBlock +
    - 247 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    +
    + + +
    +   +
    +
    - 292 + + -
    +
    +
      - blocks, order, err := etherman.GetRollupInfoByBlockRange(ctx, initBlock.NumberU64(), &finalBlockNumber) +
    - 293 + + -
    +
    +
      - require.NoError(t, err) +
    - 294 + + -
    +
    +
      - t.Logf("Blocks: %+v", blocks) +
    - 295 + + -
    - + - assert.Equal(t, uint64(15), blocks[1].BlockNumber) +
    +
    +   +
    - 296 + + -
    +
    +
      - assert.Equal(t, uint64(2), blocks[1].SequencedForceBatches[0][0].BatchNumber) +
    - 297 + + -
    +
    +
      - assert.Equal(t, forcedGer, common.BytesToHash(blocks[1].SequencedForceBatches[0][0].ForcedGlobalExitRoot[:])) +
    - 298 + + -
    +
    +
      - assert.Equal(t, forcedTimestamp, blocks[1].SequencedForceBatches[0][0].ForcedTimestamp) +
    -
     
    -
    - 302 + + -
    +
    +
     
    - 303 + + -
    +
    +
      - func TestSendSequences(t *testing.T) { +
    - 304 + + -
    +
    +
      - // Set up testing environment +
    - 305 + + -
    - + - etherman, ethBackend, auth, _, br, da, _ := newTestingEnv(t) +
    +
    +   +
    - 306 + + -
    +
    +
     
    - 307 + + -
    +
    +
      - // Read currentBlock +
    - 308 + + -
    +
    +
      - ctx := context.Background() +
    -
     
    -
    - 324 + + -
    +
    +
      - BatchL2Data: batchL2Data, +
    - 325 + + -
    +
    +
      - LastL2BLockTimestamp: time.Now().Unix(), +
    - 326 + + -
    +
    +
      - } +
    - 327 + + -
    - + - daMessage, _ := hex.DecodeString("0x1234") +
    +
    +   +
    - 328 + + -
    +
    +
      - lastL2BlockTStamp := tx1.Time().Unix() +
    - 329 + + -
    - + - tx, err := etherman.sequenceBatches(*auth, []ethmanTypes.Sequence{sequence}, uint64(lastL2BlockTStamp), uint64(1), auth.From, daMessage) +
    +
    +   +
    - 330 + + -
    +
    +
      - require.NoError(t, err) +
    - 331 + + -
    - + - da.Mock.On("GetBatchL2Data", []uint64{2}, []common.Hash{crypto.Keccak256Hash(batchL2Data)}, daMessage).Return([][]byte{batchL2Data}, nil) +
    +
    +   +
    - 332 + + -
    - + +
    +
    +  
    - 333 + + -
    +
    +
      - log.Debug("TX: ", tx.Hash()) +
    - 334 + + -
    +
    +
      - ethBackend.Commit() +
    - 335 + + -
    +
    +
     
    -
     
    -
    - 352 + + -
    +
    +
     
    - 353 + + -
    +
    +
      - func TestGasPrice(t *testing.T) { +
    - 354 + + -
    +
    +
      - // Set up testing environment +
    - 355 + + -
    - + - etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 356 + + -
    +
    +
      - etherscanM := new(etherscanMock) +
    - 357 + + -
    +
    +
      - ethGasStationM := new(ethGasStationMock) +
    - 358 + + -
    +
    +
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} +
    -
     
    -
    - 371 + + -
    +
    +
     
    - 372 + + -
    +
    +
      - func TestErrorEthGasStationPrice(t *testing.T) { +
    - 373 + + -
    +
    +
      - // Set up testing environment +
    - 374 + + -
    - + - etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 375 + + -
    +
    +
      - ethGasStationM := new(ethGasStationMock) +
    - 376 + + -
    +
    +
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, ethGasStationM} +
    - 377 + + -
    +
    +
      - ctx := context.Background() +
    - 378 + + -
    +
    +
     
    - 379 + + -
    +
    +
      - ethGasStationM.On("SuggestGasPrice", ctx).Return(big.NewInt(0), fmt.Errorf("error getting gasPrice from ethGasStation")) +
    - 380 + + -
    +
    +
      - gp := etherman.GetL1GasPrice(ctx) +
    - 381 + + -
    - + - assert.Equal(t, big.NewInt(1263075579), gp) +
    +
    +   +
    - 382 + + -
    +
    +
     
    - 383 + + -
    +
    +
      - etherscanM := new(etherscanMock) +
    - 384 + + -
    +
    +
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} +
    -
     
    -
    - 390 + + -
    +
    +
     
    - 391 + + -
    +
    +
      - func TestErrorEtherScanPrice(t *testing.T) { +
    - 392 + + -
    +
    +
      - // Set up testing environment +
    - 393 + + -
    - + - etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 394 + + -
    +
    +
      - etherscanM := new(etherscanMock) +
    - 395 + + -
    +
    +
      - ethGasStationM := new(ethGasStationMock) +
    - 396 + + -
    +
    +
      - etherman.GasProviders.Providers = []ethereum.GasPricer{etherman.EthClient, etherscanM, ethGasStationM} +
    -
     
    -
    - 404 + + -
    +
    +
     
    - 405 + + -
    +
    +
      - func TestGetForks(t *testing.T) { +
    - 406 + + -
    +
    +
      - // Set up testing environment +
    - 407 + + -
    - + - etherman, _, _, _, _, _, _ := newTestingEnv(t) +
    +
    +   +
    - 408 + + -
    +
    +
      - ctx := context.Background() +
    - 409 + + -
    +
    +
      - forks, err := etherman.GetForks(ctx, 0, 132) +
    - 410 + + -
    +
    +
      - require.NoError(t, err) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - -
    -
    @@ -0,0 +1,16 @@
    @@ -72830,6 +148503,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_contracts.go + RENAMED + +
    +
    @@ -72837,302 +148525,402 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -1,38 +0,0 @@
    + 1 +
    - + + - package etherman
    + 2 +
    - + + -
    + 3 +
    - + + - import (
    + 4 +
    - + - "context" + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/feijoapolygonzkevm"
    + 5 +
    - + -
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    + 6 +
    - + - "github.com/ethereum/go-ethereum/common" + - + "github.com/ethereum/go-ethereum/accounts/abi/bind"
    + 7 +
    - + - "github.com/jackc/pgx/v4" + - + "github.com/ethereum/go-ethereum/common"
    + 8 +
    - + + - )
    + 9 +
    - + + -
    + 10 +
    - + - type dataAvailabilityProvider interface { + - + // FeijoaContracts represents the contracts of the Feijoa upgrade
    + 11 +
    - + - GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error) + - + type FeijoaContracts struct {
    + 12 +
    - + - } + - + FeijoaZKEVMAddress common.Address
    + 13 +
    - + -
    + - + FeijoaZKEVM *feijoapolygonzkevm.Feijoapolygonzkevm
    + 14 +
    - + - type stateProvider interface { + - + //FeijoaRollupManager *feijoapolygonrollupmanager.Feijoapolygonrollupmanager
    + 15 +
    - + - GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) + - + //FeijoaGlobalExitRootManager *feijoapolygonzkevmglobalexitroot.Feijoapolygonzkevmglobalexitroot
    + 16 +
    - + + - }
    -
    + + + 17 + + +
    + - +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go - RENAMED - -
    -
    -
    -
    - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + - - - - + + + + + + + + + + + + + + + - - + + +
    -
    @@ -23,7 +24,7 @@
    + + 18 + +
    + - + // NewFeijoaContracts creates a new FeijoaContracts +
    +
    + 19 + +
    + - + func NewFeijoaContracts(ethClient bind.ContractBackend, l1Config L1Config) (*FeijoaContracts, error) { +
    +
    + 20 + +
    + - + FeijoaZKEVMAddress := l1Config.ZkEVMAddr +
    +
    + 21 + +
    + - + FeijoaZKEVM, err := feijoapolygonzkevm.NewFeijoapolygonzkevm(FeijoaZKEVMAddress, ethClient) +
    +
    + 22 + +
    + - + if err != nil { +
    +
    23 +
    -   -
    + - + log.Errorf("error creating FeijoaZKEVM client (addr: %s). Error: %w", FeijoaZKEVMAddress.String(), err)
    + 24 +
    -   - // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth + - + return nil, err
    + 25 +
    -   - // must be 1337. The address that holds the auth will have an initial balance of 10 ETH + - + }
    + 26 +
    - - func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *polygonzkevmbridge.Polygonzkevmbridge, error) { +
    + 27 +
    -   - if auth == nil { + - + return &FeijoaContracts{
    + 28 +
    -   - // read only client + - + FeijoaZKEVMAddress: FeijoaZKEVMAddress,
    + 29 +
    -   - return &Client{}, nil, common.Address{}, nil, nil + - + FeijoaZKEVM: FeijoaZKEVM,
    -
    @@ -37,8 +38,26 @@
    +
    + 30 + +
    + - + }, nil +
    - 37 + + 31 +
    -   - }, + - + }
    - 38 + + 32 +
    -   + - +
    +
    +
    + 33 + +
    + - + // GetAddresses returns the addresses of the contracts +
    +
    + 34 + +
    + - + func (f *FeijoaContracts) GetAddresses() []common.Address { +
    +
    + 35 + +
    + - + return []common.Address{ +
    +
    + 36 + +
    + - + f.FeijoaZKEVMAddress, +
    +
    + 37 + +
    + - }
    - 39 + + 38 +
    -   - blockGasLimit := uint64(999999999999999999) //nolint:gomnd + - + }
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    @@ -73144,21 +148932,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 40 + + -
    +
    +
      - client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) +
    - 41 + + -
    +
    +
     
    @@ -73334,141 +149122,131 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 42 + + -
    +
    +
      - // Deploy contracts +
    - 43 + + -
    +
    +
      - const polDecimalPlaces = 18 +
    - 44 + + -
    +
    +
      - totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd +
    -
    @@ -102,7 +121,7 @@
    -
    - 102 + + -
    +
    +
      - log.Error("error: ", err) +
    - 103 + + -
    +
    +
      - return nil, nil, common.Address{}, nil, err +
    - 104 + + -
    +
    +
      - } +
    - 105 + + -
    - - - br, err := polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client()) +
    +
    +   +
    - 106 + + -
    +
    +
      - if err != nil { +
    - 107 + + -
    +
    +
      - log.Error("error: ", err) +
    - 108 + + -
    +
    +
      - return nil, nil, common.Address{}, nil, err +
    -
    @@ -182,6 +201,11 @@
    -
    - 182 + + -
    +
    +
      - return nil, nil, common.Address{}, nil, err +
    - 183 + + -
    +
    +
      - } +
    - 184 + + -
    +
    +
     
    @@ -73523,1938 +149301,1917 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_event_sequence_blobs.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + - - - - - - - - - - - - - - - - - - -
    +
    @@ -1,173 +0,0 @@
    +
    - 185 + + 1 +
    -   - _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{}) + - + package etherman
    - 186 + + 2 +
    -   - if err != nil { + - +
    - 187 + + 3 +
    -   - log.Error("error: ", err) + - + import (
    -
    @@ -199,6 +223,8 @@
    +
    + 4 + +
    + - + "context" +
    - 199 + + 5 +
    -   - SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr}, + - + "encoding/json"
    - 200 + + 6 +
    -   - auth: map[common.Address]bind.TransactOpts{}, + - + "fmt"
    - 201 + + 7 +
    -   - cfg: cfg, + - + "strings"
    - + + 8 -
    -   +
    +
    + -
    - + + 9 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/feijoapolygonzkevm"
    - 202 + + 10 +
    -   - } + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 203 + + 11 +
    -   - err = c.AddOrReplaceAuth(*auth) + - + "github.com/ethereum/go-ethereum/accounts/abi"
    - 204 + + 12 +
    -   - if err != nil { + - + "github.com/ethereum/go-ethereum/common"
    -
    + + + 13 + + +
    + - + "github.com/ethereum/go-ethereum/core/types"
    -
    -
    - - - - - - - + + + + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - -
    -
     
    - 24 + + 14 +
    -   + - + "github.com/ethereum/go-ethereum/crypto" +
    +
    + 15 + +
    + - + ) +
    +
    + 16 + +
    + -
    - 25 + + 17 +
    -   - // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth + - + const (
    - 26 + + 18 +
    -   - // must be 1337. The address that holds the auth will have an initial balance of 10 ETH + - + // SequenceBlobsOrder identifies a SequenceBlobs order
    - 27 + + 19 +
    - + - func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider, st stateProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) { + - + SequenceBlobsOrder EventOrder = "SequenceBlobs"
    - 28 + + 20 +
    -   - if auth == nil { + - + )
    - 29 + + 21 +
    -   - // read only client + - +
    - 30 + + 22 +
    -   - return &Client{}, nil, common.Address{}, nil, nil + - + var (
    -
     
    +
    + 23 + +
    + - + // Events Feijoa Signatures +
    - 38 + + 24 +
    -   - }, + - + // Events new ZkEvm/RollupBase
    - 39 + + 25 +
    -   - } + - + // lastBlobSequenced is the count of blob sequenced after process this event
    - 40 + + 26 +
    -   - blockGasLimit := uint64(999999999999999999) //nolint:gomnd + - + // if the first event have 1 blob -> lastBlobSequenced=1
    - 41 + + 27 +
    - + - // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) + - + eventSequenceBlobsSignatureHash = crypto.Keccak256Hash([]byte("SequenceBlobs(uint64)"))
    - 42 + + 28 +
    -   - client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit)) + - + )
    - 43 + + 29 +
    -   + -
    - 44 + + 30 +
    - + - // DAC Setup + - + // EventFeijoaSequenceBlobsProcessor is the processor for event SequenceBlobs(uint64)
    - 45 + + 31 +
    - + - daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client()) + - + type EventFeijoaSequenceBlobsProcessor struct {
    - 46 + + 32 +
    - + - if err != nil { + - + contracts *FeijoaContracts
    - 47 + + 33 +
    - + - return nil, nil, common.Address{}, nil, err + - + }
    - 48 + + 34 +
    - + - } + - +
    - 49 + + 35 +
    - + - client.Commit() + - + // NewEventFeijoaSequenceBlobsProcessor creates a new EventFeijoaSequenceBlobsProcessor
    - 50 + + 36 +
    - + - _, err = da.Initialize(auth) + - + func NewEventFeijoaSequenceBlobsProcessor(contracts *FeijoaContracts) *EventFeijoaSequenceBlobsProcessor {
    - 51 + + 37 +
    - + - if err != nil { + - + return &EventFeijoaSequenceBlobsProcessor{
    - 52 + + 38 +
    - + - return nil, nil, common.Address{}, nil, err + - + contracts: contracts,
    - 53 + + 39 +
    - + + - }
    - 54 + + 40 +
    - + - client.Commit() + - + }
    - 55 + + 41 +
    - + - _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{}) + - +
    - 56 + + 42 +
    - + - if err != nil { + - + // EventSignature returns the event signature supported
    - 57 + + 43 +
    - + - return nil, nil, common.Address{}, nil, err + - + func (e *EventFeijoaSequenceBlobsProcessor) EventSignature() common.Hash {
    - 58 + + 44 +
    - + - } + - + return eventSequenceBlobsSignatureHash
    - 59 + + 45 +
    - + - client.Commit() + - + }
    - 60 + + 46 +
    - + + -
    - 61 + + 47 +
    -   - // Deploy contracts + - + // AddEventDataToBlock adds the event data to the block and returns the Order
    - 62 + + 48 +
    -   - const polDecimalPlaces = 18 + - + func (e *EventFeijoaSequenceBlobsProcessor) AddEventDataToBlock(ctx context.Context, vLog types.Log, block *Block, callData *CallData) (*Order, error) {
    - 63 + + 49 +
    -   - totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd + - + //err := contract.UnpackLog(&event, "SequenceBlobs", vLog.Data)
    -
     
    +
    + 50 + +
    + - + eventData, err := e.contracts.FeijoaZKEVM.ParseSequenceBlobs(vLog) +
    - 121 + + 51 +
    -   - log.Error("error: ", err) + - + if err != nil {
    - 122 + + 52 +
    -   - return nil, nil, common.Address{}, nil, err + - + return nil, err
    - 123 + + 53 +
    -   + - }
    - 124 + + 54 +
    - + - br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client()) + - + for idx := range vLog.Topics {
    - 125 + + 55 +
    -   - if err != nil { + - + log.Debugf("vlog.Topics[%d]: %s ", idx, vLog.Topics[idx].Hex())
    - 126 + + 56 +
    -   - log.Error("error: ", err) + - + }
    - 127 + + 57 +
    -   - return nil, nil, common.Address{}, nil, err + - + log.Debugf("LastBlobSequenced: %d", eventData.LastBlobSequenced)
    -
     
    +
    + 58 + +
    + - + // decode Data +
    - 201 + + 59 +
    -   - return nil, nil, common.Address{}, nil, err + - + inputData, err := e.parseCallData(callData)
    - 202 + + 60 +
    -   - } + - + if err != nil {
    - 203 + + 61 +
    -   -
    + - + return nil, err
    - 204 + + 62 +
    - + - _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr) + - + }
    - 205 + + 63 +
    - + - if err != nil { + - + inputData.EventData = &SequenceBlobsEventData{
    - 206 + + 64 +
    - + - log.Error("error: ", err) + - + LastBlobSequenced: eventData.LastBlobSequenced,
    - 207 + + 65 +
    - + - return nil, nil, common.Address{}, nil, err + - + }
    - 208 + + 66 +
    - + - } + - +
    - 209 + + 67 +
    -   - _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{}) + - + if inputData.thereIsAnyBlobType() {
    - 210 + + 68 +
    -   - if err != nil { + - + // TODO:Retrieve blobs
    - 211 + + 69 +
    -   - log.Error("error: ", err) + - + return nil, fmt.Errorf("data-availability in blobs: not supported yet")
    -
     
    +
    + 70 + +
    + - + } +
    - 223 + + 71 +
    -   - SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr}, + - + // Add the blobs to the block list
    - 224 + + 72 +
    -   - auth: map[common.Address]bind.TransactOpts{}, + - + block.SequenceBlobs = append(block.SequenceBlobs, *inputData)
    - 225 + + 73 +
    -   - cfg: cfg, + - + order := Order{
    - 226 + + 74 +
    - + - da: daBackend, + - + Name: SequenceBatchesOrder,
    - 227 + + 75 +
    - + - state: st, + - + Pos: len(block.SequenceBlobs) - 1,
    - 228 + + 76 +
    -   + - }
    - 229 + + 77 +
    -   - err = c.AddOrReplaceAuth(*auth) + - +
    - 230 + + 78 +
    -   - if err != nil { + - + return &order, nil
    -
    + + + 79 + + +
    + - + // Extract Calldata
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -42,12 +42,17 @@
    - 42 + + 80 +
    -   - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" + - + }
    - 43 + + 81 +
    -   - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts + - +
    - 44 + + 82 +
    -   - EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT" + - + func (e *EventFeijoaSequenceBlobsProcessor) parseCallData(callData *CallData) (*SequenceBlobs, error) {
    - + + 83 -
    -   -
    +
    +
    + - + //smcAbi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - + + 84 -
    -   -
    +
    +
    + - + smcAbi, err := abi.JSON(strings.NewReader(feijoapolygonzkevm.FeijoapolygonzkevmABI))
    - + + 85 -
    -   -
    +
    +
    + - + if err != nil {
    - 45 + + 86 +
    -   - // EventID_NodeOOC is triggered when an OOC at node level is detected + - + return nil, err +
    +
    + 87 + +
    + - + }
    - 46 + + 88 +
    -   - EventID_NodeOOC EventID = "NODE OOC" + - + method, err := smcAbi.MethodById(callData.MethodID())
    - 47 + + 89 +
    -   - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters + - + if err != nil {
    - 48 + + 90 +
    -   - EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW" + - + return nil, err
    - 49 + + 91 +
    -   - // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters + - + }
    - 50 + + 92 +
    -   - EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW" + - + // Unpack method inputs
    - + + 93 -
    -   -
    +
    +
    + - + data, err := method.Inputs.Unpack(callData.InputData())
    - + + 94 -
    -   -
    +
    +
    + - + if err != nil {
    - 51 + + 95 +
    -   - // Source_Node is the source of the event + - + return nil, err
    - 52 + + 96 +
    -   - Source_Node Source = "node" + - + }
    - 53 + + 97 +
    -   -
    -
    -
    -
    + - + bytedata, err := json.Marshal(data[0])
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 42 + + 98 +
    -   - EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT" + - + if err != nil {
    - 43 + + 99 +
    -   - // EventID_SequenceSenderHalt is triggered when the SequenceSender halts + - + return nil, err
    - 44 + + 100 +
    -   - EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT" + - + }
    - 45 + + 101 +
    - + - // EventID_UnsupportedPrecompile is triggered when the executor returns an unsupported precompile error + - + // Solidity: function sequenceBlobs((uint8,bytes)[] blobsRaw, address l2Coinbase, bytes32 finalAccInputHash) returns()
    - 46 + + 102 +
    - + - EventID_UnsupportedPrecompile EventID = "UNSUPPORTED PRECOMPILE" + - + var blobsRaw []feijoapolygonzkevm.PolygonRollupBaseFeijoaBlobData
    - 47 + + 103 +
    - + -
    + - + err = json.Unmarshal(bytedata, &blobsRaw)
    - 48 + + 104 +
    -   - // EventID_NodeOOC is triggered when an OOC at node level is detected + - + if err != nil {
    - 49 + + 105 +
    -   - EventID_NodeOOC EventID = "NODE OOC" + - + return nil, err
    - 50 + + 106 +
    -   - // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters + - + }
    - 51 + + 107 +
    -   - EventID_UsedZKCountersOverflow EventID = "USED ZKCOUNTERS OVERFLOW" + - + blobs := make([]SequenceBlob, 0)
    - 52 + + 108 +
    -   - // EventID_ReservedZKCountersOverflow is triggered when reserved ZK counters exceeds remaining batch ZK counters + - +
    - 53 + + 109 +
    -   - EventID_ReservedZKCountersOverflow EventID = "RESERVED ZKCOUNTERS OVERFLOW" + - + for i := range blobsRaw {
    - 54 + + 110 +
    - + - // EventID_InvalidInfoRoot is triggered when an invalid l1InfoRoot was synced + - + //log.Debugf("BlobType: %d", blobs[i].BlobType)
    - 55 + + 111 +
    - + - EventID_InvalidInfoRoot EventID = "INVALID INFOROOT" + - + var blobBlobTypeParams *BlobBlobTypeParams
    - 56 + + 112 +
    -   - // Source_Node is the source of the event + - + var blobTypeParams *BlobCommonParams
    - 57 + + 113 +
    -   - Source_Node Source = "node" + - + var txData []byte
    - 58 + + 114 +
    -   -
    -
    -
    -
    + - + switch BlobType(blobsRaw[i].BlobType) {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
    @@ -30,3 +30,6 @@
    - 30 + + 115 +
    -   - include: + - + case TypeCallData:
    - 31 + + 116 +
    -   - - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments + - + blobTypeParams, txData, err = parseBlobCallDataTypeParams(blobsRaw[i].BlobTypeParams)
    - 32 + + 117 +
    -   - - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments + - + if err != nil {
    - + + 118 -
    -   -
    +
    +
    + - + return nil, err
    - + + 119 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    -
    +
    + 120
    -
    + +
    + - + case TypeBlobTransaction:
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    - 30 + + 121 +
    -   - include: + - + return nil, fmt.Errorf("blobType 'BlobTransaction' not supported yet")
    - 31 + + 122 +
    -   - - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments + - + default:
    - 32 + + 123 +
    -   - - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments + - + return nil, fmt.Errorf("blobType not supported")
    - 33 + + 124 +
    - + - exclude-rules: + - + }
    - 34 + + 125 +
    - + - - path: cmd/policy.go + - + blobs = append(blobs, SequenceBlob{
    - 35 + + 126 +
    - + - text: "unused" -
    -
    -
    + - + Type: BlobType(blobsRaw[i].BlobType),
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + +
    -
    @@ -22,9 +22,9 @@
    - 22 + + 127 +
    -   - github.com/prometheus/common v0.45.0 + - + Params: *blobTypeParams,
    - 23 + + 128 +
    -   - github.com/rubenv/sql-migrate v1.6.1 + - + Data: txData,
    - 24 + + 129 +
    -   - github.com/spf13/afero v1.11.0 + - + BlobBlobTypeParams: blobBlobTypeParams,
    - 25 + + 130 +
    - - github.com/spf13/viper v1.17.0 + })
    - 26 + + 131 +
    -   - github.com/stretchr/testify v1.8.4 + - + }
    - 27 + + 132 +
    - - github.com/umbracle/ethgo v0.1.3 + l1CoinBase := (data[1]).(common.Address)
    - 28 + + 133 +
    -   - github.com/urfave/cli/v2 v2.26.0 + - + finalAccInputHashRaw := (data[2]).([32]byte)
    - 29 + + 134 +
    -   - go.uber.org/zap v1.26.0 + - + finalAccInputHash := common.Hash(finalAccInputHashRaw)
    - 30 + + 135 +
    -   - golang.org/x/crypto v0.18.0 + - +
    -
    @@ -45,7 +45,7 @@
    -
    - 45 + + 136 +
    -   - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect + - + return &SequenceBlobs{
    - 46 + + 137 +
    -   - github.com/bahlo/generic-list-go v0.2.0 // indirect + - + Blobs: blobs,
    - 47 + + 138 +
    -   - github.com/beorn7/perks v1.0.1 // indirect + - + L2Coinbase: l1CoinBase,
    - 48 + + 139 +
    - - github.com/bits-and-blooms/bitset v1.10.0 // indirect + FinalAccInputHash: finalAccInputHash,
    - 49 + + 140 +
    -   - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + - + }, nil
    - 50 + + 141 +
    -   - github.com/buger/jsonparser v1.1.1 // indirect + - + }
    - 51 + + 142 +
    -   - github.com/cespare/xxhash/v2 v2.2.0 // indirect + - +
    -
    @@ -63,12 +63,12 @@
    -
    - 63 + + 143 +
    -   - github.com/cyphar/filepath-securejoin v0.2.4 // indirect + - + // returns data and the transtaction_data
    - 64 + + 144 +
    -   - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + - + func parseBlobCallDataTypeParams(data []byte) (*BlobCommonParams, []byte, error) {
    - 65 + + 145 +
    -   - github.com/deckarep/golang-set/v2 v2.1.0 // indirect + - + // https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/feijoa/contracts/v2/lib/PolygonRollupBaseFeijoa.sol
    - 66 + + 146 +
    - - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect + // case: if (currentBlob.blobType == CALLDATA_BLOB_TYPE)
    - 67 + + 147 +
    -   - github.com/dlclark/regexp2 v1.7.0 // indirect + - + //
    - 68 + + 148 +
    -   - github.com/emirpasic/gods v1.18.1 // indirect + - + // maxSequenceTimestamp uint64
    - 69 + + 149 +
    -   - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect + - + // zkGasLimit uint64
    - 70 + + 150 +
    -   - github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect + - + // l1InfoLeafIndex uint32
    - 71 + + 151 +
    - - github.com/fsnotify/fsnotify v1.6.0 // indirect + // transactions []byte
    - 72 + + 152 +
    -   - github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect + - +
    - 73 + + 153 +
    -   - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + - + // Prepare blob params using ABI encoder
    - 74 + + 154 +
    -   - github.com/getsentry/sentry-go v0.18.0 // indirect + - + uint64Ty, _ := abi.NewType("uint64", "", nil)
    -
    @@ -101,6 +101,7 @@
    -
    - 101 + + 155 +
    -   - github.com/jackc/puddle v1.3.0 // indirect + - + uint32Ty, _ := abi.NewType("uint32", "", nil)
    - 102 + + 156 +
    -   - github.com/jackpal/go-nat-pmp v1.0.2 // indirect + - + bytesTy, _ := abi.NewType("bytes", "", nil)
    - 103 + + 157 +
    -   - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + - + arguments := abi.Arguments{
    - + + 158 -
    -   -
    +
    +
    + - + {Type: uint64Ty},
    - 104 + + 159 +
    -   - github.com/karrick/godirwalk v1.17.0 // indirect + - + {Type: uint64Ty},
    - 105 + + 160 +
    -   - github.com/kevinburke/ssh_config v1.2.0 // indirect + - + {Type: uint32Ty},
    - 106 + + 161 +
    -   - github.com/klauspost/compress v1.17.0 // indirect + - + {Type: bytesTy},
    -
    @@ -116,6 +117,7 @@
    -
    - 116 + + 162 +
    -   - github.com/mattn/go-isatty v0.0.20 // indirect + - + }
    - 117 + + 163 +
    -   - github.com/mattn/go-runewidth v0.0.13 // indirect + - + unpacked, err := arguments.Unpack(data)
    - 118 + + 164 +
    -   - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect + - + if err != nil {
    - + + 165 -
    -   -
    +
    +
    + - + return nil, nil, err
    - 119 + + 166 +
    -   - github.com/mitchellh/pointerstructure v1.2.0 // indirect + - + }
    - 120 + + 167 +
    -   - github.com/mmcloughlin/addchain v0.4.0 // indirect + - + result := &BlobCommonParams{}
    - 121 + + 168 +
    -   - github.com/olekukonko/tablewriter v0.0.5 // indirect + - + result.MaxSequenceTimestamp = unpacked[0].(uint64)
    -
    @@ -128,14 +130,14 @@
    +
    + 169 + +
    + - + result.ZkGasLimit = unpacked[1].(uint64) +
    - 128 + + 170 +
    -   - github.com/rogpeppe/go-internal v1.11.0 // indirect + - + result.L1InfoLeafIndex = unpacked[2].(uint32)
    - 129 + + 171 +
    -   - github.com/rs/cors v1.7.0 // indirect + - + transactionData := unpacked[3].([]byte)
    - 130 + + 172 +
    -   - github.com/russross/blackfriday/v2 v2.1.0 // indirect + - + return result, transactionData, nil
    - 131 + + 173 +
    - - github.com/sagikazarmark/locafero v0.3.0 // indirect + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -75478,717 +151235,683 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - -
    +
     
    - 132 + + -
    +
    +
      - github.com/sagikazarmark/slog-shim v0.1.0 // indirect +
    - 133 + + -
    +
    +
      - github.com/sergi/go-diff v1.2.0 // indirect +
    - 134 + + -
    +
    +
      - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect +
    - 135 + + -
    +
    +
      - github.com/sirupsen/logrus v1.9.0 // indirect +
    - 136 + + -
    +
    +
      - github.com/skeema/knownhosts v1.2.1 // indirect +
    - 137 + + -
    +
    +
      - github.com/sourcegraph/conc v0.3.0 // indirect +
    - 138 + + -
    - - - github.com/spf13/cast v1.5.1 // indirect +
    +
    +   +
    - 139 + + -
    +
    +
      - github.com/spf13/pflag v1.0.5 // indirect +
    - 140 + + -
    +
    +
      - github.com/status-im/keycard-go v0.2.0 // indirect +
    - 141 + + -
    +
    +
      - github.com/stretchr/objx v0.5.0 // indirect +
    -
    @@ -170,8 +172,9 @@
    +
    + + +
    +   +
    +
    - 170 + + -
    +
    +
      - ) +
    - 171 + + -
    +
    +
     
    - 172 + + -
    +
    +
      - require ( +
    - 173 + + -
    +
    +
      - github.com/fatih/color v1.16.0 +
    - 174 + + -
    - - - github.com/joho/godotenv v1.5.1 +
    +
    +   +
    - 175 + + -
    +
    +
      - github.com/prometheus/client_golang v1.18.0 +
    - 176 + + -
    +
    +
      - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa +
    - 177 + + -
    +
    +
      - ) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -76202,63 +151925,44 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
     
    - 22 + + -
    +
    +
      - github.com/prometheus/common v0.45.0 +
    - 23 + + -
    +
    +
      - github.com/rubenv/sql-migrate v1.6.1 +
    - 24 + + -
    +
    +
      - github.com/spf13/afero v1.11.0 +
    - 25 + + -
    - + - github.com/spf13/viper v1.18.2 +
    +
    +   +
    - 26 + + -
    +
    +
      - github.com/stretchr/testify v1.8.4 +
    - 27 + + -
    - + - github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0 +
    +
    +   +
    - 28 + + -
    +
    +
      - github.com/urfave/cli/v2 v2.26.0 +
    - 29 + + -
    +
    +
      - go.uber.org/zap v1.26.0 +
    - 30 + + -
    +
    +
      - golang.org/x/crypto v0.18.0 +
    -
     
    -
    - 45 + + -
    +
    +
      - github.com/VictoriaMetrics/fastcache v1.12.1 // indirect +
    - 46 + + -
    +
    +
      - github.com/bahlo/generic-list-go v0.2.0 // indirect +
    - 47 + + -
    +
    +
      - github.com/beorn7/perks v1.0.1 // indirect +
    - 48 + + -
    - + - github.com/bits-and-blooms/bitset v1.12.0 // indirect +
    +
    +   +
    - 49 + + -
    +
    +
      - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect +
    - 50 + + -
    +
    +
      - github.com/buger/jsonparser v1.1.1 // indirect +
    - 51 + + -
    +
    +
      - github.com/cespare/xxhash/v2 v2.2.0 // indirect +
    -
     
    -
    - 63 + + -
    +
    +
      - github.com/cyphar/filepath-securejoin v0.2.4 // indirect +
    - 64 + + -
    +
    +
      - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect +
    - 65 + + -
    +
    +
      - github.com/deckarep/golang-set/v2 v2.1.0 // indirect +
    - 66 + + -
    - + - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect +
    +
    +   +
    - 67 + + -
    +
    +
      - github.com/dlclark/regexp2 v1.7.0 // indirect +
    - 68 + + -
    +
    +
      - github.com/emirpasic/gods v1.18.1 // indirect +
    - 69 + + -
    +
    +
      - github.com/ethereum/c-kzg-4844 v0.4.0 // indirect +
    - 70 + + -
    +
    +
      - github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect +
    - 71 + + -
    - + - github.com/fsnotify/fsnotify v1.7.0 // indirect +
    +
    +   +
    - 72 + + -
    +
    +
      - github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect +
    - 73 + + -
    +
    +
      - github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect +
    - 74 + + -
    +
    +
      - github.com/getsentry/sentry-go v0.18.0 // indirect +
    -
     
    -
    - 101 + + -
    +
    +
      - github.com/jackc/puddle v1.3.0 // indirect +
    - 102 + + -
    +
    +
      - github.com/jackpal/go-nat-pmp v1.0.2 // indirect +
    - 103 + + -
    +
    +
      - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect +
    - 104 + + -
    - + - github.com/jmoiron/sqlx v1.2.0 // indirect +
    +
    +   +
    - 105 + + -
    +
    +
      - github.com/karrick/godirwalk v1.17.0 // indirect +
    - 106 + + -
    +
    +
      - github.com/kevinburke/ssh_config v1.2.0 // indirect +
    - 107 + + -
    +
    +
      - github.com/klauspost/compress v1.17.0 // indirect +
    -
     
    -
    - 117 + + -
    +
    +
      - github.com/mattn/go-isatty v0.0.20 // indirect +
    - 118 + + -
    +
    +
      - github.com/mattn/go-runewidth v0.0.13 // indirect +
    - 119 + + -
    +
    +
      - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect +
    - 120 + + -
    - + - github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect +
    +
    +   +
    - 121 + + -
    +
    +
      - github.com/mitchellh/pointerstructure v1.2.0 // indirect +
    - 122 + + -
    +
    +
      - github.com/mmcloughlin/addchain v0.4.0 // indirect +
    - 123 + + -
    +
    +
      - github.com/olekukonko/tablewriter v0.0.5 // indirect +
    -
     
    -
    - 130 + + -
    +
    +
      - github.com/rogpeppe/go-internal v1.11.0 // indirect +
    - 131 + + -
    +
    +
      - github.com/rs/cors v1.7.0 // indirect +
    - 132 + + -
    +
    +
      - github.com/russross/blackfriday/v2 v2.1.0 // indirect +
    - 133 + + -
    - + - github.com/sagikazarmark/locafero v0.4.0 // indirect +
    +
    +   +
    - 134 + + -
    +
    +
      - github.com/sagikazarmark/slog-shim v0.1.0 // indirect +
    - 135 + + -
    +
    +
      - github.com/sergi/go-diff v1.2.0 // indirect +
    - 136 + + -
    +
    +
      - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect +
    - 137 + + -
    +
    +
      - github.com/sirupsen/logrus v1.9.0 // indirect +
    - 138 + + -
    +
    +
      - github.com/skeema/knownhosts v1.2.1 // indirect +
    - 139 + + -
    +
    +
      - github.com/sourcegraph/conc v0.3.0 // indirect +
    - 140 + + -
    - + - github.com/spf13/cast v1.6.0 // indirect +
    +
    +   +
    - 141 + + -
    +
    +
      - github.com/spf13/pflag v1.0.5 // indirect +
    - 142 + + -
    +
    +
      - github.com/status-im/keycard-go v0.2.0 // indirect +
    - 143 + + -
    +
    +
      - github.com/stretchr/objx v0.5.0 // indirect +
    -
     
    +
    + + +
    +   +
    +
    - 172 + + -
    +
    +
      - ) +
    - 173 + + -
    +
    +
     
    - 174 + + -
    +
    +
      - require ( +
    - 175 + + -
    - + - github.com/0xPolygon/agglayer v0.0.1 +
    +
    +   +
    - 176 + + -
    - + - github.com/0xPolygon/cdk-data-availability v0.0.5 +
    +
    +   +
    - 177 + + -
    +
    +
      - github.com/fatih/color v1.16.0 +
    - 178 + + -
    +
    +
      - github.com/prometheus/client_golang v1.18.0 +
    - 179 + + -
    +
    +
      - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa +
    - 180 + + -
    +
    +
      - ) +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml - RENAMED - -
    -
    -
    -
    - - - - -
    -
    @@ -0,0 +1,84 @@
    @@ -77105,6 +152809,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events.go + RENAMED + +
    +
    @@ -77112,846 +152831,766 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -77959,21 +153598,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    @@ -1,76 +0,0 @@
    + 1 +
    - + - # .goreleaser-cdk.yaml + - + package etherman
    + 2 +
    - + - project_name: cdk-validium-node + - +
    + 3 +
    - + -
    + - + import (
    + 4 +
    - + - release: + - + "fmt"
    + 5 +
    - + - disable: false + - + "math/big"
    + 6 +
    - + - draft: true + - +
    + 7 +
    - + - prerelease: auto + - + "github.com/ethereum/go-ethereum/common"
    + 8 +
    - + -
    + - + "github.com/ethereum/go-ethereum/crypto/kzg4844"
    + 9 +
    - + - before: + - + )
    + 10 +
    - + - hooks: + - +
    + 11 +
    - + - - go mod download + - + // BlobType is the type of the blob type
    + 12 +
    - + - - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 + - + type BlobType uint8
    + 13 +
    - + - - packr2 + - +
    + 14 +
    - + -
    + - + const (
    + 15 +
    - + - builds: + - + // TypeCallData The data is stored on call data directly
    + 16 +
    - + - - main: ./cmd/ + - + TypeCallData BlobType = 0
    + 17 +
    - + - binary: zkevm-node + - + // TypeBlobTransaction The data is stored on a blob
    + 18 +
    - + - goos: + - + TypeBlobTransaction BlobType = 1
    + 19 +
    - + - - linux + - + // TypeForcedBlob The data is a forced Blob
    + 20 +
    - + - - darwin + - + TypeForcedBlob BlobType = 2
    + 21 +
    - + - goarch: + - + )
    + 22 +
    - + - - amd64 + - +
    + 23 +
    - + - - arm64 + - + // SequenceBlob is for each Blob inside a SequenceBlobs
    + 24 +
    - + - env: + - + type SequenceBlob struct {
    + 25 +
    - + - - CGO_ENABLED=0 + - + Type BlobType
    + 26 +
    - + - ldflags: + - + Params BlobCommonParams
    + 27 +
    - + - - -s -w + - + Data []byte
    + 28 +
    - + - - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }} + - + // Field only valid if BlobType == BlobTransaction
    + 29 +
    - + - - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }} + - + BlobBlobTypeParams *BlobBlobTypeParams
    + 30 +
    - + - - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }} + - + }
    + 31 +
    - + - - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }} + - +
    + 32 +
    - + -
    + - + func (s *SequenceBlob) String() string {
    + 33 +
    - + - archives: + - + return fmt.Sprintf("Type: %d, Params: %v, Data: %v, BlobBlobTypeParams: %v", s.Type, s.Params, s.Data, s.BlobBlobTypeParams)
    + 34 +
    - + - - files: + - + }
    + 35 +
    - + - - LICENSE + - +
    + 36 +
    - + - - README.md + - + // BlobCommonParams is the data for a SequenceBlob
    + 37 +
    - + -
    + - + type BlobCommonParams struct {
    + 38 +
    - + - dockers: + - + MaxSequenceTimestamp uint64
    + 39 +
    - + - - image_templates: + - + ZkGasLimit uint64
    + 40 +
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 + - + L1InfoLeafIndex uint32
    + 41 +
    - + - dockerfile: Dockerfile.release + - + }
    + 42 +
    - + - use: buildx + - +
    + 43 +
    - + - goos: linux + - + // BlobBlobTypeParams is the data for a SequenceBlob stored on a Blob
    + 44 +
    - + - goarch: amd64 + - + // case: if (currentBlob.blobType ==> BLOBTX_BLOB_TYPE)
    + 45 +
    - + - build_flag_templates: + - + // sames as calldata plus BlobIndex, ...
    + 46 +
    - + - - --platform=linux/amd64 + - + type BlobBlobTypeParams struct {
    + 47 +
    - + - - --label=org.opencontainers.image.title={{ .ProjectName }} + - + BlobIndex *big.Int
    + 48 +
    - + - - --label=org.opencontainers.image.description={{ .ProjectName }} + - + Z []byte
    + 49 +
    - + - - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + - + Y []byte
    + 50 +
    - + - - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} + - + Commitment kzg4844.Commitment
    + 51 +
    - + - - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} + - + Proof kzg4844.Proof
    + 52 +
    - + - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - + }
    + 53 +
    - + - - --label=org.opencontainers.image.revision={{ .FullCommit }} + - +
    + 54 +
    - + - skip_push: false + - + // SequenceBlobs is the data in the event SequenceBlobs
    + 55 +
    - + -
    + - + type SequenceBlobs struct {
    + 56 +
    - + - - image_templates: + - + Blobs []SequenceBlob
    + 57 +
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 + - + L2Coinbase common.Address // from Calldata
    + 58 +
    - + - dockerfile: Dockerfile.release + - + FinalAccInputHash common.Hash
    + 59 +
    - + - use: buildx + - + EventData *SequenceBlobsEventData
    + 60 +
    - + - goos: linux + - + }
    + 61 +
    - + - goarch: arm64 + - +
    + 62 +
    - + - build_flag_templates: + - + // SequenceBlobsEventData is the data in the event SequenceBlobs
    + 63 +
    - + - - --platform=linux/arm64 + - + type SequenceBlobsEventData struct {
    + 64 +
    - + - - --label=org.opencontainers.image.title={{ .ProjectName }} + - + // LastBlobSequenced is the count of blob sequenced after process this event
    + 65 +
    - + - - --label=org.opencontainers.image.description={{ .ProjectName }} + - + // if the first event have 1 blob -> lastBlobSequenced=1
    + 66 +
    - + - - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }} + - + LastBlobSequenced uint64
    + 67 +
    - + - - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }} + - + }
    + 68 +
    - + - - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} + - +
    + 69 +
    - + - - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} + - + func (s *SequenceBlobs) thereIsAnyBlobType() bool {
    + 70 +
    - + - - --label=org.opencontainers.image.revision={{ .FullCommit }} + - + for blobIndex := range s.Blobs {
    + 71 +
    - + - skip_push: false + - + if s.Blobs[blobIndex].Type == TypeBlobTransaction {
    + 72 +
    - + -
    + - + return true
    + 73 +
    - + - docker_manifests: + - + }
    + 74 +
    - + - - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }} + - + }
    + 75 +
    - + - image_templates: + - + return false
    + 76 -
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 -
    -
    - 77 - -
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 -
    -
    - 78 - -
    - + - skip_push: false -
    -
    - 79 - -
    - + -
    -
    -
    - 80 - -
    - + - - name_template: 0xpolygon/{{ .ProjectName }}:latest -
    -
    - 81 - -
    - + - image_templates: -
    -
    - 82 - -
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 -
    -
    - 83 - -
    - + - - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 -
    -
    - 84 - +
    - + - skip_push: false + - + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go - RENAMED - -
    -
    @@ -77981,34 +153605,34 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - -
    -
    @@ -58,6 +58,46 @@
    +
     
    - 58 + + -
    +
    +
      - return result, nil +
    - 59 + + -
    +
    +
      - } +
    - 60 + + -
    +
    +
     
    @@ -78414,507 +154038,333 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 61 + + -
    +
    +
      - // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root +
    - 62 + + -
    +
    +
      - func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) { +
    - 63 + + -
    +
    +
      - response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -78924,12 +154374,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/feijoa_events_test.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    - 58 + + -
    +
    +
      - return result, nil +
    - 59 + + -
    +
    +
      - } +
    - 60 + + -
    +
    +
     
    - 61 - -
    - + - // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last -
    -
    - 62 - -
    - + - // known batch is returned as a list. -
    -
    - 63 - -
    - + - func (c *Client) BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) { -
    -
    - 64 - -
    - + - return c.batchesByNumbers(ctx, numbers, "zkevm_getBatchDataByNumbers") -
    -
    - 65 - -
    - + - } -
    -
    - 66 + + -
    - + +
    +
    +  
    - 67 - -
    - + - // ForcedBatchesByNumbers returns forced batches data. -
    -
    - 68 - -
    - + - func (c *Client) ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) { -
    -
    - 69 - -
    - + - return c.batchesByNumbers(ctx, numbers, "zkevm_getForcedBatchDataByNumbers") -
    -
    - 70 - -
    - + - } -
    -
    - 71 + + -
    - + +
    +
    +  
    - 72 - -
    - + - // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last -
    -
    - 73 - -
    - + - // known batch is returned as a list. -
    -
    - 74 - -
    - + - func (c *Client) batchesByNumbers(_ context.Context, numbers []*big.Int, method string) ([]*types.BatchData, error) { -
    -
    - 75 - -
    - + - batchNumbers := make([]types.BatchNumber, 0, len(numbers)) -
    -
    - 76 - -
    - + - for _, n := range numbers { -
    -
    - 77 - -
    - + - batchNumbers = append(batchNumbers, types.BatchNumber(n.Int64())) -
    -
    - 78 - -
    - + - } -
    -
    - 79 + + -
    - + - if len(batchNumbers) == 0 { +
    +
    +   +
    - 80 + + -
    - + - batchNumbers = append(batchNumbers, types.LatestBatchNumber) +
    +
    +   +
    - 81 + + -
    - + - } +
    +
    +   +
    - 82 + + -
    - + +
    +
    +  
    - 83 + + -
    - + - response, err := JSONRPCCall(c.url, method, &types.BatchFilter{Numbers: batchNumbers}) +
    +
    +   +
    - 84 + + -
    - + - if err != nil { +
    +
    +   +
    - 85 + + -
    - + - return nil, err +
    +
    +   +
    - 86 + + -
    - + - } +
    +
    +   +
    - 87 + + -
    - + +
    +
    +  
    - 88 + + -
    - + - if response.Error != nil { +
    +
    +   +
    - 89 + + -
    - + - return nil, response.Error.RPCError() +
    +
    +   +
    - 90 + + -
    - + - } +
    +
    +   +
    - 91 + + -
    - + +
    +
    +  
    - 92 + + -
    - + - var result *types.BatchDataResult +
    +
    +   +
    - 93 + + -
    - + - err = json.Unmarshal(response.Result, &result) +
    +
    +   +
    - 94 + + -
    - + - if err != nil { +
    +
    +   +
    - 95 + + -
    - + - return nil, err +
    +
    +   +
    - 96 + + -
    - + - } +
    +
    +   +
    - 97 + + -
    - + +
    +
    +  
    - 98 + + -
    - + - return result.Data, nil +
    +
    +   +
    - 99 + + -
    - + - } +
    +
    +   +
    - 100 + + -
    - + +
    +
    +  
    - 101 + + -
    +
    +
      - // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root +
    - 102 + + -
    +
    +
      - func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) { +
    - 103 - -
    +
    + + +
      - response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) +
    -
    @@ -68,8 +68,6 @@
    +
    @@ -1,17 +0,0 @@
    - 68 + + 1 +
    -   - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { + - + package etherman
    - 69 + + 2 +
    -   - if arg == nil { + - +
    - 70 + + 3 +
    -   - return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) + - + import (
    - 71 + 4
    - - } else if blockArg == nil { + "testing"
    - 72 + 5
    - - return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 1", nil, false) +
    - 73 + + 6 +
    -   - } + - + "github.com/stretchr/testify/require"
    - 74 + + 7 +
    -   - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) + - + )
    - 75 + + 8 +
    -   - if respErr != nil { + - +
    -
    @@ -106,13 +104,16 @@
    -
    - 106 + + 9 +
    -   - result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) + - + func TestXxx(t *testing.T) {
    - 107 + + 10 +
    -   - if err != nil { + - + _, err := NewFeijoaContracts(nil, L1Config{})
    - 108 + + 11 +
    -   - errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) + - + require.NoError(t, err)
    - 109 + + 12 +
    - - logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas) + }
    - 110 + + 13 +
    -   - return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) + - +
    - 111 + + 14 +
    -   - } + - + func TestFeijoaEventsSignature(t *testing.T) {
    - 112 + + 15 +
    -   -
    + - + // Signature extracted from https://sepolia.etherscan.io/tx/0x644699c839d34a61c531d7ecf12390bf38c06a62715ca4edce978b9213ce3cd1#eventlog
    - 113 + + 16 +
    -   - if result.Reverted() { + - + require.Equal(t, "0x470f4ca4b003755c839b80ab00c3efbeb69d6eafec00e1a3677482933ec1fd0c", eventSequenceBlobsSignatureHash.String())
    - 114 + + 17 +
    -   - data := make([]byte, len(result.ReturnValue)) + - + }
    - 115 - -
    -   - copy(data, result.ReturnValue) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -79352,31 +154721,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - -
    +
     
    @@ -79161,71 +154610,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 116 - -
    -   - return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, result.Err.Error(), data) -
    -
    - 117 - -
    -   - } else if result.Failed() { -
    -
    - 118 - -
    -   - return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) -
    -
    -
    @@ -191,6 +192,9 @@
    -
    - 191 - -
    -   - if errors.Is(err, runtime.ErrExecutionReverted) { -
    -
    - 192 - -
    -   - data := make([]byte, len(returnValue)) -
    -
    - 193 - -
    -   - copy(data, returnValue) -
    -
    @@ -79257,68 +154641,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 194 - -
    -   - return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data) -
    -
    - 195 + + -
    +
    +
      - } else if err != nil { +
    - 196 + + -
    +
    +
      - return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) +
    -
    @@ -941,6 +945,9 @@
    -
    - 941 + + -
    +
    +
      - if e.cfg.SequencerNodeURI != "" { +
    - 942 + + -
    +
    +
      - return e.relayTxToSequencerNode(input) +
    - 943 + + -
    +
    +
      - } else { +
    - 944 + + -
    +
    +
      - ip := "" +
    - 945 + + -
    +
    +
      - ips := httpRequest.Header.Get("X-Forwarded-For") +
    - 946 + + -
    +
    +
     
    @@ -79386,6 +154755,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/interfaces.go + RENAMED + +
    +
    @@ -79393,36 +154777,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -79446,447 +154830,436 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    +
    @@ -0,0 +1,16 @@
    - 68 + + -
    +
    +
      - return e.txMan.NewDbTxScope(e.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { +
    - 69 + + -
    +
    +
      - if arg == nil { +
    - 70 + + -
    +
    +
      - return RPCErrorResponse(types.InvalidParamsErrorCode, "missing value for required argument 0", nil, false) +
    - 71 + + -
    +
    +
      - } +
    - 72 + + -
    +
    +
      - block, respErr := e.getBlockByArg(ctx, blockArg, dbTx) +
    - 73 + + -
    +
    +
      - if respErr != nil { +
    -
     
    -
    - 104 + + -
    +
    +
      - result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) +
    - 105 + + -
    +
    +
      - if err != nil { +
    - 106 + + -
    +
    +
      - errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error()) +
    - 107 + + -
    - + - logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas)) +
    +
    +   +
    - 108 + + -
    +
    +
      - return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError) +
    - 109 + + -
    +
    +
      - } +
    - 110 + + -
    +
    +
     
    - 111 + + -
    +
    +
      - if result.Reverted() { +
    - 112 - -
    -   - data := make([]byte, len(result.ReturnValue)) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 113 + + 1 +
    -   - copy(data, result.ReturnValue) + + + package etherman
    - 114 + 2
    + - if len(data) == 0 { +
    - 115 + 3
    + - return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) + import (
    - 116 + 4
    + - } + "context"
    - 117 + + 5 +
    -   - return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, result.Err.Error(), data) + + +
    - 118 + + 6 +
    -   - } else if result.Failed() { + + + "github.com/ethereum/go-ethereum/common"
    - 119 + + 7 +
    -   - return nil, types.NewRPCError(types.DefaultErrorCode, result.Err.Error()) + + + "github.com/jackc/pgx/v4"
    -
     
    -
    - 192 + + 8 +
    -   - if errors.Is(err, runtime.ErrExecutionReverted) { + + + )
    - 193 + + 9 +
    -   - data := make([]byte, len(returnValue)) + + +
    - 194 + + 10 +
    -   - copy(data, returnValue) + + + type dataAvailabilityProvider interface {
    - 195 + 11
    + - if len(data) == 0 { + GetBatchL2Data(batchNum []uint64, hash []common.Hash, dataAvailabilityMessage []byte) ([][]byte, error)
    - 196 + 12
    + - return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) + }
    - 197 + 13
    + - } +
    - 198 + + 14 +
    -   - return nil, types.NewRPCErrorWithData(types.RevertedErrorCode, err.Error(), data) + + + type stateProvider interface {
    - 199 + + 15 +
    -   - } else if err != nil { + + + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 200 + + 16 +
    -   - return nil, types.NewRPCError(types.DefaultErrorCode, err.Error()) + + + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/simulated.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - -
    -
     
    +
    @@ -5,25 +5,26 @@
    - 945 + 5
      - if e.cfg.SequencerNodeURI != "" { + "fmt"
    - 946 + 6
      - return e.relayTxToSequencerNode(input) + "math/big"
    - 947 + 7
      - } else { +
    - 948 + + 8 +
    - + - if err := checkPolicy(context.Background(), e.pool, input); err != nil { + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonrollupmanager"
    - 949 + + 9 +
    - + - return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false) + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevm"
    - 950 + + 10 +
    - + - } + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevmbridge"
    - 951 + + 11 +
    -   - ip := "" + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/etrogpolygonzkevmglobalexitroot"
    - 952 + + 12 +
    -   - ips := httpRequest.Header.Get("X-Forwarded-For") + - + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mocketrogpolygonrollupmanager"
    - 953 + 13
      -
    -
    -
    -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockverifier"
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - @@ -79900,333 +155273,268 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -80240,21 +155548,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - + + + - - - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - - + - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -81060,65 +156523,89 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    -
    @@ -6,6 +6,7 @@
    - 6 + 14
      - "errors" + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/pol"
    - 7 + + -
    +
    +
      - "fmt" +
    - 8 + + -
    +
    +
      - "math/big" +
    - 9 + + -
    +
    +
      - "sync" +
    - 10 + + -
    +
    +
      - "testing" +
    - 11 + 15
      - "time" + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proxy"
    -
    @@ -503,7 +504,7 @@
    -
    - 503 + 16
      - latest, + "github.com/0xPolygonHermez/zkevm-node/log"
    - 504 + 17
      - }, + "github.com/ethereum/go-ethereum/accounts/abi/bind"
    - 505 + 18
      - expectedResult: nil, + "github.com/ethereum/go-ethereum/common"
    - 506 + 19
    - - expectedError: types.NewRPCError(types.RevertedErrorCode, "execution reverted"), + "github.com/ethereum/go-ethereum/core/types"
    - 507 + 20
      - setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { + "github.com/ethereum/go-ethereum/crypto"
    - 508 + 21
      - nonce := uint64(7) + "github.com/ethereum/go-ethereum/ethclient/simulated"
    - 509 + 22
      - m.DbTx.On("Rollback", context.Background()).Return(nil).Once() + )
    -
    @@ -5416,3 +5417,237 @@
    -
    - 5416 + 23
      - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) +
    - 5417 + 24
      - assert.ElementsMatch(t, []int{16}, results[5]) + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - 5418 + 25
      - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - + + 26 -
    -   -
    +
    +
    + - + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts) (*Client, *simulated.Backend, common.Address, *etrogpolygonzkevmbridge.Etrogpolygonzkevmbridge, error) {
    - + + 27 -
    +
    +
      -
    + if auth == nil {
    - + + 28 -
    +
    +
      -
    + // read only client
    - + + 29 -
    +
    +
      -
    + return &Client{}, nil, common.Address{}, nil, nil
    - - -
    -   -
    -
    +
    +
    @@ -31,14 +32,32 @@
    - + + 31 -
    +
    +
      -
    + // 10000000 ETH in wei
    - + + 32 -
    +
    +
      -
    + balance, _ := new(big.Int).SetString("10000000000000000000000000", 10) //nolint:gomnd
    - + + 33 -
    +
    +
      -
    + address := auth.From
    - + + 34 -
    -   -
    +
    +
    + - + genesisAlloc := map[common.Address]types.Account{
    - + + 35 -
    +
    +
      -
    + address: {
    - + + 36 -
    +
    +
      -
    + Balance: balance,
    - + + 37 -
    +
    +
      -
    + },
    - + + 38 -
    +
    +
      -
    + }
    - + + 39 -
    +
    +
      -
    + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - + + 40 -
    +
    +
      -
    + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - + + 41 -
    +
    +
     
    @@ -80430,501 +155738,561 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 42 -
    +
    +
      -
    + // Deploy contracts
    - + + 43 -
    +
    +
      -
    + const polDecimalPlaces = 18
    - + + 44 -
    +
    +
      -
    + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - + +
    @@ -61,18 +80,18 @@
    -
    +
    + 61 + +
      -
    + const posRollupManager = 4
    - + + 62 -
    +
    +
      -
    + calculatedRollupManagerAddr := crypto.CreateAddress(auth.From, nonce+posRollupManager)
    - + + 63 -
    +
    +
      -
    + genesis := common.HexToHash("0xfd3434cd8f67e59d73488a2b8da242dd1f02849ea5dd99f0ca22c836c3d5b4a9") // Random value. Needs to be different to 0x0
    - + + 64 -
    -   -
    +
    +
    + - + exitManagerAddr, _, globalExitRoot, err := etrogpolygonzkevmglobalexitroot.DeployEtrogpolygonzkevmglobalexitroot(auth, client.Client(), calculatedRollupManagerAddr, calculatedBridgeAddr)
    - + + 65 -
    +
    +
      -
    + if err != nil {
    - + + 66 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 67 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 68 -
    +
    +
      -
    + }
    - + + 69 -
    -   -
    +
    +
    + - + implementationBridgeAddr, _, _, err := etrogpolygonzkevmbridge.DeployEtrogpolygonzkevmbridge(auth, client.Client())
    - + + 70 -
    +
    +
      -
    + if err != nil {
    - + + 71 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 72 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 73 -
    +
    +
      -
    + }
    - + + 74 -
    +
    +
     
    - + + 75 -
    -   -
    +
    +
    + - + implementationMockRollupManagerAddr, _, _, err := mocketrogpolygonrollupmanager.DeployMocketrogpolygonrollupmanager(auth, client.Client(), exitManagerAddr, polAddr, calculatedBridgeAddr)
    - + + 76 -
    +
    +
      -
    + if err != nil {
    - + + 77 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 78 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
    @@ -92,17 +111,17 @@
    -
    +
    + 92 + +
      -
    + return nil, nil, common.Address{}, nil, fmt.Errorf("RollupManagerAddr (%s) is different from the expected contract address (%s)",
    - + + 93 -
    +
    +
      -
    + mockRollupManagerAddr.String(), calculatedRollupManagerAddr.String())
    - + + 94 -
    +
    +
      -
    + }
    - + + 95 -
    -   -
    +
    +
    + - + initZkevmAddr, _, _, err := etrogpolygonzkevm.DeployEtrogpolygonzkevm(auth, client.Client(), exitManagerAddr, polAddr, bridgeAddr, mockRollupManagerAddr)
    - + + 96 -
    +
    +
      -
    + if err != nil {
    - + + 97 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 98 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 99 -
    +
    +
      -
    + }
    - + + 100 -
    +
    +
    + - + mockRollupManager, err := mocketrogpolygonrollupmanager.NewMocketrogpolygonrollupmanager(mockRollupManagerAddr, client.Client()) +
    +
    + 101 + +
      -
    + if err != nil {
    - + + 102 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 103 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 104 -
    +
    +
      -
    + }
    - + + 105 -
    +
    +
    + - + br, err := etrogpolygonzkevmbridge.NewEtrogpolygonzkevmbridge(bridgeAddr, client.Client()) +
    +
    + 106 + +
      -
    + if err != nil {
    - + + 107 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 108 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
    @@ -157,13 +176,13 @@
    -
    +
    + 157 + +
      -
    + bridgeAddr.String(), calculatedBridgeAddr.String())
    - + + 158 -
    +
    +
      -
    + }
    - + + 159 -
    +
    +
     
    - + + 160 -
    +
    +
    + - + rollupManager, err := etrogpolygonrollupmanager.NewEtrogpolygonrollupmanager(mockRollupManagerAddr, client.Client()) +
    +
    + 161 + +
      -
    + if err != nil {
    - + + 162 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 163 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 164 -
    +
    +
      -
    + }
    - + + 165 -
    +
    +
     
    - + + 166 -
    +
    +
    + - + trueZkevm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(zkevmAddr, client.Client()) //nolint +
    +
    + 167 + +
      -
    + if err != nil {
    - + + 168 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 169 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
    @@ -182,6 +201,11 @@
    -
    +
    + 182 + +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 183 -
    +
    +
      -
    + }
    - + + 184 -
    +
    +
     
    @@ -80980,63 +156348,158 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 185 -
    +
    +
      -
    + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - + + 186 -
    +
    +
      -
    + if err != nil {
    - + + 187 -
    +
    +
      -
    + log.Error("error: ", err)
    - + +
    @@ -190,15 +214,17 @@
    -
    +
    + 190 + +
      -
    + client.Commit()
    - + + 191 -
    +
    +
     
    - + + 192 -
    +
    +
      -
    + c := &Client{ +
    +
    + 193 + +
    + - + EthClient: client.Client(), +
    +
    + 194 + +
    + - + EtrogZkEVM: trueZkevm, +
    +
    + 195 + +
    + - + EtrogRollupManager: rollupManager, +
    +
    + 196 + +
    + - + Pol: polContract, +
    +
    + 197 + +
    + - + EtrogGlobalExitRootManager: globalExitRoot, +
    +
    + 198 + +
    + - + RollupID: rollupID, +
    +
    + 199 + +
    + - + SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr}, +
    +
    + 200 + +
    + - + auth: map[common.Address]bind.TransactOpts{}, +
    +
    + 201 + +
    + - + cfg: cfg,
    - + + 202 -
    +
    +
      -
    + }
    - + + 203 -
    +
    +
      -
    + err = c.AddOrReplaceAuth(*auth)
    - + + 204 -
    +
    +
      -
    + if err != nil { +
    +
    +
    +
    +
    + + + + + - - - - - - + + + - - - - - - + + + + + + + + + + + + + + + - - - - - - - - + + + - - - - - - - - - - - - + + + - - - - - + - + + - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -82384,6 +157981,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
     
    - + + 5 -
    +
    +
      -
    + "fmt"
    - + + 6 -
    +
    +
      -
    + "math/big"
    - + + 7 -
    +
    +
     
    + 8 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockpolygonrollupmanager" +
    +
    @@ -81160,1223 +156647,1333 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 9 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/mockverifier"
    - + + 10 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/pol"
    - + + 11 -
    +
    +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +
    +
    + 12 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonrollupmanager" +
    +
    + 13 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevm" +
    +
    + 14 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmbridge" +
    +
    + 15 + +
    + + + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygonzkevmglobalexitroot" +
    +
    + 16 + +
      -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/proxy"
    - + + 17 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 18 -
    +
    +
      -
    + "github.com/ethereum/go-ethereum/accounts/abi/bind"
    - + + 19 -
    +
    +
      -
    + "github.com/ethereum/go-ethereum/common"
    - + + 20 -
    +
    +
    + + + "github.com/ethereum/go-ethereum/core" +
    +
    + 21 + +
      -
    + "github.com/ethereum/go-ethereum/crypto"
    - + + 22 -
    +
    +
      -
    + "github.com/ethereum/go-ethereum/ethclient/simulated"
    - + + 23 -
    +
    +
      -
    + )
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth
    - + + 26 -
    +
    +
      -
    + // must be 1337. The address that holds the auth will have an initial balance of 10 ETH
    - + + 27 -
    +
    +
    + + + func NewSimulatedEtherman(cfg Config, auth *bind.TransactOpts, daBackend dataAvailabilityProvider, st stateProvider) (etherman *Client, ethBackend *simulated.Backend, polAddr common.Address, br *polygonzkevmbridge.Polygonzkevmbridge, err error) { +
    +
    + 28 + +
      -
    + if auth == nil {
    - + + 29 -
    +
    +
      -
    + // read only client
    - + + 30 -
    +
    +
      -
    + return &Client{}, nil, common.Address{}, nil, nil
    - + +
     
    -
    +
    + 32 + +
      -
    + // 10000000 ETH in wei
    - + + 33 -
    +
    +
      -
    + balance, _ := new(big.Int).SetString("10000000000000000000000000", 10) //nolint:gomnd
    - + + 34 -
    +
    +
      -
    + address := auth.From
    - + + 35 + +
    + + + genesisAlloc := map[common.Address]core.GenesisAccount{ +
    +
    + 36 -
    +
    +
      -
    + address: {
    - + + 37 -
    +
    +
      -
    + Balance: balance,
    - + + 38 -
    +
    +
      -
    + },
    - + + 39 -
    +
    +
      -
    + }
    - + + 40 -
    +
    +
      -
    + blockGasLimit := uint64(999999999999999999) //nolint:gomnd
    - + + 41 -
    -   -
    +
    +
    + + + // client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - + + 42 -
    +
    +
      -
    + client := simulated.NewBackend(genesisAlloc, simulated.WithBlockGasLimit(blockGasLimit))
    - + + 43 -
    +
    +
     
    - + + 44 -
    -   -
    +
    +
    + + + // DAC Setup
    - + + 45 -
    -   -
    +
    +
    + + + daAddr, _, da, err := polygondatacommittee.DeployPolygondatacommittee(auth, client.Client())
    - + + 46 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 47 -
    -   -
    +
    +
    + + + return nil, nil, common.Address{}, nil, err
    - + + 48 -
    -   -
    +
    +
    + + + }
    - + + 49 -
    -   -
    +
    +
    + + + client.Commit()
    - + + 50 -
    -   -
    +
    +
    + + + _, err = da.Initialize(auth)
    - + + 51 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 52 -
    -   -
    +
    +
    + + + return nil, nil, common.Address{}, nil, err
    - + + 53 -
    -   -
    +
    +
    + + + }
    - + + 54 -
    -   -
    +
    +
    + + + client.Commit()
    - + + 55 -
    -   -
    +
    +
    + + + _, err = da.SetupCommittee(auth, big.NewInt(0), []string{}, []byte{})
    - + + 56 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 57 -
    -   -
    +
    +
    + + + return nil, nil, common.Address{}, nil, err
    - + + 58 -
    -   -
    +
    +
    + + + }
    - + + 59 -
    -   -
    +
    +
    + + + client.Commit()
    - + + 60 -
    -   +
    +
    + +
    - + + 61 -
    +
    +
      -
    + // Deploy contracts
    - + + 62 -
    +
    +
      -
    + const polDecimalPlaces = 18
    - + + 63 -
    +
    +
      -
    + totalSupply, _ := new(big.Int).SetString("10000000000000000000000000000", 10) //nolint:gomnd
    - + +
     
    -
    +
    + 80 + +
      -
    + const posRollupManager = 4
    - + + 81 -
    +
    +
      -
    + calculatedRollupManagerAddr := crypto.CreateAddress(auth.From, nonce+posRollupManager)
    - + + 82 -
    +
    +
      -
    + genesis := common.HexToHash("0xfd3434cd8f67e59d73488a2b8da242dd1f02849ea5dd99f0ca22c836c3d5b4a9") // Random value. Needs to be different to 0x0
    - + + 83 -
    -   -
    +
    +
    + + + exitManagerAddr, _, globalExitRoot, err := polygonzkevmglobalexitroot.DeployPolygonzkevmglobalexitroot(auth, client.Client(), calculatedRollupManagerAddr, calculatedBridgeAddr)
    - + + 84 -
    +
    +
      -
    + if err != nil {
    - + + 85 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 86 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 87 -
    +
    +
      -
    + }
    - + + 88 -
    -   -
    +
    +
    + + + implementationBridgeAddr, _, _, err := polygonzkevmbridge.DeployPolygonzkevmbridge(auth, client.Client())
    - + + 89 -
    +
    +
      -
    + if err != nil {
    - + + 90 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 91 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 92 -
    +
    +
      -
    + }
    - + + 93 -
    +
    +
     
    - + + 94 -
    -   -
    +
    +
    + + + implementationMockRollupManagerAddr, _, _, err := mockpolygonrollupmanager.DeployMockpolygonrollupmanager(auth, client.Client(), exitManagerAddr, polAddr, calculatedBridgeAddr)
    - + + 95 -
    +
    +
      -
    + if err != nil {
    - + + 96 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 97 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
     
    -
    +
    + 111 + +
      -
    + return nil, nil, common.Address{}, nil, fmt.Errorf("RollupManagerAddr (%s) is different from the expected contract address (%s)",
    - + + 112 -
    +
    +
      -
    + mockRollupManagerAddr.String(), calculatedRollupManagerAddr.String())
    - + + 113 -
    +
    +
      -
    + }
    - + + 114 -
    -   -
    +
    +
    + + + initZkevmAddr, _, _, err := polygonzkevm.DeployPolygonzkevm(auth, client.Client(), exitManagerAddr, polAddr, bridgeAddr, mockRollupManagerAddr)
    - + + 115 -
    +
    +
      -
    + if err != nil {
    - + + 116 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 117 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 118 -
    +
    +
      -
    + }
    - + + 119 -
    -   -
    +
    +
    + + + mockRollupManager, err := mockpolygonrollupmanager.NewMockpolygonrollupmanager(mockRollupManagerAddr, client.Client())
    - + + 120 -
    +
    +
      -
    + if err != nil {
    - + + 121 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 122 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 123 -
    +
    +
      -
    + }
    - + + 124 -
    -   -
    +
    +
    + + + br, err = polygonzkevmbridge.NewPolygonzkevmbridge(bridgeAddr, client.Client())
    - + + 125 -
    +
    +
      -
    + if err != nil {
    - + + 126 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 127 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
     
    -
    +
    + 176 + +
      -
    + bridgeAddr.String(), calculatedBridgeAddr.String())
    - + + 177 -
    +
    +
      -
    + }
    - + + 178 -
    +
    +
     
    - + + 179 -
    -   -
    +
    +
    + + + rollupManager, err := polygonrollupmanager.NewPolygonrollupmanager(mockRollupManagerAddr, client.Client())
    - + + 180 -
    +
    +
      -
    + if err != nil {
    - + + 181 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 182 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 183 -
    +
    +
      -
    + }
    - + + 184 -
    +
    +
     
    - + + 185 -
    -   -
    +
    +
    + + + trueZkevm, err := polygonzkevm.NewPolygonzkevm(zkevmAddr, client.Client()) //nolint
    - + + 186 -
    +
    +
      -
    + if err != nil {
    - + + 187 -
    +
    +
      -
    + log.Error("error: ", err)
    - + + 188 -
    +
    +
      -
    + return nil, nil, common.Address{}, nil, err
    - + +
     
    -
    +
    + 201 + +
      -
    + return nil, nil, common.Address{}, nil, err
    - + + 202 -
    +
    +
      -
    + }
    - + + 203 -
    +
    +
     
    - + + 204 -
    -   -
    +
    +
    + + + _, err = trueZkevm.SetDataAvailabilityProtocol(auth, daAddr)
    - + + 205 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 206 -
    -   -
    +
    +
    + + + log.Error("error: ", err)
    - + + 207 -
    -   -
    +
    +
    + + + return nil, nil, common.Address{}, nil, err
    - + + 208 -
    -   -
    +
    +
    + + + }
    - + + 209 -
    +
    +
      -
    + _, err = trueZkevm.SetForceBatchAddress(auth, common.Address{})
    - + + 210 -
    +
    +
      -
    + if err != nil {
    - + + 211 -
    +
    +
      -
    + log.Error("error: ", err)
    - + +
     
    -
    +
    + 214 + +
      -
    + client.Commit()
    - + + 215 -
    +
    +
     
    - + + 216 -
    +
    +
      -
    + c := &Client{
    - + + 217 -
    -   -
    +
    +
    + + + EthClient: client.Client(),
    - + + 218 -
    -   -
    +
    +
    + + + ZkEVM: trueZkevm,
    - + + 219 -
    -   -
    +
    +
    + + + RollupManager: rollupManager,
    - + + 220 -
    -   -
    +
    +
    + + + Pol: polContract,
    - + + 221 -
    -   -
    +
    +
    + + + GlobalExitRootManager: globalExitRoot,
    - + + 222 -
    -   -
    +
    +
    + + + RollupID: rollupID,
    - + + 223 -
    -   -
    +
    +
    + + + SCAddresses: []common.Address{zkevmAddr, mockRollupManagerAddr, exitManagerAddr},
    - + + 224 -
    -   -
    +
    +
    + + + auth: map[common.Address]bind.TransactOpts{},
    - + + 225 -
    -   -
    +
    +
    + + + cfg: cfg,
    - + + 226 -
    -   -
    +
    +
    + + + da: daBackend,
    - + + 227 -
    -   -
    +
    +
    + + + state: st,
    - + + 228 -
    +
    +
      -
    + }
    - + + 229 -
    +
    +
      -
    + err = c.AddOrReplaceAuth(*auth)
    - + + 230 -
    +
    +
      -
    + if err != nil {
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/etherman/types.go + RENAMED + +
    +
    @@ -82391,2580 +158003,2651 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + + + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    -
     
    +
    @@ -19,7 +19,6 @@
    - 6 + 19
      - "errors" + VerifiedBatches []VerifiedBatch
    - 7 + 20
      - "fmt" + SequencedForceBatches [][]SequencedForceBatch
    - 8 + 21
      - "math/big" + ForkIDs []ForkID
    - 9 + + 22 +
    - + - "strings" + - + SequenceBlobs []SequenceBlobs
    - 10 + 23
      - "sync" + ReceivedAt time.Time
    - 11 + 24
      - "testing" + // GER data
    - 12 + 25
      - "time" + GlobalExitRoots, L1InfoTree []GlobalExitRoot
    -
     
    +
    @@ -50,9 +49,9 @@
    - 504 + 50
      - latest, + Nonce uint64
    - 505 + 51
      - }, + Coinbase common.Address
    - 506 + 52
      - expectedResult: nil, + // Struct used in preEtrog forks
    - 507 + + 53 +
    - + - expectedError: types.NewRPCError(types.DefaultErrorCode, "execution reverted"), + - + *preetrogpolygonzkevm.PolygonZkEVMBatchData
    - 508 + 54
      - setupMocks: func(c Config, m *mocksWrapper, testCase *testCase) { + // Struct used in Etrog
    - 509 + + 55 +
    -   - nonce := uint64(7) + - + *etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - 510 + 56
      - m.DbTx.On("Rollback", context.Background()).Return(nil).Once() + // Struct used in Elderberry
    -
     
    -
    - 5417 + 57
      - assert.ElementsMatch(t, []int{13, 14, 15}, results[4]) + *SequencedBatchElderberryData
    - 5418 + 58
      - assert.ElementsMatch(t, []int{16}, results[5]) + }
    +
    @@ -64,7 +63,7 @@
    +
    - 5419 + 64
      - } -
    -
    - 5420 - -
    - + -
    + TxHash common.Hash
    - 5421 + + 65 +
    - + - func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) { +   + Nonce uint64
    - 5422 + + 66 +
    - + - // Set up the sender +   + // Struct used in Etrog
    - 5423 + + 67 +
    - + - allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x")) + - + *etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - 5424 + + 68 +
    - + - require.NoError(t, err) +   + }
    - 5425 + + 69 +
    - + - allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1)) +   +
    - 5426 + + 70 +
    - + - require.NoError(t, err) +   + // ForcedBatch represents a ForcedBatch
    - 5427 - -
    - + -
    -
    +
    +
    @@ -93,7 +92,7 @@
    - 5428 + + 93 +
    - + - disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x")) +   + TxHash common.Hash
    - 5429 + + 94 +
    - + - require.NoError(t, err) +   + Timestamp time.Time
    - 5430 + + 95 +
    - + - disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1)) +   + Nonce uint64
    - 5431 + + 96 +
    - + - require.NoError(t, err) + - + etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData
    - 5432 + + 97 +
    - + - require.NotNil(t, disallowed) +   + }
    - 5433 + + 98 +
    - + +  
    - 5434 + + 99 +
    - + - allowedContract := common.HexToAddress("0x1") +   + // ForkID is a sturct to track the ForkID event.
    - 5435 - -
    - + - disallowedContract := common.HexToAddress("0x2") +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
     
    - 5436 + + 19 +
    - + -
    +   + VerifiedBatches []VerifiedBatch
    - 5437 + + 20 +
    - + - senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy") +   + SequencedForceBatches [][]SequencedForceBatch
    - 5438 + + 21 +
    - + - contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy") +   + ForkIDs []ForkID
    - 5439 + + -
    - + - deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy") +
    +
    +   +
    - 5440 + + 22 +
    - + -
    +   + ReceivedAt time.Time
    - 5441 + + 23 +
    - + - cfg := getSequencerDefaultConfig() +   + // GER data
    - 5442 + + 24 +
    - + - s, m, _ := newMockedServerWithCustomConfig(t, cfg) +   + GlobalExitRoots, L1InfoTree []GlobalExitRoot
    - 5443 - -
    - + - defer s.Stop() -
    +
    +
     
    - 5444 + + 49 +
    - + -
    +   + Nonce uint64
    - 5445 + + 50 +
    - + - type testCase struct { +   + Coinbase common.Address
    - 5446 + + 51 +
    - + - Name string +   + // Struct used in preEtrog forks
    - 5447 + + 52 +
    + - Input string + *oldpolygonzkevm.PolygonZkEVMBatchData
    - 5448 + + 53 +
    - + - ExpectedResult *common.Hash +   + // Struct used in Etrog
    - 5449 + + 54 +
    + - ExpectedError types.Error + *polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 5450 + + 55 +
    - + - Prepare func(t *testing.T, tc *testCase) +   + // Struct used in Elderberry
    - 5451 + + 56 +
    - + - SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase) +   + *SequencedBatchElderberryData
    - 5452 + + 57 +
    - + - } +   + }
    - 5453 - -
    - + -
    -
    +
    +
     
    - 5454 + + 63 +
    - + - testCases := []testCase{ +   + TxHash common.Hash
    - 5455 + + 64 +
    - + - { +   + Nonce uint64
    - 5456 + + 65 +
    - + - Name: "Sender & contract on allow list, accepted", +   + // Struct used in Etrog
    - 5457 + + 66 +
    + - Prepare: func(t *testing.T, tc *testCase) { + *polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 5458 + + 67 +
    - + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + }
    - 5459 + + 68 +
    - + +  
    - 5460 + + 69 +
    - + - signedTx, err := allowed.Signer(allowed.From, tx) +   + // ForcedBatch represents a ForcedBatch
    - 5461 - -
    - + - require.NoError(t, err) -
    +
    +
     
    - 5462 + + 92 +
    - + -
    +   + TxHash common.Hash
    - 5463 + + 93 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + Timestamp time.Time
    - 5464 + + 94 +
    - + - require.NoError(t, err) +   + Nonce uint64
    - 5465 + + 95 +
    + -
    + polygonzkevm.PolygonRollupBaseEtrogBatchData
    - 5466 + + 96 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + }
    - 5467 + + 97 +
    - + - require.NoError(t, err) +   +
    - 5468 + + 98 +
    - + -
    +   + // ForkID is a sturct to track the ForkID event.
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/ethtxmanager.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -59,44 +59,15 @@
    +
    - 5469 + + 59 +
    - + - tc.Input = rawTx +   + return c
    - 5470 + + 60 +
    - + - expectedHash := signedTx.Hash() +   + }
    - 5471 + + 61 +
    - + - tc.ExpectedResult = &expectedHash +   +
    - 5472 + + 62 +
    - + - tc.ExpectedError = nil + - + // getTxNonce get the nonce for the given account
    - 5473 + + 63 +
    - + - }, + - + func (c *Client) getTxNonce(ctx context.Context, from common.Address) (uint64, error) {
    - 5474 + + 64 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { + - + // Get created transactions from the database for the given account
    - 5475 + + 65 +
    - + - m.Pool. + - + createdTxs, err := c.storage.GetBySenderAndStatus(ctx, from, []MonitoredTxStatus{MonitoredTxStatusCreated}, nil)
    - 5476 + + 66 +
    - + - On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), ""). + - + if err != nil {
    - 5477 + + 67 +
    - + - Return(nil). + - + return 0, fmt.Errorf("failed to get created monitored txs: %w", err)
    - 5478 + + 68 +
    - + - Once() + - + }
    - 5479 + + 69 +
    - + - m.Pool. + - +
    - 5480 + + 70 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, allowedContract). + - + var nonce uint64
    - 5481 + + 71 +
    - + - Return(true, nil). + - + if len(createdTxs) > 0 {
    - 5482 + + 72 +
    - + - Once() + - + // if there are pending txs, we adjust the nonce accordingly
    - 5483 + + 73 +
    - + - m.Pool. + - + for _, createdTx := range createdTxs {
    - 5484 + + 74 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, allowed.From). + - + if createdTx.nonce > nonce {
    - 5485 + + 75 +
    - + - Return(true, nil). + - + nonce = createdTx.nonce
    - 5486 + + 76 +
    - + - Once() + - + }
    - 5487 + + 77 +
    - + - }, + - + }
    - 5488 + + 78 +
    - + - }, + - +
    - 5489 + + 79 +
    - + - { + - + nonce++
    - 5490 + + 80 +
    - + - Name: "Contract not on allow list, rejected", + - + } else {
    - 5491 + + 81 +
    - + - Prepare: func(t *testing.T, tc *testCase) { + - + // if there are no pending txs, we get the pending nonce from the etherman
    - 5492 + + 82 +
    - + - tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) + - + if nonce, err = c.etherman.PendingNonce(ctx, from); err != nil {
    - 5493 + + 83 +
    - + -
    + - + return 0, fmt.Errorf("failed to get pending nonce: %w", err)
    - 5494 + + 84 +
    - + - signedTx, err := allowed.Signer(allowed.From, tx) + - + }
    - 5495 + + 85 +
    - + - require.NoError(t, err) + - + }
    - 5496 + + 86 +
    - + + -
    - 5497 + + 87 +
    - + - txBinary, err := signedTx.MarshalBinary() + - + return nonce, nil
    - 5498 + + 88 +
    - + - require.NoError(t, err) + - + }
    - 5499 + + 89 +
    - + + -
    - 5500 + + 90 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + // Add a transaction to be sent and monitored
    - 5501 + + 91 +
    - + - require.NoError(t, err) +   + func (c *Client) Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error {
    - 5502 + + 92 +
    - + -
    + - + // get nonce
    - 5503 + + 93 +
    - + - tc.Input = rawTx + - + nonce, err := c.getTxNonce(ctx, from)
    - 5504 + + 94 +
    - + - tc.ExpectedResult = nil +   + if err != nil {
    - 5505 + + 95 +
    - + - tc.ExpectedError = contractDenied + - + err := fmt.Errorf("failed to get nonce: %w", err)
    - 5506 + + 96 +
    - + - }, +   + log.Errorf(err.Error())
    - 5507 + + 97 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + return err
    - 5508 + + 98 +
    - + - m.Pool. +   + }
    - 5509 + + 99 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract). + - +
    - 5510 + + 100 +
    - + - Return(false, contractDenied). +   + // get gas
    - 5511 + + 101 +
    - + - Once() +   + gas, err := c.etherman.EstimateGas(ctx, from, to, value, data)
    - 5512 + + 102 +
    - + - }, +   + if err != nil {
    - 5513 + +
    @@ -594,7 +565,7 @@
    +
    + 594 +
    - + - }, +   + // causing possible side effects and wasting resources.
    - 5514 + + 595 +
    - + - { +   + func (c *Client) reviewMonitoredTxNonce(ctx context.Context, mTx *monitoredTx, mTxLogger *log.Logger) error {
    - 5515 + + 596 +
    - + - Name: "Sender not on allow list, rejected", +   + mTxLogger.Debug("reviewing nonce")
    - 5516 + + 597 +
    - + - Prepare: func(t *testing.T, tc *testCase) { + - + nonce, err := c.getTxNonce(ctx, mTx.from)
    - 5517 + + 598 +
    - + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + if err != nil {
    - 5518 + + 599 +
    - + -
    +   + err := fmt.Errorf("failed to load current nonce for acc %v: %w", mTx.from.String(), err)
    - 5519 + + 600 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + mTxLogger.Errorf(err.Error()) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - 5520 + + 59 +
    - + - require.NoError(t, err) +   + return c
    - 5521 + + 60 +
    - + -
    +   + }
    - 5522 + + 61 +
    - + - txBinary, err := signedTx.MarshalBinary() +   +
    - 5523 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 5524 + + -
    - + +
    +
    +  
    - 5525 + + -
    - + - rawTx := hex.EncodeToHex(txBinary) +
    +
    +   +
    - 5526 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 5527 + + -
    - + +
    +
    +  
    - 5528 + + -
    - + - tc.Input = rawTx +
    +
    +   +
    - 5529 + + -
    - + - tc.ExpectedResult = nil +
    +
    +   +
    - 5530 + + -
    - + - tc.ExpectedError = senderDenied +
    +
    +   +
    - 5531 + + -
    - + - }, +
    +
    +   +
    - 5532 + + -
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +
    +
    +   +
    - 5533 + + -
    - + - m.Pool. +
    +
    +   +
    - 5534 + + -
    - + - On("CheckPolicy", context.Background(), pool.SendTx, allowedContract). +
    +
    +   +
    - 5535 + + -
    - + - Return(true, nil). +
    +
    +   +
    - 5536 + + -
    - + - Once() +
    +
    +   +
    - 5537 + + -
    - + - m.Pool. +
    +
    +   +
    - 5538 + + -
    - + - On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From). +
    +
    +   +
    - 5539 + + -
    - + - Return(false, senderDenied). +
    +
    +   +
    - 5540 + + -
    - + - Once() +
    +
    +   +
    - 5541 + + -
    - + - }, +
    +
    +   +
    - 5542 + + -
    - + - }, +
    +
    +   +
    - 5543 + + -
    - + - { +
    +
    +   +
    - 5544 + + -
    - + - Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility +
    +
    +   +
    - 5545 + + -
    - + - Prepare: func(t *testing.T, tc *testCase) { +
    +
    +   +
    - 5546 + + -
    - + - tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +
    +
    +   +
    - 5547 + + -
    - + +
    +
    +  
    - 5548 + + -
    - + - txBinary, err := tx.MarshalBinary() +
    +
    +   +
    - 5549 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 5550 + + -
    - + +
    +
    +  
    - 5551 + + 62 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + // Add a transaction to be sent and monitored
    - 5552 + + 63 +
    - + - require.NoError(t, err) +   + func (c *Client) Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error {
    - 5553 + + 64 +
    + -
    + // get next nonce
    - 5554 + + 65 +
    + - tc.Input = rawTx + nonce, err := c.etherman.CurrentNonce(ctx, from)
    - 5555 + + 66 +
    - + - expectedHash := tx.Hash() +   + if err != nil {
    - 5556 + + 67 +
    + - tc.ExpectedResult = &expectedHash + err := fmt.Errorf("failed to get current nonce: %w", err)
    - 5557 + + 68 +
    - + - tc.ExpectedError = nil +   + log.Errorf(err.Error())
    - 5558 + + 69 +
    - + - }, +   + return err
    - 5559 + + 70 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + }
    - 5560 + + -
    - + - m.Pool. +
    +
    +   +
    - 5561 + + 71 +
    - + - On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), ""). +   + // get gas
    - 5562 + + 72 +
    - + - Return(nil). +   + gas, err := c.etherman.EstimateGas(ctx, from, to, value, data)
    - 5563 + + 73 +
    - + - Once() +   + if err != nil {
    - 5564 + +
     
    +
    + 565 +
    - + - // policy does not reject this case for backward compat +   + // causing possible side effects and wasting resources.
    - 5565 + + 566 +
    - + - }, +   + func (c *Client) reviewMonitoredTxNonce(ctx context.Context, mTx *monitoredTx, mTxLogger *log.Logger) error {
    - 5566 + + 567 +
    - + - }, +   + mTxLogger.Debug("reviewing nonce")
    - 5567 + + 568 +
    + - { + nonce, err := c.etherman.CurrentNonce(ctx, mTx.from)
    - 5568 + + 569 +
    - + - Name: "Unsigned tx with disallowed contract, rejected", +   + if err != nil {
    - 5569 + + 570 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + err := fmt.Errorf("failed to load current nonce for acc %v: %w", mTx.from.String(), err)
    - 5570 + + 571 +
    - + - tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + mTxLogger.Errorf(err.Error()) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/ethtxmanager_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -47,7 +47,7 @@
    - 5571 + + 47 +
    - + +  
    - 5572 + + 48 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + currentNonce := uint64(1)
    - 5573 + + 49 +
    - + - require.NoError(t, err) +   + etherman.
    - 5574 + + 50 +
    - + -
    + - + On("PendingNonce", ctx, from).
    - 5575 + + 51 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + Return(currentNonce, nil).
    - 5576 + + 52 +
    - + - require.NoError(t, err) +   + Once()
    - 5577 + + 53 +
    - + +  
    - 5578 + +
    @@ -165,7 +165,7 @@
    +
    + 165 +
    - + - rawTx := hex.EncodeToHex(txBinary) +   + // Add
    - 5579 + + 166 +
    - + - require.NoError(t, err) +   + currentNonce := uint64(1)
    - 5580 + + 167 +
    - + -
    +   + etherman.
    - 5581 + + 168 +
    - + - tc.Input = rawTx + - + On("PendingNonce", ctx, from).
    - 5582 + + 169 +
    - + - tc.ExpectedResult = nil +   + Return(currentNonce, nil).
    - 5583 + + 170 +
    - + - tc.ExpectedError = contractDenied +   + Once()
    - 5584 + + 171 +
    - + - }, +   +
    - 5585 + +
    @@ -331,7 +331,7 @@
    +
    + 331 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   + // Add
    - 5586 + + 332 +
    - + - m.Pool. +   + currentNonce := uint64(1)
    - 5587 + + 333 +
    - + - On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract). +   + etherman.
    - 5588 + + 334 +
    - + - Return(false, contractDenied). + - + On("PendingNonce", ctx, from).
    - 5589 + + 335 +
    - + - Once() +   + Return(currentNonce, nil).
    - 5590 + + 336 +
    - + - }, +   + Once()
    - 5591 + + 337 +
    - + - }, +   +
    - 5592 + +
    @@ -521,7 +521,7 @@
    +
    + 521 +
    - + - { +   + // Add
    - 5593 + + 522 +
    - + - Name: "Send invalid tx input", // for backward compatibility +   + currentNonce := uint64(1)
    - 5594 + + 523 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + etherman.
    - 5595 + + 524 +
    - + - tc.Input = "0x1234" + - + On("PendingNonce", ctx, from).
    - 5596 + + 525 +
    - + - tc.ExpectedResult = nil +   + Return(currentNonce, nil).
    - 5597 + + 526 +
    - + - tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input") +   + Once()
    - 5598 + + 527 +
    - + - }, +   +
    - 5599 + +
    @@ -593,7 +593,7 @@
    +
    + 593 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {}, +   +
    - 5600 + + 594 +
    - + - }, +   + currentNonce = uint64(2)
    - 5601 + + 595 +
    - + - { +   + etherman.
    - 5602 + + 596 +
    - + - Name: "Sender not on deploy allow list, rejected", + - + On("PendingNonce", ctx, from).
    - 5603 + + 597 +
    - + - Prepare: func(t *testing.T, tc *testCase) { +   + Return(currentNonce, nil).
    - 5604 + + 598 +
    - + - deployAddr := common.HexToAddress("0x0") +   + Once()
    - 5605 + + 599 +
    - + - tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{}) +   + secondGasEstimation := uint64(2)
    - 5606 + +
    @@ -751,7 +751,7 @@
    +
    + 751 +
    - + +  
    - 5607 + + 752 +
    - + - signedTx, err := disallowed.Signer(disallowed.From, tx) +   + currentNonce := uint64(1)
    - 5608 + + 753 +
    - + - require.NoError(t, err) +   + etherman.
    - 5609 + + 754 +
    - + -
    + - + On("PendingNonce", ctx, from).
    - 5610 + + 755 +
    - + - txBinary, err := signedTx.MarshalBinary() +   + Return(currentNonce, nil).
    - 5611 + + 756 +
    - + - require.NoError(t, err) +   + Once()
    - 5612 + + 757 +
    - + +  
    - 5613 - -
    - + - rawTx := hex.EncodeToHex(txBinary) -
    +
    +
    @@ -832,7 +832,7 @@
    - 5614 + + 832 +
    - + - require.NoError(t, err) +   +
    - 5615 + + 833 +
    - + -
    +   + currentNonce := uint64(1)
    - 5616 + + 834 +
    - + - tc.Input = rawTx +   + etherman.
    - 5617 + + 835 +
    - + - tc.ExpectedResult = nil + - + On("PendingNonce", ctx, from).
    - 5618 + + 836 +
    - + - tc.ExpectedError = deployDenied +   + Return(currentNonce, nil).
    - 5619 + + 837 +
    - + - }, +   + Once()
    - 5620 + + 838 +
    - + - SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) { +   +
    - 5621 + +
    @@ -886,7 +886,7 @@
    +
    + 886 +
    - + - m.Pool. +   +
    - 5622 + + 887 +
    - + - On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From). +   + currentNonce := uint64(1)
    - 5623 + + 888 +
    - + - Return(false, nil). +   + etherman.
    - 5624 + + 889 +
    - + - Once() + - + On("PendingNonce", ctx, from).
    - 5625 + + 890 +
    - + - }, +   + Return(currentNonce, nil).
    - 5626 + + 891 +
    - + - }, +   + Once()
    - 5627 + + 892 +
    - + - } +   +
    +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - -
    +
     
    - 5628 + + 47 +
    - + +  
    - 5629 + + 48 +
    - + - for _, testCase := range testCases { +   + currentNonce := uint64(1)
    - 5630 + + 49 +
    - + - t.Run(testCase.Name, func(t *testing.T) { +   + etherman.
    - 5631 + + 50 +
    + - tc := testCase + On("CurrentNonce", ctx, from).
    - 5632 + + 51 +
    - + - tc.Prepare(t, &tc) +   + Return(currentNonce, nil).
    - 5633 + + 52 +
    - + - tc.SetupMocks(t, m, tc) +   + Once()
    - 5634 + + 53 +
    - + +  
    - 5635 - -
    - + - res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input) -
    +
    +
     
    - 5636 + + 165 +
    - + - require.NoError(t, err) +   + // Add
    - 5637 + + 166 +
    - + -
    +   + currentNonce := uint64(1)
    - 5638 + + 167 +
    - + - assert.Equal(t, float64(1), res.ID) +   + etherman.
    - 5639 + + 168 +
    + - assert.Equal(t, "2.0", res.JSONRPC) + On("CurrentNonce", ctx, from).
    - 5640 + + 169 +
    - + -
    +   + Return(currentNonce, nil).
    - 5641 + + 170 +
    - + - if res.Result != nil || tc.ExpectedResult != nil { +   + Once()
    - 5642 + + 171 +
    - + - var result common.Hash +   +
    - 5643 + +
     
    +
    + 331 +
    - + - err = json.Unmarshal(res.Result, &result) +   + // Add
    - 5644 + + 332 +
    - + - require.NoError(t, err) +   + currentNonce := uint64(1)
    - 5645 + + 333 +
    - + - assert.Equal(t, *tc.ExpectedResult, result) +   + etherman.
    - 5646 + + 334 +
    + - } + On("CurrentNonce", ctx, from).
    - 5647 + + 335 +
    - + - if res.Error != nil || tc.ExpectedError != nil { +   + Return(currentNonce, nil).
    - 5648 + + 336 +
    - + - assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code) +   + Once()
    - 5649 + + 337 +
    - + - assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message) +   +
    - 5650 + +
     
    +
    + 521 +
    - + - } +   + // Add
    - 5651 + + 522 +
    - + - }) +   + currentNonce := uint64(1)
    - 5652 + + 523 +
    - + - } +   + etherman.
    - 5653 + + 524 +
    + - } -
    -
    -
    + On("CurrentNonce", ctx, from).
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go - RENAMED - -
    -
    -
    -
    - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
    @@ -204,6 +204,53 @@
    - 204 + 525
      - }) + Return(currentNonce, nil).
    - 205 + 526
      - } + Once()
    - 206 + 527
    @@ -84973,463 +160656,521 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    +
    +
     
    - + + 593 -
    +
    +
     
    - + + 594 -
    +
    +
      -
    + currentNonce = uint64(2)
    - + + 595 -
    +
    +
      -
    + etherman.
    - + + 596 -
    -   -
    +
    +
    + + + On("CurrentNonce", ctx, from).
    - + + 597 -
    +
    +
      -
    + Return(currentNonce, nil).
    - + + 598 -
    +
    +
      -
    + Once()
    - + + 599 -
    +
    +
      -
    + secondGasEstimation := uint64(2)
    - + +
     
    -
    +
    + 751 + +
     
    - + + 752 -
    +
    +
      -
    + currentNonce := uint64(1)
    - + + 753 -
    +
    +
      -
    + etherman.
    - + + 754 -
    -   -
    +
    +
    + + + On("CurrentNonce", ctx, from).
    - + + 755 -
    +
    +
      -
    + Return(currentNonce, nil).
    - + + 756 -
    +
    +
      -
    + Once()
    - + + 757 -
    +
    +
     
    - + +
     
    -
    +
    + 832 + +
     
    - + + 833 -
    +
    +
      -
    + currentNonce := uint64(1)
    - + + 834 -
    +
    +
      -
    + etherman.
    - + + 835 -
    -   -
    +
    +
    + + + On("CurrentNonce", ctx, from).
    - + + 836 -
    +
    +
      -
    + Return(currentNonce, nil).
    - + + 837 -
    +
    +
      -
    + Once()
    - + + 838 -
    +
    +
     
    - + +
     
    -
    +
    + 886 + +
     
    - + + 887 -
    +
    +
      -
    + currentNonce := uint64(1)
    - + + 888 -
    +
    +
      -
    + etherman.
    - + + 889 -
    -   -
    +
    +
    + + + On("CurrentNonce", ctx, from).
    - + + 890 -
    +
    +
      -
    + Return(currentNonce, nil).
    - + + 891 -
    +
    +
      -
    + Once()
    - + + 892 -
    +
    +
     
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -16,7 +16,6 @@
    +
    - + + 16 -
    +
    +
      -
    + GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
    - + + 17 -
    +
    +
      -
    + WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
    - + + 18 -
    +
    +
      -
    + SendTx(ctx context.Context, tx *types.Transaction) error
    - + + 19 -
    -   -
    +
    +
    + - + PendingNonce(ctx context.Context, account common.Address) (uint64, error)
    - + + 20 -
    +
    +
      -
    + CurrentNonce(ctx context.Context, account common.Address) (uint64, error)
    - + + 21 -
    +
    +
      -
    + SuggestedGasPrice(ctx context.Context) (*big.Int, error)
    - + + 22 -
    +
    +
      -
    + EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte) (uint64, error)
    - + +
    @@ -29,7 +28,6 @@
    -
    +
    + 29 + +
      -
    + Add(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error
    - + + 30 -
    +
    +
      -
    + Get(ctx context.Context, owner, id string, dbTx pgx.Tx) (monitoredTx, error)
    - + + 31 -
    +
    +
      -
    + GetByStatus(ctx context.Context, owner *string, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error)
    - + + 32 -
    -   -
    +
    +
    + - + GetBySenderAndStatus(ctx context.Context, sender common.Address, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error)
    - + + 33 -
    +
    +
      -
    + GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error)
    - + + 34 -
    +
    +
      -
    + Update(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error
    - + + 35 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -85444,107 +161185,107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -85552,6 +161293,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
     
    - + + 16 -
    +
    +
      -
    + GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
    - + + 17 -
    +
    +
      -
    + WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
    - + + 18 -
    +
    +
      -
    + SendTx(ctx context.Context, tx *types.Transaction) error
    - 207 + 19
      - // GetFullBlockByNumber returns information about a block by block number + CurrentNonce(ctx context.Context, account common.Address) (uint64, error)
    - 208 + 20
      - func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { + SuggestedGasPrice(ctx context.Context) (*big.Int, error)
    - 209 + 21
      - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { + EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte) (uint64, error)
    -
    @@ -516,7 +563,7 @@
    +
     
    - 516 + 28
      -
    + Add(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error
    - 517 + 29
      - if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice + Get(ctx context.Context, owner, id string, dbTx pgx.Tx) (monitoredTx, error)
    - 518 + 30
      - // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice + GetByStatus(ctx context.Context, owner *string, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error)
    - 519 + + -
    - - - txEGPPct, err = z.pool.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP) +
    +
    +   +
    - 520 + 31
      - if err != nil { + GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error)
    - 521 + 32
      - return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false) + Update(ctx context.Context, mTx monitoredTx, dbTx pgx.Tx) error
    - 522 + 33
      - } + }
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/pgstorage.go + RENAMED + +
    +
    @@ -85559,21 +161315,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -123,50 +123,6 @@
    - 204 + 123
      - }) + return mTxs, nil
    - 205 + 124
    @@ -85583,7 +161339,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 206 + 125
    @@ -85592,637 +161348,637 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 207 + + 126 +
    - + - type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) + - + // GetBySenderAndStatus loads all monitored txs of the given sender that match the provided status
    - 208 + + 127 +
    - + -
    + - + func (s *PostgresStorage) GetBySenderAndStatus(ctx context.Context, sender common.Address, statuses []MonitoredTxStatus, dbTx pgx.Tx) ([]monitoredTx, error) {
    - 209 + + 128 +
    - + - // GetBatchDataByNumbers returns L2 batch data by batch numbers. + - + hasStatusToFilter := len(statuses) > 0
    - 210 + + 129 +
    - + - func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) { + - +
    - 211 + + 130 +
    - + - return z.getBatchData(filter, z.state.GetBatchL2DataByNumbers) + - + conn := s.dbConn(dbTx)
    - 212 + + 131 +
    - + - } + - + cmd := `
    - 213 + + 132 +
    - + -
    + - + SELECT owner, id, from_addr, to_addr, nonce, value, data, gas, gas_offset, gas_price, status, block_num, history, created_at, updated_at
    - 214 + + 133 +
    - + - // GetForcedBatchDataByNumbers returns forced batch data by batch numbers. + - + FROM state.monitored_txs
    - 215 + + 134 +
    - + - func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) { + - + WHERE from_addr = $1`
    - 216 + + 135 +
    - + - return z.getBatchData(filter, z.state.GetForcedBatchDataByNumbers) + - + if hasStatusToFilter {
    - 217 + + 136 +
    - + - } + - + cmd += `
    - 218 + + 137 +
    - + -
    + - + AND status = ANY($2)`
    - 219 + + 138 +
    - + - func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) (interface{}, types.Error) { + - + }
    - 220 + + 139 +
    - + - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { + - + cmd += `
    - 221 + + 140 +
    - + - batchNumbers := make([]uint64, 0, len(filter.Numbers)) + - + ORDER BY created_at`
    - 222 + + 141 +
    - + - for _, bn := range filter.Numbers { + - +
    - 223 + + 142 +
    - + - n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx) + - + mTxs := []monitoredTx{}
    - 224 + + 143 +
    - + - if rpcErr != nil { + - +
    - 225 + + 144 +
    - + - return nil, rpcErr + - + var rows pgx.Rows
    - 226 + + 145 +
    - + - } + - + var err error
    - 227 + + 146 +
    - + - batchNumbers = append(batchNumbers, n) + - + if hasStatusToFilter {
    - 228 + + 147 +
    - + - } + - + rows, err = conn.Query(ctx, cmd, sender.String(), statuses)
    - 229 + + 148 +
    - + -
    + - + } else {
    - 230 + + 149 +
    - + - batchesData, err := f(ctx, batchNumbers, dbTx) + - + rows, err = conn.Query(ctx, cmd, sender.String())
    - 231 + + 150 +
    - + - if errors.Is(err, state.ErrNotFound) { + - + }
    - 232 + + 151 +
    - + - return nil, nil + - +
    - 233 + + 152 +
    - + - } else if err != nil { + - + if errors.Is(err, pgx.ErrNoRows) {
    - 234 + + 153 +
    - + - return RPCErrorResponse(types.DefaultErrorCode, + - + return []monitoredTx{}, nil
    - 235 + + 154 +
    - + - fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true) + - + } else if err != nil {
    - 236 + + 155 +
    - + - } + - + return nil, err
    - 237 + + 156 +
    - + -
    + - + }
    - 238 + + 157 +
    - + - ret := make([]*types.BatchData, 0, len(batchNumbers)) + - +
    - 239 + + 158 +
    - + - for _, n := range batchNumbers { + - + for rows.Next() {
    - 240 + + 159 +
    - + - data := &types.BatchData{Number: types.ArgUint64(n)} + - + mTx := monitoredTx{}
    - 241 + + 160 +
    - + - if b, ok := batchesData[n]; ok { + - + err := s.scanMtx(rows, &mTx)
    - 242 + + 161 +
    - + - data.BatchL2Data = b + - + if err != nil {
    - 243 + + 162 +
    - + - data.Empty = false + - + return nil, err
    - 244 + + 163 +
    - + - } else { + - + }
    - 245 + + 164 +
    - + - data.Empty = true + - + mTxs = append(mTxs, mTx)
    - 246 + + 165 +
    - + - } + - + }
    - 247 + + 166 +
    - + - ret = append(ret, data) + - +
    - 248 + + 167 +
    - + - } + - + return mTxs, nil
    - 249 + + 168 +
    - + -
    + - + }
    - 250 + + 169 +
    - + - return types.BatchDataResult{Data: ret}, nil + - +
    - 251 + + 170 +
    - + - }) +   + // GetByBlock loads all monitored tx that have the blockNumber between
    - 252 + + 171 +
    - + - } +   + // fromBlock and toBlock
    - 253 + + 172 +
    - + -
    +   + func (s *PostgresStorage) GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error) { +
    +
    +
    +
    +
    + + + + + - - + - - - - - - - - - - - - - - - - -
    +
     
    - 254 + 123
      - // GetFullBlockByNumber returns information about a block by block number + return mTxs, nil
    - 255 + 124
      - func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) { + }
    - 256 + 125
      - return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { +
    -
     
    +
    + + +
    +   +
    +
    - 563 + + -
    +
    +
     
    - 564 + + -
    +
    +
      - if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice +
    - 565 + + -
    +
    +
      - // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice +
    - 566 + + -
    - + - txEGPPct, err = state.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP) +
    +
    +   +
    - 567 + + -
    +
    +
      - if err != nil { +
    - 568 + + -
    +
    +
      - return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false) +
    - 569 + + -
    +
    +
      - } +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -86515,11 +162271,86 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + + + + + + + + + + + + + + + +
    -
    @@ -2705,3 +2705,32 @@
    - 2705 + + -
    +
    +
      - }) +
    - 2706 + + -
    +
    +
      - } +
    - 2707 + + -
    +
    +
      - } +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 126 + +
    +   + // GetByBlock loads all monitored tx that have the blockNumber between +
    +
    + 127 + +
    +   + // fromBlock and toBlock +
    +
    + 128 + +
    +   + func (s *PostgresStorage) GetByBlock(ctx context.Context, fromBlock, toBlock *uint64, dbTx pgx.Tx) ([]monitoredTx, error) { +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/ethtxmanager/pgstorage_test.go + RENAMED + +
    +
    @@ -86527,473 +162358,768 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -163,72 +163,6 @@
    - 2705 + 163
      - }) + assert.Equal(t, "confirmed2", mTxs[7].id)
    - 2706 + 164
      - } + }
    - 2707 + 165
      - } +
    - 2708 + + 166 + +
    + - + func TestAddAndGetBySenderAndStatus(t *testing.T) { +
    +
    + 167 + +
    + - + dbCfg := dbutils.NewStateConfigFromEnv() +
    +
    + 168 + +
    + - + require.NoError(t, dbutils.InitOrResetState(dbCfg)) +
    +
    + 169 + +
    + - +
    +
    +
    + 170 + +
    + - + storage, err := NewPostgresStorage(dbCfg) +
    +
    + 171 + +
    + - + require.NoError(t, err) +
    +
    + 172 + +
    + - +
    +
    +
    + 173 + +
    + - + from := common.HexToAddress("0x1") +
    +
    + 174 + +
    + - + to := common.HexToAddress("0x2") +
    +
    + 175 + +
    + - + baseMtx := monitoredTx{ +
    +
    + 176 + +
    + - + owner: "owner", from: common.HexToAddress("0x1"), to: &to, nonce: uint64(1), value: big.NewInt(2), data: []byte("data"), blockNumber: big.NewInt(1), +
    +
    + 177 + +
    + - + gas: uint64(3), gasPrice: big.NewInt(4), history: map[common.Hash]bool{common.HexToHash("0x3"): true, common.HexToHash("0x4"): true}, +
    +
    + 178 + +
    + - + } +
    +
    + 179 + +
    + - +
    +
    +
    + 180 + +
    + - + type mTxReplaceInfo struct { +
    +
    + 181 + +
    + - + id string +
    +
    + 182 + +
    + - + status MonitoredTxStatus +
    +
    + 183 + +
    + - + } +
    +
    + 184 + +
    + - +
    +
    +
    + 185 + +
    + - + mTxsReplaceInfo := []mTxReplaceInfo{ +
    +
    + 186 + +
    + - + {id: "created1", status: MonitoredTxStatusCreated}, +
    +
    + 187 + +
    + - + {id: "sent1", status: MonitoredTxStatusSent}, +
    +
    + 188 + +
    + - + {id: "failed1", status: MonitoredTxStatusFailed}, +
    +
    + 189 + +
    + - + {id: "confirmed1", status: MonitoredTxStatusConfirmed}, +
    +
    + 190 + +
    + - + {id: "created2", status: MonitoredTxStatusCreated}, +
    +
    + 191 + +
    + - + {id: "sent2", status: MonitoredTxStatusSent}, +
    +
    + 192 + +
    + - + {id: "failed2", status: MonitoredTxStatusFailed}, +
    +
    + 193 + +
    + - + {id: "confirmed2", status: MonitoredTxStatusConfirmed}, +
    +
    + 194 + +
    + - + } +
    +
    + 195 + +
    + - +
    +
    +
    + 196 + +
    + - + for _, replaceInfo := range mTxsReplaceInfo { +
    +
    + 197 + +
    + - + baseMtx.id = replaceInfo.id +
    +
    + 198 +
    - + -
    + - + baseMtx.status = replaceInfo.status
    - 2709 + + 199 +
    - + - func TestClient_BatchesByNumbers(t *testing.T) { + - + baseMtx.createdAt = baseMtx.createdAt.Add(time.Microsecond)
    - 2710 + + 200 +
    - + - const batchesCount = 6 + - + baseMtx.updatedAt = baseMtx.updatedAt.Add(time.Microsecond)
    - 2711 + + 201 +
    - + -
    + - + err = storage.Add(context.Background(), baseMtx, nil)
    - 2712 + + 202 +
    - + - s, m, _ := newSequencerMockedServer(t) + - + require.NoError(t, err)
    - 2713 + + 203 +
    - + - defer s.Stop() + - + }
    - 2714 + + 204 +
    - + + -
    - 2715 + + 205 +
    - + - batchesDataMap := make(map[uint64][]byte, batchesCount) + - + mTxs, err := storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{MonitoredTxStatusConfirmed}, nil)
    - 2716 + + 206 +
    - + - for i := 0; i < batchesCount; i++ { + - + require.NoError(t, err)
    - 2717 + + 207 +
    - + - batchesDataMap[uint64(i+1)] = []byte(fmt.Sprintf("batch %d data", i+1)) + - + assert.Equal(t, 2, len(mTxs))
    - 2718 + + 208 +
    - + - } + - + assert.Equal(t, "confirmed1", mTxs[0].id)
    - 2719 + + 209 +
    - + -
    + - + assert.Equal(t, "confirmed2", mTxs[1].id)
    - 2720 + + 210 +
    - + - m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything). + - +
    - 2721 + + 211 +
    - + - Return(batchesDataMap, nil).Once() + - + mTxs, err = storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{MonitoredTxStatusSent, MonitoredTxStatusCreated}, nil)
    - 2722 + + 212 +
    - + -
    + - + require.NoError(t, err)
    - 2723 + + 213 +
    - + - m.State.On("BeginStateTransaction", context.Background()). + - + assert.Equal(t, 4, len(mTxs))
    - 2724 + + 214 +
    - + - Return(m.DbTx, nil).Once() + - + assert.Equal(t, "created1", mTxs[0].id)
    - 2725 + + 215 +
    - + -
    + - + assert.Equal(t, "sent1", mTxs[1].id)
    - 2726 + + 216 +
    - + - m.DbTx.On("Commit", context.Background()).Return(nil).Once() + - + assert.Equal(t, "created2", mTxs[2].id)
    - 2727 + + 217 +
    - + -
    + - + assert.Equal(t, "sent2", mTxs[3].id)
    - 2728 + + 218 +
    - + - zkEVMClient := client.NewClient(s.ServerURL) + - +
    - 2729 + + 219 +
    - + - reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)} + - + mTxs, err = storage.GetBySenderAndStatus(context.Background(), from, []MonitoredTxStatus{}, nil)
    - 2730 + + 220 +
    - + - result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum) + - + require.NoError(t, err)
    - 2731 + + 221 +
    - + - require.NoError(t, err) + - + assert.Equal(t, 8, len(mTxs))
    - 2732 + + 222 +
    - + - require.Len(t, result, len(reqBatchesNum)) + - + assert.Equal(t, "created1", mTxs[0].id)
    - 2733 + + 223 +
    - + - for i, batchNum := range reqBatchesNum { + - + assert.Equal(t, "sent1", mTxs[1].id)
    - 2734 + + 224 +
    - + - require.Equal(t, hex.EncodeToHex(batchesDataMap[batchNum.Uint64()]), result[i].BatchL2Data.Hex()) + - + assert.Equal(t, "failed1", mTxs[2].id)
    - 2735 + + 225 +
    - + - } + - + assert.Equal(t, "confirmed1", mTxs[3].id)
    - 2736 + + 226 +
    - + - } -
    -
    -
    + - + assert.Equal(t, "created2", mTxs[4].id)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -0,0 +1,61 @@
    - + + 227 -
    -   -
    +
    +
    + - + assert.Equal(t, "sent2", mTxs[5].id)
    - + + 228 -
    -   -
    +
    +
    + - + assert.Equal(t, "failed2", mTxs[6].id)
    - + + 229 -
    -   -
    +
    +
    + - + assert.Equal(t, "confirmed2", mTxs[7].id)
    - + + 230 -
    -   -
    +
    +
    + - + }
    - + + 231 -
    -   +
    +
    + -
    - + + 232 -
    +
    +
      -
    + func TestAddRepeated(t *testing.T) {
    - + + 233 -
    +
    +
      -
    + dbCfg := dbutils.NewStateConfigFromEnv()
    - + + 234 -
    +
    +
      -
    + require.NoError(t, dbutils.InitOrResetState(dbCfg))
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - -
    +
     
    - + + 163 -
    +
    +
      -
    + assert.Equal(t, "confirmed2", mTxs[7].id)
    - + + 164 -
    +
    +
      -
    + }
    - + + 165 -
    +
    +
     
    @@ -87488,687 +163614,64 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - package jsonrpc -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + -
    -
    -
    - 6 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" -
    -
    - 7 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/pool" -
    -
    - 8 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 9 - -
    - + - "github.com/ethereum/go-ethereum/common" -
    -
    - 10 - -
    - + - ethTypes "github.com/ethereum/go-ethereum/core/types" -
    -
    - 11 - -
    - + - ) -
    -
    - 12 - -
    - + -
    -
    -
    - 13 - -
    - + - func checkPolicy(ctx context.Context, p types.PoolInterface, input string) error { -
    -
    - 14 - -
    - + - tx, err := hexToTx(input) -
    -
    - 15 - -
    - + - if err != nil { -
    -
    - 16 - -
    - + - // ignore it, let the later processing reject -
    -
    - 17 - -
    - + - return nil -
    -
    - 18 - -
    - + - } -
    -
    - 19 - -
    - + -
    -
    -
    - 20 - -
    - + - // if the tx is signed, check the from address. If there is no from address, the tx is not rejected as it -
    -
    - 21 - -
    - + - // will get rejected later. This maintains backward compatibility with RPC expectations. TODO: verify this is ok behavior -
    -
    - 22 - -
    - + - var from common.Address -
    -
    - 23 - -
    - + - if from, err = state.GetSender(*tx); err != nil { -
    -
    - 24 - -
    - + - // if not signed, then skip check, it fails later on its own -
    -
    - 25 - -
    - + - return nil -
    -
    - 26 - -
    - + - } -
    -
    - 27 - -
    - + -
    -
    -
    - 28 - -
    - + - switch resolvePolicy(tx) { -
    -
    - 29 - -
    - + - case pool.SendTx: -
    -
    - 30 - -
    - + - var allow bool -
    -
    - 31 - -
    - + - if allow, err = p.CheckPolicy(ctx, pool.SendTx, *tx.To()); err != nil { -
    -
    - 32 - -
    - + - return err -
    -
    - 33 - -
    - + - } -
    -
    - 34 - -
    - + - if !allow { -
    -
    - 35 - -
    - + - return pool.ErrContractDisallowedSendTx -
    -
    - 36 - -
    - + - } -
    -
    - 37 - -
    - + - if allow, err = p.CheckPolicy(ctx, pool.SendTx, from); err != nil { -
    -
    - 38 - -
    - + - return err -
    -
    - 39 - -
    - + - } -
    -
    - 40 - -
    - + - if !allow { -
    -
    - 41 - -
    - + - return pool.ErrSenderDisallowedSendTx -
    -
    - 42 - -
    - + - } -
    -
    - 43 - -
    - + - case pool.Deploy: -
    -
    - 44 - -
    - + - var allow bool -
    -
    - 45 - -
    - + - // check that sender may deploy contracts -
    -
    - 46 - -
    - + - if allow, err = p.CheckPolicy(ctx, pool.Deploy, from); err != nil { -
    -
    - 47 - -
    - + - return err -
    -
    - 48 - -
    - + - } -
    -
    - 49 - -
    - + - if !allow { -
    -
    - 50 - -
    - + - return pool.ErrSenderDisallowedDeploy -
    -
    - 51 - -
    - + - } -
    -
    - 52 - -
    - + - } -
    -
    - 53 - -
    - + - return nil -
    -
    - 54 - -
    - + - } -
    -
    - 55 - -
    - + -
    -
    -
    - 56 - -
    - + - func resolvePolicy(tx *ethTypes.Transaction) pool.PolicyName { -
    -
    - 57 - -
    - + - if tx.To() == nil || tx.To().Hex() == common.HexToAddress("0x0").Hex() { -
    -
    - 58 - -
    - + - return pool.Deploy -
    -
    - 59 - -
    - + - } -
    -
    - 60 + + -
    - + - return pool.SendTx +
    +
    +   +
    - 61 + + -
    - + - } +
    +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -88192,127 +163695,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -15,6 +15,8 @@
    - 15 + + -
    +
    +
      - InvalidParamsErrorCode = -32602 +
    - 16 + + -
    +
    +
      - // ParserErrorCode error code for parsing errors +
    - 17 + + -
    +
    +
      - ParserErrorCode = -32700 +
    - 18 + + -
    +
    +
      - ) +
    - 19 + + -
    +
    +
     
    - 20 + + -
    +
    +
      - var ( +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - @@ -88322,12 +163821,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/event/event.go RENAMED
    @@ -88385,138 +163884,157 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + + +
    -
     
    - 15 + + -
    +
    +
      - InvalidParamsErrorCode = -32602 +
    - 16 + + -
    +
    +
      - // ParserErrorCode error code for parsing errors +
    - 17 + + -
    +
    +
      - ParserErrorCode = -32700 +
    - 18 + + -
    - + - // AccessDeniedCode error code when requests are denied +
    +
    +   +
    - 19 + + -
    - + - AccessDeniedCode = -32800 +
    +
    +   +
    - 20 + 166
      - ) + func TestAddRepeated(t *testing.T) {
    - 21 + 167
      -
    + dbCfg := dbutils.NewStateConfigFromEnv()
    - 22 + 168
      - var ( + require.NoError(t, dbutils.InitOrResetState(dbCfg))
    -
    @@ -23,8 +23,8 @@
    +
    @@ -42,6 +42,9 @@
    - 23 + 42
      - CountPendingTransactions(ctx context.Context) (uint64, error) + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - 24 + 43
      - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - 25 + 44
      - GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) + EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
    - 26 + + -
    +
    +
      - CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error) +
    - 27 + + -
    - - - CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) +
    +
    +   +
    - 28 + 45
      - EffectiveGasPriceEnabled() bool + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - 29 + 46
      - } + EventID_NodeOOC EventID = "NODE OOC"
    - 30 + 47
      -
    + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
    +
    +
    +
    +
    + + + - - - - + + + @@ -88524,6 +164042,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -64,6 +64,8 @@
    +
     
    - 64 + 42
      - GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) + EventID_SynchronizerHalt EventID = "SYNCHRONIZER HALT"
    - 65 + 43
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + // EventID_SequenceSenderHalt is triggered when the SequenceSender halts
    - 66 + 44
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) + EventID_SequenceSenderHalt EventID = "SEQUENCESENDER HALT"
    - + + 45 -
    -   -
    +
    +
    + + + // EventID_UnsupportedPrecompile is triggered when the executor returns an unsupported precompile error
    - + + 46 -
    -   +
    +
    + + + EventID_UnsupportedPrecompile EventID = "UNSUPPORTED PRECOMPILE" +
    +
    + 47 + +
    + +
    - 67 + 48
      - GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error) + // EventID_NodeOOC is triggered when an OOC at node level is detected
    - 68 + 49
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) + EventID_NodeOOC EventID = "NODE OOC"
    - 69 + 50
      - GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) + // EventID_UsedZKCountersOverflow is triggered when used ZK counters exceeds remaining batch ZK counters
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/event/eventlog.go + RENAMED + +
    +
    @@ -88531,238 +164064,179 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -29,7 +29,7 @@
    - 23 + 29
      - CountPendingTransactions(ctx context.Context) (uint64, error) + }
    - 24 + 30
      - GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) +
    - 25 + 31
      - GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) -
    -
    - 26 - -
    - + - CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) + // LogExecutorError is used to store Executor error for runtime debugging
    - 27 + + 32 +
    -   - CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error) -
    -
    - - -
    -   -
    + - + func (e *EventLog) LogExecutorError(ctx context.Context, responseError executor.ExecutorError, processBatchRequest interface{}) {
    - 28 + 33
      - EffectiveGasPriceEnabled() bool + timestamp := time.Now()
    - 29 + 34
      - } +
    - 30 + 35
      -
    + // if it's a user related error, ignore it
    -
     
    +
    @@ -47,6 +47,30 @@
    - 64 + 47
      - GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) + log.Errorf("error found in the executor: %v at %v", responseError, timestamp)
    - 65 + 48
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) + payload, err := json.Marshal(processBatchRequest)
    - 66 + 49
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) -
    -
    - 67 - -
    - + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) + if err != nil {
    - 68 + + -
    - + - GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +
    +
    +   +
    - 69 + + -
    +
    +
      - GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error) +
    - 70 + + -
    +
    +
      - GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) +
    - 71 + + -
    +
    +
      - GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -88983,27 +164457,57 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - -
    -
    @@ -446,6 +446,23 @@
    - 446 + + -
    +
    +
      - return res, nil +
    - 447 + + -
    +
    +
      - } +
    - 448 + + -
    +
    +
     
    @@ -88939,32 +164413,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 449 + 50
      - // TransactionOrHash for union type of transaction and types.Hash + log.Errorf("error marshaling payload: %v", err)
    - 450 + 51
      - type TransactionOrHash struct { + } else {
    - 451 + 52
      - Hash *common.Hash + event := &Event{
    - 446 + 29
      - return res, nil + }
    - 447 + 30
      - } +
    - 448 + 31 + +
    +   + // LogExecutorError is used to store Executor error for runtime debugging +
    +
    + 32 + +
    + + + func (e *EventLog) LogExecutorError(ctx context.Context, responseError executor.ExecutorError, processBatchRequest *executor.ProcessBatchRequest) { +
    +
    + 33 + +
    +   + timestamp := time.Now() +
    +
    + 34
    @@ -89011,418 +164515,378 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 35 + +
    +   + // if it's a user related error, ignore it +
    +
    +
     
    +
    + 47 + +
    +   + log.Errorf("error found in the executor: %v at %v", responseError, timestamp) +
    +
    + 48 + +
    +   + payload, err := json.Marshal(processBatchRequest) +
    +
    + 49 + +
    +   + if err != nil { +
    +
    - 449 + 50
    + - // BatchFilter is a list of batch numbers to retrieve + log.Errorf("error marshaling payload: %v", err)
    - 450 + 51
    + - type BatchFilter struct { + } else {
    - 451 + 52
    + - Numbers []BatchNumber `json:"numbers"` + event := &Event{
    - 452 + 53
    + - } + ReceivedAt: timestamp,
    - 453 + 54
    + -
    + Source: Source_Node,
    - 454 + 55
    + - // BatchData is an abbreviated structure that only contains the number and L2 batch data + Component: Component_Executor,
    - 455 + 56
    + - type BatchData struct { + Level: Level_Error,
    - 456 + 57
    + - Number ArgUint64 `json:"number"` + EventID: EventID_ExecutorError,
    - 457 + 58
    + - BatchL2Data ArgBytes `json:"batchL2Data,omitempty"` + Description: responseError.String(),
    - 458 + 59
    + - Empty bool `json:"empty"` + Json: string(payload),
    - 459 + 60
    + - } + }
    - 460 + 61
    + -
    + err = e.storage.LogEvent(ctx, event)
    - 461 + 62
    + - // BatchDataResult is a list of BatchData for a BatchFilter + if err != nil {
    - 462 + 63
    + - type BatchDataResult struct { + log.Errorf("error storing event: %v", err)
    - 463 + 64
    + - Data []*BatchData `json:"data"` + }
    - 464 + 65
    + - } + }
    - 465 + 66
    + -
    + }
    - 466 + + 67 +
    -   - // TransactionOrHash for union type of transaction and types.Hash + + +
    - 467 + + 68 +
    -   - type TransactionOrHash struct { + + + // LogExecutorErrorV2 is used to store Executor error for runtime debugging
    - 468 + + 69 +
    -   - Hash *common.Hash -
    -
    -
    + + + func (e *EventLog) LogExecutorErrorV2(ctx context.Context, responseError executor.ExecutorError, processBatchRequest *executor.ProcessBatchRequestV2) {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - + + +
    -
    @@ -26,7 +26,7 @@
    - 26 + + 70 +
    -   - var err error + + + timestamp := time.Now()
    - 27 + + 71 +
    -   - mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves) + + + log.Errorf("error found in the executor: %v at %v", responseError, timestamp)
    - 28 + + 72 +
    -   - if err != nil { + + + payload, err := json.Marshal(processBatchRequest)
    - 29 + + 73 +
    - - - log.Error("error initializing si siblings. Error: ", err) + + + if err != nil {
    - 30 + 74
      - return nil, err + log.Errorf("error marshaling payload: %v", err)
    - 31 + 75
      - } + } else {
    - 32 + 76
      - log.Debug("Initial count: ", mt.count) + event := &Event{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/.golangci.yml + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - @@ -89455,1071 +164919,1022 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - - + +
    -
    @@ -34,6 +34,25 @@
    +
    @@ -30,3 +30,6 @@
    - 34 + 30
      - return mt, nil + include:
    - 35 + 31
      - } + - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - 36 + 32
      -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + +
    +
     
    - + + 30 -
    +
    +
      -
    + include:
    - + + 31 -
    +
    +
      -
    + - EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - + + 32 -
    +
    +
      -
    + - EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
    - + + 33 -
    -   -
    +
    +
    + + + exclude-rules:
    - + + 34 -
    -   -
    +
    +
    + + + - path: cmd/policy.go
    - + + 35 -
    -   -
    +
    +
    + + + text: "unused"
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/go.mod + RENAMED + +
    +
    +
    +
    + + + + + - - -
    +
    @@ -3,35 +3,35 @@
    - 37 + 3
      - func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) { + go 1.21
    - 38 + 4
      - var ( +
    - 39 + 5
      - nodes [][][]byte -
    -
    -
    + require (
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 26 + + 6 +
    -   - var err error + - + github.com/0xPolygonHermez/zkevm-data-streamer v0.2.2
    - 27 + 7
      - mt.siblings, mt.currentRoot, err = mt.initSiblings(initialLeaves) + github.com/didip/tollbooth/v6 v6.1.2
    - 28 + 8
      - if err != nil { + github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127
    - 29 + + 9 +
    - + - log.Error("error initializing siblings. Error: ", err) + - + github.com/ethereum/go-ethereum v1.13.14
    - 30 + 10
      - return nil, err + github.com/go-git/go-billy/v5 v5.5.0
    - 31 + + 11 +
    -   - } + - + github.com/go-git/go-git/v5 v5.12.0
    - 32 + 12
      - log.Debug("Initial count: ", mt.count) + github.com/gobuffalo/packr/v2 v2.8.3
    -
     
    -
    - 34 + + 13 +
    -   - return mt, nil + - + github.com/google/uuid v1.6.0
    - 35 + 14
      - } + github.com/habx/pg-commands v0.6.1
    - 36 + 15
      -
    + github.com/hermeznetwork/tracerr v0.3.2
    - 37 + + 16 +
    - + - // ResetL1InfoTree resets the L1InfoTree. + - + github.com/iden3/go-iden3-crypto v0.0.16
    - 38 + + 17 +
    - + - func (mt *L1InfoTree) ResetL1InfoTree(initialLeaves [][32]byte) (*L1InfoTree, error) { +   + github.com/invopop/jsonschema v0.12.0
    - 39 + + 18 +
    - + - log.Info("Resetting L1InfoTree...") + - + github.com/jackc/pgconn v1.14.3
    - 40 + + 19 +
    - + - newMT := &L1InfoTree{ + - + github.com/jackc/pgx/v4 v4.18.3
    - 41 + + 20 +
    - + - zeroHashes: generateZeroHashes(32), // nolint:gomnd +   + github.com/mitchellh/mapstructure v1.5.0
    - 42 + + 21 +
    - + - height: 32, // nolint:gomnd + - + github.com/prometheus/client_model v0.6.1
    - 43 + + 22 +
    - + - count: uint32(len(initialLeaves)), + - + github.com/prometheus/common v0.53.0
    - 44 + + 23 +
    - + - } +   + github.com/rubenv/sql-migrate v1.6.1
    - 45 + + 24 +
    - + - var err error +   + github.com/spf13/afero v1.11.0
    - 46 + + 25 +
    - + - newMT.siblings, newMT.currentRoot, err = newMT.initSiblings(initialLeaves) + - + github.com/spf13/viper v1.17.0
    - 47 + + 26 +
    - + - if err != nil { + - + github.com/stretchr/testify v1.9.0
    - 48 + + 27 +
    - + - log.Error("error initializing siblings. Error: ", err) + - + github.com/umbracle/ethgo v0.1.3
    - 49 + + 28 +
    - + - return nil, err + - + github.com/urfave/cli/v2 v2.27.2
    - 50 + + 29 +
    - + - } + - + go.uber.org/zap v1.27.0
    - 51 + + 30 +
    - + - log.Debug("Reset initial count: ", newMT.count) + - + golang.org/x/crypto v0.22.0
    - 52 + + 31 +
    - + - log.Debug("Reset initial root: ", newMT.currentRoot) + - + golang.org/x/net v0.24.0
    - 53 + + 32 +
    - + - return newMT, nil + - + golang.org/x/sync v0.7.0
    - 54 + + 33 +
    - + - } + - + google.golang.org/grpc v1.63.2
    - 55 + + 34 +
    - + -
    + - + google.golang.org/protobuf v1.34.0
    - 56 + 35
      - func buildIntermediate(leaves [][32]byte) ([][][]byte, [][32]byte) { + gopkg.in/yaml.v2 v2.4.0
    - 57 + 36
      - var ( + gopkg.in/yaml.v3 v3.0.1
    - 58 + 37
      - nodes [][][]byte + )
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -2,21 +2,12 @@
    +
    @@ -40,16 +40,16 @@
    - 2 + 40
      -
    + dario.cat/mergo v1.0.0 // indirect
    - 3 + 41
      - import ( + github.com/DataDog/zstd v1.5.2 // indirect
    - 4 + 42
      - "bytes" + github.com/Microsoft/go-winio v0.6.1 // indirect
    - 5 + + 43 +
    - - "errors" + github.com/ProtonMail/go-crypto v1.0.0 // indirect
    - 6 + 44
      - "math/big" + github.com/StackExchange/wmi v1.2.1 // indirect
    - 7 + 45
      -
    + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
    - 8 + 46
      - "github.com/0xPolygonHermez/zkevm-node/log" + github.com/bahlo/generic-list-go v0.2.0 // indirect
    - 9 + 47
      - "github.com/0xPolygonHermez/zkevm-node/state" + github.com/beorn7/perks v1.0.1 // indirect
    - 10 + + 48 +
    -   - ) + - + github.com/bits-and-blooms/bitset v1.10.0 // indirect
    - 11 + 49
      -
    -
    -
    - 12 - -
    - - - var ( + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
    - 13 + + 50 +
    - - - // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero +   + github.com/buger/jsonparser v1.1.1 // indirect
    - 14 + + 51 +
    - - - ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") +   + github.com/cespare/xxhash/v2 v2.2.0 // indirect
    - 15 + + 52 +
    - -
    + github.com/cloudflare/circl v1.3.7 // indirect
    - 16 + + 53 +
    - - - // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero +   + github.com/cockroachdb/errors v1.9.1 // indirect
    - 17 + + 54 +
    - - - ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") +   + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
    - 18 + + 55 +
    - - - ) +   + github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
    - 19 - -
    - - -
    -
    +
    +
    @@ -57,18 +57,18 @@
    - 20 + 57
      - // EffectiveGasPrice implements the effective gas prices calculations and checks + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
    - 21 + 58
      - type EffectiveGasPrice struct { + github.com/consensys/bavard v0.1.13 // indirect
    - 22 + 59
      - cfg EffectiveGasPriceCfg + github.com/consensys/gnark-crypto v0.12.1 // indirect
    -
    @@ -122,33 +113,8 @@
    +
    + 60 + +
    + - + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect +
    - 122 + 61
      - bfEffectiveGasPrice.Int(effectiveGasPrice) + github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
    - 123 + 62
      -
    + github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
    - 124 + 63
      - if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { + github.com/cyphar/filepath-securejoin v0.2.4 // indirect
    - 125 + + 64 +
    - - - return nil, ErrEffectiveGasPriceIsZero +   + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
    - 126 + 65
      - } + github.com/deckarep/golang-set/v2 v2.1.0 // indirect
    - 127 + + 66 +
    -   -
    + - + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
    - 128 + 67
      - return effectiveGasPrice, nil + github.com/dlclark/regexp2 v1.7.0 // indirect
    - 129 + 68
      - } + github.com/emirpasic/gods v1.18.1 // indirect
    - 130 + + 69 +
    - - -
    +   + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
    - 131 + + 70 +
    - - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage + github.com/fjl/memsize v0.0.2 // indirect
    - 132 + + 71 +
    - - func (e *EffectiveGasPrice) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { + github.com/fsnotify/fsnotify v1.6.0 // indirect
    - 133 + + 72 +
    - - - const bits = 256 +   + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
    - 134 + + 73 +
    - - - var bitsBigInt = big.NewInt(bits) +   + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
    - 135 + + 74 +
    - - -
    +   + github.com/getsentry/sentry-go v0.18.0 // indirect
    - 136 - -
    - - - if effectiveGasPrice == nil || gasPrice == nil || -
    +
    +
    @@ -83,23 +83,25 @@
    - 137 + + 83 +
    - - - gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 { +   + github.com/gogo/protobuf v1.3.2 // indirect
    - 138 + + 84 +
    - - - return 0, ErrEffectiveGasPriceEmpty +   + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
    - 139 + + 85 +
    - - - } +   + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
    - 140 + + -
    - - +
    +
    +  
    - 141 + + 86 +
    - - - if gasPrice.Cmp(effectiveGasPrice) <= 0 { +   + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
    - 142 + + 87 +
    - - - return state.MaxEffectivePercentage, nil +   + github.com/google/gofuzz v1.2.0 // indirect
    - 143 + + 88 +
    - - - } +   + github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
    - 144 + + 89 +
    - - -
    +   + github.com/hashicorp/go-bexpr v0.1.10 // indirect
    - 145 + + 90 +
    - - - // Simulate Ceil with integer division +   + github.com/hashicorp/hcl v1.0.0 // indirect
    - 146 + + 91 +
    - - b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt) + github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect
    - 147 + + 92 +
    - - - b = b.Add(b, gasPrice) +   + github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
    - 148 + + 93 +
    - - - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +   + github.com/huin/goupnp v1.3.0 // indirect
    - 149 + + 94 +
    - - - b = b.Div(b, gasPrice) +   + github.com/jackc/chunkreader/v2 v2.0.1 // indirect
    - 150 + + 95 +
    - - - // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) +   + github.com/jackc/pgio v1.0.0 // indirect
    - 151 + + 96 +
    - - - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +   + github.com/jackc/pgpassfile v1.0.0 // indirect
    - 152 + + 97 +
    - -
    + github.com/jackc/pgproto3/v2 v2.3.3 // indirect
    - 153 + + 98 +
    - - - return uint8(b.Uint64()), nil +   + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
    - 154 + + 99 +
    - - - } -
    -
    -
    +   + github.com/jackc/pgtype v1.14.0 // indirect
    -
    -
    - - - - - @@ -90534,62 +165949,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + @@ -90613,368 +166033,398 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - + + + + - - + + + - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - + @@ -90998,43 +166448,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -91042,21 +166492,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 2 + 100
      -
    + github.com/jackc/puddle v1.3.0 // indirect
    - 3 + 101
      - import ( + github.com/jackpal/go-nat-pmp v1.0.2 // indirect
    - 4 + 102
      - "bytes" + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    - 5 + 103
      - "math/big" + github.com/karrick/godirwalk v1.17.0 // indirect
    - 6 + 104
      -
    + github.com/kevinburke/ssh_config v1.2.0 // indirect
    - 7 + 105
      - "github.com/0xPolygonHermez/zkevm-node/log" + github.com/klauspost/compress v1.17.0 // indirect
    +
    @@ -114,6 +116,8 @@
    +
    - 8 + 114
      - "github.com/0xPolygonHermez/zkevm-node/state" + github.com/mattn/go-colorable v0.1.13 // indirect
    - 9 + 115
      - ) + github.com/mattn/go-isatty v0.0.20 // indirect
    - 10 + 116
      -
    + github.com/mattn/go-runewidth v0.0.13 // indirect
    - + + 117 -
    +
    +
      -
    + github.com/mitchellh/pointerstructure v1.2.0 // indirect
    - + + 118 -
    +
    +
      -
    + github.com/mmcloughlin/addchain v0.4.0 // indirect
    - + + 119 -
    +
    +
      -
    + github.com/olekukonko/tablewriter v0.0.5 // indirect
    - - -
    -   -
    -
    +
    +
    @@ -126,17 +130,17 @@
    - + + 126 -
    +
    +
      -
    + github.com/rogpeppe/go-internal v1.11.0 // indirect
    - + + 127 -
    +
    +
      -
    + github.com/rs/cors v1.7.0 // indirect
    - 11 + 128
      - // EffectiveGasPrice implements the effective gas prices calculations and checks + github.com/russross/blackfriday/v2 v2.1.0 // indirect
    - 12 + + 129 +
    -   - type EffectiveGasPrice struct { + - + github.com/sagikazarmark/locafero v0.3.0 // indirect
    - 13 + 130
      - cfg EffectiveGasPriceCfg + github.com/sagikazarmark/slog-shim v0.1.0 // indirect
    -
     
    +
    + 131 + +
    + - + github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect +
    - 113 + 132
      - bfEffectiveGasPrice.Int(effectiveGasPrice) + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
    - 114 + 133
      -
    + github.com/sirupsen/logrus v1.9.0 // indirect +
    +
    + 134 + +
    + - + github.com/skeema/knownhosts v1.2.2 // indirect
    - 115 + 135
      - if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { + github.com/sourcegraph/conc v0.3.0 // indirect
    - 116 + + 136 +
    - + - return nil, state.ErrEffectiveGasPriceIsZero + - + github.com/spf13/cast v1.5.1 // indirect
    - 117 + 137
      - } + github.com/spf13/pflag v1.0.5 // indirect
    - 118 + 138
      -
    + github.com/status-im/keycard-go v0.2.0 // indirect +
    +
    + 139 + +
    + - + github.com/stretchr/objx v0.5.2 // indirect
    - 119 + 140
      - return effectiveGasPrice, nil + github.com/subosito/gotenv v1.6.0 // indirect
    - 120 + 141
      - } + github.com/supranational/blst v0.3.11 // indirect
    - + + 142 -
    +
    +
      -
    + github.com/tklauser/go-sysconf v0.3.12 // indirect
    - + +
    @@ -146,15 +150,15 @@
    -
    +
    + 146 + +
      -
    + github.com/valyala/fastjson v1.4.1 // indirect
    - + + 147 -
    +
    +
      -
    + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
    - + + 148 -
    +
    +
      -
    + github.com/xanzy/ssh-agent v0.3.3 // indirect
    - + + 149 -
    -   -
    +
    +
    + - + github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
    - + + 150 -
    +
    +
      -
    + go.uber.org/multierr v1.10.0 // indirect
    - + + 151 -
    +
    +
      -
    + golang.org/x/mod v0.14.0 // indirect
    - + + 152 -
    -   -
    +
    +
    + - + golang.org/x/sys v0.19.0 // indirect
    - + + 153 -
    -   -
    +
    +
    + - + golang.org/x/term v0.19.0 // indirect
    - + + 154 -
    +
    +
      -
    + golang.org/x/text v0.14.0 // indirect
    - + + 155 -
    +
    +
      -
    + golang.org/x/time v0.5.0 // indirect
    - + + 156 -
    +
    +
      -
    + golang.org/x/tools v0.15.0 // indirect
    - + + 157 -
    -   -
    +
    +
    + - + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
    - + + 158 -
    +
    +
      -
    + gopkg.in/ini.v1 v1.67.0 // indirect
    - + + 159 -
    +
    +
      -
    + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
    - + + 160 -
    +
    +
      -
    + gopkg.in/warnings.v0 v0.1.2 // indirect
    - + +
    @@ -168,7 +172,9 @@
    -
    +
    + 168 + +
      -
    + )
    - + + 169 -
    +
    +
     
    - - -
    +
    + 170 + +
      -
    + require (
    - + + 171 -
    +
    +
      -
    + github.com/fatih/color v1.16.0
    - + + 172 -
    -   -
    +
    +
    + - + github.com/prometheus/client_golang v1.19.0
    - + + 173 -
    +
    +
      -
    + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
    - + + 174 -
    +
    +
      -
    + )
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice_test.go - RENAMED - -
    -
    @@ -91064,21 +166499,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + + + + - - - - - - + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - -
    -
    @@ -23,8 +24,6 @@
    +
     
    - 23 + 3
      - ) + go 1.21
    - 24 + 4
    @@ -91088,376 +166523,497 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 25 + 5
      - func TestCalculateEffectiveGasPricePercentage(t *testing.T) { + require (
    - 26 + + 6 +
    - - - egp := NewEffectiveGasPrice(egpCfg) + + + github.com/0xPolygonHermez/zkevm-data-streamer v0.2.3-0.20240422135400-0df0d27226b3
    - 27 + + 7 +
    - - -
    +   + github.com/didip/tollbooth/v6 v6.1.2
    - 28 + 8
      - testCases := []struct { + github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127
    - 29 + + 9 +
    -   - name string + + + github.com/ethereum/go-ethereum v1.13.11
    - 30 + 10
      - breakEven *big.Int + github.com/go-git/go-billy/v5 v5.5.0
    -
    @@ -37,14 +36,14 @@
    +
    + 11 + +
    + + + github.com/go-git/go-git/v5 v5.11.0 +
    - 37 + 12
      - name: "Nil breakEven or gasPrice", + github.com/gobuffalo/packr/v2 v2.8.3 +
    +
    + 13 + +
    + + + github.com/google/uuid v1.5.0
    - 38 + 14
      - gasPrice: big.NewInt(1), + github.com/habx/pg-commands v0.6.1
    - 39 + 15
      - expectedValue: uint8(0), + github.com/hermeznetwork/tracerr v0.3.2
    - 40 + + 16 +
    - - - err: ErrEffectiveGasPriceEmpty, + + + github.com/iden3/go-iden3-crypto v0.0.15
    - 41 + 17
      - }, + github.com/invopop/jsonschema v0.12.0
    - 42 + + 18 +
    -   - { + + + github.com/jackc/pgconn v1.14.1
    - 43 + + 19 +
    -   - name: "Zero breakEven or gasPrice", + + + github.com/jackc/pgx/v4 v4.18.1
    - 44 + 20
      - breakEven: big.NewInt(1), + github.com/mitchellh/mapstructure v1.5.0 +
    +
    + 21 + +
    + + + github.com/prometheus/client_model v0.5.0 +
    +
    + 22 + +
    + + + github.com/prometheus/common v0.45.0
    - 45 + 23
      - gasPrice: big.NewInt(0), + github.com/rubenv/sql-migrate v1.6.1
    - 46 + 24
      - expectedValue: uint8(0), + github.com/spf13/afero v1.11.0
    - 47 + + 25 +
    - - - err: ErrEffectiveGasPriceEmpty, + + + github.com/spf13/viper v1.18.2 +
    +
    + 26 + +
    + + + github.com/stretchr/testify v1.8.4 +
    +
    + 27 + +
    + + + github.com/umbracle/ethgo v0.1.4-0.20230712173909-df37dddf16f0 +
    +
    + 28 + +
    + + + github.com/urfave/cli/v2 v2.26.0 +
    +
    + 29 + +
    + + + go.uber.org/zap v1.26.0 +
    +
    + 30 + +
    + + + golang.org/x/crypto v0.18.0 +
    +
    + 31 + +
    + + + golang.org/x/net v0.20.0 +
    +
    + 32 + +
    + + + golang.org/x/sync v0.5.0 +
    +
    + 33 + +
    + + + google.golang.org/grpc v1.60.1 +
    +
    + 34 + +
    + + + google.golang.org/protobuf v1.32.0
    - 48 + 35
      - }, + gopkg.in/yaml.v2 v2.4.0
    - 49 + 36
      - { + gopkg.in/yaml.v3 v3.0.1
    - 50 + 37
      - name: "Both positive, gasPrice less than breakEven", + )
    -
    @@ -104,7 +103,7 @@
    +
     
    - 104 + 40
      -
    + dario.cat/mergo v1.0.0 // indirect
    - 105 + 41
      - for _, tc := range testCases { + github.com/DataDog/zstd v1.5.2 // indirect
    - 106 + 42
      - t.Run(tc.name, func(t *testing.T) { + github.com/Microsoft/go-winio v0.6.1 // indirect
    - 107 + + 43 +
    - - - actual, err := egp.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven) + + + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
    - 108 + 44
      - assert.Equal(t, tc.err, err) + github.com/StackExchange/wmi v1.2.1 // indirect
    - 109 + 45
      - if actual != 0 { + github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
    - 110 + 46
      - assert.Equal(t, tc.expectedValue, actual) -
    -
    -
    + github.com/bahlo/generic-list-go v0.2.0 // indirect
    -
    -
    - - - - - + + + - - - - @@ -91467,142 +167023,182 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + @@ -91612,808 +167208,762 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - -
    -
     
    - 24 + 47
      - ) + github.com/beorn7/perks v1.0.1 // indirect +
    +
    + 48 + +
    + + + github.com/bits-and-blooms/bitset v1.12.0 // indirect
    - 25 + 49
      -
    + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
    - 26 + 50
      - func TestCalculateEffectiveGasPricePercentage(t *testing.T) { + github.com/buger/jsonparser v1.1.1 // indirect
    - + + 51 -
    +
    +
      -
    + github.com/cespare/xxhash/v2 v2.2.0 // indirect
    - + + 52 -
    -   -
    +
    +
    + + + github.com/cloudflare/circl v1.3.3 // indirect
    - 27 + 53
      - testCases := []struct { + github.com/cockroachdb/errors v1.9.1 // indirect
    - 28 + 54
      - name string + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
    - 29 + 55
      - breakEven *big.Int + github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
    - 36 + 57
      - name: "Nil breakEven or gasPrice", + github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
    - 37 + 58
      - gasPrice: big.NewInt(1), + github.com/consensys/bavard v0.1.13 // indirect
    - 38 + 59
      - expectedValue: uint8(0), + github.com/consensys/gnark-crypto v0.12.1 // indirect
    - 39 + 60
    + - err: state.ErrEffectiveGasPriceEmpty, + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
    - 40 + 61
      - }, + github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 // indirect
    - 41 + 62
      - { + github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
    - 42 + 63
      - name: "Zero breakEven or gasPrice", + github.com/cyphar/filepath-securejoin v0.2.4 // indirect
    - 43 + 64
      - breakEven: big.NewInt(1), + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
    - 44 + 65
      - gasPrice: big.NewInt(0), + github.com/deckarep/golang-set/v2 v2.1.0 // indirect +
    +
    + 66 + +
    + + + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
    - 45 + 67
      - expectedValue: uint8(0), + github.com/dlclark/regexp2 v1.7.0 // indirect +
    +
    + 68 + +
    +   + github.com/emirpasic/gods v1.18.1 // indirect +
    +
    + 69 + +
    +   + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
    - 46 + 70
    + - err: state.ErrEffectiveGasPriceEmpty, + github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect +
    +
    + 71 + +
    + + + github.com/fsnotify/fsnotify v1.7.0 // indirect
    - 47 + 72
      - }, + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
    - 48 + 73
      - { + github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect
    - 49 + 74
      - name: "Both positive, gasPrice less than breakEven", + github.com/getsentry/sentry-go v0.18.0 // indirect
    - 103 + 83
      -
    + github.com/gogo/protobuf v1.3.2 // indirect
    - 104 + 84
      - for _, tc := range testCases { + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
    - 105 + 85
      - t.Run(tc.name, func(t *testing.T) { + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
    - 106 + + 86 +
    + - actual, err := state.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven) + github.com/golang/protobuf v1.5.3 // indirect
    - 107 + 87
      - assert.Equal(t, tc.err, err) + github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
    - 108 + 88
      - if actual != 0 { + github.com/google/gofuzz v1.2.0 // indirect
    - 109 + 89
      - assert.Equal(t, tc.expectedValue, actual) -
    -
    -
    + github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -76,4 +76,13 @@
    - 76 + 90
      -
    + github.com/hashicorp/go-bexpr v0.1.10 // indirect
    - 77 + 91
      - // ErrZeroL1GasPrice is returned if the L1 gas price is 0. + github.com/hashicorp/hcl v1.0.0 // indirect
    - 78 + + 92 +
    -   - ErrZeroL1GasPrice = errors.New("L1 gas price 0") + + + github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect
    - + + 93 -
    +
    +
      -
    + github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
    - + + 94 -
    +
    +
      -
    + github.com/huin/goupnp v1.3.0 // indirect
    - + + 95 -
    +
    +
      -
    + github.com/jackc/chunkreader/v2 v2.0.1 // indirect
    - + + 96 -
    +
    +
      -
    + github.com/jackc/pgio v1.0.0 // indirect
    - + + 97 -
    +
    +
      -
    + github.com/jackc/pgpassfile v1.0.0 // indirect
    - + + 98 -
    -   -
    +
    +
    + + + github.com/jackc/pgproto3/v2 v2.3.2 // indirect
    - + + 99 -
    +
    +
      -
    + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
    - + + 100 -
    +
    +
      -
    + github.com/jackc/pgtype v1.14.0 // indirect
    - + + 101 -
    +
    +
      -
    + github.com/jackc/puddle v1.3.0 // indirect
    - 79 + 102
      - ) -
    -
    -
    + github.com/jackpal/go-nat-pmp v1.0.2 // indirect
    -
    -
    - - - - - - - - - - - - + - + + - - - - - - - - - - -
    -
     
    - 76 + 103
      -
    + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
    - 77 + + 104 +
    -   - // ErrZeroL1GasPrice is returned if the L1 gas price is 0. + + + github.com/jmoiron/sqlx v1.2.0 // indirect
    - 78 + 105
      - ErrZeroL1GasPrice = errors.New("L1 gas price 0") + github.com/karrick/godirwalk v1.17.0 // indirect
    - 79 + + 106 +
    - + -
    +   + github.com/kevinburke/ssh_config v1.2.0 // indirect
    - 80 + + 107 +
    - + - // ErrSenderDisallowedSendTx is returned when transactions by sender are is disallowed by policy +   + github.com/klauspost/compress v1.17.0 // indirect
    - 81 + +
     
    +
    + 116 +
    - + - ErrSenderDisallowedSendTx = errors.New("sender disallowed send_tx by policy") +   + github.com/mattn/go-colorable v0.1.13 // indirect
    - 82 + + 117 +
    - + -
    +   + github.com/mattn/go-isatty v0.0.20 // indirect
    - 83 + + 118 +
    - + - // ErrContractDisallowedSendTx is returned when transactions to contract are is disallowed by policy +   + github.com/mattn/go-runewidth v0.0.13 // indirect
    - 84 + 119
    + - ErrContractDisallowedSendTx = errors.New("contract disallowed send_tx by policy") + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
    - 85 + 120
    + -
    + github.com/miguelmota/go-solidity-sha3 v0.1.1 // indirect
    - 86 + + 121 +
    - + - // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy +   + github.com/mitchellh/pointerstructure v1.2.0 // indirect
    - 87 + + 122 +
    - + - ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy") +   + github.com/mmcloughlin/addchain v0.4.0 // indirect
    - 88 + 123
      - ) + github.com/olekukonko/tablewriter v0.0.5 // indirect
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go - RENAMED - -
    -
    -
    -
    - - - + - - + + + - - + - - - - - - - - - - - - - - + - - - - - - - - -
    -
    @@ -38,6 +38,7 @@
    +
     
    - 38 + 130
      - MarkWIPTxsAsPending(ctx context.Context) error + github.com/rogpeppe/go-internal v1.11.0 // indirect
    - 39 + 131
      - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) + github.com/rs/cors v1.7.0 // indirect
    - 40 + 132
      - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) + github.com/russross/blackfriday/v2 v2.1.0 // indirect
    - + + 133 -
    -   -
    +
    +
    + + + github.com/sagikazarmark/locafero v0.4.0 // indirect
    - 41 + 134
      - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) + github.com/sagikazarmark/slog-shim v0.1.0 // indirect +
    +
    + 135 + +
    + + + github.com/sergi/go-diff v1.2.0 // indirect
    - 42 + 136
      - } + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
    - 43 + 137
      -
    + github.com/sirupsen/logrus v1.9.0 // indirect
    -
    @@ -48,3 +49,12 @@
    +
    + 138 + +
    + + + github.com/skeema/knownhosts v1.2.1 // indirect +
    - 48 + 139
      - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) + github.com/sourcegraph/conc v0.3.0 // indirect
    - 49 + + 140 +
    -   - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) + + + github.com/spf13/cast v1.6.0 // indirect
    - 50 + 141
      - } + github.com/spf13/pflag v1.0.5 // indirect
    - + + 142 -
    +
    +
      -
    + github.com/status-im/keycard-go v0.2.0 // indirect
    - + + 143 -
    -   -
    +
    +
    + + + github.com/stretchr/objx v0.5.0 // indirect
    - + + 144 -
    +
    +
      -
    + github.com/subosito/gotenv v1.6.0 // indirect
    - + + 145 -
    +
    +
      -
    + github.com/supranational/blst v0.3.11 // indirect
    - + + 146 -
    +
    +
      -
    + github.com/tklauser/go-sysconf v0.3.12 // indirect
    - - -
    -   -
    -
    +
    +
     
    - + + 150 -
    +
    +
      -
    + github.com/valyala/fastjson v1.4.1 // indirect
    - + + 151 -
    +
    +
      -
    + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
    - + + 152 -
    +
    +
      -
    + github.com/xanzy/ssh-agent v0.3.3 // indirect
    -
    + + + 153 + + +
    + + + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
    -
    -
    - - - - - - - - - - - + - + - + + - - - - - - - - - - - - @@ -92423,12 +167973,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/.goreleaser-cdk.yaml RENAMED
    + + +
    -
     
    - 38 + 154
      - MarkWIPTxsAsPending(ctx context.Context) error + go.uber.org/multierr v1.10.0 // indirect
    - 39 + 155
      - GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error) + golang.org/x/mod v0.14.0 // indirect
    - 40 + + 156 +
    -   - MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error) + + + golang.org/x/sys v0.16.0 // indirect
    - 41 + + 157 +
    + - policy + golang.org/x/term v0.16.0 // indirect
    - 42 + 158
      - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) + golang.org/x/text v0.14.0 // indirect
    - 43 + 159
      - } + golang.org/x/time v0.5.0 // indirect
    - 44 + 160
      -
    + golang.org/x/tools v0.15.0 // indirect
    -
     
    +
    + 161 + +
    + + + google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect +
    - 49 + 162
      - GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) + gopkg.in/ini.v1 v1.67.0 // indirect
    - 50 + 163
      - PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error) + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
    - 51 + 164
      - } + gopkg.in/warnings.v0 v0.1.2 // indirect
    - 52 + +
     
    +
    + 172 +
    - + - type policy interface { +   + )
    - 53 + + 173 +
    - + - CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) +   +
    - 54 + + 174 +
    - + - AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error +   + require (
    - 55 + 175
    + - RemoveAddressesFromPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error + github.com/0xPolygon/agglayer v0.0.1
    - 56 + 176
    + - ClearPolicy(ctx context.Context, policy PolicyName) error + github.com/0xPolygon/cdk-data-availability v0.0.5
    - 57 + + 177 +
    - + - DescribePolicies(ctx context.Context) ([]Policy, error) +   + github.com/fatih/color v1.16.0
    - 58 + + 178 +
    + - DescribePolicy(ctx context.Context, name PolicyName) (Policy, error) + github.com/prometheus/client_golang v1.18.0
    - 59 + + 179 +
    - + - ListAcl(ctx context.Context, policy PolicyName, query []common.Address) ([]common.Address, error) +   + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
    - 60 + + 180 +
    - + - } +   + )
    -
    @@ -0,0 +1,202 @@
    +
    @@ -0,0 +1,84 @@
    @@ -93285,752 +168835,915 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - + + + + + + + + + - - - - - - + +
    +
     
    +
    - + + 1 -
    -   -
    +
    +
    + + + # .goreleaser-cdk.yaml
    - + + 2 -
    -   -
    +
    +
    + + + project_name: cdk-validium-node
    - + + 3 -
    -   +
    +
    + +
    - + + 4 -
    -   -
    +
    +
    + + + release:
    - + + 5 -
    -   -
    +
    +
    + + + disable: false
    - + + 6 -
    -   -
    +
    +
    + + + draft: true
    - + + 7 -
    -   -
    +
    +
    + + + prerelease: auto
    - + + 8 -
    -   +
    +
    + +
    - + + 9 -
    -   -
    +
    +
    + + + before:
    - + + 10 -
    -   -
    +
    +
    + + + hooks:
    - + + 11 -
    -   -
    +
    +
    + + + - go mod download
    - + + 12 -
    -   -
    +
    +
    + + + - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3
    - + + 13 -
    -   -
    +
    +
    + + + - packr2
    - + + 14 -
    -   +
    +
    + +
    - + + 15 -
    -   -
    +
    +
    + + + builds:
    - + + 16 -
    -   -
    +
    +
    + + + - main: ./cmd/
    - + + 17 -
    -   -
    +
    +
    + + + binary: zkevm-node
    - + + 18 -
    -   -
    +
    +
    + + + goos:
    - + + 19 -
    -   -
    +
    +
    + + + - linux
    - + + 20 -
    -   -
    +
    +
    + + + - darwin
    - + + 21 -
    -   -
    +
    +
    + + + goarch:
    - + + 22 -
    -   -
    +
    +
    + + + - amd64
    - + + 23 -
    -   -
    +
    +
    + + + - arm64
    - + + 24 -
    -   -
    +
    +
    + + + env:
    - + + 25 -
    -   -
    +
    +
    + + + - CGO_ENABLED=0
    - + + 26 -
    -   -
    +
    +
    + + + ldflags:
    - + + 27 -
    -   -
    +
    +
    + + + - -s -w
    - + + 28 -
    -   -
    +
    +
    + + + - -X github.com/0xPolygonHermez/zkevm-node.Version={{ .Version }}
    - + + 29 -
    -   -
    +
    +
    + + + - -X github.com/0xPolygonHermez/zkevm-node.GitRev={{ .Commit }}
    - + + 30 -
    -   -
    +
    +
    + + + - -X github.com/0xPolygonHermez/zkevm-node.BuildDate={{ .Date }}
    - + + 31 -
    -   -
    +
    +
    + + + - -X github.com/0xPolygonHermez/zkevm-node.GitBranch={{ .Branch }}
    - + + 32 -
    -   +
    +
    + +
    - + + 33 -
    -   -
    +
    +
    + + + archives:
    - + + 34 -
    -   -
    +
    +
    + + + - files:
    - + + 35 -
    -   -
    +
    +
    + + + - LICENSE
    - + + 36 -
    -   -
    +
    +
    + + + - README.md
    - + + 37 -
    -   +
    +
    + +
    - + + 38 -
    -   -
    +
    +
    + + + dockers:
    - + + 39 -
    -   -
    +
    +
    + + + - image_templates:
    - + + 40 -
    -   -
    +
    +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64
    - + + 41 -
    -   -
    +
    +
    + + + dockerfile: Dockerfile.release
    - + + 42 -
    -   -
    +
    +
    + + + use: buildx
    - + + 43 -
    -   -
    +
    +
    + + + goos: linux
    - + + 44 -
    -   -
    +
    +
    + + + goarch: amd64
    - + + 45 -
    -   -
    +
    +
    + + + build_flag_templates:
    - + + 46 -
    -   -
    +
    +
    + + + - --platform=linux/amd64
    - + + 47 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.title={{ .ProjectName }}
    - + + 48 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.description={{ .ProjectName }}
    - + + 49 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
    - + + 50 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
    - + + 51 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }}
    - + + 52 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
    - + + 53 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.revision={{ .FullCommit }}
    - + + 54 -
    -   -
    +
    +
    + + + skip_push: false
    - + + 55 -
    -   +
    +
    + +
    - + + 56 -
    -   -
    +
    +
    + + + - image_templates:
    - + + 57 -
    -   -
    +
    +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
    - + + 58 -
    -   -
    +
    +
    + + + dockerfile: Dockerfile.release
    - + + 59 -
    -   -
    +
    +
    + + + use: buildx
    - + + 60 -
    -   -
    +
    +
    + + + goos: linux
    - + + 61 -
    -   -
    +
    +
    + + + goarch: arm64
    - + + 62 -
    -   -
    +
    +
    + + + build_flag_templates:
    - + + 63 -
    -   -
    +
    +
    + + + - --platform=linux/arm64
    - + + 64 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.title={{ .ProjectName }}
    - + + 65 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.description={{ .ProjectName }}
    - + + 66 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.url=https://github.com/{{ .ProjectName }}
    - + + 67 -
    -   -
    +
    +
    + + + - --label=org.opencontainers.image.source=https://github.com/{{ .ProjectName }}
    - + + 68 -
    -   +
    +
    + + + - --label=org.opencontainers.image.version={{ replace .Version "+" "-" }} +
    +
    + 69 + +
    + + + - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} +
    +
    + 70 + +
    + + + - --label=org.opencontainers.image.revision={{ .FullCommit }} +
    +
    + 71 + +
    + + + skip_push: false +
    +
    + 72 + +
    + +
    - + + 73 -
    -   +
    +
    + + + docker_manifests: +
    +
    + 74 + +
    + + + - name_template: 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }} +
    +
    + 75 + +
    + + + image_templates: +
    +
    + 76 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 +
    +
    + 77 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 +
    +
    + 78 + +
    + + + skip_push: false +
    +
    + 79 + +
    + +
    - + + 80 + +
    + + + - name_template: 0xpolygon/{{ .ProjectName }}:latest +
    +
    + 81 + +
    + + + image_templates: +
    +
    + 82 + +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 +
    +
    + 83 -
    -   -
    +
    +
    + + + - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64
    - + + 84 -
    -   -
    +
    +
    + + + skip_push: false
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/client/zkevm.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -94480,602 +170193,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -95086,7 +170229,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95096,7 +170239,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95106,7 +170249,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95116,7 +170259,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95126,7 +170269,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95136,7 +170279,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95146,7 +170289,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95156,7 +170299,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95166,7 +170309,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95176,7 +170319,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95196,7 +170339,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95206,7 +170349,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95216,7 +170359,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95226,7 +170369,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95236,7 +170379,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95246,7 +170389,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95256,7 +170399,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95266,7 +170409,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95276,7 +170419,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95296,7 +170439,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95306,7 +170449,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95316,7 +170459,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95326,7 +170469,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95336,7 +170479,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95346,7 +170489,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95356,7 +170499,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95366,7 +170509,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95376,7 +170519,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95386,7 +170529,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95396,7 +170539,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95406,7 +170549,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95416,7 +170559,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95426,7 +170569,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95436,7 +170579,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95446,7 +170589,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95456,7 +170599,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95466,7 +170609,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -95476,282 +170619,375 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -58,6 +58,46 @@
    - + + 58 -
    +
    +
      -
    + return result, nil
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    +
    +
     
    @@ -94436,33 +170149,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 61 -
    +
    +
      -
    + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    - + + 62 -
    +
    +
      -
    + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    - + + 63 -
    +
    +
      -
    + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String())
    - 1 - -
    - + - package pgpoolstorage -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + - "errors" -
    -
    - 6 - -
    - + - "fmt" -
    -
    - 7 - -
    - + - "strings" -
    -
    - 8 - -
    - + -
    -
    -
    - 9 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/pool" -
    -
    - 10 - -
    - + - "github.com/ethereum/go-ethereum/common" -
    -
    - 11 - -
    - + - "github.com/jackc/pgx/v4" -
    -
    - 12 - -
    - + - ) -
    -
    - 13 - -
    - + -
    -
    -
    - 14 - -
    - + - // CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule -
    -
    - 15 - -
    - + - // will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of -
    -
    - 16 - -
    - + - // the policy setting. -
    -
    - 17 - -
    - + - func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) { -
    -
    - 18 - -
    - + - sql := `SELECT -
    -
    - 19 - -
    - + - CASE WHEN a.address is null THEN -
    -
    - 20 - -
    - + - NOT p.allow -
    -
    - 21 - -
    - + - ELSE -
    -
    - 22 - -
    - + - p.allow -
    -
    - 23 - -
    - + - END -
    -
    - 24 - -
    - + - FROM pool.policy p -
    -
    - 25 - -
    - + - LEFT JOIN pool.acl a -
    -
    - 26 - -
    - + - ON p.name = a.policy -
    -
    - 27 - -
    - + - AND a.address = $1 -
    -
    - 28 - -
    - + - WHERE p.name = $2` -
    -
    - 29 - -
    - + -
    -
    -
    - 30 - -
    - + - rows, err := p.db.Query(ctx, sql, address.Hex(), policy) -
    -
    - 31 - -
    - + -
    -
    -
    - 32 - -
    - + - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 33 - -
    - + - return false, pool.ErrNotFound -
    -
    - 34 - -
    - + - } else if err != nil { -
    -
    - 35 - -
    - + - return false, err -
    -
    - 36 - -
    - + - } -
    -
    - 37 - -
    - + -
    -
    -
    - 38 - -
    - + - defer rows.Close() -
    -
    - 39 - -
    - + - if !rows.Next() { // should always be a row if the policy exists -
    -
    - 40 - -
    - + - return false, nil -
    -
    - 41 - -
    - + - } -
    -
    - 42 - -
    - + -
    -
    -
    - 43 - -
    - + - var allow bool -
    -
    - 44 - -
    - + - err = rows.Scan(&allow) -
    -
    - 45 - -
    - + - if err != nil { -
    -
    - 46 - -
    - + - return false, err -
    -
    - 47 - -
    - + - } -
    -
    - 48 - -
    - + - return allow, nil -
    -
    - 49 - -
    - + - } -
    -
    - 50 - -
    - + -
    -
    -
    - 51 - -
    - + - // UpdatePolicy sets the allow/deny rule for the named policy -
    -
    - 52 - -
    - + - func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error { -
    -
    - 53 - -
    - + - sql := "UPDATE pool.policy SET allow = $1 WHERE name = $2" -
    -
    - 54 - -
    - + - _, err := p.db.Exec(ctx, sql, allow, string(policy)) -
    -
    - 55 - -
    - + - if err != nil { -
    -
    - 56 - -
    - + - return err -
    -
    - 57 - -
    - + - } -
    -
    + 58 +
    - + - return nil +   + return result, nil
    + 59 +
    - + +   }
    + 60 +
    - + +  
    + - // AddAddressesToPolicy adds addresses to the named policy + // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
    + - func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { + // known batch is returned as a list.
    + - sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING" + func (c *Client) BatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    + - tx, err := p.db.Begin(ctx) + return c.batchesByNumbers(ctx, numbers, "zkevm_getBatchDataByNumbers")
    + - if err != nil { + }
    + - return err +
    + - } + // ForcedBatchesByNumbers returns forced batches data.
    + - defer func(tx pgx.Tx, ctx context.Context) { + func (c *Client) ForcedBatchesByNumbers(ctx context.Context, numbers []*big.Int) ([]*types.BatchData, error) {
    + - _ = tx.Rollback(ctx) + return c.batchesByNumbers(ctx, numbers, "zkevm_getForcedBatchDataByNumbers")
    + - }(tx, ctx) + }
    + - for _, a := range addresses { + // BatchesByNumbers returns batches from the current canonical chain by batch numbers. If the list is empty, the last
    + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) + // known batch is returned as a list.
    + - if err != nil { + func (c *Client) batchesByNumbers(_ context.Context, numbers []*big.Int, method string) ([]*types.BatchData, error) {
    + - return err + batchNumbers := make([]types.BatchNumber, 0, len(numbers))
    + - } + for _, n := range numbers {
    + - } + batchNumbers = append(batchNumbers, types.BatchNumber(n.Int64()))
    + - err = tx.Commit(ctx) + }
    + - if err != nil { + if len(batchNumbers) == 0 {
    + - return nil + batchNumbers = append(batchNumbers, types.LatestBatchNumber)
    + - return nil +
    + - } + response, err := JSONRPCCall(c.url, method, &types.BatchFilter{Numbers: batchNumbers})
    + -
    + if err != nil {
    + - // RemoveAddressesFromPolicy removes addresses from the named policy + return nil, err
    + - func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error { + }
    + - sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2" +
    + - tx, err := p.db.Begin(ctx) + if response.Error != nil {
    + - if err != nil { + return nil, response.Error.RPCError()
    + - return err + }
    + - } +
    + - defer func(tx pgx.Tx, ctx context.Context) { + var result *types.BatchDataResult
    + - _ = tx.Rollback(ctx) + err = json.Unmarshal(response.Result, &result)
    + - }(tx, ctx) + if err != nil {
    + -
    + return nil, err
    + - for _, a := range addresses { + }
    + - _, err = tx.Exec(ctx, sql, policy, a.Hex()) +
    + - if err != nil { + return result.Data, nil
    + - return err + }
    + - } +
    + 101 +
    - + - } +   + // ExitRootsByGER returns the exit roots accordingly to the provided Global Exit Root
    + 102 +
    - + - err = tx.Commit(ctx) +   + func (c *Client) ExitRootsByGER(ctx context.Context, globalExitRoot common.Hash) (*types.ExitRoots, error) {
    + 103 +
    - + - if err != nil { +   + response, err := JSONRPCCall(c.url, "zkevm_getExitRootsByGER", globalExitRoot.String()) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - + + + + + + + + + - - - - + + +
    +
    @@ -104,7 +104,7 @@
    + 104 +
    - + - return err +   + result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx)
    + 105 +
    - + - } +   + if err != nil {
    + 106 +
    - + - return nil +   + errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
    + 107 +
    - + - } + - + logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !errors.Is(err, runtime.ErrOutOfGas)
    + 108 +
    - + -
    +   + return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
    + 109 +
    - + - // ClearPolicy removes _all_ addresses from the named policy +   + }
    + 110 +
    - + - func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error { +   +
    - 111 + +
    @@ -945,6 +945,9 @@
    +
    + 945 +
    - + - sql := "DELETE FROM pool.acl WHERE policy = $1" +   + if e.cfg.SequencerNodeURI != "" {
    - 112 + + 946 +
    - + - _, err := p.db.Exec(ctx, sql, policy) +   + return e.relayTxToSequencerNode(input)
    - 113 + + 947 +
    - + - if err != nil { +   + } else {
    - 114 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 948 +
    - + - return err +   + ip := ""
    - 115 + + 949 +
    - + - } +   + ips := httpRequest.Header.Get("X-Forwarded-For")
    - 116 + + 950 +
    - + - return nil +   +
    +
    +
    +
    +
    +
    + + + + + - - + + + - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
     
    - 117 + + 104 +
    - + - } +   + result, err := e.state.ProcessUnsignedTransaction(ctx, tx, sender, blockToProcess, true, dbTx) +
    +
    + 105 + +
    +   + if err != nil {
    - 118 + + 106 +
    - + -
    +   + errMsg := fmt.Sprintf("failed to execute the unsigned transaction: %v", err.Error())
    - 119 + + 107 +
    + - // DescribePolicies return all the policies + logError := !executor.IsROMOutOfCountersError(executor.RomErrorCode(err)) && !(errors.Is(err, runtime.ErrOutOfGas))
    - 120 + + 108 +
    - + - func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error) { +   + return RPCErrorResponse(types.DefaultErrorCode, errMsg, nil, logError)
    - 121 + + 109 +
    - + - sql := "SELECT name, allow FROM pool.policy" +   + }
    - 122 + + 110 +
    - + - rows, err := p.db.Query(ctx, sql) +   +
    - 123 + +
     
    +
    + 945 +
    - + - if err != nil { +   + if e.cfg.SequencerNodeURI != "" {
    - 124 + + 946 +
    - + - if errors.Is(err, pgx.ErrNoRows) { +   + return e.relayTxToSequencerNode(input)
    - 125 + + 947 +
    - + - return nil, nil +   + } else {
    - 126 + 948
    + - } else { + if err := checkPolicy(context.Background(), e.pool, input); err != nil {
    - 127 + 949
    + - return nil, err + return RPCErrorResponse(types.AccessDeniedCode, err.Error(), nil, false)
    - 128 + 950
    @@ -95760,773 +170996,798 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 129 + + 951 +
    - + - } +   + ip := ""
    - 130 + + 952 +
    - + - defer rows.Close() +   + ips := httpRequest.Header.Get("X-Forwarded-For")
    - 131 + + 953 +
    - + +  
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_eth_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -6,6 +6,7 @@
    +
    - 132 + + 6 +
    - + - var list []pool.Policy +   + "errors"
    - 133 + + 7 +
    - + - for rows.Next() { +   + "fmt"
    - 134 + + 8 +
    - + - var name string +   + "math/big"
    - 135 + + -
    - + - var allow bool +
    +
    +   +
    - 136 + + 9 +
    - + - err = rows.Scan(&name, &allow) +   + "sync"
    - 137 + + 10 +
    - + - if err != nil { +   + "testing"
    - 138 + + 11 +
    - + - return nil, err +   + "time"
    - 139 + +
    @@ -5416,3 +5417,237 @@
    +
    + 5416 +
    - + - } +   + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 140 + + 5417 +
    - + - if pool.IsPolicy(name) { // skip unknown +   + assert.ElementsMatch(t, []int{16}, results[5])
    - 141 + + 5418 +
    - + - p := pool.Policy{ +   + }
    - 142 + + -
    - + - Name: pool.PolicyName(name), +
    +
    +   +
    - 143 + + -
    - + - Allow: allow, +
    +
    +   +
    - 144 + + -
    - + - } +
    +
    +   +
    - 145 + + -
    - + - list = append(list, p) +
    +
    +   +
    - 146 + + -
    - + - } +
    +
    +   +
    - 147 + + -
    - + - } +
    +
    +   +
    - 148 + + -
    - + - return list, nil +
    +
    +   +
    - 149 + + -
    - + - } +
    +
    +   +
    - 150 + + -
    - + +
    +
    +  
    - 151 + + -
    - + - // DescribePolicy returns the named policy +
    +
    +   +
    - 152 + + -
    - + - func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error) { +
    +
    +   +
    - 153 + + -
    - + - sql := "SELECT name, allow FROM pool.policy WHERE name = $1 LIMIT 1" +
    +
    +   +
    - 154 + + -
    - + - row := p.db.QueryRow(ctx, sql, name) +
    +
    +   +
    - 155 + + -
    - + - var ( +
    +
    +   +
    - 156 + + -
    - + - pName string +
    +
    +   +
    - 157 + + -
    - + - allow bool +
    +
    +   +
    - 158 + + -
    - + - ) +
    +
    +   +
    - 159 + + -
    - + - err := row.Scan(&pName, &allow) +
    +
    +   +
    - 160 + + -
    - + - if err != nil { +
    +
    +   +
    - 161 + + -
    - + - return pool.Policy{}, err +
    +
    +   +
    - 162 + + -
    - + - } +
    +
    +   +
    - 163 + + -
    - + - return pool.Policy{ +
    +
    +   +
    - 164 + + -
    - + - Name: pool.PolicyName(pName), +
    +
    +   +
    - 165 + + -
    - + - Allow: allow, +
    +
    +   +
    - 166 + + -
    - + - }, nil +
    +
    +   +
    - 167 + + -
    - + - } +
    +
    +   +
    - 168 + + -
    - + +
    +
    +  
    - 169 + + -
    - + - // ListAcl returns a list of the addresses associated with the policy +
    +
    +   +
    - 170 + + -
    - + - func (p *PostgresPoolStorage) ListAcl( +
    +
    +   +
    - 171 + + -
    - + - ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error) { +
    +
    +   +
    - 172 + + -
    - + - sql := "SELECT address FROM pool.acl WHERE policy = $1" +
    +
    +   +
    - 173 + + -
    - + +
    +
    +  
    - 174 + + -
    - + - if len(query) > 0 { +
    +
    +   +
    - 175 + + -
    - + - var addrs []string +
    +
    +   +
    - 176 + + -
    - + - for _, a := range query { +
    +
    +   +
    - 177 + + -
    - + - addrs = append(addrs, a.Hex()) +
    +
    +   +
    - 178 + + -
    - + - } +
    +
    +   +
    - 179 + + -
    - + - sql = sql + fmt.Sprintf(" IN (%v)", strings.Join(addrs, ",")) +
    +
    +   +
    - 180 + + -
    - + - } +
    +
    +   +
    - 181 + + -
    - + +
    +
    +  
    - 182 + + -
    - + - rows, err := p.db.Query(ctx, sql, string(policy)) +
    +
    +   +
    - 183 + + -
    - + - if err != nil { +
    +
    +   +
    - 184 + + -
    - + - if errors.Is(err, pgx.ErrNoRows) { +
    +
    +   +
    - 185 + + -
    - + - return nil, nil +
    +
    +   +
    - 186 + + -
    - + - } else { +
    +
    +   +
    - 187 + + -
    - + - return nil, err +
    +
    +   +
    - 188 + + -
    - + - } +
    +
    +   +
    - 189 + + -
    - + - } +
    +
    +   +
    - 190 + + -
    - + - defer rows.Close() +
    +
    +   +
    - 191 + + -
    - + +
    +
    +  
    - 192 + + -
    - + - var addresses []common.Address +
    +
    +   +
    - 193 + + -
    - + - for rows.Next() { +
    +
    +   +
    - 194 + + -
    - + - var addr string +
    +
    +   +
    - 195 + + -
    - + - err = rows.Scan(&addr) +
    +
    +   +
    - 196 + + -
    - + - if err != nil { +
    +
    +   +
    - 197 + + -
    - + - return nil, err +
    +
    +   +
    - 198 + + -
    - + - } +
    +
    +   +
    - 199 + + -
    - + - addresses = append(addresses, common.HexToAddress(addr)) +
    +
    +   +
    - 200 + + -
    - + - } +
    +
    +   +
    - 201 + + -
    - + - return addresses, nil +
    +
    +   +
    - 202 + + -
    - + - } +
    +
    +   +
    -
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,43 @@
    @@ -96958,507 +172219,134 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 - -
    - + - package pool -
    -
    - 2 + + -
    - + +
    +
    +  
    - 3 - -
    - + - import "github.com/ethereum/go-ethereum/common" -
    -
    - 4 + + -
    - + +
    +
    +  
    - 5 - -
    - + - // PolicyName is a named policy -
    -
    - 6 - -
    - + - type PolicyName string -
    -
    - 7 + + -
    - + +
    +
    +  
    - 8 - -
    - + - const ( -
    -
    - 9 - -
    - + - // SendTx is the name of the policy that governs that an address may send transactions to pool -
    -
    - 10 - -
    - + - SendTx PolicyName = "send_tx" -
    -
    - 11 - -
    - + - // Deploy is the name of the policy that governs that an address may deploy a contract -
    -
    - 12 - -
    - + - Deploy PolicyName = "deploy" -
    -
    - 13 - -
    - + - ) -
    -
    - 14 + + -
    - + +
    +
    +  
    - 15 - -
    - + - // Policy describes state of a named policy -
    -
    - 16 - -
    - + - type Policy struct { -
    -
    - 17 - -
    - + - Name PolicyName -
    -
    - 18 - -
    - + - Allow bool -
    -
    - 19 - -
    - + - } -
    -
    - 20 + + -
    - + +
    +
    +  
    - 21 - -
    - + - // Desc returns the string representation of a policy rule -
    -
    - 22 - -
    - + - func (p *Policy) Desc() string { -
    -
    - 23 - -
    - + - if p.Allow { -
    -
    - 24 - -
    - + - return "allow" -
    -
    - 25 - -
    - + - } -
    -
    - 26 - -
    - + - return "deny" -
    -
    - 27 - -
    - + - } -
    -
    - 28 + + -
    - + +
    +
    +  
    - 29 - -
    - + - // Acl describes exception to a named Policy by address -
    -
    - 30 - -
    - + - type Acl struct { -
    -
    - 31 - -
    - + - PolicyName PolicyName -
    -
    - 32 - -
    - + - Address common.Address -
    -
    - 33 - -
    - + - } -
    -
    - 34 + + -
    - + +
    +
    +  
    - 35 - -
    - + - // IsPolicy tests if a string represents a known named Policy -
    -
    - 36 - -
    - + - func IsPolicy(name string) bool { -
    -
    - 37 - -
    - + - for _, p := range []PolicyName{SendTx, Deploy} { -
    -
    - 38 - -
    - + - if name == string(p) { -
    -
    - 39 - -
    - + - return true -
    -
    - 40 - -
    - + - } -
    -
    - 41 + + -
    - + - } +
    +
    +   +
    - 42 + + -
    - + - return false +
    +
    +   +
    - 43 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -97532,143 +172420,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -97721,367 +172599,314 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -93,6 +93,13 @@
    - 93 + + -
    +
    +
      - time.Sleep(cfg.IntervalToRefreshGasPrices.Duration) +
    - 94 + + -
    +
    +
      - } +
    - 95 + + -
    +
    +
      - }(&cfg, p) +
    - 96 + + -
    +
    +
     
    - 97 + + -
    +
    +
      - return p +
    - 98 + + -
    +
    +
      - } +
    -
    @@ -686,7 +693,7 @@
    -
    - 686 + + -
    +
    +
     
    - 687 + + -
    +
    +
      - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage +
    - 688 + + -
    +
    +
      - func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { +
    - 689 + + -
    - - - return p.effectiveGasPrice.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice) +
    +
    +   +
    - 690 + + -
    +
    +
      - } +
    - 691 + + -
    +
    +
     
    - 692 + + -
    +
    +
      - // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not +
    -
    @@ -728,3 +735,8 @@
    -
    - 728 + + -
    +
    +
      - } +
    - 729 + + -
    +
    +
      - return gas, nil +
    - 730 + + -
    +
    +
      - } +
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 93 + + -
    +
    +
      - time.Sleep(cfg.IntervalToRefreshGasPrices.Duration) +
    - 94 + + -
    +
    +
      - } +
    - 95 + + -
    +
    +
      - }(&cfg, p) +
    - 96 + + -
    - + - p.refreshBlockedAddresses() +
    +
    +   +
    - 97 + + -
    - + - go func(cfg *Config, p *Pool) { +
    +
    +   +
    - 98 + + -
    - + - for { +
    +
    +   +
    - 99 + + -
    - + - time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration) +
    +
    +   +
    - 100 + + -
    - + - p.refreshBlockedAddresses() +
    +
    +   +
    - 101 + + -
    - + - } +
    +
    +   +
    - 102 + + -
    - + - }(&cfg, p) +
    +
    +   +
    - 103 + + -
    +
    +
     
    - 104 + + -
    +
    +
      - return p +
    - 105 + + -
    +
    +
      - } +
    -
     
    -
    - 693 + + -
    +
    +
     
    - 694 + + -
    +
    +
      - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage +
    - 695 + + -
    +
    +
      - func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { +
    - 696 + + -
    - + - return state.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice) +
    +
    +   +
    - 697 + + -
    +
    +
      - } +
    - 698 + + -
    +
    +
     
    - 699 + + -
    +
    +
      - // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not +
    -
     
    -
    - 735 + + -
    +
    +
      - } +
    - 736 + + -
    +
    +
      - return gas, nil +
    - 737 + + -
    +
    +
      - } +
    - 738 + + -
    - + +
    +
    +  
    - 739 + + -
    - + - // CheckPolicy checks if an address is allowed by policy name +
    +
    +   +
    - 740 + + -
    - + - func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) { +
    +
    +   +
    - 741 + + -
    - + - return p.storage.CheckPolicy(ctx, policy, address) +
    +
    +   +
    - 742 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -98674,113 +173499,118 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    -
    @@ -2032,3 +2032,69 @@
    - 2032 + + -
    +
    +
      - require.NoError(t, err) +
    - 2033 + + -
    +
    +
      - return signedTx +
    - 2034 + + -
    +
    +
      - } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - -
    +
     
    +
    - + + 6 -
    +
    +
      -
    + "errors"
    - + + 7 -
    +
    +
      -
    + "fmt"
    - + + 8 -
    +
    +
      -
    + "math/big"
    - + + 9 -
    -   -
    +
    +
    + + + "strings"
    - + + 10 -
    +
    +
      -
    + "sync"
    - + + 11 -
    +
    +
      -
    + "testing"
    - + + 12 -
    +
    +
      -
    + "time"
    -
    -
    -
    -
    - - - + + + + + + + + + + + + + - - -
     
    - 2032 + 5417
      - require.NoError(t, err) + assert.ElementsMatch(t, []int{13, 14, 15}, results[4])
    - 2033 + 5418
      - return signedTx + assert.ElementsMatch(t, []int{16}, results[5])
    - 2034 + 5419
    @@ -98790,7 +173620,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2035 + 5420
    @@ -98800,67 +173630,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2036 + 5421
    + - func Test_PolicyAcl(t *testing.T) { + func TestSendRawTransactionJSONRPCCallWithPolicyApplied(t *testing.T) {
    - 2037 + 5422
    + - initOrResetDB(t) + // Set up the sender
    - 2038 + 5423
    + -
    + allowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0x28b2b0318721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    - 2039 + 5424
    + - poolSqlDB, err := db.NewSQLDB(poolDBCfg) + require.NoError(t, err)
    - 2040 + 5425
    + - require.NoError(t, err) + allowed, err := bind.NewKeyedTransactorWithChainID(allowedPrivateKey, big.NewInt(1))
    - 2041 + 5426
    + - defer poolSqlDB.Close() //nolint:gosec,errcheck + require.NoError(t, err)
    - 2042 + 5427
    @@ -98870,27 +173700,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2043 + 5428
    + - ctx := context.Background() + disallowedPrivateKey, err := crypto.HexToECDSA(strings.TrimPrefix("0xdeadbeef8721be8c8339199172cd7cc8f5e273800a35616ec893083a4b32c02e", "0x"))
    - 2044 + 5429
    + - s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) + require.NoError(t, err)
    - 2045 + 5430 + +
    + + + disallowed, err := bind.NewKeyedTransactorWithChainID(disallowedPrivateKey, big.NewInt(1)) +
    +
    + 5431
    @@ -98900,7 +173740,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2046 + 5432 + +
    + + + require.NotNil(t, disallowed) +
    +
    + 5433
    @@ -98910,17 +173760,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2047 + 5434
    + - p := pool.NewPool(cfg, bc, s, nil, uint64(1), nil) + allowedContract := common.HexToAddress("0x1")
    - 2048 + 5435 + +
    + + + disallowedContract := common.HexToAddress("0x2") +
    +
    + 5436
    @@ -98930,67 +173790,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2049 + 5437
    + - randAddr := func() common.Address { + senderDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed send_tx by policy")
    - 2050 + 5438
    + - buf := make([]byte, 20) + contractDenied := types.NewRPCError(types.AccessDeniedCode, "contract disallowed send_tx by policy")
    - 2051 + 5439
    + - _, err = rand.Read(buf) + deployDenied := types.NewRPCError(types.AccessDeniedCode, "sender disallowed deploy by policy")
    - 2052 + 5440
    + - require.NoError(t, err) +
    - 2053 + 5441
    + - return common.BytesToAddress(buf) + cfg := getSequencerDefaultConfig()
    - 2054 + 5442
    + - } + s, m, _ := newMockedServerWithCustomConfig(t, cfg)
    - 2055 + 5443 + +
    + + + defer s.Stop() +
    +
    + 5444
    @@ -99000,237 +173870,237 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2056 + 5445
    + - // Policies start out as deny lists, since there are no addresses on the + type testCase struct {
    - 2057 + 5446
    + - // lists, random addresses will always be allowed + Name string
    - 2058 + 5447
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + Input string
    - 2059 + 5448
    + - allow, err := p.CheckPolicy(ctx, policy, randAddr()) + ExpectedResult *common.Hash
    - 2060 + 5449
    + - require.NoError(t, err) + ExpectedError types.Error
    - 2061 + 5450
    + - require.True(t, allow) + Prepare func(t *testing.T, tc *testCase)
    - 2062 + 5451
    + - } + SetupMocks func(t *testing.T, m *mocksWrapper, tc testCase)
    - 2063 + 5452
    + -
    + }
    - 2064 + 5453
    + - addr := randAddr() +
    - 2065 + 5454
    + -
    + testCases := []testCase{
    - 2066 + 5455
    + - // put addr on lists + {
    - 2067 + 5456
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + Name: "Sender & contract on allow list, accepted",
    - 2068 + 5457
    + - ctag, err := poolSqlDB.Exec(ctx, "INSERT INTO pool.acl (policy, address) VALUES ($1,$2)", policy, addr.Hex()) + Prepare: func(t *testing.T, tc *testCase) {
    - 2069 + 5458
    + - require.NoError(t, err) + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 2070 + 5459
    + - require.Equal(t, int64(1), ctag.RowsAffected()) +
    - 2071 + 5460
    + - } + signedTx, err := allowed.Signer(allowed.From, tx)
    - 2072 + 5461
    + -
    + require.NoError(t, err)
    - 2073 + 5462
    + - // addr should not be denied by policy +
    - 2074 + 5463
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + txBinary, err := signedTx.MarshalBinary()
    - 2075 + 5464
    + - allow, err := p.CheckPolicy(ctx, policy, addr) + require.NoError(t, err)
    - 2076 + 5465
    + - require.NoError(t, err) +
    - 2077 + 5466
    + - require.False(t, allow) + rawTx := hex.EncodeToHex(txBinary)
    - 2078 + 5467
    + - } + require.NoError(t, err)
    - 2079 + 5468
    @@ -99240,2050 +174110,1906 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2080 + 5469
    + - // change policies to allow by acl + tc.Input = rawTx
    - 2081 + 5470
    + - ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true") + expectedHash := signedTx.Hash()
    - 2082 + 5471
    + - require.NoError(t, err) + tc.ExpectedResult = &expectedHash
    - 2083 + 5472
    + - require.Equal(t, int64(2), ctag.RowsAffected()) + tc.ExpectedError = nil
    - 2084 + 5473
    + -
    + },
    - 2085 + 5474
    + - // addr is now allowed + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 2086 + 5475
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + m.Pool.
    - 2087 + 5476
    + - allow, err := p.CheckPolicy(ctx, policy, addr) + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - 2088 + 5477
    + - require.NoError(t, err) + Return(nil).
    - 2089 + 5478
    + - require.True(t, allow) + Once()
    - 2090 + 5479
    + - } + m.Pool.
    - 2091 + 5480
    + -
    + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - 2092 + 5481
    + - // random addrs are now denied + Return(true, nil).
    - 2093 + 5482
    + - for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { + Once()
    - 2094 + 5483
    + - for _, a := range []common.Address{randAddr(), randAddr()} { + m.Pool.
    - 2095 + 5484
    + - allow, err := s.CheckPolicy(ctx, policy, a) + On("CheckPolicy", context.Background(), pool.SendTx, allowed.From).
    - 2096 + 5485
    + - require.NoError(t, err) + Return(true, nil).
    - 2097 + 5486
    + - require.False(t, allow) + Once()
    - 2098 + 5487
    + - } + },
    - 2099 + 5488
    + - } + },
    - 2100 + 5489
    + - } -
    -
    -
    + {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -292,6 +292,7 @@
    - 292 + + 5490 +
    -   - // prior to executing the call. + + + Name: "Contract not on allow list, rejected",
    - 293 + + 5491 +
    -   - map<string, OverrideAccountV2> state_override = 23; + + + Prepare: func(t *testing.T, tc *testCase) {
    - 294 + + 5492 +
    -   - DebugV2 debug = 24; + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5493 -
    -   +
    +
    + +
    - 295 + + 5494 +
    -   - } + + + signedTx, err := allowed.Signer(allowed.From, tx)
    - 296 + + 5495 +
    -   -
    + + + require.NoError(t, err)
    - 297 + + 5496 +
    -   - message L1DataV2 { -
    -
    -
    + + +
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    - 292 + + 5497 +
    -   - // prior to executing the call. + + + txBinary, err := signedTx.MarshalBinary()
    - 293 + + 5498 +
    -   - map<string, OverrideAccountV2> state_override = 23; + + + require.NoError(t, err)
    - 294 + + 5499 +
    -   - DebugV2 debug = 24; + + +
    - 295 + 5500
    + - uint64 execution_mode = 25; + rawTx := hex.EncodeToHex(txBinary)
    - 296 + + 5501 +
    -   - } + + + require.NoError(t, err)
    - 297 + + 5502 +
    -   + +
    - 298 + + 5503 +
    -   - message L1DataV2 { -
    -
    -
    + + + tc.Input = rawTx
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/addrqueue.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -211,6 +211,10 @@
    - 211 + + 5504 +
    -   - if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce { + + + tc.ExpectedResult = nil
    - 212 + + 5505 +
    -   - log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr) + + + tc.ExpectedError = contractDenied
    - 213 + + 5506 +
    -   - a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx + + + },
    - + + 5507 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5508 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5509 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    - + + 5510 -
    -   -
    +
    +
    + + + Return(false, contractDenied).
    - 214 + + 5511 +
    -   - } + + + Once()
    - 215 + + 5512 +
    -   -
    + + + },
    - 216 + + 5513 +
    -   - return a.readyTx, oldReadyTx, txsToDelete -
    -
    -
    + + + },
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    - 211 + + 5514 +
    -   - if oldReadyTx != nil && oldReadyTx.Nonce > a.currentNonce { + + + {
    - 212 + + 5515 +
    -   - log.Infof("set readyTx %s as notReadyTx from addrQueue %s", oldReadyTx.HashStr, a.fromStr) + + + Name: "Sender not on allow list, rejected",
    - 213 + + 5516 +
    -   - a.notReadyTxs[oldReadyTx.Nonce] = oldReadyTx + + + Prepare: func(t *testing.T, tc *testCase) {
    - 214 + 5517
    + - } else if oldReadyTx != nil { // if oldReadyTx doesn't have a valid nonce then we add it to the txsToDelete + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 215 + 5518
    + - reason := runtime.ErrIntrinsicInvalidNonce.Error() +
    - 216 + 5519
    + - oldReadyTx.FailedReason = &reason + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - 217 + 5520
    + - txsToDelete = append(txsToDelete, oldReadyTx) + require.NoError(t, err)
    - 218 + + 5521 +
    -   - } + + +
    - 219 + + 5522 +
    -   -
    + + + txBinary, err := signedTx.MarshalBinary()
    - 220 + + 5523 +
    -   - return a.readyTx, oldReadyTx, txsToDelete -
    -
    -
    + + + require.NoError(t, err)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/datastreamer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -42,6 +43,7 @@
    - 42 + + 5524 +
    -   - l2Transactions = append(l2Transactions, l2Transaction) + + +
    - 43 + + 5525 +
    -   - } + + + rawTx := hex.EncodeToHex(txBinary)
    - 44 + + 5526 +
    -   -
    + + + require.NoError(t, err)
    - + + 5527 -
    -   +
    +
    + +
    - 45 + + 5528 +
    -   - f.dataToStream <- state.DSL2FullBlock{ + + + tc.Input = rawTx
    - 46 + + 5529 +
    -   - DSL2Block: l2Block, + + + tc.ExpectedResult = nil
    - 47 + + 5530 +
    -   - Txs: l2Transactions, -
    -
    -
    + + + tc.ExpectedError = senderDenied
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    - 43 + + 5531 +
    -   - l2Transactions = append(l2Transactions, l2Transaction) + + + },
    - 44 + + 5532 +
    -   - } + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - 45 + + 5533 +
    -   -
    + + + m.Pool.
    - 46 + 5534
    + - log.Infof("sending l2block %d to datastream channel", blockResponse.BlockNumber) + On("CheckPolicy", context.Background(), pool.SendTx, allowedContract).
    - 47 + + 5535 +
    -   - f.dataToStream <- state.DSL2FullBlock{ + + + Return(true, nil).
    - 48 + + 5536 +
    -   - DSL2Block: l2Block, + + + Once()
    - 49 + + 5537 +
    -   - Txs: l2Transactions, -
    -
    -
    + + + m.Pool.
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -38,7 +39,7 @@
    - 38 + + 5538 +
    -   - workerIntf workerInterface + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowed.From).
    - 39 + + 5539 +
    -   - poolIntf txPool + + + Return(false, senderDenied).
    - 40 + + 5540 +
    -   - stateIntf stateInterface + + + Once()
    - 41 + + 5541 +
    - - - etherman etherman + + + },
    - 42 + + 5542 +
    -   - wipBatch *Batch + + + },
    - 43 + + 5543 +
    -   - wipL2Block *L2Block + + + {
    - 44 + + 5544 +
    -   - batchConstraints state.BatchConstraintsCfg + + + Name: "Unsigned tx with allowed contract, accepted", // for backward compatibility
    -
    @@ -87,7 +88,7 @@
    -
    - 87 + + 5545 +
    -   - workerIntf workerInterface, + + + Prepare: func(t *testing.T, tc *testCase) {
    - 88 + + 5546 +
    -   - poolIntf txPool, + + + tx := ethTypes.NewTransaction(1, allowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - 89 + + 5547 +
    -   - stateIntf stateInterface, + + +
    - 90 + + 5548 +
    - - - etherman etherman, + + + txBinary, err := tx.MarshalBinary()
    - 91 + + 5549 +
    -   - sequencerAddr common.Address, + + + require.NoError(t, err)
    - 92 + + 5550 +
    -   - isSynced func(ctx context.Context) bool, + + +
    - 93 + + 5551 +
    -   - batchConstraints state.BatchConstraintsCfg, + + + rawTx := hex.EncodeToHex(txBinary)
    -
    @@ -220,10 +221,98 @@
    -
    - 220 + + 5552 +
    -   - f.storedFlushIDCond.L.Unlock() + + + require.NoError(t, err)
    - 221 + + 5553 +
    -   - } + + +
    - 222 + + 5554 +
    -   -
    + + + tc.Input = rawTx
    - + + 5555 -
    -   -
    +
    +
    + + + expectedHash := tx.Hash()
    - + + 5556 -
    -   -
    +
    +
    + + + tc.ExpectedResult = &expectedHash
    - + + 5557 -
    -   -
    +
    +
    + + + tc.ExpectedError = nil
    - + + 5558 -
    -   -
    +
    +
    + + + },
    - + + 5559 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5560 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5561 -
    -   -
    +
    +
    + + + On("AddTx", context.Background(), mock.IsType(ethTypes.Transaction{}), "").
    - + + 5562 -
    -   -
    +
    +
    + + + Return(nil).
    - + + 5563 -
    -   -
    +
    +
    + + + Once()
    - + + 5564 -
    -   -
    +
    +
    + + + // policy does not reject this case for backward compat
    - + + 5565 -
    -   -
    +
    +
    + + + },
    - + + 5566 -
    -   -
    +
    +
    + + + },
    - + + 5567 -
    -   -
    +
    +
    + + + {
    - + + 5568 -
    -   -
    +
    +
    + + + Name: "Unsigned tx with disallowed contract, rejected",
    - + + 5569 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5570 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, disallowedContract, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5571 -
    -   +
    +
    + +
    - + + 5572 -
    -   -
    +
    +
    + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - + + 5573 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5574 -
    -   +
    +
    + +
    - + + 5575 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5576 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5577 -
    -   +
    +
    + +
    - + + 5578 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5579 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5580 -
    -   +
    +
    + +
    - + + 5581 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5582 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5583 -
    -   -
    +
    +
    + + + tc.ExpectedError = contractDenied
    - + + 5584 -
    -   -
    +
    +
    + + + },
    - + + 5585 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5586 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5587 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.SendTx, disallowedContract).
    - + + 5588 -
    -   -
    +
    +
    + + + Return(false, contractDenied).
    - + + 5589 -
    -   -
    +
    +
    + + + Once()
    - + + 5590 -
    -   -
    +
    +
    + + + },
    - + + 5591 -
    -   -
    +
    +
    + + + },
    - + + 5592 -
    -   -
    +
    +
    + + + {
    - + + 5593 -
    -   -
    +
    +
    + + + Name: "Send invalid tx input", // for backward compatibility
    - + + 5594 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5595 -
    -   -
    +
    +
    + + + tc.Input = "0x1234"
    - + + 5596 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5597 -
    -   -
    +
    +
    + + + tc.ExpectedError = types.NewRPCError(types.InvalidParamsErrorCode, "invalid tx input")
    - + + 5598 -
    -   -
    +
    +
    + + + },
    - + + 5599 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {},
    - + + 5600 -
    -   -
    +
    +
    + + + },
    - + + 5601 -
    -   -
    +
    +
    + + + {
    - + + 5602 -
    -   -
    +
    +
    + + + Name: "Sender not on deploy allow list, rejected",
    - + + 5603 -
    -   -
    +
    +
    + + + Prepare: func(t *testing.T, tc *testCase) {
    - + + 5604 -
    -   -
    +
    +
    + + + deployAddr := common.HexToAddress("0x0")
    - + + 5605 -
    -   -
    +
    +
    + + + tx := ethTypes.NewTransaction(1, deployAddr, big.NewInt(1), uint64(1), big.NewInt(1), []byte{})
    - + + 5606 -
    -   +
    +
    + +
    - + + 5607 -
    -   -
    +
    +
    + + + signedTx, err := disallowed.Signer(disallowed.From, tx)
    - + + 5608 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5609 -
    -   +
    +
    + +
    - + + 5610 -
    -   -
    +
    +
    + + + txBinary, err := signedTx.MarshalBinary()
    - + + 5611 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5612 -
    -   +
    +
    + +
    - + + 5613 -
    -   -
    +
    +
    + + + rawTx := hex.EncodeToHex(txBinary)
    - + + 5614 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5615 -
    -   +
    +
    + +
    - + + 5616 -
    -   -
    +
    +
    + + + tc.Input = rawTx
    - + + 5617 -
    -   -
    +
    +
    + + + tc.ExpectedResult = nil
    - + + 5618 -
    -   -
    +
    +
    + + + tc.ExpectedError = deployDenied
    - + + 5619 -
    -   -
    +
    +
    + + + },
    - + + 5620 -
    -   -
    +
    +
    + + + SetupMocks: func(t *testing.T, m *mocksWrapper, tc testCase) {
    - + + 5621 -
    -   -
    +
    +
    + + + m.Pool.
    - + + 5622 -
    -   -
    +
    +
    + + + On("CheckPolicy", context.Background(), pool.Deploy, disallowed.From).
    - + + 5623 -
    -   -
    +
    +
    + + + Return(false, nil).
    - + + 5624 -
    -   -
    +
    +
    + + + Once()
    - + + 5625 -
    -   -
    +
    +
    + + + },
    - + + 5626 -
    -   -
    +
    +
    + + + },
    - + + 5627 -
    -   -
    +
    +
    + + + }
    - + + 5628 -
    -   +
    +
    + +
    - 223 + + 5629 +
    -   - func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { + + + for _, testCase := range testCases {
    - + + 5630 -
    -   -
    +
    +
    + + + t.Run(testCase.Name, func(t *testing.T) {
    - + + 5631 -
    -   -
    +
    +
    + + + tc := testCase
    - + + 5632 -
    -   -
    +
    +
    + + + tc.Prepare(t, &tc)
    - + + 5633 -
    -   -
    +
    +
    + + + tc.SetupMocks(t, m, tc)
    - + + 5634 -
    -   +
    +
    + +
    - + + 5635 -
    -   -
    +
    +
    + + + res, err := s.JSONRPCCall("eth_sendRawTransaction", tc.Input)
    - + + 5636 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5637 -
    -   +
    +
    + +
    - + + 5638 -
    -   -
    +
    +
    + + + assert.Equal(t, float64(1), res.ID)
    - 224 + + 5639 +
    -   - firstL1InfoRootUpdate := true + + + assert.Equal(t, "2.0", res.JSONRPC)
    - 225 + + 5640 +
    -   - skipFirstSleep := true + + +
    - 226 + + 5641 +
    -   -
    + + + if res.Result != nil || tc.ExpectedResult != nil {
    - + + 5642 -
    -   -
    +
    +
    + + + var result common.Hash
    - + + 5643 -
    -   -
    +
    +
    + + + err = json.Unmarshal(res.Result, &result)
    - + + 5644 -
    -   -
    +
    +
    + + + require.NoError(t, err)
    - + + 5645 -
    -   -
    +
    +
    + + + assert.Equal(t, *tc.ExpectedResult, result)
    - + + 5646 -
    -   -
    +
    +
    + + + }
    - 227 + + 5647 +
    -   - for { + + + if res.Error != nil || tc.ExpectedError != nil {
    - 228 + + 5648 +
    -   - if skipFirstSleep { + + + assert.Equal(t, tc.ExpectedError.ErrorCode(), res.Error.Code)
    - 229 + + 5649 +
    -   - skipFirstSleep = false + + + assert.Equal(t, tc.ExpectedError.Error(), res.Error.Message)
    -
    @@ -244,7 +333,7 @@
    -
    - 244 + + 5650 +
    -   -
    + + + }
    - 245 + + 5651 +
    -   - l1InfoRoot, err := f.stateIntf.GetLatestL1InfoRoot(ctx, maxBlockNumber) + + + })
    - 246 + + 5652 +
    -   - if err != nil { + + + }
    - 247 + + 5653 +
    - - - log.Errorf("error checking latest L1InfoRoot, error: %v", err) + + + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -101727,118 +176418,113 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - @@ -101922,182 +176608,202 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - + - - - - - - - - - - - - - - - - + - + + + - - - - - @@ -102107,7 +176813,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102117,7 +176823,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102127,7 +176833,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102137,7 +176843,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102147,7 +176853,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102157,7 +176863,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102167,7 +176873,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102177,7 +176883,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102187,7 +176893,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102197,7 +176903,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102207,7 +176913,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102217,7 +176923,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102227,7 +176933,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102237,7 +176943,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102247,7 +176953,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102257,7 +176963,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102267,7 +176973,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102277,7 +176983,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102287,7 +176993,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102297,7 +177003,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102307,7 +177013,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102317,7 +177023,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102327,7 +177033,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102337,7 +177043,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102347,7 +177053,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102357,7 +177063,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102367,7 +177073,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102377,7 +177083,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102387,7 +177093,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -102397,402 +177103,610 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - + + + + + + + + + +
    +
    @@ -204,6 +204,53 @@
    - 248 + 204
      - continue + })
    - 249 + 205
      - } + }
    - 250 + 206
    @@ -101292,428 +176018,393 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -254,26 +343,19 @@
    -
    - 254 + + -
    +
    +
      - } +
    - 255 + + -
    +
    +
     
    - 256 + + -
    +
    +
      - if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { -
    -
    - 257 - -
    - - - log.Infof("received new L1InfoRoot, l1InfoTreeIndex: %d, l1InfoTreeRoot: %s, l1Block: %d", -
    -
    - 258 - -
    - - - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.BlockNumber) +
    - 259 + + -
    +
    +
     
    - 260 + + -
    - - - // Sanity check l1BlockState (l1InfoRoot.BlockNumber) blockhash matches blockhash on ethereum. We skip it if l1InfoRoot.BlockNumber == 0 (empty tree) +
    +
    +   +
    - 261 + + -
    - - - if l1InfoRoot.BlockNumber > 0 { +
    +
    +   +
    - 262 + + -
    - - - l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil) +
    +
    +   +
    - 263 + + -
    +
    +
      - if err != nil { +
    - 264 + + -
    - - - log.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err) +
    +
    +   +
    - 265 + + -
    +
    +
      - continue +
    - 266 + + -
    +
    +
      - } +
    - 267 + + -
    +
    +
     
    - 268 + + -
    - - - l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber)) +
    +
    +   +
    - 269 + + -
    - - - if err != nil { +
    +
    +   +
    - 270 + + -
    - - - log.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err) +
    +
    +   +
    - 271 + + -
    - - - continue +
    +
    +   +
    - 272 + + -
    - - - } +
    +
    +   +
    - 273 + + -
    - - - if l1BlockState.BlockHash != l1BlockEth.Hash() { +
    +
    +   +
    - 274 + + -
    - - - log.Warnf("skipping use of l1InfoTreeIndex %d, L1 block %d blockhash %s doesn't match blockhash on ethereum %s (L1 reorg?)", +
    +
    +   +
    - 275 + + -
    - - - l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) +
    +
    +   +
    - 276 + + -
    - - - continue +
    +
    +   +
    - 277 + + -
    +
    +
      - } +
    - 278 + + -
    +
    +
      - } +
    - 279 + + -
    +
    +
     
    -
    @@ -283,12 +365,7 @@
    -
    - 283 + + -
    +
    +
      - f.lastL1InfoTree = l1InfoRoot +
    - 284 + + -
    +
    +
      - f.lastL1InfoTreeMux.Unlock() +
    - 285 + + -
    +
    +
     
    - 286 + + -
    - - - if !f.lastL1InfoTreeValid { +
    +
    +   +
    - 287 + + -
    - - - f.lastL1InfoTreeCond.L.Lock() +
    +
    +   +
    - 288 + + -
    - - - f.lastL1InfoTreeValid = true +
    +
    +   +
    - 289 + + -
    - - - f.lastL1InfoTreeCond.Broadcast() +
    +
    +   +
    - 290 + + -
    - - - f.lastL1InfoTreeCond.L.Unlock() +
    +
    +   +
    - 291 + + -
    - - - } +
    +
    +   +
    - 292 + + -
    +
    +
      - } +
    - 293 + + -
    +
    +
      - } +
    - 294 + + -
    +
    +
      - } +
    -
    @@ -390,6 +467,7 @@
    -
    - 390 + + -
    +
    +
      - SkipWriteBlockInfoRoot_V2: true, +
    - 391 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 392 + + -
    +
    +
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, +
    - 393 + + -
    +
    +
      - } +
    - 394 + + -
    +
    +
     
    - 395 + + -
    +
    +
      - txGasPrice := tx.GasPrice +
    -
    @@ -436,7 +514,7 @@
    -
    - 436 + + -
    +
    +
      - } +
    - 437 + + -
    +
    +
      - } +
    - 438 + + -
    +
    +
     
    - 439 + + -
    - - - egpPercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) +
    +
    +   +
    - 440 + 207
      - if err != nil { + // GetFullBlockByNumber returns information about a block by block number
    - 441 + 208
      - if f.effectiveGasPrice.IsEnabled() { + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
    - 442 + 209
      - return nil, err + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    -
    @@ -549,7 +627,7 @@
    +
    @@ -516,7 +563,7 @@
    - 549 + 516
    @@ -101848,62 +176534,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 550 + 517
      - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging + if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice
    - 551 + 518
      - if !egpEnabled { + // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice
    - 552 + 519
    - - effectivePercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) + txEGPPct, err = z.pool.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP)
    - 553 + 520
      - if err != nil { + if err != nil {
    - 554 + 521
      - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) + return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false)
    - 555 + 522
      - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) + }
    - 39 + 204
      - workerIntf workerInterface + })
    - 40 + 205
      - poolIntf txPool + }
    - 41 + 206
      - stateIntf stateInterface +
    - 42 + + 207 +
    + - etherman ethermanInterface + type batchDataFunc func(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 43 + + 208 +
    -   - wipBatch *Batch + + +
    - 44 + + 209 +
    -   - wipL2Block *L2Block + + + // GetBatchDataByNumbers returns L2 batch data by batch numbers.
    - 45 + + 210 +
    -   - batchConstraints state.BatchConstraintsCfg + + + func (z *ZKEVMEndpoints) GetBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    -
     
    +
    + 211 + +
    + + + return z.getBatchData(filter, z.state.GetBatchL2DataByNumbers) +
    - 88 + + 212 +
    -   - workerIntf workerInterface, + + + }
    - 89 + + 213 +
    -   - poolIntf txPool, + + +
    - 90 + + 214 +
    -   - stateIntf stateInterface, + + + // GetForcedBatchDataByNumbers returns forced batch data by batch numbers.
    - 91 + + 215 +
    + - etherman ethermanInterface, + func (z *ZKEVMEndpoints) GetForcedBatchDataByNumbers(filter types.BatchFilter) (interface{}, types.Error) {
    - 92 + + 216 +
    -   - sequencerAddr common.Address, + + + return z.getBatchData(filter, z.state.GetForcedBatchDataByNumbers)
    - 93 + + 217 +
    -   - isSynced func(ctx context.Context) bool, + + + }
    - 94 + + 218 +
    -   - batchConstraints state.BatchConstraintsCfg, + + +
    -
     
    +
    + 219 + +
    + + + func (z *ZKEVMEndpoints) getBatchData(filter types.BatchFilter, f batchDataFunc) (interface{}, types.Error) { +
    + + 220 + +
    + + + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) { +
    +
    221 +
    -   - f.storedFlushIDCond.L.Unlock() + + + batchNumbers := make([]uint64, 0, len(filter.Numbers))
    + 222 +
    -   - } + + + for _, bn := range filter.Numbers {
    + 223 +
    -   -
    + + + n, rpcErr := bn.GetNumericBatchNumber(ctx, z.state, z.etherman, dbTx)
    + - func (f *finalizer) checkValidL1InfoRoot(ctx context.Context, l1InfoRoot state.L1InfoTreeExitRootStorageEntry) (bool, error) { + if rpcErr != nil {
    + - // Check L1 block hash matches + return nil, rpcErr
    + - l1BlockState, err := f.stateIntf.GetBlockByNumber(ctx, l1InfoRoot.BlockNumber, nil) + }
    + - if err != nil { + batchNumbers = append(batchNumbers, n)
    + - return false, fmt.Errorf("error getting L1 block %d from the state, error: %v", l1InfoRoot.BlockNumber, err) + }
    + - } +
    + -
    + batchesData, err := f(ctx, batchNumbers, dbTx)
    + - l1BlockEth, err := f.etherman.HeaderByNumber(ctx, new(big.Int).SetUint64(l1InfoRoot.BlockNumber)) + if errors.Is(err, state.ErrNotFound) {
    + - if err != nil { + return nil, nil
    + - return false, fmt.Errorf("error getting L1 block %d from ethereum, error: %v", l1InfoRoot.BlockNumber, err) + } else if err != nil {
    + - } + return RPCErrorResponse(types.DefaultErrorCode,
    + -
    + fmt.Sprintf("couldn't load batch data from state by numbers %v", filter.Numbers), err, true)
    + - if l1BlockState.BlockHash != l1BlockEth.Hash() { + }
    + - warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, l1Block: %d. L1 block hash %s doesn't match block hash on ethereum %s (L1 reorg?)", +
    + - l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, l1BlockState.BlockHash, l1BlockEth.Hash()) + ret := make([]*types.BatchData, 0, len(batchNumbers))
    + - log.Warnf(warnmsg) + for _, n := range batchNumbers {
    + - f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + data := &types.BatchData{Number: types.ArgUint64(n)}
    + -
    + if b, ok := batchesData[n]; ok {
    + - return false, nil + data.BatchL2Data = b
    + - } + data.Empty = false
    + -
    + } else {
    + - // Check l1InfoRootIndex and GER matches. We retrieve the info of the last l1InfoTree event in the block, since in the case we have several l1InfoTree events + data.Empty = true
    + - // in the same block, the function checkL1InfoTreeUpdate retrieves only the last one and skips the others + }
    + - log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash) + ret = append(ret, data)
    + - blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber) + }
    + - if err != nil { +
    + - return false, err + return types.BatchDataResult{Data: ret}, nil
    + - } + })
    + -
    + }
    + - //Get L1InfoTree events of the L1 block where the l1InforRoot we need to check was synced +
    + 254 +
    - + - lastGER := state.ZeroHash +   + // GetFullBlockByNumber returns information about a block by block number
    + 255 +
    - + - for _, block := range blocks { +   + func (z *ZKEVMEndpoints) GetFullBlockByNumber(number types.BlockNumber, fullTx bool) (interface{}, types.Error) {
    + 256 +
    - + - blockEventsOrder := eventsOrder[block.BlockHash] +   + return z.txMan.NewDbTxScope(z.state, func(ctx context.Context, dbTx pgx.Tx) (interface{}, types.Error) {
    - 257 + +
     
    +
    + 563 +
    - + - for _, order := range blockEventsOrder { +   +
    - 258 + + 564 +
    - + - if order.Name == ethermanTypes.L1InfoTreeOrder { +   + if txEGP.Cmp(txGasPrice) == -1 { // txEGP < txGasPrice
    - 259 + + 565 +
    - + - lastGER = block.L1InfoTree[order.Pos].GlobalExitRoot +   + // We need to "round" the final effectiveGasPrice to a 256 fraction of the txGasPrice
    - 260 + + 566 +
    + - log.Debugf("l1InfoTree event, pos: %d, GER: %s", order.Pos, lastGER) + txEGPPct, err = state.CalculateEffectiveGasPricePercentage(txGasPrice, txEGP)
    - 261 + + 567 + +
    +   + if err != nil { +
    +
    + 568 + +
    +   + return nil, nil, types.NewRPCError(types.DefaultErrorCode, "failed to calculate effective gas price percentage", err, false) +
    +
    + 569 + +
    +   + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/endpoints_zkevm_test.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -2705,3 +2705,32 @@
    +
    + 2705 + +
    +   + }) +
    +
    + 2706 + +
    +   + } +
    +
    + 2707 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + -
    - + - } +
    +
    +   +
    - 262 + + -
    - + - } +
    +
    +   +
    - 263 + + -
    - + - } +
    +
    +   +
    - 264 + + -
    - + +
    +
    +  
    - 265 + + -
    - + - // Get the deposit count in the moment when the L1InfoRoot was synced +
    +
    +   +
    - 266 + + -
    - + - depositCount, err := f.etherman.DepositCount(ctx, &l1InfoRoot.BlockNumber) +
    +
    +   +
    - 267 + + -
    - + - if err != nil { +
    +
    +   +
    - 268 + + -
    - + - return false, err +
    +
    +   +
    - 269 + + -
    - + - } +
    +
    +   +
    - 270 + + -
    - + - // l1InfoTree index starts at 0, therefore we need to subtract 1 to the depositCount to get the last index at that moment +
    +
    +   +
    - 271 + + -
    - + - index := uint32(depositCount.Uint64()) +
    +
    +   +
    - 272 + + -
    - + - if index > 0 { // we check this as protection, but depositCount should be greater that 0 in this context +
    +
    +   +
    - 273 + + -
    - + - index-- +
    +
    +   +
    - 274 + + -
    - + - } else { +
    +
    +   +
    - 275 + + -
    - + - warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. DepositCount value returned by the smartcontrat is 0 and that isn't possible in this context", +
    +
    +   +
    - 276 + + -
    - + - l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber) +
    +
    +   +
    - 277 + + -
    - + - log.Warn(warnmsg) +
    +
    +   +
    - 278 + + -
    - + - f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) +
    +
    +   +
    - 279 + + -
    - + +
    +
    +  
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    - 280 + + 2705 +
    - + - return false, nil +   + })
    - 281 + + 2706 +
    - + +   }
    - 282 + + 2707 +
    - + -
    +   + }
    - 283 + 2708
    + - log.Debugf("checking valid l1InfoRoot, index: %d, GER: %s, l1Block: %d, scIndex: %d, scGER: %s", +
    - 284 + 2709
    + - l1InfoRoot.BlockNumber, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, index, lastGER) + func TestClient_BatchesByNumbers(t *testing.T) {
    - 285 + 2710
    + -
    + const batchesCount = 6
    - 286 + 2711
    + - if (l1InfoRoot.GlobalExitRoot.GlobalExitRoot != lastGER) || (l1InfoRoot.L1InfoTreeIndex != index) { +
    - 287 + 2712
    + - warnmsg := fmt.Sprintf("invalid l1InfoRoot %s, index: %d, GER: %s, blockNum: %d. It doesn't match with smartcontract l1InfoRoot, index: %d, GER: %s", + s, m, _ := newSequencerMockedServer(t)
    - 288 + 2713
    + - l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.GlobalExitRoot.GlobalExitRoot, l1InfoRoot.BlockNumber, index, lastGER) + defer s.Stop()
    - 289 + 2714
    + - log.Warn(warnmsg) +
    - 290 + 2715
    + - f.LogEvent(ctx, event.Level_Critical, event.EventID_InvalidInfoRoot, warnmsg, nil) + batchesDataMap := make(map[uint64][]byte, batchesCount)
    - 291 + 2716
    + -
    + for i := 0; i < batchesCount; i++ {
    - 292 + 2717
    + - return false, nil + batchesDataMap[uint64(i+1)] = []byte(fmt.Sprintf("batch %d data", i+1))
    - 293 + 2718
    @@ -102802,7 +177716,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 294 + 2719
    @@ -102812,27 +177726,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 295 + 2720
    + - return true, nil + m.State.On("GetBatchL2DataByNumbers", mock.Anything, mock.Anything, mock.Anything).
    - 296 + 2721
    + - } + Return(batchesDataMap, nil).Once()
    - 297 + 2722
    @@ -102840,169 +177754,129 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 298 - -
    -   - func (f *finalizer) checkL1InfoTreeUpdate(ctx context.Context) { -
    -
    - 299 + 2723
    + - broadcastL1InfoTreeValid := func() { + m.State.On("BeginStateTransaction", context.Background()).
    - 300 + 2724
    + - if !f.lastL1InfoTreeValid { + Return(m.DbTx, nil).Once()
    - 301 + 2725
    + - f.lastL1InfoTreeCond.L.Lock() +
    - 302 + 2726
    + - f.lastL1InfoTreeValid = true + m.DbTx.On("Commit", context.Background()).Return(nil).Once()
    - 303 + 2727
    + - f.lastL1InfoTreeCond.Broadcast() +
    - 304 + 2728
    + - f.lastL1InfoTreeCond.L.Unlock() + zkEVMClient := client.NewClient(s.ServerURL)
    - 305 + 2729
    + - } + reqBatchesNum := []*big.Int{big.NewInt(1), big.NewInt(3), big.NewInt(4)}
    - 306 + 2730
    + - } + result, err := zkEVMClient.BatchesByNumbers(context.Background(), reqBatchesNum)
    - 307 + 2731
    + -
    -
    -
    - 308 - -
    -   - firstL1InfoRootUpdate := true -
    -
    - 309 - -
    -   - skipFirstSleep := true -
    -
    - 310 - -
    -   -
    + require.NoError(t, err)
    - 311 + 2732
    + - if f.cfg.L1InfoTreeCheckInterval.Duration.Seconds() == 0 { //nolint:gomnd + require.Len(t, result, len(reqBatchesNum))
    - 312 + 2733
    + - broadcastL1InfoTreeValid() + for i, batchNum := range reqBatchesNum {
    - 313 + 2734
    + - return + require.Equal(t, hex.EncodeToHex(batchesDataMap[batchNum.Uint64()]), result[i].BatchL2Data.Hex())
    - 314 + 2735
    @@ -103012,164 +177886,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 315 + 2736
    + -
    -
    -
    - 316 - -
    -   - for { -
    -
    - 317 - -
    -   - if skipFirstSleep { + }
    - 318 - -
    -   - skipFirstSleep = false +
    +
    - - +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/policy.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -0,0 +1,61 @@
    - 333 + + -
    +
    +
     
    - 334 - -
    -   - l1InfoRoot, err := f.stateIntf.GetLatestL1InfoRoot(ctx, maxBlockNumber) -
    -
    - 335 - -
    -   - if err != nil { -
    -
    - 336 - -
    - + - log.Errorf("error getting latest l1InfoRoot, error: %v", err) -
    -
    - 337 - -
    -   - continue -
    -
    - 338 - -
    -   - } -
    -
    - 339 + + -
    +
    +
     
    -
     
    -
    - 343 - -
    -   - } -
    -
    - 344 + + -
    +
    +
     
    - 345 - -
    -   - if firstL1InfoRootUpdate || l1InfoRoot.L1InfoTreeIndex > f.lastL1InfoTree.L1InfoTreeIndex { -
    -
    - 346 - -
    - + - log.Infof("received new l1InfoRoot %s, index: %d, l1Block: %d", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) -
    -
    @@ -103181,125 +177964,55 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 347 + + -
    +
    +
     
    - 348 - -
    - + - // Check if new l1InfoRoot is valid. We skip it if l1InfoTreeIndex is 0 (it's a special case) -
    -
    - 349 - -
    - + - if l1InfoRoot.L1InfoTreeIndex > 0 { -
    -
    - 350 - -
    - + - valid, err := f.checkValidL1InfoRoot(ctx, l1InfoRoot) -
    -
    - 351 + + -
    +
    +
      - if err != nil { -
    -
    - 352 - -
    - + - log.Errorf("error validating new l1InfoRoot, index: %d, error: %v", l1InfoRoot.L1InfoTreeIndex, err) +
    - 353 + + -
    +
    +
      - continue +
    - 354 + + -
    +
    +
      - } +
    - 355 + + -
    +
    +
     
    - 356 - -
    - + - if !valid { -
    -
    - 357 - -
    - + - log.Warnf("invalid l1InfoRoot %s, index: %d, l1Block: %d. Stopping syncing l1InfoTreeIndex", l1InfoRoot.L1InfoTreeRoot, l1InfoRoot.L1InfoTreeIndex, l1InfoRoot.BlockNumber) -
    -
    - 358 - -
    - + - return -
    -
    @@ -103361,80 +178074,65 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 359 + + -
    +
    +
      - } +
    - 360 + + -
    +
    +
      - } +
    - 361 + + -
    +
    +
     
    -
     
    -
    - 365 + + -
    +
    +
      - f.lastL1InfoTree = l1InfoRoot +
    - 366 + + -
    +
    +
      - f.lastL1InfoTreeMux.Unlock() +
    - 367 + + -
    +
    +
     
    - 368 - -
    - + - broadcastL1InfoTreeValid() -
    -
    @@ -103486,377 +178184,303 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 369 + + -
    +
    +
      - } +
    - 370 + + -
    +
    +
      - } +
    - 371 + + -
    +
    +
      - } +
    -
     
    -
    - 467 + + -
    +
    +
      - SkipWriteBlockInfoRoot_V2: true, +
    - 468 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 469 + + -
    +
    +
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, -
    -
    - 470 - -
    - + - ExecutionMode: executor.ExecutionMode0, +
    - 471 + + -
    +
    +
      - } +
    - 472 + + -
    +
    +
     
    - 473 + + -
    +
    +
      - txGasPrice := tx.GasPrice +
    -
     
    -
    - 514 + + -
    +
    +
      - } +
    - 515 + + -
    +
    +
      - } +
    - 516 + + -
    +
    +
     
    - 517 - -
    - + - egpPercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) -
    -
    - 518 + + -
    +
    +
      - if err != nil { +
    - 519 + + -
    +
    +
      - if f.effectiveGasPrice.IsEnabled() { +
    - 520 + + -
    +
    +
      - return nil, err +
    -
     
    -
    - 627 + + -
    +
    +
     
    - 628 + + -
    +
    +
      - // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging +
    - 629 + + -
    +
    +
      - if !egpEnabled { -
    -
    - 630 - -
    - + - effectivePercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice) +
    - 631 + + -
    +
    +
      - if err != nil { +
    - 632 + + -
    +
    +
      - log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err) +
    - 633 + + -
    +
    +
      - tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - @@ -103880,33 +178504,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -103924,562 +178548,682 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -30,12 +31,14 @@
    - 30 + + -
    +
    +
      - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) +
    - 31 + + -
    +
    +
      - } +
    - 32 + + -
    +
    +
     
    - 33 + + -
    - - - // etherman contains the methods required to interact with ethereum. +
    +
    +   +
    - 34 + + -
    - - - type etherman interface { +
    +
    +   +
    - 35 + + -
    +
    +
      - TrustedSequencer() (common.Address, error) +
    - 36 + + -
    +
    +
      - GetLatestBatchNumber() (uint64, error) +
    - 37 + + -
    +
    +
      - GetLatestBlockNumber(ctx context.Context) (uint64, error) +
    - 38 + + -
    +
    +
      - HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) +
    - 39 + + -
    +
    +
      - } +
    - 40 + + -
    +
    +
     
    - 41 + + -
    +
    +
      - // stateInterface gathers the methods required to interact with the state. +
    - 31 + + 1 +
    -   - GetEarliestProcessedTx(ctx context.Context) (common.Hash, error) + + + package jsonrpc
    - 32 + + 2 +
    -   - } + + +
    - 33 + + 3 +
    -   -
    + + + import (
    - 34 + + 4 +
    + - // ethermanInterface contains the methods required to interact with ethereum. + "context"
    - 35 + + 5 +
    + - type ethermanInterface interface { +
    - 36 + + 6 +
    -   - TrustedSequencer() (common.Address, error) + + + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    - 37 + + 7 +
    -   - GetLatestBatchNumber() (uint64, error) + + + "github.com/0xPolygonHermez/zkevm-node/pool"
    - 38 + + 8 +
    -   - GetLatestBlockNumber(ctx context.Context) (uint64, error) + + + "github.com/0xPolygonHermez/zkevm-node/state"
    - 39 + + 9 +
    -   - HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) + + + "github.com/ethereum/go-ethereum/common"
    - 40 + 10
    + - GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]ethermanTypes.Block, map[common.Hash][]ethermanTypes.Order, error) + ethTypes "github.com/ethereum/go-ethereum/core/types"
    - 41 + 11
    + - DepositCount(ctx context.Context, blockNumber *uint64) (*big.Int, error) + )
    - 42 + + 12 +
    -   - } + + +
    - 43 + + 13 +
    -   -
    + + + func checkPolicy(ctx context.Context, p types.PoolInterface, input string) error {
    - 44 + + 14 +
    -   - // stateInterface gathers the methods required to interact with the state. + + + tx, err := hexToTx(input)
    -
    + + + 15 + + +
    + + + if err != nil {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - + + + - - - - - - - - - - - - - - - - + - - + + + - - - - - - - - - - - - - - - - - - + - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + +
    -
    @@ -283,6 +284,7 @@
    - 283 + + 16 +
    -   - ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber), + + + // ignore it, let the later processing reject
    - 284 + + 17 +
    -   - SkipVerifyL1InfoRoot_V2: true, + + + return nil
    - 285 + + 18 +
    -   - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + + + }
    - + + 19 -
    -   +
    +
    + +
    - 286 + + 20 +
    -   - } + + + // if the tx is signed, check the from address. If there is no from address, the tx is not rejected as it
    - 287 + + 21 +
    -   - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + + + // will get rejected later. This maintains backward compatibility with RPC expectations. TODO: verify this is ok behavior
    - 288 + + 22 +
    -   - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, + + + var from common.Address
    -
    @@ -411,6 +413,9 @@
    +
    + 23 + +
    + + + if from, err = state.GetSender(*tx); err != nil { +
    - 411 + + 24 +
    -   - return err + + + // if not signed, then skip check, it fails later on its own
    - 412 + + 25 +
    -   + + + return nil +
    +
    + 26 + +
    + + }
    - 413 + + 27 +
    -   + +
    - + + 28 -
    -   -
    +
    +
    + + + switch resolvePolicy(tx) {
    - + + 29 -
    -   -
    +
    +
    + + + case pool.SendTx:
    - + + 30 -
    -   -
    +
    +
    + + + var allow bool
    - 414 + + 31 +
    -   - // Update txs status in the pool + + + if allow, err = p.CheckPolicy(ctx, pool.SendTx, *tx.To()); err != nil {
    - 415 + + 32 +
    -   - for _, txResponse := range blockResponse.TransactionResponses { + + + return err
    - 416 + + 33 +
    -   - // Change Tx status to selected + + + }
    -
    @@ -420,6 +425,9 @@
    +
    + 34 + +
    + + + if !allow { +
    - 420 + + 35 +
    -   + + + return pool.ErrContractDisallowedSendTx +
    +
    + 36 + +
    + + }
    - 421 + + 37 +
    -   - } + + + if allow, err = p.CheckPolicy(ctx, pool.SendTx, from); err != nil {
    - 422 + + 38 +
    -   -
    + + + return err
    - + + 39 -
    -   -
    +
    +
    + + + }
    - + + 40 -
    -   -
    +
    +
    + + + if !allow {
    - + + 41 -
    -   -
    +
    +
    + + + return pool.ErrSenderDisallowedSendTx
    - 423 + + 42 +
    -   - // Send L2 block to data streamer + + + }
    - 424 + + 43 +
    -   - err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex()) + + + case pool.Deploy:
    - 425 + + 44 +
    -   - if err != nil { + + + var allow bool
    -
    @@ -427,6 +435,9 @@
    +
    + 45 + +
    + + + // check that sender may deploy contracts +
    - 427 + + 46 +
    -   - log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) + + + if allow, err = p.CheckPolicy(ctx, pool.Deploy, from); err != nil {
    - 428 + + 47 +
    -   + + + return err +
    +
    + 48 + +
    + + + } +
    +
    + 49 + +
    + + + if !allow { +
    +
    + 50 + +
    + + + return pool.ErrSenderDisallowedDeploy +
    +
    + 51 + +
    + + + } +
    +
    + 52 + +
    + + }
    - 429 + + 53 +
    -   -
    + + + return nil
    - + + 54 -
    -   -
    +
    +
    + + + }
    - + + 55 -
    -   +
    +
    + +
    - + + 56 -
    -   -
    +
    +
    + + + func resolvePolicy(tx *ethTypes.Transaction) pool.PolicyName {
    - 430 + + 57 +
    -   - for _, tx := range l2Block.transactions { + + + if tx.To() == nil || tx.To().Hex() == common.HexToAddress("0x0").Hex() {
    - 431 + + 58 +
    -   - // Delete the tx from the pending list in the worker (addrQueue) + + + return pool.Deploy
    - 432 + + 59 +
    -   - f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From) + + + }
    + 60 + +
    + + + return pool.SendTx +
    +
    + 61 + +
    + + + } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/errors.go + RENAMED + +
    +
    +
    +
    + + + + + + @@ -104494,17 +179238,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -104538,357 +179282,390 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + - + + +
    -
    @@ -582,6 +593,7 @@
    +
    @@ -15,6 +15,8 @@
    - 582 + 15
      - SkipFirstChangeL2Block_V2: false, + InvalidParamsErrorCode = -32602
    - 583 + 16
      - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), + // ParserErrorCode error code for parsing errors
    - 584 + 17
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + ParserErrorCode = -32700 +
    +
    + + +
    +   +
    - 585 + 18
      - } + )
    - 586 + 19
    @@ -104514,12 +179258,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 587 + 20
      - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + var (
    - 284 + 15
      - ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber), + InvalidParamsErrorCode = -32602
    - 285 + 16
      - SkipVerifyL1InfoRoot_V2: true, + // ParserErrorCode error code for parsing errors
    - 286 + 17
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + ParserErrorCode = -32700
    - 287 + 18
    + - ExecutionMode: executor.ExecutionMode0, + // AccessDeniedCode error code when requests are denied +
    +
    + 19 + +
    + + + AccessDeniedCode = -32800
    - 288 + 20
      - } + )
    - 289 + 21
      - batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ +
    - 290 + 22
      - GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot, + var (
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/interfaces.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -23,8 +23,8 @@
    - 413 + 23
      - return err + CountPendingTransactions(ctx context.Context) (uint64, error)
    - 414 + 24
      - } + GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 415 + 25
      -
    + GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 416 + + -
    - + - //TODO: remove this log +
    +
    +   +
    - 417 + + 26 +
    - + - log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum) +   + CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
    - 418 + + 27 +
    - + -
    + - + CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error)
    - 419 + 28
      - // Update txs status in the pool + EffectiveGasPriceEnabled() bool
    - 420 + 29
      - for _, txResponse := range blockResponse.TransactionResponses { + }
    - 421 + 30
      - // Change Tx status to selected +
    -
     
    +
    @@ -64,6 +64,8 @@
    - 425 + 64
      - } + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    - 426 + 65
      - } + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 427 + 66
      -
    -
    -
    - 428 - -
    - + - //TODO: remove this log + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - 429 + + -
    - + - log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum) +
    +
    +   +
    - 430 + + -
    - + +
    +
    +  
    - 431 + 67
      - // Send L2 block to data streamer + GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
    - 432 + 68
      - err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex()) + GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
    - 433 + 69
      - if err != nil { + GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    +
    +
    +
    +
    + + + - - - - @@ -104898,72 +179675,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + @@ -104973,12 +179760,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/jsonrpc/types/types.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + +
     
    - 435 + 23
      - log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) + CountPendingTransactions(ctx context.Context) (uint64, error)
    - 436 + 24
      - } + GetTransactionByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 437 + 25
      -
    + GetTransactionByL2Hash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
    - 438 + 26
    + - //TODO: remove this log + CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error)
    - 439 + + 27 +
    - + - log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum) +   + CalculateEffectiveGasPrice(rawTx []byte, txGasPrice *big.Int, txGasUsed uint64, l1GasPrice uint64, l2GasPrice uint64) (*big.Int, error)
    - 440 + + -
    - + +
    +
    +  
    - 441 + 28
      - for _, tx := range l2Block.transactions { + EffectiveGasPriceEnabled() bool
    - 442 + 29
      - // Delete the tx from the pending list in the worker (addrQueue) + }
    - 443 + 30
      - f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From) +
    - 593 + 64
      - SkipFirstChangeL2Block_V2: false, + GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    - 594 + 65
      - Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()), + GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 595 + 66
      - L1InfoTreeData_V2: map[uint32]state.L1DataV2{}, + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    +
    + 67 + +
    + + + GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 596 + 68
    + - ExecutionMode: executor.ExecutionMode0, + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 597 + 69
      - } + GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, effectivePercentages []uint8, err error)
    - 598 + 70
      -
    + GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error)
    - 599 + 71
      - batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ + GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error)
    -
    @@ -27,7 +27,7 @@
    +
    @@ -446,6 +446,23 @@
    - 27 + 446
      - pool txPool + return res, nil
    - 28 + 447
      - stateIntf stateInterface + }
    - 29 + 448
      - eventLog *event.EventLog +
    - 30 + + -
    - - - etherman etherman +
    +
    +   +
    - 31 + + -
    +
    +
      - worker *Worker +
    - 32 + + -
    +
    +
      - finalizer *finalizer +
    - 33 + + -
    +
    +
     
    -
    @@ -42,7 +42,7 @@
    -
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
     
    - 44 + + -
    +
    +
      - // New init sequencer +
    - 45 + + -
    - - - func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman etherman, eventLog *event.EventLog) (*Sequencer, error) { +
    +
    +   +
    - 46 + + -
    +
    +
      - addr, err := etherman.TrustedSequencer() +
    - 47 + + -
    +
    +
      - if err != nil { +
    - 48 + + -
    +
    +
      - return nil, fmt.Errorf("failed to get trusted sequencer address, error: %v", err) +
    -
    @@ -256,6 +256,8 @@
    +
    + + +
    +   +
    +
    - 256 + + -
    +
    +
      - case state.DSL2FullBlock: +
    - 257 + + -
    +
    +
      - l2Block := data +
    - 258 + + -
    +
    +
     
    @@ -105197,62 +179984,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 259 + 449
      - err = s.streamServer.StartAtomicOp() + // TransactionOrHash for union type of transaction and types.Hash
    - 260 + 450
      - if err != nil { + type TransactionOrHash struct {
    - 261 + 451
      - log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) + Hash *common.Hash
    +
    +
    +
    +
    + + + - - - - + + + + + + + + + - - - - - - - - + - - - - - - - - - - + + + + + + + + + - + + +
    -
    @@ -267,6 +269,8 @@
    +
     
    - 267 + 446
      - Value: l2Block.L2BlockNumber, + return res, nil
    - 268 + 447
      - } + }
    - 269 + 448
    @@ -105261,168 +180057,257 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 449 -
    -   -
    +
    +
    + + + // BatchFilter is a list of batch numbers to retrieve
    - + + 450 -
    -   +
    +
    + + + type BatchFilter struct { +
    +
    + 451 + +
    + + + Numbers []BatchNumber `json:"numbers"` +
    +
    + 452 + +
    + + + } +
    +
    + 453 + +
    + +
    - 270 + + 454 +
    -   - _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) + + + // BatchData is an abbreviated structure that only contains the number and L2 batch data
    - 271 + + 455 +
    -   - if err != nil { + + + type BatchData struct {
    - 272 + + 456 +
    -   - log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) + + + Number ArgUint64 `json:"number"`
    -
    @@ -281,6 +285,8 @@
    +
    + 457 + +
    + + + BatchL2Data ArgBytes `json:"batchL2Data,omitempty"` +
    - 281 + + 458 +
    -   - Value: l2Block.L2BlockNumber - 1, + + + Empty bool `json:"empty"`
    - 282 + + 459 +
    -   - } + + + }
    - 283 + + 460 +
    -   + +
    - + + 461 -
    -   -
    +
    +
    + + + // BatchDataResult is a list of BatchData for a BatchFilter
    - + + 462 -
    -   +
    +
    + + + type BatchDataResult struct { +
    +
    + 463 + +
    + + + Data []*BatchData `json:"data"` +
    +
    + 464 + +
    + + + } +
    +
    + 465 + +
    + +
    - 284 + 466
      - previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + // TransactionOrHash for union type of transaction and types.Hash
    - 285 + 467
      - if err != nil { + type TransactionOrHash struct {
    - 286 + 468
      - log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) + Hash *common.Hash
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree.go + RENAMED + +
    +
    +
    +
    + + + - - - - + + + + + + + + + + + +
    -
    @@ -303,12 +309,16 @@
    +
    @@ -192,11 +192,6 @@
    - 303 + 192
      - ChainID: uint32(chainID), + return mt.ComputeMerkleProof(mt.count, initialLeaves)
    - 304 + 193
      - } + }
    - 305 + 194
    @@ -105431,78 +180316,122 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 195 -
    -   -
    +
    +
    + - + // GetRoot returns the root of the L1InfoTree
    - + + 196 -
    -   +
    +
    + - + func (mt *L1InfoTree) GetRoot() common.Hash { +
    +
    + 197 + +
    + - + return mt.currentRoot +
    +
    + 198 + +
    + - + } +
    +
    + 199 + +
    + -
    - 306 + 200
      - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) + // GetCurrentRootCountAndSiblings returns the latest root, count and sibblings
    - 307 + 201
      - if err != nil { + func (mt *L1InfoTree) GetCurrentRootCountAndSiblings() (common.Hash, uint32, [][32]byte) {
    - 308 + 202
      - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + return mt.currentRoot, mt.count, mt.siblings +
    +
    +
    +
    +
    + + + + + + + + + + + + + + - + + +
    +
     
    - 309 + 192
      - continue + return mt.ComputeMerkleProof(mt.count, initialLeaves)
    - 310 + 193
      - } + }
    - 311 + 194
    @@ -105523,6 +180452,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    @@ -105532,1180 +180491,1205 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 312 + 195
      - for _, l2Transaction := range l2Block.Txs { + // GetCurrentRootCountAndSiblings returns the latest root, count and sibblings
    - 313 + 196
      - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) + func (mt *L1InfoTree) GetCurrentRootCountAndSiblings() (common.Hash, uint32, [][32]byte) {
    - 314 + 197
      - if err != nil { + return mt.currentRoot, mt.count, mt.siblings
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -323,18 +333,25 @@
    +
    @@ -1,94 +0,0 @@
    - 323 + + 1 +
    -   - StateRoot: l2Block.StateRoot, + - + package l1infotree
    - 324 + + 2 +
    -   - } + - +
    - 325 + + 3 +
    -   -
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/common"
    - + + 5 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/crypto"
    - 326 + + 6 +
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode()) + - + )
    - 327 + + 7 +
    -   - if err != nil { + - +
    - 328 + + 8 +
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + - + const (
    - 329 + + 9 +
    -   - continue + - + emptyHistoricL1InfoTreeRoot = "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757"
    - 330 + + 10 +
    -   - } + - + )
    - 331 + + 11 +
    -   + -
    - + + 12 -
    -   -
    +
    +
    + - + // L1InfoTreeRecursive is a recursive implementation of the L1InfoTree of Feijoa
    - + + 13 -
    -   -
    +
    +
    + - + type L1InfoTreeRecursive struct {
    - 332 + + 14 +
    -   - err = s.streamServer.CommitAtomicOp() + - + historicL1InfoTree *L1InfoTree
    - 333 + + 15 +
    -   - if err != nil { + - + currentLeaf common.Hash
    - 334 + + 16 +
    -   - log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) + - + }
    - 335 + + 17 +
    -   - continue + - +
    - 336 + + 18 +
    -   - } + - + // L1InfoTreeRecursiveSnapshot provides the information generated when a new
    - 337 + + 19 +
    -   -
    + - + // leaf is added to the tree
    - + + 20 -
    -   -
    +
    +
    + - + type L1InfoTreeRecursiveSnapshot struct {
    - + + 21 -
    -   -
    +
    +
    + - + HistoricL1InfoTreeRoot common.Hash
    - + + 22 -
    -   -
    +
    +
    + - + L1Data common.Hash
    - 338 + + 23 +
    -   - // Stream a bookmark + - + L1InfoTreeRoot common.Hash
    - 339 + + 24 +
    -   - case state.DSBookMark: + - + }
    - 340 + + 25 +
    -   - bookmark := data + - +
    -
    + + + 26 + + +
    + - + // NewL1InfoTreeRecursive creates a new empty L1InfoTreeRecursive
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - + + + - + + + - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    + 27 +
    -   - pool txPool + - + func NewL1InfoTreeRecursive(height uint8) (*L1InfoTreeRecursive, error) {
    + 28 +
    -   - stateIntf stateInterface + - + historic, err := NewL1InfoTree(height, nil)
    + 29 +
    -   - eventLog *event.EventLog + - + if err != nil {
    + 30 +
    - + - etherman ethermanInterface + - + return nil, err
    + 31 +
    -   - worker *Worker + - + }
    + 32 +
    -   - finalizer *finalizer + - +
    + 33 +
    -   -
    + - + mtr := &L1InfoTreeRecursive{
    -
     
    +
    + 34 + +
    + - + historicL1InfoTree: historic, +
    - 42 + + 35 +
    -   - } + - + currentLeaf: common.Hash{},
    - 43 + + 36 +
    -   -
    + - + }
    - 44 + + 37 +
    -   - // New init sequencer + - + return mtr, nil
    - 45 + + 38 +
    - + - func New(cfg Config, batchCfg state.BatchConfig, poolCfg pool.Config, txPool txPool, stateIntf stateInterface, etherman ethermanInterface, eventLog *event.EventLog) (*Sequencer, error) { + - + }
    - 46 + + 39 +
    -   - addr, err := etherman.TrustedSequencer() + - +
    - 47 + + 40 +
    -   - if err != nil { + - + // NewL1InfoTreeRecursiveFromLeaves creates a new L1InfoTreeRecursive from leaves as they are
    - 48 + + 41 +
    -   - return nil, fmt.Errorf("failed to get trusted sequencer address, error: %v", err) + - + func NewL1InfoTreeRecursiveFromLeaves(height uint8, leaves [][32]byte) (*L1InfoTreeRecursive, error) {
    -
     
    +
    + 42 + +
    + - + mtr, err := NewL1InfoTreeRecursive(height) +
    - 256 + + 43 +
    -   - case state.DSL2FullBlock: + - + if err != nil {
    - 257 + + 44 +
    -   - l2Block := data + - + return nil, err
    - 258 + + 45 +
    -   + - + } +
    +
    + 46 + +
    + -
    - 259 + + 47 + +
    + - + for i, leaf := range leaves { +
    +
    + 48 +
    - + - //TODO: remove this log + - + _, err := mtr.AddLeaf(uint32(i), leaf)
    - 260 + + 49 +
    - + - log.Infof("start atomic op for l2block %d", l2Block.L2BlockNumber) + - + if err != nil {
    - 261 + + 50 +
    -   - err = s.streamServer.StartAtomicOp() + - + return nil, err
    - 262 + + 51 +
    -   - if err != nil { + - + }
    - 263 + + 52 +
    -   - log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) + - + mtr.currentLeaf = leaf
    -
     
    +
    + 53 + +
    + - + } +
    - 269 + + 54 +
    -   - Value: l2Block.L2BlockNumber, + - + return mtr, nil
    - 270 + + 55 +
    -   - } + - + }
    - 271 + + 56 +
    -   + -
    - 272 + + 57 +
    - + - //TODO: remove this log + - + // AddLeaf hashes the current historicL1InfoRoot + currentLeaf data into the new historicLeaf value,
    - 273 + + 58 +
    - + - log.Infof("add stream bookmark for l2block %d", l2Block.L2BlockNumber) + - + // then adds it to the historicL1InfoTree and finally stores the new leaf as the currentLeaf
    - 274 + + 59 +
    -   - _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) + - + func (mt *L1InfoTreeRecursive) AddLeaf(index uint32, leaf [32]byte) (common.Hash, error) {
    - 275 + + 60 +
    -   - if err != nil { + - + // adds the current l1InfoTreeRoot into the historic tree to generate
    - 276 + + 61 +
    -   - log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) + - + // the next historicL2InfoTreeRoot
    -
     
    -
    - 285 + + 62 +
    -   - Value: l2Block.L2BlockNumber - 1, + - + l1InfoTreeRoot := mt.GetRoot()
    - 286 + + 63 +
    -   - } + - + _, err := mt.historicL1InfoTree.AddLeaf(index, l1InfoTreeRoot)
    - 287 + + 64 +
    -   -
    + - + if err != nil {
    - 288 + + 65 +
    - + - //TODO: remove this log + - + return common.Hash{}, err
    - 289 + + 66 +
    - + - log.Infof("get previous l2block %d", l2Block.L2BlockNumber-1) + - + }
    - 290 + + 67 +
    -   - previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) + - +
    - 291 + + 68 +
    -   - if err != nil { + - + mt.currentLeaf = leaf
    - 292 + + 69 +
    -   - log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) + - +
    -
     
    -
    - 309 + + 70 +
    -   - ChainID: uint32(chainID), + - + return mt.GetRoot(), nil
    - 310 + + 71 +
    -   - } + - + }
    - 311 + + 72 +
    -   + -
    - 312 + + 73 +
    - + - //TODO: remove this log + - + // GetRoot returns the root of the L1InfoTreeRecursive
    - 313 + + 74 +
    - + - log.Infof("add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber) + - + func (mt *L1InfoTreeRecursive) GetRoot() common.Hash {
    - 314 + + 75 +
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) + - + // if the historicL1InfoTree is empty and the the current leaf is also empty
    - 315 + + 76 +
    -   - if err != nil { + - + // returns the root as all zeros 0x0000...0000
    - 316 + + 77 +
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + - + if mt.historicL1InfoTree.GetRoot().String() == emptyHistoricL1InfoTreeRoot &&
    - 317 + + 78 +
    -   - continue + - + mt.currentLeaf.Cmp(common.Hash{}) == 0 {
    - 318 + + 79 +
    -   - } + - + return common.Hash{}
    - 319 + + 80 +
    -   -
    + - + }
    - 320 + + 81 +
    - + - //TODO: remove this log + - +
    - 321 + + 82 +
    - + - log.Infof("adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber) + - + l1InfoTreeRoot := crypto.Keccak256Hash(mt.historicL1InfoTree.GetRoot().Bytes(), mt.currentLeaf[:])
    - 322 + + 83 +
    -   - for _, l2Transaction := range l2Block.Txs { + - + return l1InfoTreeRoot
    - 323 + + 84 +
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) + - + }
    - 324 + + 85 +
    -   - if err != nil { + - +
    -
     
    -
    - 333 + + 86 +
    -   - StateRoot: l2Block.StateRoot, + - + // GetHistoricRoot returns the root of the HistoricL1InfoTree
    - 334 + + 87 +
    -   - } + - + func (mt *L1InfoTreeRecursive) GetHistoricRoot() common.Hash {
    - 335 + + 88 +
    -   -
    + - + return mt.historicL1InfoTree.GetRoot()
    - 336 + + 89 +
    - + - //TODO: remove this log + - + }
    - 337 + + 90 +
    - + - log.Infof("add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber) + - +
    - 338 + + 91 +
    -   - _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode()) + - + // ComputeMerkleProof computes the Merkle proof from the leaves
    - 339 + + 92 +
    -   - if err != nil { + - + func (mt *L1InfoTreeRecursive) ComputeMerkleProof(gerIndex uint32, leaves [][32]byte) ([][32]byte, common.Hash, error) {
    - 340 + + 93 +
    -   - log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) + - + return mt.historicL1InfoTree.ComputeMerkleProof(gerIndex, leaves)
    - 341 + + 94 +
    -   - continue + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 342 + + -
    +
    +
      - } +
    - 343 + + -
    +
    +
     
    - 344 + + -
    - + - //TODO: remove this log +
    +
    +   +
    - 345 + + -
    - + - log.Infof("commit atomic op for l2block %d", l2Block.L2BlockNumber) +
    +
    +   +
    - 346 + + -
    +
    +
      - err = s.streamServer.CommitAtomicOp() +
    - 347 + + -
    +
    +
      - if err != nil { +
    - 348 + + -
    +
    +
      - log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) +
    - 349 + + -
    +
    +
      - continue +
    - 350 + + -
    +
    +
      - } +
    - 351 + + -
    +
    +
     
    - 352 + + -
    - + - //TODO: remove this log +
    +
    +   +
    - 353 + + -
    - + - log.Infof("l2block %d sent to datastream", l2Block.L2BlockNumber) +
    +
    +   +
    - 354 + + -
    - + +
    +
    +  
    - 355 + + -
    +
    +
      - // Stream a bookmark +
    - 356 + + -
    +
    +
      - case state.DSBookMark: +
    - 357 + + -
    +
    +
      - bookmark := data -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/worker.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -106719,66 +181703,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -107174,68 +182133,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -107298,1459 +182252,1368 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -23,6 +23,7 @@
    - 23 + + -
    +
    +
      - state stateInterface +
    - 24 + + -
    +
    +
      - batchConstraints state.BatchConstraintsCfg +
    - 25 + + -
    +
    +
      - readyTxsCond *timeoutCond +
    - 26 + + -
    +
    +
      - } +
    - 27 + + -
    +
    +
     
    - 28 + + -
    +
    +
      - // NewWorker creates an init a worker +
    -
    @@ -60,6 +61,12 @@
    -
    - 60 + + -
    +
    +
      - return nil, pool.ErrOutOfCounters +
    - 61 + + -
    +
    +
      - } +
    - 62 + + -
    +
    +
     
    @@ -106844,66 +181823,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 63 + + -
    +
    +
      - addr, found := w.pool[tx.FromStr] +
    - 64 + + -
    +
    +
      - if !found { +
    - 65 + + -
    +
    +
      - // Unlock the worker to let execute other worker functions while creating the new AddrQueue +
    -
    @@ -174,6 +181,8 @@
    -
    - 174 + + -
    +
    +
      - defer w.workerMutex.Unlock() +
    - 175 + + -
    +
    +
      - log.Debugf("move tx %s to notReady (from: %s, actualNonce: %d, actualBalance: %s)", txHash.String(), from.String(), actualNonce, actualBalance.String()) +
    - 176 + + -
    +
    +
     
    @@ -106929,66 +181903,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 177 + + -
    +
    +
      - addrQueue, found := w.pool[from.String()] +
    - 178 + + -
    +
    +
      - if found { +
    - 179 + + -
    +
    +
      - // Sanity check. The txHash must be the readyTx +
    -
    @@ -195,6 +204,8 @@
    -
    - 195 + + -
    +
    +
      - w.workerMutex.Lock() +
    - 196 + + -
    +
    +
      - defer w.workerMutex.Unlock() +
    - 197 + + -
    +
    +
     
    @@ -107014,66 +181983,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 198 + + -
    +
    +
      - addrQueue, found := w.pool[addr.String()] +
    - 199 + + -
    +
    +
      - if found { +
    - 200 + + -
    +
    +
      - deletedReadyTx := addrQueue.deleteTx(txHash) +
    -
    @@ -293,6 +304,8 @@
    -
    - 293 + + -
    +
    +
      - w.workerMutex.Lock() +
    - 294 + + -
    +
    +
      - defer w.workerMutex.Unlock() +
    - 295 + + -
    +
    +
     
    @@ -107099,68 +182063,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 296 + + -
    +
    +
      - if w.txSortedList.len() == 0 { +
    - 297 + + -
    +
    +
      - return nil, ErrTransactionsListEmpty +
    - 298 + + -
    +
    +
      - } +
    -
    @@ -342,6 +355,7 @@
    -
    - 342 + + -
    +
    +
     
    - 343 + + -
    +
    +
      - if foundAt != -1 { +
    - 344 + + -
    +
    +
      - log.Debugf("best fitting tx %s found at index %d with gasPrice %d", tx.HashStr, foundAt, tx.GasPrice) +
    - 345 + + -
    +
    +
      - return tx, nil +
    - 346 + + -
    +
    +
      - } else { +
    - 347 + + -
    +
    +
      - return nil, ErrNoFittingTransaction +
    -
    @@ -382,3 +396,9 @@
    -
    - 382 + + -
    +
    +
      - w.readyTxsCond.L.Unlock() +
    - 383 + + -
    +
    +
      - } +
    - 384 + + -
    +
    +
      - } +
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    -
    - 23 + + -
    +
    +
      - state stateInterface +
    - 24 + + -
    +
    +
      - batchConstraints state.BatchConstraintsCfg +
    - 25 + + -
    +
    +
      - readyTxsCond *timeoutCond +
    - 26 + + -
    - + - wipTx *TxTracker +
    +
    +   +
    - 27 + + -
    +
    +
      - } +
    - 28 + + -
    +
    +
     
    - 29 + + -
    +
    +
      - // NewWorker creates an init a worker +
    -
     
    -
    - 61 + + -
    +
    +
      - return nil, pool.ErrOutOfCounters +
    - 62 + + -
    +
    +
      - } +
    - 63 + + -
    +
    +
     
    - 64 + + -
    - + - if (w.wipTx != nil) && (w.wipTx.FromStr == tx.FromStr) && (w.wipTx.Nonce == tx.Nonce) { +
    +
    +   +
    - 65 + + -
    - + - log.Infof("adding tx %s (nonce %d) from address %s that matches current processing tx %s (nonce %d), rejecting it as duplicated nonce", tx.Hash, tx.Nonce, tx.From, w.wipTx.Hash, w.wipTx.Nonce) +
    +
    +   +
    - 66 + + -
    - + - w.workerMutex.Unlock() +
    +
    +   +
    - 67 + + -
    - + - return nil, ErrDuplicatedNonce +
    +
    +   +
    - 68 + + -
    - + - } +
    +
    +   +
    - 69 + + -
    - + +
    +
    +  
    - 70 + + -
    +
    +
      - addr, found := w.pool[tx.FromStr] +
    - 71 + + -
    +
    +
      - if !found { +
    - 72 + + -
    +
    +
      - // Unlock the worker to let execute other worker functions while creating the new AddrQueue +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/l1infotree/tree_recursive_test.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -1,113 +0,0 @@
    - 181 + + 1 +
    -   - defer w.workerMutex.Unlock() + - + package l1infotree_test
    - 182 + + 2 +
    -   - log.Debugf("move tx %s to notReady (from: %s, actualNonce: %d, actualBalance: %s)", txHash.String(), from.String(), actualNonce, actualBalance.String()) + - +
    - 183 + + 3 +
    -   -
    + - + import (
    - 184 + + 4 +
    - + - w.resetWipTx(txHash) + - + "encoding/json"
    - 185 + + 5 +
    - + -
    + - + "os"
    - 186 + + 6 +
    -   - addrQueue, found := w.pool[from.String()] + - + "strconv"
    - 187 + + 7 +
    -   - if found { + - + "testing"
    - 188 + + 8 +
    -   - // Sanity check. The txHash must be the readyTx + - +
    -
     
    -
    - 204 + + 9 +
    -   - w.workerMutex.Lock() + - + "github.com/0xPolygonHermez/zkevm-node/l1infotree"
    - 205 + + 10 +
    -   - defer w.workerMutex.Unlock() + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 206 + + 11 +
    -   -
    + - + "github.com/ethereum/go-ethereum/common"
    - 207 + + 12 +
    - + - w.resetWipTx(txHash) + - + "github.com/stretchr/testify/assert"
    - 208 + + 13 +
    - + -
    + - + "github.com/stretchr/testify/require"
    - 209 + + 14 +
    -   - addrQueue, found := w.pool[addr.String()] + - + )
    - 210 + + 15 +
    -   - if found { + - +
    - 211 + + 16 +
    -   - deletedReadyTx := addrQueue.deleteTx(txHash) + - + const (
    -
     
    -
    - 304 + + 17 +
    -   - w.workerMutex.Lock() + - + l1InfoRootRecursiveHeight = uint8(32)
    - 305 + + 18 +
    -   - defer w.workerMutex.Unlock() + - + emptyL1InfoTreeRecursiveRoot = "0x27ae5ba08d7291c96c8cbddcc148bf48a6d68c7974b94356f53754ef6171d757"
    - 306 + + 19 +
    -   -
    + - + filenameTestData = "../test/vectors/src/merkle-tree/l1-info-tree-recursive/smt-full-output.json"
    - 307 + + 20 +
    - + - w.wipTx = nil + - + )
    - 308 + + 21 +
    - + + -
    - 309 + + 22 +
    -   - if w.txSortedList.len() == 0 { + - + type vectorTestData struct {
    - 310 + + 23 +
    -   - return nil, ErrTransactionsListEmpty + - + GlobalExitRoot common.Hash `json:"globalExitRoot"`
    - 311 + + 24 +
    -   - } + - + BlockHash common.Hash `json:"blockHash"`
    -
     
    -
    - 355 + + 25 +
    -   -
    + - + MinTimestamp string `json:"minTimestamp"`
    - 356 + + 26 +
    -   - if foundAt != -1 { + - + SmtProof []common.Hash `json:"smtProof"`
    - 357 + + 27 +
    -   - log.Debugf("best fitting tx %s found at index %d with gasPrice %d", tx.HashStr, foundAt, tx.GasPrice) + - + Index uint32 `json:"index"`
    - 358 + + 28 +
    - + - w.wipTx = tx + - + PreviousIndex uint32 `json:"previousIndex"`
    - 359 + + 29 +
    -   - return tx, nil + - + PreviousL1InfoTreeRoot common.Hash `json:"previousL1InfoTreeRoot"`
    - 360 + + 30 +
    -   - } else { + - + L1DataHash common.Hash `json:"l1DataHash"`
    - 361 + + 31 +
    -   - return nil, ErrNoFittingTransaction + - + L1InfoTreeRoot common.Hash `json:"l1InfoTreeRoot"`
    -
     
    -
    - 396 + + 32 +
    -   - w.readyTxsCond.L.Unlock() + - + HistoricL1InfoRoot common.Hash `json:"historicL1InfoRoot"`
    - 397 + + 33 +
    -   - } + - + }
    - 398 + + 34 +
    -   - } + - +
    - 399 + + 35 +
    - + -
    + - + func readData(t *testing.T) []vectorTestData {
    - 400 + + 36 +
    - + - func (w *Worker) resetWipTx(txHash common.Hash) { + - + data, err := os.ReadFile(filenameTestData)
    - 401 + + 37 +
    - + - if (w.wipTx != nil) && (w.wipTx.Hash == txHash) { + - + require.NoError(t, err)
    - 402 + + 38 +
    - + - w.wipTx = nil + - + var mtTestVectors []vectorTestData
    - 403 + + 39 +
    - + - } + - + err = json.Unmarshal(data, &mtTestVectors)
    - 404 + + 40 +
    - + - } -
    -
    -
    + - + require.NoError(t, err)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
    @@ -41,4 +41,6 @@
    + 41 +
    -   - // gas offset: 100 + - + return mtTestVectors
    + 42 +
    -   - // final gas: 1100 + - + }
    + 43 +
    -   - GasOffset uint64 `mapstructure:"GasOffset"` + - +
    - + + 44 -
    -   -
    +
    +
    + - + func TestEmptyL1InfoRootRecursive(t *testing.T) {
    - + + 45 -
    -   -
    +
    +
    + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight)
    - 44 + + 46 +
    -   - } -
    -
    -
    + - + require.NoError(t, err)
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
     
    - 41 + + 47 +
    -   - // gas offset: 100 + - + require.NotNil(t, mtr)
    - 42 + + 48 +
    -   - // final gas: 1100 + - + root := mtr.GetRoot()
    - 43 + + 49 +
    -   - GasOffset uint64 `mapstructure:"GasOffset"` + - + require.Equal(t, common.Hash{}.String(), root.String())
    - 44 + + 50 +
    - + - // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx + - + }
    - 45 + + 51 +
    - + - MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"` + - +
    - 46 + + 52 +
    -   - } -
    -
    -
    + - + func TestEmptyHistoricL1InfoRootRecursive(t *testing.T) {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
    @@ -17,8 +17,8 @@
    - 17 + + 53 +
    -   -
    + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight)
    - 18 + + 54 +
    -   - // etherman contains the methods required to interact with ethereum. + - + require.NoError(t, err)
    - 19 + + 55 +
    -   - type etherman interface { + - + require.NotNil(t, mtr)
    - 20 + + 56 +
    - - BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error) + root := mtr.GetHistoricRoot()
    - 21 + + 57 +
    - - EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error) + require.Equal(t, emptyL1InfoTreeRecursiveRoot, root.String())
    - 22 + + 58 +
    -   - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) + - + }
    - 23 + + 59 +
    -   - GetLatestBatchNumber() (uint64, error) + - +
    - 24 + + 60 +
    -   - } + - + func TestBuildTreeVectorData(t *testing.T) {
    -
    @@ -41,3 +41,7 @@
    +
    + 61 + +
    + - + data := readData(t) +
    - 41 + + 62 +
    -   - Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight)
    - 42 + + 63 +
    -   - ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx) + - + require.NoError(t, err)
    - 43 + + 64 +
    -   - } + - + for _, testVector := range data {
    - + + 65 -
    -   -
    +
    +
    + - + minTimestamp, err := strconv.ParseUint(testVector.MinTimestamp, 10, 0)
    - + + 66 -
    -   -
    +
    +
    + - + require.NoError(t, err)
    - + + 67 -
    -   -
    +
    +
    + - + l1Data := l1infotree.HashLeafData(testVector.GlobalExitRoot, testVector.BlockHash, minTimestamp)
    - + + 68 -
    -   -
    +
    +
    + - + l1DataHash := common.BytesToHash(l1Data[:])
    -
    + + + 69 + + +
    + - + assert.Equal(t, testVector.L1DataHash.String(), l1DataHash.String(), "l1Data doesn't match leaf", testVector.Index)
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 17 + + 70 +
    -   + -
    - 18 + + 71 +
    -   - // etherman contains the methods required to interact with ethereum. + - + l1InfoTreeRoot, err := mtr.AddLeaf(testVector.Index-1, l1Data)
    - 19 + + 72 +
    -   - type etherman interface { + - + require.NoError(t, err)
    - 20 + + 73 +
    - + - BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error) + - + assert.Equal(t, testVector.L1InfoTreeRoot.String(), l1InfoTreeRoot.String(), "l1InfoTreeRoot doesn't match leaf", testVector.Index)
    - 21 + + 74 +
    - + - EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (*types.Transaction, error) + - + assert.Equal(t, testVector.L1InfoTreeRoot.String(), mtr.GetRoot().String(), "l1InfoTreeRoot doesn't match leaf", testVector.Index)
    - 22 + + 75 +
    -   - GetLatestBlockHeader(ctx context.Context) (*types.Header, error) + - + assert.Equal(t, testVector.HistoricL1InfoRoot.String(), mtr.GetHistoricRoot().String(), "HistoricL1InfoTreeRoot doesn't match leaf", testVector.Index)
    - 23 + + 76 +
    -   - GetLatestBatchNumber() (uint64, error) + - + }
    - 24 + + 77 +
    -   + - }
    -
     
    -
    - 41 + + 78 +
    -   - Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error + - +
    - 42 + + 79 +
    -   - ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx) + - + func TestBuildTreeFromLeaves(t *testing.T) {
    - 43 + + 80 +
    -   - } + - + data := readData(t)
    - 44 + + 81 +
    - + + -
    - 45 + + 82 +
    - + - type dataAbilitier interface { + - + leaves := [][32]byte{}
    - 46 + + 83 +
    - + - PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error) + - + for _, testVector := range data {
    - 47 + + 84 +
    - + - } + - + leaves = append(leaves, testVector.L1DataHash)
    -
    + + + 85 + + +
    + - + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -6,13 +6,11 @@
    - 6 + + 86 +
    -   - "fmt" + - +
    - 7 + + 87 +
    -   - "time" + - + newMtr, err := l1infotree.NewL1InfoTreeRecursiveFromLeaves(l1InfoRootRecursiveHeight, leaves)
    - 8 + + 88 +
    -   -
    + - + require.NoError(t, err)
    - 9 + 89
    - - ethman "github.com/0xPolygonHermez/zkevm-node/etherman" + assert.Equal(t, data[len(data)-1].L1InfoTreeRoot.String(), newMtr.GetRoot().String(), "L1InfoTreeRoot doesn't match leaf")
    - 10 + + 90 +
    -   - "github.com/0xPolygonHermez/zkevm-node/etherman/types" + - + }
    - 11 + + 91 +
    -   - "github.com/0xPolygonHermez/zkevm-node/ethtxmanager" + - +
    - 12 + + 92 +
    -   - "github.com/0xPolygonHermez/zkevm-node/event" + - + func TestProofsTreeVectorData(t *testing.T) {
    - 13 + + 93 +
    -   - "github.com/0xPolygonHermez/zkevm-node/log" + - + data := readData(t)
    - 14 + + 94 +
    -   - "github.com/0xPolygonHermez/zkevm-node/state" + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(l1InfoRootRecursiveHeight)
    - 15 + 95
    - - ethTypes "github.com/ethereum/go-ethereum/core/types" + require.NoError(t, err)
    - 16 + + 96 +
    -   - "github.com/jackc/pgx/v4" + - +
    - 17 + + 97 +
    -   - ) + - + leaves := [][32]byte{}
    - 18 + + 98 +
    -   -
    + - + for _, testVector := range data {
    -
    @@ -41,16 +39,18 @@
    +
    + 99 + +
    + - + l1InfoTreeRoot, err := mtr.AddLeaf(testVector.Index-1, testVector.L1DataHash) +
    - 41 + + 100 +
    -   - ethTxManager ethTxManager + - + require.NoError(t, err)
    - 42 + + 101 +
    -   - etherman etherman + - +
    - 43 + + 102 +
    -   - eventLog *event.EventLog + - + leaves = append(leaves, l1InfoTreeRoot)
    - + + 103 -
    -   +
    +
    + -
    - 44 + + 104 +
    -   - } + - + mp, _, err := mtr.ComputeMerkleProof(testVector.Index, leaves)
    - 45 + + 105 +
    -   -
    + - + require.NoError(t, err)
    - 46 + + 106 +
    -   - // New inits sequence sender + - + for i, v := range mp {
    - 47 + + 107 +
    - - func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*SequenceSender, error) { + c := common.Hash(v)
    - 48 + + 108 +
    -   - return &SequenceSender{ + - + if c.String() != testVector.SmtProof[i].String() {
    - 49 + + 109 +
    -   - cfg: cfg, + - + log.Info("MerkleProof: index ", testVector.Index, " mk:", i, " v:", c.String(), " expected:", testVector.SmtProof[i].String())
    - 50 + + 110 +
    -   - state: state, + - + }
    - 51 + + 111 +
    -   - etherman: etherman, + - + }
    - 52 + + 112 +
    -   - ethTxManager: manager, + - + }
    - 53 + + 113 +
    -   - eventLog: eventLog, + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - @@ -108878,23 +183736,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -108908,1123 +183766,1142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    @@ -108763,78 +183626,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 54 + + -
    +
    +
      - }, nil +
    - 55 + + -
    +
    +
      - } +
    - 56 + + -
    +
    +
     
    -
    @@ -185,9 +185,14 @@
    -
    - 185 + + -
    +
    +
      - } +
    - 186 + + -
    +
    +
     
    - 187 + + -
    +
    +
      - // add sequence to be monitored +
    - 188 + + -
    - - - firstSequence := sequences[0] +
    +
    +   +
    - 189 + + -
    +
    +
     
    - 190 + + -
    - - - to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 191 + + -
    +
    +
      - if err != nil { +
    - 192 + + -
    +
    +
      - log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err) +
    - 193 + + -
    +
    +
      - return +
    -
    @@ -218,8 +223,6 @@
    -
    - 218 + + -
    +
    +
      - sequences := []types.Sequence{} +
    - 219 + + -
    +
    +
      - // var estimatedGas uint64 +
    - 220 + + -
    +
    +
     
    - 221 + + -
    - - - var tx *ethTypes.Transaction +
    +
    +   +
    - 222 + + -
    - - +
    +
    +  
    - 223 + + -
    +
    +
      - // Add sequences until too big for a single L1 tx or last batch is reached +
    - 224 + + -
    +
    +
      - for { +
    - 225 + + -
    +
    +
      - //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to +
    -
    @@ -288,31 +291,11 @@
    -
    - 288 + + -
    +
    +
     
    - 289 + + -
    +
    +
      - sequences = append(sequences, seq) +
    - 290 + + -
    +
    +
      - // Check if can be send +
    - 291 + + -
    - - - firstSequence := sequences[0] +
    +
    +   +
    - 292 + + -
    - - - lastSequence := sequences[len(sequences)-1] +
    +
    +   +
    - 293 + + -
    - - - tx, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 294 + + -
    - - - if err == nil && tx.Size() > s.cfg.MaxTxSizeForL1 { +
    +
    +   +
    - 295 + + -
    - - - log.Infof("oversized Data on TX oldHash %s (txSize %d > %d)", tx.Hash(), tx.Size(), s.cfg.MaxTxSizeForL1) +
    +
    +   +
    - 296 + + -
    - - - err = ErrOversizedData +
    +
    +   +
    - 297 + + -
    - - - } +
    +
    +   +
    - 298 + + -
    - - - if err != nil { +
    +
    +   +
    - 299 + + -
    - - - log.Infof("Handling estimage gas send sequence error: %v", err) +
    +
    +   +
    - 300 + + -
    - - - sequences, err = s.handleEstimateGasSendSequenceErr(ctx, sequences, currentBatchNumToSequence, err) +
    +
    +   +
    - 301 + + -
    - - - if sequences != nil { +
    +
    +   +
    - 302 + + -
    - - - if len(sequences) > 0 { +
    +
    +   +
    - 303 + + -
    - - - // Handling the error gracefully, re-processing the sequence as a sanity check +
    +
    +   +
    - 304 + + -
    - - - lastSequence = sequences[len(sequences)-1] +
    +
    +   +
    - 305 + + -
    - - - _, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase) +
    +
    +   +
    - 306 + + -
    - - - return sequences, err +
    +
    +   +
    - 307 + + -
    - - - } +
    +
    +   +
    - 308 + + -
    - - - } +
    +
    +   +
    - 309 + + -
    - - - return sequences, err +
    +
    +   +
    - 310 + + -
    - - - } +
    +
    +   +
    - 311 + + -
    - - - // estimatedGas = tx.Gas() +
    +
    +   +
    - 312 + + -
    - - +
    +
    +  
    - 313 + + -
    - - - //Check if the current batch is the last before a change to a new forkid, in this case we need to close and send the sequence to L1 +
    +
    +   +
    - 314 + + -
    - - - if (s.cfg.ForkUpgradeBatchNumber != 0) && (currentBatchNumToSequence == (s.cfg.ForkUpgradeBatchNumber)) { +
    +
    +   +
    - 315 + + -
    - - - log.Infof("sequence should be sent to L1, as we have reached the batch %d from which a new forkid is applied (upgrade)", s.cfg.ForkUpgradeBatchNumber) +
    +
    +   +
    - 316 + + -
    +
    +
      - return sequences, nil +
    - 317 + + -
    +
    +
      - } +
    - 318 + + -
    +
    +
     
    -
    @@ -343,78 +326,6 @@
    +
    + + +
    +   +
    +
    - 343 + + -
    +
    +
      - return nil, nil +
    - 344 + + -
    +
    +
      - } +
    - 345 + + -
    +
    +
     
    - 346 + + -
    - - - // handleEstimateGasSendSequenceErr handles an error on the estimate gas. It will return: +
    +
    +   +
    - 347 + + -
    - - - // nil, error: impossible to handle gracefully +
    +
    +   +
    - 348 + + -
    - - - // sequence, nil: handled gracefully. Potentially manipulating the sequences +
    +
    +   +
    - 349 + + -
    - - - // nil, nil: a situation that requires waiting +
    +
    +   +
    - 350 + + -
    - - - func (s *SequenceSender) handleEstimateGasSendSequenceErr( +
    +
    +   +
    - 351 + + -
    - - - ctx context.Context, +
    +
    +   +
    - 352 + + -
    - - - sequences []types.Sequence, +
    +
    +   +
    - 353 + + -
    - - - currentBatchNumToSequence uint64, +
    +
    +   +
    - 354 + + -
    - - - err error, +
    +
    +   +
    - 355 + + -
    - - - ) ([]types.Sequence, error) { +
    +
    +   +
    - 356 + + -
    - - - // Insufficient allowance +
    +
    +   +
    - 357 + + -
    - - - if errors.Is(err, ethman.ErrInsufficientAllowance) { +
    +
    +   +
    - 358 + + -
    - - - return nil, err +
    +
    +   +
    - 359 + + -
    - - - } +
    +
    +   +
    - 360 + + -
    - - - if isDataForEthTxTooBig(err) { +
    +
    +   +
    - 361 + + -
    - - - // Remove the latest item and send the sequences +
    +
    +   +
    - 362 + + -
    - - - log.Infof( +
    +
    +   +
    - 363 + + -
    - - - "Done building sequences, selected batches to %d. Batch %d caused the L1 tx to be too big", +
    +
    +   +
    - 364 + + -
    - - - currentBatchNumToSequence-1, currentBatchNumToSequence, +
    +
    +   +
    - 365 + + -
    - - - ) +
    +
    +   +
    - 366 + + -
    - - - sequences = sequences[:len(sequences)-1] +
    +
    +   +
    - 367 + + -
    - - - return sequences, nil +
    +
    +   +
    - 368 + + -
    - - - } +
    +
    +   +
    - 369 + + -
    - - +
    +
    +  
    - 370 + + -
    - - - // while estimating gas a new block is not created and the POE SC may return +
    +
    +   +
    - 371 + + -
    - - - // an error regarding timestamp verification, this must be handled +
    +
    +   +
    - 372 + + -
    - - - // if errors.Is(err, ethman.ErrTimestampMustBeInsideRange) { +
    +
    +   +
    - 373 + + -
    - - - // // query the sc about the value of its lastTimestamp variable +
    +
    +   +
    - 374 + + -
    - - - // lastTimestamp, err := s.etherman.GetLastBatchTimestamp() +
    +
    +   +
    - 375 + + -
    - - - // if err != nil { +
    +
    +   +
    - 376 + + -
    - - - // return nil, err +
    +
    +   +
    - 377 + + -
    - - - // } +
    +
    +   +
    - 378 + + -
    - - - // // check POE SC lastTimestamp against sequences' one +
    +
    +   +
    - 379 + + -
    - - - // for _, seq := range sequences { +
    +
    +   +
    - 380 + + -
    - - - // if seq.Timestamp < int64(lastTimestamp) { +
    +
    +   +
    - 381 + + -
    - - - // // TODO: gracefully handle this situation by creating an L2 reorg +
    +
    +   +
    - 382 + + -
    - - - // log.Fatalf("sequence timestamp %d is < POE SC lastTimestamp %d", seq.Timestamp, lastTimestamp) +
    +
    +   +
    - 383 + + -
    - - - // } +
    +
    +   +
    - 384 + + -
    - - - // lastTimestamp = uint64(seq.Timestamp) +
    +
    +   +
    - 385 + + -
    - - - // } +
    +
    +   +
    - 386 + + -
    - - - // blockTimestamp, err := s.etherman.GetLatestBlockTimestamp(ctx) +
    +
    +   +
    - 387 + + -
    - - - // if err != nil { +
    +
    +   +
    - 388 + + -
    - - - // log.Error("error getting block timestamp: ", err) +
    +
    +   +
    - 389 + + -
    - - - // } +
    +
    +   +
    - 390 + + -
    - - - // log.Debugf("block.timestamp: %d is smaller than seq.Timestamp: %d. A new block must be mined in L1 before the gas can be estimated.", blockTimestamp, sequences[0].Timestamp) +
    +
    +   +
    - 391 + + -
    - - - // return nil, nil +
    +
    +   +
    - 392 + + -
    - - - // } +
    +
    +   +
    - 393 + + -
    - - +
    +
    +  
    - 394 + + -
    - - - // Unknown error +
    +
    +   +
    - 395 + + -
    - - - if len(sequences) == 1 { +
    +
    +   +
    - 396 + + -
    - - - // TODO: gracefully handle this situation by creating an L2 reorg +
    +
    +   +
    - 397 + + -
    - - - log.Errorf( +
    +
    +   +
    - 398 - -
    - - - "Error when estimating gas for BatchNum %d (alone in the sequences): %v", +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/client.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - -
    +
    @@ -7,7 +7,6 @@
    - 399 + + 7 +
    - - - currentBatchNumToSequence, err, +   + "github.com/0xPolygonHermez/zkevm-node/log"
    - 400 + + 8 +
    - - - ) +   + "github.com/0xPolygonHermez/zkevm-node/merkletree/hashdb"
    - 401 + + 9 +
    - - - } +   + "google.golang.org/grpc"
    - 402 + 10
    - - // Remove the latest item and send the sequences + "google.golang.org/grpc/connectivity"
    - 403 + + 11 +
    - - - log.Infof( +   + "google.golang.org/grpc/credentials/insecure"
    - 404 + + 12 +
    - - - "Done building sequences, selected batches to %d. Batch %d excluded due to unknown error: %v", +   + )
    - 405 + + 13 +
    - - - currentBatchNumToSequence, currentBatchNumToSequence+1, err, +   +
    - 406 + +
    @@ -15,37 +14,18 @@
    +
    + 15 +
    - - - ) +   + func NewMTDBServiceClient(ctx context.Context, c Config) (hashdb.HashDBServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - 407 + + 16 +
    - - - sequences = sequences[:len(sequences)-1] +   + opts := []grpc.DialOption{
    - 408 + + 17 +
    - - -
    +   + grpc.WithTransportCredentials(insecure.NewCredentials()),
    - 409 + + -
    - - - return sequences, nil +
    +
    +   +
    - 410 + + 18 +
    - - - } +   + }
    - 411 + 19
    @@ -110034,136 +184911,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 412 + 20
    - - func isDataForEthTxTooBig(err error) bool { + mtDBConn, err := grpc.NewClient(c.URI, opts...)
    - 413 + 21
    - - return errors.Is(err, ethman.ErrGasRequiredExceedsAllowance) || + if err != nil {
    - 414 + 22
    - - errors.Is(err, ErrOversizedData) || + log.Fatalf("fail to create grpc connection to merkletree: %v", err)
    - 415 + 23
    - - errors.Is(err, ethman.ErrContentLengthTooLarge) + }
    - 416 + 24
    - - } +
    - 417 + 25
    - -
    -
    -
    - 418 - -
    -   - func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { -
    -
    - 419 - -
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) + log.Infof("trying to connect to merkletree: %v", c.URI)
    - 420 + 26
      - if err != nil && err != state.ErrNotFound { -
    -
    -
    + const maxWaitSeconds = 120
    -
    -
    - - - - - - - - - @@ -110178,455 +185021,409 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    - 6 + 27
      - "fmt" + ctx, cancel := context.WithTimeout(ctx, maxWaitSeconds*time.Second)
    - 7 + + 28 +
    -   - "time" + - + mtDBConn.Connect()
    - 8 + + 29 +
    -   -
    + - + err = waitForConnection(ctx, mtDBConn)
    - 9 + 30
      - "github.com/0xPolygonHermez/zkevm-node/etherman/types" + if err != nil {
    - 10 + + 31 +
    -   - "github.com/0xPolygonHermez/zkevm-node/ethtxmanager" + - + log.Fatalf("fail to connect to merkletree: %v", err)
    - 11 + 32
      - "github.com/0xPolygonHermez/zkevm-node/event" + }
    - 12 + 33
      - "github.com/0xPolygonHermez/zkevm-node/log" + log.Infof("connected to merkletree")
    - 13 + 34
    -   - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - - -
     
    - 14 + 35
      - "github.com/jackc/pgx/v4" + mtDBClient := hashdb.NewHashDBServiceClient(mtDBConn)
    - 15 + 36
      - ) + return mtDBClient, mtDBConn, cancel
    - 16 + 37
      -
    + }
    -
     
    +
    + 38 + +
    + - +
    +
    + 39 +
    -   - ethTxManager ethTxManager + - + func waitForConnection(ctx context.Context, conn *grpc.ClientConn) error {
    + 40 +
    -   - etherman etherman + - + for {
    + 41 +
    -   - eventLog *event.EventLog + - + select {
    + 42 +
    - + - da dataAbilitier + - + case <-ctx.Done():
    + 43 +
    -   - } + - + return ctx.Err()
    + 44 +
    -   -
    + - + case <-time.After(time.Second):
    + 45 +
    -   - // New inits sequence sender + - + s := conn.GetState()
    + 46 +
    - + - func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog, da dataAbilitier) (*SequenceSender, error) { + - + if s == connectivity.Ready {
    + 47 +
    -   - return &SequenceSender{ + - + return nil
    + 48 +
    -   - cfg: cfg, + - + }
    + 49 +
    -   - state: state, + - + }
    + 50 +
    -   - etherman: etherman, + - + }
    + 51 -
    -   - ethTxManager: manager, -
    -
    - 52 - -
    -   - eventLog: eventLog, -
    -
    - 53 - -
    - + - da: da, -
    -
    - 54 - -
    -   - }, nil -
    -
    - 55 - +
    -   + - }
    - 56 - -
    -   -
    +
    +
    - - +
    +
    + + + - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -110926,109 +185718,167 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
     
    - 185 + 7
      - } + "github.com/0xPolygonHermez/zkevm-node/log"
    - 186 + 8
      -
    + "github.com/0xPolygonHermez/zkevm-node/merkletree/hashdb"
    - 187 + 9
      - // add sequence to be monitored + "google.golang.org/grpc"
    - 188 + + -
    - + - dataAvailabilityMessage, err := s.da.PostSequence(ctx, sequences) +
    +
    +   +
    - 189 + + 10 +
    - + - if err != nil { +   + "google.golang.org/grpc/credentials/insecure"
    - 190 + + 11 +
    - + - log.Error("error posting sequences to the data availability protocol: ", err) +   + )
    - 191 + + 12 +
    - + - return +   +
    - 192 + +
     
    +
    + 14 +
    - + - } +   + func NewMTDBServiceClient(ctx context.Context, c Config) (hashdb.HashDBServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - 193 + 15
      -
    + opts := []grpc.DialOption{
    - 194 + + 16 +
    - + - firstSequence := sequences[0] +   + grpc.WithTransportCredentials(insecure.NewCredentials()),
    - 195 + 17
    + - to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase, dataAvailabilityMessage) + grpc.WithBlock(),
    - 196 + 18
      - if err != nil { + }
    - 197 + + -
    +
    +
      - log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err) +
    - 198 + + -
    +
    +
      - return +
    -
     
    -
    - 223 + + -
    +
    +
      - sequences := []types.Sequence{} +
    - 224 + + -
    +
    +
      - // var estimatedGas uint64 +
    - 225 + + -
    +
    +
     
    @@ -110653,137 +185450,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 226 + 19
      - // Add sequences until too big for a single L1 tx or last batch is reached + const maxWaitSeconds = 120
    - 227 + 20
      - for { + ctx, cancel := context.WithTimeout(ctx, maxWaitSeconds*time.Second)
    - 228 + + 21 +
    -   - //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to + + +
    -
     
    -
    - 291 + + 22 +
    -   -
    + + + log.Infof("trying to connect to merkletree: %v", c.URI)
    - 292 + + 23 +
    -   - sequences = append(sequences, seq) + + + mtDBConn, err := grpc.DialContext(ctx, c.URI, opts...)
    - 293 + 24
      - // Check if can be send + if err != nil {
    - 294 + 25
    + - if len(sequences) == int(s.cfg.MaxBatchesForL1) { + log.Fatalf("fail to dial: %v", err)
    - 295 + + 26 +
    - + - log.Info( +   + }
    - 296 + + 27 +
    - + - "sequence should be sent to L1, because MaxBatchesForL1 (%d) has been reached", +   + log.Infof("connected to merkletree")
    - 297 + + 28 +
    - + - s.cfg.MaxBatchesForL1, +   +
    - 298 + + 29 +
    - + - ) +   + mtDBClient := hashdb.NewHashDBServiceClient(mtDBConn)
    - + + 30 -
    +
    +
      -
    + return mtDBClient, mtDBConn, cancel
    - + + 31 -
    +
    +
      -
    + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/tree.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + + + + - + + +
    +
    @@ -93,9 +93,6 @@
    +
    - + + 93 -
    +
    +
      -
    + }
    - + + 94 -
    +
    +
     
    - + + 95 -
    +
    +
      -
    + k := new(big.Int).SetBytes(scCodeHash)
    - + + 96 -
    -   -
    +
    +
    + - + if k.Cmp(big.NewInt(0)) == 0 { +
    +
    + 97 + +
    + - + return []byte{}, nil +
    +
    + 98 + +
    + - + }
    - 299 + 99
      - return sequences, nil +
    - 300 + 100
      - } + // this code gets actual smart contract code from sc code storage
    - 301 + 101
      -
    + scCode, err := tree.getProgram(ctx, scalarToh4(k))
    +
    +
    +
    +
    + + + @@ -111062,374 +185912,937 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
     
    - 326 + 93
      - return nil, nil + }
    - 327 + 94
      - } +
    - 328 + 95
      -
    + k := new(big.Int).SetBytes(scCodeHash)
    - + + 96 -
    +
    +
     
    - + + 97 -
    +
    +
      -
    + // this code gets actual smart contract code from sc code storage
    - + + 98 -
    +
    +
      -
    + scCode, err := tree.getProgram(ctx, scalarToh4(k)) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/merkletree/tree_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + + + + + + - - + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - - + + + + + + + + + - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,86 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package merkletree
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   +
    +
    + - + "fmt" +
    +
    + 6 + +
    + - + "testing" +
    +
    + 7 + +
    + -
    - + + 8 -
    -   +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/hex" +
    +
    + 9 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/test/contracts/bin/EmitLog2" +
    +
    + 10 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/test/testutils" +
    +
    + 11 + +
    + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 12 + +
    + - + "github.com/google/uuid" +
    +
    + 13 + +
    + - + "github.com/stretchr/testify/require" +
    +
    + 14 + +
    + - + ) +
    +
    + 15 + +
    + -
    - + + 16 -
    -   +
    +
    + - + func TestGetCode(t *testing.T) { +
    +
    + 17 + +
    + - + ctx := context.Background() +
    +
    + 18 + +
    + - + zkProverURI := testutils.GetEnv("ZKPROVER_URI", "localhost") +
    +
    + 19 + +
    + -
    - + + 20 -
    -   +
    +
    + - + cfg := Config{URI: fmt.Sprintf("%s:50061", zkProverURI)} +
    +
    + 21 + +
    + - + c, _, _ := NewMTDBServiceClient(ctx, cfg) +
    +
    + 22 + +
    + - + sTree := NewStateTree(c) +
    +
    + 23 + +
    + -
    - + + 24 -
    -   +
    +
    + - + type testCase struct { +
    +
    + 25 + +
    + - + name string +
    +
    + 26 + +
    + - + addr common.Address +
    +
    + 27 + +
    + - + root []byte +
    +
    + 28 + +
    + - + expectedResult []byte +
    +
    + 29 + +
    + - + expectedError error +
    +
    + 30 + +
    + - + setup func(*testing.T, *testCase, *StateTree) +
    +
    + 31 + +
    + - + } +
    +
    + 32 + +
    + -
    - + + 33 -
    -   +
    +
    + - + testCases := []testCase{ +
    +
    + 34 + +
    + - + { +
    +
    + 35 + +
    + - + name: "get existent code successfully", +
    +
    + 36 + +
    + - + addr: common.HexToAddress("0x1"), +
    +
    + 37 + +
    + - + root: common.HexToHash("0x0").Bytes(), +
    +
    + 38 + +
    + - + expectedResult: hex.DecodeBig(EmitLog2.EmitLog2Bin).Bytes(), +
    +
    + 39 + +
    + - + expectedError: nil, +
    +
    + 40 + +
    + - + setup: func(t *testing.T, tc *testCase, sTree *StateTree) { +
    +
    + 41 + +
    + - + txID := uuid.NewString() +
    +
    + 42 + +
    + -
    - + + 43 -
    -   +
    +
    + - + err := sTree.StartBlock(ctx, common.Hash(tc.root), txID) +
    +
    + 44 + +
    + - + require.NoError(t, err) +
    +
    + 45 + +
    + -
    - + + 46 -
    -   +
    +
    + - + newRoot, _, err := sTree.SetCode(ctx, tc.addr, tc.expectedResult, tc.root, txID) +
    +
    + 47 + +
    + - + require.NoError(t, err) +
    +
    + 48 + +
    + - + tc.root = newRoot +
    +
    + 49 + +
    + -
    - + + 50 -
    -   +
    +
    + - + err = sTree.FinishBlock(ctx, common.Hash(tc.root), txID) +
    +
    + 51 + +
    + - + require.NoError(t, err) +
    +
    + 52 + +
    + -
    - + + 53 + +
    + - + err = sTree.Flush(ctx, common.Hash(newRoot), txID) +
    +
    + 54 + +
    + - + require.NoError(t, err) +
    +
    + 55 + +
    + - + }, +
    +
    + 56 + +
    + - + }, +
    +
    + 57 + +
    + - + { +
    +
    + 58 + +
    + - + name: "get non-existent code successfully", +
    +
    + 59 + +
    + - + addr: common.HexToAddress("0x2"), +
    +
    + 60 + +
    + - + root: common.HexToHash("0x0").Bytes(), +
    +
    + 61 + +
    + - + expectedResult: []byte{}, +
    +
    + 62 + +
    + - + expectedError: nil, +
    +
    + 63 + +
    + - + setup: func(t *testing.T, tc *testCase, sTree *StateTree) { +
    +
    + 64 + +
    + - + }, +
    +
    + 65 + +
    + - + }, +
    +
    + 66 -
    -   -
    +
    +
    + - + }
    - + + 67 -
    -   +
    +
    + -
    - + + 68 -
    -   -
    +
    +
    + - + for _, tc := range testCases {
    - + + 69 -
    -   -
    +
    +
    + - + t.Run(tc.name, func(t *testing.T) {
    - + + 70 -
    -   -
    +
    +
    + - + tc := tc
    - + + 71 -
    -   -
    +
    +
    + - + tc.setup(t, &tc, sTree)
    - + + 72 -
    -   +
    +
    + -
    - + + 73 -
    -   -
    +
    +
    + - + result, err := sTree.GetCode(ctx, tc.addr, tc.root)
    - + + 74 -
    -   -
    +
    +
    + - + require.NoError(t, err)
    - + + 75 -
    -   +
    +
    + -
    - + + 76 -
    -   -
    +
    +
    + - + if tc.expectedResult != nil || result != nil {
    - + + 77 -
    -   -
    +
    +
    + - + require.Equal(t, len(tc.expectedResult), len(result))
    - + + 78 -
    -   -
    +
    +
    + - + require.ElementsMatch(t, tc.expectedResult, result)
    - + + 79 -
    -   -
    +
    +
    + - + }
    - + + 80 -
    -   +
    +
    + -
    - + + 81 -
    -   -
    +
    +
    + - + if tc.expectedError != nil || err != nil {
    - + + 82 -
    -   -
    +
    +
    + - + require.Equal(t, tc.expectedError, err)
    - + + 83 -
    -   -
    +
    +
    + - + }
    - + + 84 -
    -   -
    +
    +
    + - + })
    - + + 85 -
    -   -
    +
    +
    + - + }
    - + + 86 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - -
    +
     
    @@ -111751,278 +187164,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 329 - -
    -   - func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) { -
    -
    - 330 - -
    -   - lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil) -
    -
    - 331 - -
    -   - if err != nil && err != state.ErrNotFound { -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -30,7 +30,7 @@
    -
    - 30 - -
    -   - stateMock := new(StateMock) -
    -
    - 31 - -
    -   - ethermanMock := new(EthermanMock) -
    -
    - 32 - -
    -   - ethTxManagerMock := new(EthTxManagerMock) -
    -
    - 33 - -
    - - - ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil) -
    -
    - 34 - -
    -   - assert.NoError(t, err) -
    -
    - 35 - -
    -   -
    -
    -
    - 36 - -
    -   - testCases := []IsSyncedTestCase{ -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 30 - -
    -   - stateMock := new(StateMock) -
    -
    - 31 - -
    -   - ethermanMock := new(EthermanMock) -
    -
    - 32 - -
    -   - ethTxManagerMock := new(EthTxManagerMock) -
    -
    - 33 - -
    - + - ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil, nil) -
    -
    - 34 - -
    -   - assert.NoError(t, err) -
    -
    - 35 - -
    -   -
    -
    -
    - 36 - -
    -   - testCases := []IsSyncedTestCase{ -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -69,6 +69,7 @@
    -
    - 69 - -
    -   - ChainId: s.cfg.ChainID, -
    -
    - 70 - -
    -   - ForkId: request.ForkID, -
    -
    - 71 - -
    -   - ContextId: uuid.NewString(), -
    -
    @@ -112033,71 +187174,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 72 - -
    -   - } -
    -
    - 73 - -
    -   -
    -
    -
    - 74 - -
    -   - if request.SkipFirstChangeL2Block_V2 { -
    -
    -
    @@ -131,6 +132,7 @@
    -
    - 131 - -
    -   - ForkId: forkId, -
    -
    - 132 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 133 - -
    -   - SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot, -
    -
    @@ -112108,71 +187184,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 134 - -
    -   - } -
    -
    - 135 - -
    -   -
    -
    -
    - 136 - -
    -   - if forcedBlockHashL1 != nil { -
    -
    -
    @@ -231,6 +233,7 @@
    -
    - 231 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 232 - -
    -   - SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot, -
    -
    - 233 - -
    -   - L1InfoRoot: processingCtx.L1InfoRoot.Bytes(), -
    -
    @@ -112183,329 +187194,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - 234 - -
    -   - } -
    -
    - 235 - -
    -   -
    -
    -
    - 236 - -
    -   - if processingCtx.ForcedBlockHashL1 != nil { -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 69 - -
    -   - ChainId: s.cfg.ChainID, -
    -
    - 70 - -
    -   - ForkId: request.ForkID, -
    -
    - 71 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 72 - -
    - + - ExecutionMode: request.ExecutionMode, -
    -
    - 73 - -
    -   - } -
    -
    - 74 - -
    -   -
    -
    -
    - 75 - -
    -   - if request.SkipFirstChangeL2Block_V2 { -
    -
    -
     
    -
    - 132 - -
    -   - ForkId: forkId, -
    -
    - 133 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 134 - -
    -   - SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot, -
    -
    - 135 - -
    - + - ExecutionMode: executor.ExecutionMode1, -
    -
    - 136 - -
    -   - } -
    -
    - 137 - -
    -   -
    -
    -
    - 138 - -
    -   - if forcedBlockHashL1 != nil { -
    -
    -
     
    -
    - 233 - -
    -   - ContextId: uuid.NewString(), -
    -
    - 234 - -
    -   - SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot, -
    -
    - 235 - -
    -   - L1InfoRoot: processingCtx.L1InfoRoot.Bytes(), -
    -
    - 236 - -
    - + - ExecutionMode: processingCtx.ExecutionMode, -
    -
    - 237 - -
    -   - } -
    -
    - 238 - -
    -   -
    -
    -
    - 239 - -
    -   - if processingCtx.ForcedBlockHashL1 != nil { -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -12,6 +12,7 @@
    -
    - 12 - -
    -   - BlockHash common.Hash -
    -
    - 13 - -
    -   - ParentHash common.Hash -
    -
    - 14 - -
    -   - ReceivedAt time.Time -
    -
    @@ -112513,151 +187201,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      -
    -
    -
    - 15 - -
    -   - } -
    -
    - 16 - -
    -   -
    -
    -
    - 17 - -
    -   - // NewBlock creates a block with the given data. -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 12 - -
    -   - BlockHash common.Hash +
    - 13 + + -
    +
    +
      - ParentHash common.Hash +
    - 14 + + -
    +
    +
      - ReceivedAt time.Time +
    - 15 + + -
    - + - Checked bool +
    +
    +   +
    - 16 + + -
    +
    +
      - } +
    - 17 + + -
    +
    +
     
    - 18 + + -
    +
    +
      - // NewBlock creates a block with the given data. -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go - RENAMED - -
    -
    -
    -
    - - - - -
    -
    @@ -0,0 +1,44 @@
    @@ -113104,6 +187709,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice.go + RENAMED + +
    +
    @@ -113111,446 +187731,1110 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    -
    - 1 - -
    - + - package state -
    +
    @@ -2,21 +2,12 @@
    + 2 +
    - + +  
    + 3 +
    - + +   import (
    + 4 +
    - + - "errors" +   + "bytes"
    + 5 +
    - + - "math/big" + - + "errors"
    + 6 +
    - + - ) +   + "math/big"
    + 7 +
    - + +  
    + 8 +
    - + - const ( +   + "github.com/0xPolygonHermez/zkevm-node/log"
    + 9 +
    - + - // MaxEffectivePercentage is the maximum value that can be used as effective percentage +   + "github.com/0xPolygonHermez/zkevm-node/state"
    + 10 +
    - + - MaxEffectivePercentage = uint8(255) +   + )
    + 11 +
    - + - ) +   +
    + 12 +
    - + -
    + - + var (
    + 13 +
    - + - var ( + - + // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero
    + 14 +
    - + - // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero + - + ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero")
    + 15 +
    - + - ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero") + - +
    + 16 +
    - + -
    + - + // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero
    + 17 +
    - + - // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero + - + ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero")
    + 18 +
    - + - ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero") + - + )
    + 19 +
    - + - ) + - +
    + 20 +
    - + -
    +   + // EffectiveGasPrice implements the effective gas prices calculations and checks
    + 21 +
    - + - // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage +   + type EffectiveGasPrice struct {
    + 22 +
    - + - func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { +   + cfg EffectiveGasPriceCfg
    - 23 + +
    @@ -122,33 +113,8 @@
    +
    + 122 +
    - + +   + bfEffectiveGasPrice.Int(effectiveGasPrice) +
    +
    + 123 + +
    +   +
    +
    +
    + 124 + +
    +   + if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { +
    +
    + 125 + +
    + - + return nil, ErrEffectiveGasPriceIsZero +
    +
    + 126 + +
    +   + } +
    +
    + 127 + +
    +   +
    +
    +
    + 128 + +
    +   + return effectiveGasPrice, nil +
    +
    + 129 + +
    +   + } +
    +
    + 130 + +
    + - +
    +
    +
    + 131 + +
    + - + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage +
    +
    + 132 + +
    + - + func (e *EffectiveGasPrice) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) { +
    +
    + 133 + +
    + - const bits = 256
    - 24 + + 134 +
    - + + - var bitsBigInt = big.NewInt(bits)
    - 25 + + 135 +
    - + + -
    - 26 + + 136 +
    - + + - if effectiveGasPrice == nil || gasPrice == nil ||
    - 27 + + 137 +
    - + + - gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 {
    - 28 + + 138 +
    - + + - return 0, ErrEffectiveGasPriceEmpty
    - 29 + + 139 +
    - + + - }
    - 30 + + 140 +
    - + + -
    - 31 + + 141 +
    - + + - if gasPrice.Cmp(effectiveGasPrice) <= 0 {
    - 32 + + 142 + +
    + - + return state.MaxEffectivePercentage, nil +
    +
    + 143 + +
    + - + } +
    +
    + 144 + +
    + - +
    +
    +
    + 145 + +
    + - + // Simulate Ceil with integer division +
    +
    + 146 + +
    + - + b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt) +
    +
    + 147 + +
    + - + b = b.Add(b, gasPrice) +
    +
    + 148 + +
    + - + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    + 149 + +
    + - + b = b.Div(b, gasPrice) +
    +
    + 150 + +
    + - + // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) +
    +
    + 151 + +
    + - + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    + 152 + +
    + - +
    +
    +
    + 153 + +
    + - + return uint8(b.Uint64()), nil +
    +
    + 154 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - @@ -113560,12 +188844,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/effectivegasprice_test.go RENAMED
    - - - - - - - - + + + - - -
    +
     
    +
    + 2 + +
    +   +
    +
    +
    + 3 + +
    +   + import ( +
    +
    + 4 + +
    +   + "bytes" +
    +
    + + +
    +   +
    +
    +
    + 5 + +
    +   + "math/big" +
    +
    + 6 + +
    +   +
    +
    +
    + 7 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    + 8 + +
    +   + "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    + 9 + +
    +   + ) +
    +
    + 10 + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 11 + +
    +   + // EffectiveGasPrice implements the effective gas prices calculations and checks +
    +
    + 12 + +
    +   + type EffectiveGasPrice struct { +
    +
    + 13 + +
    +   + cfg EffectiveGasPriceCfg +
    +
    +
     
    +
    + 113 + +
    +   + bfEffectiveGasPrice.Int(effectiveGasPrice) +
    +
    + 114 + +
    +   +
    +
    +
    + 115 + +
    +   + if effectiveGasPrice.Cmp(new(big.Int).SetUint64(0)) == 0 { +
    +
    + 116 +
    + - return MaxEffectivePercentage, nil + return nil, state.ErrEffectiveGasPriceIsZero +
    +
    + 117 + +
    +   + } +
    +
    + 118 + +
    +   +
    +
    +
    + 119 + +
    +   + return effectiveGasPrice, nil +
    +
    + 120 + +
    +   + } +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 33 + + -
    - + - } +
    +
    +   +
    - 34 + + -
    - + +
    +
    +  
    - 35 + + -
    - + - // Simulate Ceil with integer division +
    +
    +   +
    - 36 + + -
    - + - b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt) +
    +
    +   +
    - 37 + + -
    - + - b = b.Add(b, gasPrice) +
    +
    +   +
    - 38 + + -
    - + - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    +   +
    - 39 + + -
    - + - b = b.Div(b, gasPrice) +
    +
    +   +
    - 40 + + -
    - + - // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte) +
    +
    +   +
    - 41 + + -
    - + - b = b.Sub(b, big.NewInt(1)) //nolint:gomnd +
    +
    +   +
    - 42 + + -
    - + +
    +
    +  
    - 43 + + -
    - + - return uint8(b.Uint64()), nil +
    +
    +   +
    - 44 + + -
    - + - } +
    +
    +   +
    -
    @@ -19,8 +19,10 @@
    +
    @@ -23,8 +24,6 @@
    - 19 + 23
      -
    + )
    - 20 + 24
      - // Genesis contains the information to populate state on creation +
    - 21 + 25
      - type Genesis struct { + func TestCalculateEffectiveGasPricePercentage(t *testing.T) {
    - 22 + + 26 +
    - - // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1 + egp := NewEffectiveGasPrice(egpCfg)
    - 23 + + 27 +
    - - BlockNumber uint64 +
    - + + 28 -
    +
    +
      -
    + testCases := []struct {
    - + + 29 -
    +
    +
      -
    + name string
    - 24 + 30
      - // Root hash of the genesis block + breakEven *big.Int
    +
    @@ -37,14 +36,14 @@
    +
    - 25 + 37
      - Root common.Hash + name: "Nil breakEven or gasPrice",
    - 26 + 38
      - // Actions is the data to populate into the state trie + gasPrice: big.NewInt(1),
    -
    + + + 39 + + +
    +   + expectedValue: uint8(0), +
    + + + + 40 + + +
    + - + err: ErrEffectiveGasPriceEmpty,
    -
    -
    - - - - - - - - - - - - - - - -
    -
     
    - 19 + 41
      -
    + },
    - 20 + 42
      - // Genesis contains the information to populate state on creation + {
    - 21 + 43
      - type Genesis struct { + name: "Zero breakEven or gasPrice",
    - 22 + + 44 +
    - + - // RollupBlockNumber is the block number where the polygonZKEVM smc was deployed on L1 +   + breakEven: big.NewInt(1),
    - 23 + + 45 +
    - + - RollupBlockNumber uint64 +   + gasPrice: big.NewInt(0),
    - 24 + + 46 +
    - + - // RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1 +   + expectedValue: uint8(0),
    - 25 + + 47 +
    - + - RollupManagerBlockNumber uint64 + - + err: ErrEffectiveGasPriceEmpty,
    - 26 + 48
      - // Root hash of the genesis block + },
    - 27 + 49
      - Root common.Hash + {
    - 28 + 50
      - // Actions is the data to populate into the state trie + name: "Both positive, gasPrice less than breakEven",
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - @@ -113921,32 +189182,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -113971,238 +189232,313 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -18,8 +18,6 @@
    +
    @@ -104,7 +103,7 @@
    - 18 + 104
      - double = 2 +
    - 19 + 105
      - ether155V = 27 + for _, tc := range testCases {
    - 20 + 106
      - etherPre155V = 35 -
    -
    - 21 - -
    - - - // MaxEffectivePercentage is the maximum value that can be used as effective percentage + t.Run(tc.name, func(t *testing.T) {
    - 22 + + 107 +
    - - MaxEffectivePercentage = uint8(255) + actual, err := egp.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven)
    - 23 + 108
      - // Decoding constants + assert.Equal(t, tc.err, err)
    - 24 + 109
      - headerByteLength uint64 = 1 + if actual != 0 {
    - 25 + 110
      - sLength uint64 = 32 + assert.Equal(t, tc.expectedValue, actual)
    - 18 + 24
      - double = 2 + )
    - 19 + 25
      - ether155V = 27 +
    - 20 + 26
      - etherPre155V = 35 + func TestCalculateEffectiveGasPricePercentage(t *testing.T) {
    - 21 + 27
      - // Decoding constants + testCases := []struct {
    - 22 + 28
      - headerByteLength uint64 = 1 + name string
    - 23 + 29
      - sLength uint64 = 32 + breakEven *big.Int
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go - RENAMED - -
    -
    -
    -
    - - - + - - + + + - - - - + + + + + + + + + + + + - - + + +
    -
    @@ -24,6 +24,9 @@
    +
     
    - 24 + 36
      - GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error) + name: "Nil breakEven or gasPrice",
    - 25 + 37
      - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error) + gasPrice: big.NewInt(1),
    - 26 + 38
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error) + expectedValue: uint8(0),
    - + + 39 -
    +
    +
    + + + err: state.ErrEffectiveGasPriceEmpty, +
    +
    + 40 + +
      -
    + },
    - + + 41 -
    +
    +
      -
    + {
    - + + 42 -
    +
    +
      -
    + name: "Zero breakEven or gasPrice",
    - 27 + 43
      - AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error + breakEven: big.NewInt(1),
    - 28 + 44
      - GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error) + gasPrice: big.NewInt(0),
    - 29 + 45 + +
    +   + expectedValue: uint8(0), +
    +
    + 46 + +
    + + + err: state.ErrEffectiveGasPriceEmpty, +
    +
    + 47 + +
    +   + }, +
    +
    + 48 + +
    +   + { +
    +
    + 49
      - GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error) + name: "Both positive, gasPrice less than breakEven",
    -
    @@ -146,10 +149,13 @@
    +
     
    - 146 + 103
      - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) +
    - 147 + 104
      - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + for _, tc := range testCases {
    - 148 + 105
      - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + t.Run(tc.name, func(t *testing.T) {
    - 149 + + 106 +
    - - - GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error) + + + actual, err := state.CalculateEffectiveGasPricePercentage(tc.gasPrice, tc.breakEven)
    - 150 + 107
      - GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) + assert.Equal(t, tc.err, err)
    - 151 + 108
      - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) + if actual != 0 {
    - 152 + 109
      - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) + assert.Equal(t, tc.expectedValue, actual) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/errors.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + + + + + - - - - - - - - - - - - - - - @@ -114300,12 +189631,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -114324,282 +189655,356 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + + + + + + + + + + + - + + +
    +
    @@ -76,4 +76,13 @@
    - + + 76 -
    +
    +
     
    + 77 + +
    +   + // ErrZeroL1GasPrice is returned if the L1 gas price is 0. +
    +
    + 78 + +
    +   + ErrZeroL1GasPrice = errors.New("L1 gas price 0") +
    +
    @@ -114224,68 +189560,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 153 + + -
    +
    +
      - GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) +
    - 154 + + -
    +
    +
      - GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error) +
    - 155 + + -
    +
    +
      - GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) +
    -
    @@ -159,4 +165,5 @@
    -
    - 159 + + -
    +
    +
      - UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    - 160 + + -
    +
    +
      - GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error) +
    - 161 + + -
    +
    +
      - GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error) +
    - 162 + 79
      - } + )
    - 24 + 76
      - GetTxsOlderThanNL1BlocksUntilTxHash(ctx context.Context, nL1Blocks uint64, earliestTxHash common.Hash, dbTx pgx.Tx) ([]common.Hash, error) +
    - 25 + 77
      - GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*Block, error) + // ErrZeroL1GasPrice is returned if the L1 gas price is 0.
    - 26 + 78
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*Block, error) + ErrZeroL1GasPrice = errors.New("L1 gas price 0")
    - 27 + 79
    + - GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*Block, error) +
    - 28 + 80
    + - GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*Block, error) + // ErrSenderDisallowedSendTx is returned when transactions by sender are is disallowed by policy
    - 29 + 81
    + - UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error + ErrSenderDisallowedSendTx = errors.New("sender disallowed send_tx by policy")
    - 30 + + 82 +
    -   - AddGlobalExitRoot(ctx context.Context, exitRoot *GlobalExitRoot, dbTx pgx.Tx) error + + +
    - 31 + + 83 +
    -   - GetLatestGlobalExitRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (GlobalExitRoot, time.Time, error) + + + // ErrContractDisallowedSendTx is returned when transactions to contract are is disallowed by policy +
    +
    + 84 + +
    + + + ErrContractDisallowedSendTx = errors.New("contract disallowed send_tx by policy") +
    +
    + 85 + +
    + + +
    +
    +
    + 86 + +
    + + + // ErrSenderDisallowedDeploy is returned when deploy transactions are disallowed by policy +
    +
    + 87 + +
    + + + ErrSenderDisallowedDeploy = errors.New("sender disallowed deploy by policy")
    - 32 + 88
      - GetNumberOfBlocksSinceLastGERUpdate(ctx context.Context, dbTx pgx.Tx) (uint64, error) + )
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/interfaces.go + RENAMED + +
    +
    +
    +
    + + + - - - - + - - - - - - - - - - + - - - - - - - - - - + + + @@ -114607,21 +190012,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    @@ -38,6 +38,7 @@
    - 149 + 38
      - GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) + MarkWIPTxsAsPending(ctx context.Context) error
    - 150 + 39
      - GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
    - 151 + 40
      - GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) + MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
    - 152 + + -
    - + - GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]L1InfoTreeExitRootStorageEntry, error) +
    +
    +   +
    - 153 + 41
      - GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
    - 154 + 42
      - GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) + }
    - 155 + 43
      - GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    - 156 - -
    - + - GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) -
    +
    +
    @@ -48,3 +49,12 @@
    - 157 + + 48 +
    - + - GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +   + GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
    - 158 + + 49 +
    - + - GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) +   + PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
    - 159 + 50
      - GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) + }
    - 160 + + -
    +
    +
      - GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error) +
    - 161 + + -
    +
    +
      - GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) +
    -
     
    +
    + + +
    +   +
    +
    - 165 + + -
    +
    +
      - UpdateBatchAsChecked(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    - 166 + + -
    +
    +
      - GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error) +
    - 167 + + -
    +
    +
      - GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error) +
    - 168 + + -
    - + - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) +
    +
    +   +
    - 169 + + -
    +
    +
      - } +
    +
    +
    + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree.go - RENAMED - -
    -
    @@ -114629,241 +190019,260 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -34,20 +34,20 @@
    +
     
    - 34 + 38
      - if s.l1InfoTree != nil { + MarkWIPTxsAsPending(ctx context.Context) error
    - 35 + 39
      - return nil + GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
    - 36 + 40
      - } + MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
    - 37 + + 41 +
    - - - log.Debugf("Building L1InfoTree cache") + + + policy
    - 38 + + 42 +
    - - - allLeaves, err := s.storage.GetAllL1InfoRootEntries(ctx, dbTx) +   + GetEarliestProcessedTx(ctx context.Context) (common.Hash, error)
    - 39 + 43
      - if err != nil { + }
    - 40 + + 44 +
    - - - log.Error("error getting all leaves. Error: ", err) +   +
    - 41 - -
    - - - return fmt.Errorf("error getting all leaves. Error: %w", err) -
    +
    +
     
    - 42 + 49
      - } + GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error)
    - 43 + 50
      - var leaves [][32]byte + PreProcessTransaction(ctx context.Context, tx *types.Transaction, dbTx pgx.Tx) (*state.ProcessBatchResponse, error)
    - 44 + 51
      - for _, leaf := range allLeaves { + }
    - 45 + + 52 +
    -   - leaves = append(leaves, leaf.Hash()) + + + type policy interface {
    - 46 + + 53 +
    -   - } + + + CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error)
    - 47 + + 54 +
    - - - mt, err := l1infotree.NewL1InfoTree(uint8(32), leaves) //nolint:gomnd + + + AddAddressesToPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error
    - 48 + + 55 +
    -   - if err != nil { + + + RemoveAddressesFromPolicy(ctx context.Context, policy PolicyName, addresses []common.Address) error
    - 49 + + 56 +
    - - - log.Error("error creating L1InfoTree. Error: ", err) + + + ClearPolicy(ctx context.Context, policy PolicyName) error
    - 50 + + 57 +
    - - - return fmt.Errorf("error creating L1InfoTree. Error: %w", err) + + + DescribePolicies(ctx context.Context) ([]Policy, error)
    - 51 + + 58 +
    -   - } + + + DescribePolicy(ctx context.Context, name PolicyName) (Policy, error)
    - 52 + + 59 +
    -   - s.l1InfoTree = mt + + + ListAcl(ctx context.Context, policy PolicyName, query []common.Address) ([]common.Address, error)
    - 53 + + 60 +
    -   - return nil + + + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pgpoolstorage/policy.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - @@ -114947,68 +190356,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -115042,764 +190456,771 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -55,6 +55,14 @@
    +
    @@ -0,0 +1,202 @@
    - 55 + + -
    +
    +
     
    - 56 + + -
    +
    +
      - // AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error +
    - 57 + + -
    +
    +
      - func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) { +
    - 58 + + -
    +
    +
      - var newIndex uint32 +
    - 59 + + -
    +
    +
      - gerIndex, err := s.GetLatestIndex(ctx, dbTx) +
    - 60 + + -
    +
    +
      - if err != nil && !errors.Is(err, ErrNotFound) { +
    -
    @@ -74,6 +82,9 @@
    +
    + + +
    +   +
    +
    - 74 + + -
    +
    +
      - log.Error("error add new leaf to the L1InfoTree. Error: ", err) +
    - 75 + + -
    +
    +
      - return nil, err +
    - 76 + + -
    +
    +
      - } +
    - 77 + + -
    +
    +
      - entry := L1InfoTreeExitRootStorageEntry{ +
    - 78 + + -
    +
    +
      - L1InfoTreeLeaf: *l1InfoTreeLeaf, +
    - 79 + + -
    +
    +
      - L1InfoTreeRoot: root, +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 34 + + -
    +
    +
      - if s.l1InfoTree != nil { +
    - 35 + + -
    +
    +
      - return nil +
    - 36 + + -
    +
    +
      - } +
    - 37 + + -
    - + - // Reset L1InfoTree siblings and leaves +
    +
    +   +
    - 38 + + -
    - + - allLeaves, err := s.GetAllL1InfoRootEntries(ctx, dbTx) +
    +
    +   +
    - 39 + + -
    +
    +
      - if err != nil { +
    - 40 + + -
    - + - log.Error("error getting all leaves to reset l1InfoTree. Error: ", err) +
    +
    +   +
    - 41 + + -
    - + - return err +
    +
    +   +
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
      - var leaves [][32]byte +
    - 44 + + -
    +
    +
      - for _, leaf := range allLeaves { +
    - 45 + + -
    +
    +
      - leaves = append(leaves, leaf.Hash()) +
    - 46 + + -
    +
    +
      - } +
    - 47 + + -
    - + - mt, err := s.l1InfoTree.ResetL1InfoTree(leaves) +
    +
    +   +
    - 48 + + -
    +
    +
      - if err != nil { +
    - 49 + + -
    - + - log.Error("error resetting l1InfoTree. Error: ", err) +
    +
    +   +
    - 50 + + -
    - + - return err +
    +
    +   +
    - 51 + + -
    +
    +
      - } +
    - 52 + + -
    +
    +
      - s.l1InfoTree = mt +
    - 53 + + -
    +
    +
      - return nil +
    -
     
    +
    + + +
    +   +
    +
    - 55 + + -
    +
    +
     
    - 56 + + -
    +
    +
      - // AddL1InfoTreeLeaf adds a new leaf to the L1InfoTree and returns the entry and error +
    - 57 + + -
    +
    +
    +   +
    +
    +
    + + +
      - func (s *State) AddL1InfoTreeLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) { +
    - 58 + + -
    - + - var stateTx *StateTx +
    +
    +   +
    - 59 + + -
    - + - if dbTx != nil { +
    +
    +   +
    - 60 + + -
    - + - var ok bool +
    +
    +   +
    - 61 + + -
    - + - stateTx, ok = dbTx.(*StateTx) +
    +
    +   +
    - 62 + + -
    - + - if !ok { +
    +
    +   +
    - 63 + + -
    - + - return nil, fmt.Errorf("error casting dbTx to stateTx") +
    +
    +   +
    - 64 + + -
    - + - } +
    +
    +   +
    - 65 + + -
    - + - } +
    +
    +   +
    - 66 + + -
    +
    +
      - var newIndex uint32 +
    - 67 + + -
    +
    +
      - gerIndex, err := s.GetLatestIndex(ctx, dbTx) +
    - 68 + + -
    +
    +
      - if err != nil && !errors.Is(err, ErrNotFound) { +
    -
     
    +
    + + +
    +   +
    +
    - 82 + + -
    +
    +
      - log.Error("error add new leaf to the L1InfoTree. Error: ", err) +
    - 83 + + -
    +
    +
      - return nil, err +
    - 84 + + -
    +
    +
      - } +
    - 85 + + -
    - + - if stateTx != nil { +
    +
    +   +
    - 86 + + -
    - + - stateTx.SetL1InfoTreeModified() +
    +
    +   +
    - 87 + + -
    - + - } +
    +
    +   +
    - 88 + + -
    +
    +
      - entry := L1InfoTreeExitRootStorageEntry{ +
    - 89 + + -
    +
    +
      - L1InfoTreeLeaf: *l1InfoTreeLeaf, +
    - 90 + + -
    +
    +
      - L1InfoTreeRoot: root, +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - @@ -116570,223 +191976,183 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -116914,448 +192280,308 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -16,10 +16,10 @@
    - 16 + + -
    +
    +
     
    - 17 + + -
    +
    +
      - // AddBlock adds a new block to the State Store +
    - 18 + + -
    +
    +
      - func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error { +
    - 19 + + -
    - - - const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at) VALUES ($1, $2, $3, $4)" +
    +
    +   +
    - 20 + + -
    +
    +
     
    - 21 + + -
    +
    +
      - e := p.getExecQuerier(dbTx) +
    - 22 + + -
    - - - _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt) +
    +
    +   +
    - 23 + + -
    +
    +
      - return err +
    - 24 + + -
    +
    +
      - } +
    - 25 + + -
    +
    +
     
    -
    @@ -30,11 +30,11 @@
    +
    + + +
    +   +
    +
    - 30 + + -
    +
    +
      - parentHash string +
    - 31 + + -
    +
    +
      - block state.Block +
    - 32 + + -
    +
    +
      - ) +
    - 33 + + -
    - - - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1" +
    +
    +   +
    - 34 + + -
    +
    +
     
    - 35 + + -
    +
    +
      - q := p.getExecQuerier(dbTx) +
    - 36 + + -
    +
    +
     
    - 37 + + -
    - - - err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) +
    +
    +   +
    - 38 + + -
    +
    +
      - if errors.Is(err, pgx.ErrNoRows) { +
    - 39 + + -
    +
    +
      - return nil, state.ErrStateNotSynchronized +
    - 40 + + -
    +
    +
      - } +
    -
    @@ -43,6 +43,55 @@
    +
    + + +
    +   +
    +
    - 43 + + -
    +
    +
      - return &block, err +
    - 44 + + -
    +
    +
      - } +
    - 45 + + -
    +
    +
     
    @@ -116295,78 +191716,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 46 + + -
    +
    +
      - // GetPreviousBlock gets the offset previous L1 block respect to latest. +
    - 47 + + -
    +
    +
      - func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) { +
    - 48 + + -
    +
    +
      - var ( +
    -
    @@ -50,11 +99,31 @@
    -
    - 50 + + -
    +
    +
      - parentHash string +
    - 51 + + -
    +
    +
      - block state.Block +
    - 52 + + -
    +
    +
      - ) -
    -
    - 53 - -
    - - - const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1" +
    - 54 + + -
    +
    +
     
    - 55 + + -
    +
    +
      - q := p.getExecQuerier(dbTx) +
    - 56 + + -
    +
    +
     
    - 57 - -
    - - - err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) -
    -
    - 58 + + -
    +
    +
      - if errors.Is(err, pgx.ErrNoRows) { +
    - 59 + + -
    +
    +
      - return nil, state.ErrNotFound +
    - 60 + + -
    +
    +
      - } +
    -
    @@ -70,11 +139,11 @@
    -
    - 70 + + -
    +
    +
      - parentHash string +
    - 71 + + -
    +
    +
      - block state.Block +
    - 72 + + -
    +
    +
      - ) -
    -
    - 73 - -
    - - - const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at FROM state.block WHERE block_num = $1" +
    - 74 + + -
    +
    +
     
    - 75 + + -
    +
    +
      - q := p.getExecQuerier(dbTx) +
    - 76 + + -
    +
    +
     
    - 77 - -
    - - - err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt) -
    -
    - 78 + + -
    +
    +
      - if errors.Is(err, pgx.ErrNoRows) { +
    - 79 + + -
    +
    +
      - return nil, state.ErrNotFound +
    - 80 + + -
    +
    +
      - } +
    -
    @@ -82,3 +151,14 @@
    -
    - 82 + + -
    +
    +
      - block.ParentHash = common.HexToHash(parentHash) +
    - 83 + + -
    +
    +
      - return &block, err +
    - 84 + + -
    +
    +
      - } +
    - 16 - -
    -   -
    -
    -
    - 17 - -
    -   - // AddBlock adds a new block to the State Store -
    -
    - 18 - -
    -   - func (p *PostgresStorage) AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error { -
    -
    - 19 + + 1 +
    + - const addBlockSQL = "INSERT INTO state.block (block_num, block_hash, parent_hash, received_at, checked) VALUES ($1, $2, $3, $4, $5)" -
    -
    - 20 - -
    -   -
    -
    -
    - 21 - -
    -   - e := p.getExecQuerier(dbTx) + package pgpoolstorage
    - 22 + + 2 +
    + - _, err := e.Exec(ctx, addBlockSQL, block.BlockNumber, block.BlockHash.String(), block.ParentHash.String(), block.ReceivedAt, block.Checked) -
    -
    - 23 - -
    -   - return err -
    -
    - 24 - -
    -   - } -
    -
    - 25 - -
    -  
    -
     
    -
    - 30 - -
    -   - parentHash string -
    -
    - 31 + + 3 +
    -   - block state.Block + + + import (
    - 32 + + 4 +
    -   - ) + + + "context"
    - 33 + + 5 +
    + - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block ORDER BY block_num DESC LIMIT 1" + "errors"
    - 34 + + 6 +
    -   -
    + + + "fmt"
    - 35 + + 7 +
    -   - q := p.getExecQuerier(dbTx) + + + "strings"
    - 36 + + 8 +
    -   + +
    - 37 + + 9 +
    + - err := q.QueryRow(ctx, getLastBlockSQL).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) -
    -
    - 38 - -
    -   - if errors.Is(err, pgx.ErrNoRows) { -
    -
    - 39 - -
    -   - return nil, state.ErrStateNotSynchronized -
    -
    - 40 - -
    -   - } -
    -
    -
     
    -
    - 43 - -
    -   - return &block, err + "github.com/0xPolygonHermez/zkevm-node/pool"
    - 44 + + 10 +
    -   - } + + + "github.com/ethereum/go-ethereum/common"
    - 45 + + 11 +
    -   -
    + + + "github.com/jackc/pgx/v4"
    - 46 + 12
    + - // GetFirstUncheckedBlock returns the first L1 block that has not been checked from a given block number. + )
    - 47 + 13
    + - func (p *PostgresStorage) GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { +
    - 48 + 14
    + - var ( + // CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule
    - 49 + 15
    + - blockHash string + // will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of
    - 50 + 16
    + - parentHash string + // the policy setting.
    - 51 + 17
    + - block state.Block + func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error) {
    - 52 + 18
    + - ) + sql := `SELECT
    - 53 + 19
    + - const getLastBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND checked=false ORDER BY block_num LIMIT 1" + CASE WHEN a.address is null THEN
    - 54 + 20
    + -
    + NOT p.allow
    - 55 + 21
    + - q := p.getExecQuerier(dbTx) + ELSE
    - 56 + 22
    + -
    + p.allow
    - 57 + 23
    + - err := q.QueryRow(ctx, getLastBlockSQL, fromBlockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + END
    - 58 + 24
    + - if errors.Is(err, pgx.ErrNoRows) { + FROM pool.policy p
    - 59 + 25
    + - return nil, state.ErrNotFound + LEFT JOIN pool.acl a
    - 60 + 26
    + - } + ON p.name = a.policy
    - 61 + 27
    + - block.BlockHash = common.HexToHash(blockHash) + AND a.address = $1
    - 62 + 28
    + - block.ParentHash = common.HexToHash(parentHash) + WHERE p.name = $2`
    - 63 + 29
    + - return &block, err +
    - 64 + 30
    + - } + rows, err := p.db.Query(ctx, sql, address.Hex(), policy)
    - 65 + 31
    @@ -117365,107 +192591,107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 66 + 32
    + - func (p *PostgresStorage) GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) { + if errors.Is(err, pgx.ErrNoRows) {
    - 67 + 33
    + - const getUncheckedBlocksSQL = "SELECT block_num, block_hash, parent_hash, received_at, checked FROM state.block WHERE block_num>=$1 AND block_num<=$2 AND checked=false ORDER BY block_num" + return false, pool.ErrNotFound
    - 68 + 34
    + -
    + } else if err != nil {
    - 69 + 35
    + - q := p.getExecQuerier(dbTx) + return false, err
    - 70 + 36
    + -
    + }
    - 71 + 37
    + - rows, err := q.Query(ctx, getUncheckedBlocksSQL, fromBlockNumber, toBlockNumber) +
    - 72 + 38
    + - if err != nil { + defer rows.Close()
    - 73 + 39
    + - return nil, err + if !rows.Next() { // should always be a row if the policy exists
    - 74 + 40
    + - } + return false, nil
    - 75 + 41
    + - defer rows.Close() + }
    - 76 + 42
    @@ -117475,147 +192701,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 77 + 43
    + - var blocks []*state.Block + var allow bool
    - 78 + 44
    + - for rows.Next() { + err = rows.Scan(&allow)
    - 79 + 45
    + - var ( + if err != nil {
    - 80 + 46
    + - blockHash string + return false, err
    - 81 + 47
    + - parentHash string + }
    - 82 + 48
    + - block state.Block + return allow, nil
    - 83 + 49
    + - ) + }
    - 84 + 50
    + - err := rows.Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) +
    - 85 + 51
    + - if err != nil { + // UpdatePolicy sets the allow/deny rule for the named policy
    - 86 + 52
    + - return nil, err + func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error {
    - 87 + 53
    + - } + sql := "UPDATE pool.policy SET allow = $1 WHERE name = $2"
    - 88 + 54
    + - block.BlockHash = common.HexToHash(blockHash) + _, err := p.db.Exec(ctx, sql, allow, string(policy))
    - 89 + 55
    + - block.ParentHash = common.HexToHash(parentHash) + if err != nil {
    - 90 + 56
    + - blocks = append(blocks, &block) + return err
    - 91 + 57
    @@ -117625,17 +192851,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 92 + 58
    + - return blocks, nil + return nil
    - 93 + 59
    @@ -117645,7 +192871,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 94 + 60
    @@ -117654,1636 +192880,1453 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 95 - -
    -   - // GetPreviousBlock gets the offset previous L1 block respect to latest. -
    -
    - 96 - -
    -   - func (p *PostgresStorage) GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) { -
    -
    - 97 - -
    -   - var ( -
    -
    -
     
    -
    - 99 - -
    -   - parentHash string -
    -
    - 100 + + 61 +
    -   - block state.Block + + + // AddAddressesToPolicy adds addresses to the named policy
    - 101 + + 62 +
    -   - ) + + + func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
    - 102 + + 63 +
    + - const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block ORDER BY block_num DESC LIMIT 1 OFFSET $1" + sql := "INSERT INTO pool.acl (policy, address) VALUES ($1, $2) ON CONFLICT DO NOTHING"
    - 103 + 64
    + -
    + tx, err := p.db.Begin(ctx)
    - 104 + 65
    + - q := p.getExecQuerier(dbTx) + if err != nil {
    - 105 + 66
    + -
    + return err
    - 106 + 67
    + - err := q.QueryRow(ctx, getPreviousBlockSQL, offset).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + }
    - 107 + 68
    + - if errors.Is(err, pgx.ErrNoRows) { + defer func(tx pgx.Tx, ctx context.Context) {
    - 108 + 69
    + - return nil, state.ErrNotFound + _ = tx.Rollback(ctx)
    - 109 + 70
    + - } + }(tx, ctx)
    - 110 + 71
    + - block.BlockHash = common.HexToHash(blockHash) +
    - 111 + 72
    + - block.ParentHash = common.HexToHash(parentHash) + for _, a := range addresses {
    - 112 + 73
    + - return &block, err + _, err = tx.Exec(ctx, sql, policy, a.Hex())
    - 113 + 74
    + - } + if err != nil {
    - 114 + 75
    + -
    + return err
    - 115 + 76
    + - // GetPreviousBlockToBlockNumber gets the previous L1 block respect blockNumber. + }
    - 116 + 77
    + - func (p *PostgresStorage) GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) { + }
    - 117 + 78
    + - var ( + err = tx.Commit(ctx)
    - 118 + 79
    + - blockHash string + if err != nil {
    - 119 + 80
    + - parentHash string + return nil
    - 120 + 81
    + - block state.Block + }
    - 121 + 82
    + - ) + return nil
    - 122 + 83
    + - const getPreviousBlockSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num < $1 ORDER BY block_num DESC LIMIT 1 " + }
    - 123 + + 84 +
    -   + +
    - 124 + + 85 +
    -   - q := p.getExecQuerier(dbTx) + + + // RemoveAddressesFromPolicy removes addresses from the named policy
    - 125 + + 86 +
    -   -
    + + + func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error {
    - 126 + + 87 +
    + - err := q.QueryRow(ctx, getPreviousBlockSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + sql := "DELETE FROM pool.acl WHERE policy = $1 AND address = $2"
    - 127 + + 88 +
    -   - if errors.Is(err, pgx.ErrNoRows) { + + + tx, err := p.db.Begin(ctx)
    - 128 + + 89 +
    -   - return nil, state.ErrNotFound + + + if err != nil {
    - 129 + + 90 +
    -   - } + + + return err
    -
     
    -
    - 139 + + 91 +
    -   - parentHash string + + + }
    - 140 + + 92 +
    -   - block state.Block + + + defer func(tx pgx.Tx, ctx context.Context) {
    - 141 + + 93 +
    -   - ) + + + _ = tx.Rollback(ctx)
    - 142 + + 94 +
    + - const getBlockByNumberSQL = "SELECT block_num, block_hash, parent_hash, received_at,checked FROM state.block WHERE block_num = $1" + }(tx, ctx)
    - 143 + + 95 +
    -   + +
    - 144 + + 96 +
    -   - q := p.getExecQuerier(dbTx) + + + for _, a := range addresses {
    - 145 + + 97 +
    -   -
    + + + _, err = tx.Exec(ctx, sql, policy, a.Hex())
    - 146 + + 98 +
    + - err := q.QueryRow(ctx, getBlockByNumberSQL, blockNumber).Scan(&block.BlockNumber, &blockHash, &parentHash, &block.ReceivedAt, &block.Checked) + if err != nil {
    - 147 + + 99 +
    -   - if errors.Is(err, pgx.ErrNoRows) { + + + return err
    - 148 + + 100 +
    -   - return nil, state.ErrNotFound + + + }
    - 149 + + 101 +
    -   + + }
    -
     
    -
    - 151 + + 102 +
    -   - block.ParentHash = common.HexToHash(parentHash) + + + err = tx.Commit(ctx)
    - 152 + + 103 +
    -   - return &block, err + + + if err != nil {
    - 153 + + 104 +
    -   - } + + + return err
    - 154 + 105
    + -
    + }
    - 155 + 106
    + - // UpdateCheckedBlockByNumber update checked flag for a block + return nil
    - 156 + 107
    + - func (p *PostgresStorage) UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error { + }
    - 157 + 108
    + - const query = ` +
    - 158 + 109
    + - UPDATE state.block + // ClearPolicy removes _all_ addresses from the named policy
    - 159 + 110
    + - SET checked = $1 WHERE block_num = $2` + func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error {
    - 160 + 111
    + -
    + sql := "DELETE FROM pool.acl WHERE policy = $1"
    - 161 + 112
    + - e := p.getExecQuerier(dbTx) + _, err := p.db.Exec(ctx, sql, policy)
    - 162 + 113
    + - _, err := e.Exec(ctx, query, newCheckedStatus, blockNumber) + if err != nil {
    - 163 + 114
    + - return err + return err
    - 164 + 115
    + - } -
    -
    -
    + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -53,7 +53,7 @@
    - 53 + + 116 +
    -   - const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index + + + return nil
    - 54 + + 117 +
    -   - FROM state.exit_root + + + }
    - 55 + + 118 +
    -   - WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1 + + +
    - 56 + + 119 +
    - - - ORDER BY l1_info_tree_index DESC` + + + // DescribePolicies return all the policies
    - 57 + + 120 +
    -   -
    + + + func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error) {
    - 58 + + 121 +
    -   - entry := state.L1InfoTreeExitRootStorageEntry{} + + + sql := "SELECT name, allow FROM pool.policy"
    - 59 + + 122 +
    -   -
    + + + rows, err := p.db.Query(ctx, sql)
    -
    @@ -112,7 +112,7 @@
    -
    - 112 + + 123 +
    -   - return entry, nil + + + if err != nil {
    - 113 + + 124 +
    -   - } + + + if errors.Is(err, pgx.ErrNoRows) {
    - 114 + + 125 +
    -   -
    + + + return nil, nil
    - 115 + + 126 +
    - - - func (p *PostgresStorage) GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + + + } else {
    - 116 + + 127 +
    -   - // TODO: Optimize this query + + + return nil, err
    - 117 + + 128 +
    -   - const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index + + + }
    - 118 + + 129 +
    -   - FROM state.exit_root -
    -
    -
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 53 + + 130 +
    -   - const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index + + + defer rows.Close()
    - 54 + + 131 +
    -   - FROM state.exit_root + + +
    - 55 + + 132 +
    -   - WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1 + + + var list []pool.Policy
    - 56 + + 133 +
    + - ORDER BY l1_info_tree_index DESC LIMIT 1` + for rows.Next() {
    - 57 + + 134 +
    -   -
    + + + var name string
    - 58 + + 135 +
    -   - entry := state.L1InfoTreeExitRootStorageEntry{} + + + var allow bool
    - 59 + + 136 +
    -   -
    + + + err = rows.Scan(&name, &allow)
    -
     
    -
    - 112 + + 137 +
    -   - return entry, nil + + + if err != nil {
    - 113 + + 138 +
    -   - } + + + return nil, err
    - 114 + + 139 +
    -   -
    + + + }
    - 115 + + 140 +
    + - func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) { + if pool.IsPolicy(name) { // skip unknown
    - 116 + + 141 +
    -   - // TODO: Optimize this query + + + p := pool.Policy{
    - 117 + + 142 +
    -   - const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index + + + Name: pool.PolicyName(name),
    - 118 + + 143 +
    -   - FROM state.exit_root -
    -
    -
    + + + Allow: allow,
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -119,7 +119,7 @@
    - 119 + + 144 +
    -   - return common.HexToHash(stateRootStr), nil + + + }
    - 120 + + 145 +
    -   - } + + + list = append(list, p)
    - 121 + + 146 +
    -   -
    + + + }
    - 122 + + 147 +
    - - - // GetLogsByBlockNumber get all the logs from a specific block ordered by log index + + + }
    - 123 + + 148 +
    -   - func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) { + + + return list, nil
    - 124 + + 149 +
    -   - const query = ` + + + }
    - 125 + + 150 +
    -   - SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3 + + +
    -
    @@ -128,7 +128,7 @@
    -
    - 128 + + 151 +
    -   - INNER JOIN state.l2block b ON b.block_num = t.l2_block_num + + + // DescribePolicy returns the named policy
    - 129 + + 152 +
    -   - INNER JOIN state.receipt r ON r.tx_hash = t.hash + + + func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error) {
    - 130 + + 153 +
    -   - WHERE b.block_num = $1 + + + sql := "SELECT name, allow FROM pool.policy WHERE name = $1 LIMIT 1"
    - 131 + + 154 +
    - - - ORDER BY l.log_index ASC` + + + row := p.db.QueryRow(ctx, sql, name)
    - 132 + + 155 +
    -   -
    + + + var (
    - 133 + + 156 +
    -   - q := p.getExecQuerier(dbTx) + + + pName string
    - 134 + + 157 +
    -   - rows, err := q.Query(ctx, query, blockNumber) + + + allow bool
    -
    @@ -159,7 +159,7 @@
    +
    + 158 + +
    + + + ) +
    + 159 +
    -   - const queryFilterByBlockHash = `AND b.block_hash = $7 ` + + + err := row.Scan(&pName, &allow)
    + 160 +
    -   - const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 ` + + + if err != nil {
    + 161 +
    -   -
    + + + return pool.Policy{}, err
    + 162 +
    - - - const queryOrder = `ORDER BY b.block_num ASC, l.log_index ASC` + + + }
    + 163 +
    -   -
    + + + return pool.Policy{
    + 164 +
    -   - // count queries + + + Name: pool.PolicyName(pName),
    + 165 -
    -   - const queryToCountLogsByBlockHash = "" + -
    -
    -
    @@ -355,3 +355,87 @@
    -
    - 355 - +
    -   - } + + + Allow: allow,
    - 356 + + 166 +
    -   - return nativeBlockHashes, nil + + + }, nil
    - 357 + + 167 +
    -   + + }
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - + + 168 -
    -   +
    +
    + +
    - + + 169 -
    -   -
    +
    +
    + + + // ListAcl returns a list of the addresses associated with the policy
    - + + 170 -
    -   -
    +
    +
    + + + func (p *PostgresPoolStorage) ListAcl(
    - + + 171 -
    -   -
    +
    +
    + + + ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error) {
    - + + 172 -
    -   -
    +
    +
    + + + sql := "SELECT address FROM pool.acl WHERE policy = $1"
    - + + 173 -
    -   +
    +
    + +
    - - -
    -   -
    +
    + 174 + +
    + + + if len(query) > 0 {
    - + + 175 -
    -   -
    +
    +
    + + + var addrs []string
    - + + 176 -
    -   -
    +
    +
    + + + for _, a := range query {
    - + + 177 -
    -   -
    +
    +
    + + + addrs = append(addrs, a.Hex())
    - + + 178 -
    -   -
    +
    +
    + + + }
    - + + 179 -
    -   -
    +
    +
    + + + sql = sql + fmt.Sprintf(" IN (%v)", strings.Join(addrs, ","))
    - + + 180 -
    -   -
    +
    +
    + + + }
    - + + 181 -
    -   +
    +
    + +
    - + + 182 -
    -   -
    +
    +
    + + + rows, err := p.db.Query(ctx, sql, string(policy))
    - + + 183 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 184 -
    -   -
    +
    +
    + + + if errors.Is(err, pgx.ErrNoRows) {
    - + + 185 -
    -   -
    +
    +
    + + + return nil, nil
    - + + 186 -
    -   -
    +
    +
    + + + } else {
    - + + 187 -
    -   -
    +
    +
    + + + return nil, err
    - + + 188 -
    -   -
    +
    +
    + + + }
    - + + 189 -
    -   -
    +
    +
    + + + }
    - + + 190 -
    -   -
    +
    +
    + + + defer rows.Close()
    - + + 191 -
    -   +
    +
    + +
    - + + 192 -
    -   -
    +
    +
    + + + var addresses []common.Address
    - + + 193 -
    -   -
    +
    +
    + + + for rows.Next() {
    - + + 194 -
    -   -
    +
    +
    + + + var addr string
    - + + 195 -
    -   -
    +
    +
    + + + err = rows.Scan(&addr)
    - + + 196 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 197 -
    -   -
    +
    +
    + + + return nil, err
    - + + 198 -
    -   -
    +
    +
    + + + }
    - + + 199 -
    -   -
    +
    +
    + + + addresses = append(addresses, common.HexToAddress(addr))
    - + + 200 -
    -   -
    +
    +
    + + + }
    - + + 201 -
    -   -
    +
    +
    + + + return addresses, nil
    - + + 202 -
    -   -
    +
    +
    + + + }
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/policy.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,43 @@
    @@ -119730,443 +194773,428 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - 119 + + 1 +
    -   - return common.HexToHash(stateRootStr), nil + + + package pool
    - 120 + + 2 +
    -   - } + + +
    - 121 + + 3 +
    -   -
    + + + import "github.com/ethereum/go-ethereum/common"
    - 122 + + 4 +
    + - // GetLogsByBlockNumber get all the logs from a specific block ordered by tx index and log index +
    - 123 + + 5 +
    -   - func (p *PostgresStorage) GetLogsByBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) ([]*types.Log, error) { + + + // PolicyName is a named policy
    - 124 + + 6 +
    -   - const query = ` + + + type PolicyName string
    - 125 + + 7 +
    -   - SELECT t.l2_block_num, b.block_hash, l.tx_hash, r.tx_index, l.log_index, l.address, l.data, l.topic0, l.topic1, l.topic2, l.topic3 + + +
    -
     
    -
    - 128 + + 8 +
    -   - INNER JOIN state.l2block b ON b.block_num = t.l2_block_num + + + const (
    - 129 + + 9 +
    -   - INNER JOIN state.receipt r ON r.tx_hash = t.hash + + + // SendTx is the name of the policy that governs that an address may send transactions to pool
    - 130 + + 10 +
    -   - WHERE b.block_num = $1 + + + SendTx PolicyName = "send_tx"
    - 131 + + 11 +
    + - ORDER BY r.tx_index ASC, l.log_index ASC` + // Deploy is the name of the policy that governs that an address may deploy a contract
    - 132 + + 12 +
    -   -
    + + + Deploy PolicyName = "deploy"
    - 133 + + 13 +
    -   - q := p.getExecQuerier(dbTx) + + + )
    - 134 + + 14 +
    -   - rows, err := q.Query(ctx, query, blockNumber) + + +
    -
     
    -
    - 159 + + 15 +
    -   - const queryFilterByBlockHash = `AND b.block_hash = $7 ` + + + // Policy describes state of a named policy
    - 160 + + 16 +
    -   - const queryFilterByBlockNumbers = `AND b.block_num BETWEEN $7 AND $8 ` + + + type Policy struct {
    - 161 + + 17 +
    -   -
    + + + Name PolicyName
    - 162 + + 18 +
    + - const queryOrder = `ORDER BY b.block_num ASC, r.tx_index ASC, l.log_index ASC` + Allow bool
    - 163 + + 19 +
    -   -
    + + + }
    - 164 + + 20 +
    -   - // count queries + + +
    - 165 + + 21 +
    -   - const queryToCountLogsByBlockHash = "" + + + + // Desc returns the string representation of a policy rule
    -
     
    -
    - 355 + + 22 +
    -   - } + + + func (p *Policy) Desc() string {
    - 356 + + 23 +
    -   - return nativeBlockHashes, nil + + + if p.Allow {
    - 357 + + 24 +
    -   - } + + + return "allow"
    - 358 + 25
    + -
    + }
    - 359 + 26
    + - // GetBatchL2DataByNumber returns the batch L2 data of the given batch number. + return "deny"
    - 360 + 27
    + - func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) { + }
    - 361 + 28
    + - batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx) +
    - 362 + 29
    + - if err != nil { + // Acl describes exception to a named Policy by address
    - 363 + 30
    + - return nil, err + type Acl struct {
    - 364 + 31
    + - } + PolicyName PolicyName
    - 365 + 32
    + - data, ok := batchData[batchNumber] + Address common.Address
    - 366 + 33
    + - if !ok { + }
    - 367 + 34
    + - return nil, state.ErrNotFound +
    - 368 + 35
    + - } + // IsPolicy tests if a string represents a known named Policy
    - 369 + 36
    + - return data, nil + func IsPolicy(name string) bool {
    - 370 + 37
    + - } + for _, p := range []PolicyName{SendTx, Deploy} {
    - 371 + 38
    + -
    + if name == string(p) {
    - 372 + 39
    + - // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables. + return true
    - 373 + 40
    + - func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { + }
    - 374 + 41
    + - const sql = "SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1)" + }
    - 375 + 42
    + - return p.getBatchData(ctx, sql, batchNumbers, dbTx) + return false
    - 376 + 43
    @@ -120174,649 +195202,772 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - + + + - - - - - - - - + + +
    +
    @@ -93,6 +93,13 @@
    +
    - 377 + + 93 +
    - + -
    +   + time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
    - 378 + + 94 +
    - + - // GetForcedBatchDataByNumbers returns the forced batch data of the given batch numbers +   + }
    - 379 + + 95 +
    - + - func (p *PostgresStorage) GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { +   + }(&cfg, p)
    - 380 + + -
    - + - const sql = "SELECT forced_batch_num, convert_from(decode(raw_txs_data, 'hex'), 'UTF8')::bytea FROM state.forced_batch WHERE forced_batch_num = ANY($1)" +
    +
    +   +
    - 381 + + -
    - + - return p.getBatchData(ctx, sql, batchNumbers, dbTx) +
    +
    +   +
    - 382 + + -
    - + - } +
    +
    +   +
    - 383 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 96 +
    - + +  
    - 384 + + 97 +
    - + - func (p *PostgresStorage) getBatchData(ctx context.Context, sql string, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { +   + return p
    - 385 + + 98 +
    - + - q := p.getExecQuerier(dbTx) +   + }
    - 386 + +
    @@ -239,7 +246,6 @@
    +
    + 239 +
    - + - rows, err := q.Query(ctx, sql, batchNumbers) +   + }
    - 387 + + 240 +
    - + - if errors.Is(err, pgx.ErrNoRows) { +   +
    - 388 + + 241 +
    - + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) +   + poolTx := NewTransaction(tx, ip, isWIP)
    - 389 + + 242 +
    - + - } else if err != nil { + - + poolTx.GasUsed = preExecutionResponse.txResponse.GasUsed
    - 390 + + 243 +
    - + - return nil, err +   + poolTx.ZKCounters = preExecutionResponse.usedZKCounters
    - 391 + + 244 +
    - + - } +   + poolTx.ReservedZKCounters = preExecutionResponse.reservedZKCounters
    - 392 + + 245 +
    - + - defer rows.Close() +   +
    - 393 + +
    @@ -687,7 +693,7 @@
    +
    + 687 +
    - + +  
    - 394 + + 688 +
    - + - batchL2DataMap, err := readBatchDataResults(rows, batchNumbers) +   + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 395 + + 689 +
    - + - if err != nil { +   + func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 396 + + 690 +
    - + - return nil, err + - + return p.effectiveGasPrice.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice)
    - 397 + + 691 +
    - + - } +   + }
    - 398 + + 692 +
    - + +  
    - 399 + + 693 +
    - + - if len(batchL2DataMap) == 0 { +   + // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not
    - 400 + +
    @@ -729,3 +735,8 @@
    +
    + 729 +
    - + - return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx) +   + }
    - 401 + + 730 +
    - + - } +   + return gas, nil
    - 402 + + 731 +
    - + +   + } +
    +
    + + +
    +  
    - 403 + + -
    - + - return batchL2DataMap, nil +
    +
    +   +
    - 404 + + -
    - + - } +
    +
    +   +
    - 405 + + -
    - + +
    +
    +  
    - 406 + + -
    - + - // GetBatchL2DataByNumbersFromBackup returns the batch L2 data of the given batch number from the backup table +
    +
    +   +
    +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -121548,19 +196769,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
     
    - 407 + + 93 +
    - + - func (p *PostgresStorage) GetBatchL2DataByNumbersFromBackup(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) { +   + time.Sleep(cfg.IntervalToRefreshGasPrices.Duration)
    - 408 + + 94 +
    - + - getBatchL2DataByBatchNumber := ` +   + }
    - 409 + + 95 +
    - + - SELECT batch_num, data FROM state.batch_data_backup +   + }(&cfg, p)
    - 410 + 96
    + - WHERE batch_num = ANY($1) + p.refreshBlockedAddresses()
    - 411 + 97
    + - ORDER BY created_at DESC + go func(cfg *Config, p *Pool) {
    - 412 + 98
    + - ` + for {
    - 413 + 99
    + - q := p.getExecQuerier(dbTx) + time.Sleep(cfg.IntervalToRefreshBlockedAddresses.Duration)
    - 414 + 100
    + - rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers) + p.refreshBlockedAddresses()
    - 415 + 101
    + - if errors.Is(err, pgx.ErrNoRows) { + }
    - 416 + 102
    + - return nil, state.ErrNotFound + }(&cfg, p)
    - 417 + + 103 +
    - + - } else if err != nil { +   +
    - 418 + + 104 +
    - + - return nil, err +   + return p
    - 419 + + 105 +
    - + - } +   + }
    - 420 + +
     
    +
    + 246 +
    - + - defer rows.Close() +   + }
    - 421 + + 247 +
    - + +  
    - 422 + + 248 +
    - + - return readBatchDataResults(rows, batchNumbers) +   + poolTx := NewTransaction(tx, ip, isWIP)
    - 423 + + -
    - + - } +
    +
    +   +
    - 424 + + 249 +
    - + -
    +   + poolTx.ZKCounters = preExecutionResponse.usedZKCounters
    - 425 + + 250 +
    - + - // readBatchDataResults retrieves batch data from the provided result set +   + poolTx.ReservedZKCounters = preExecutionResponse.reservedZKCounters
    - 426 + + 251 +
    - + - func readBatchDataResults(results pgx.Rows, batchNumbers []uint64) (map[uint64][]byte, error) { +   +
    - 427 + +
     
    +
    + 693 +
    - + - batchL2DataMap := make(map[uint64][]byte, len(batchNumbers)) +   +
    - 428 + + 694 +
    - + - for results.Next() { +   + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 429 + + 695 +
    - + - var ( +   + func (p *Pool) CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 430 + + 696 +
    + - batchNum uint64 + return state.CalculateEffectiveGasPricePercentage(gasPrice, effectiveGasPrice)
    - 431 + + 697 +
    - + - batchL2Data []byte +   + }
    - 432 + + 698 +
    - + - ) +   +
    - 433 + + 699 +
    - + -
    +   + // EffectiveGasPriceEnabled returns if effective gas price calculation is enabled or not
    - 434 + +
     
    +
    + 735 +
    - + - if err := results.Scan(&batchNum, &batchL2Data); err != nil { +   + }
    - 435 + + 736 +
    - + - return nil, err +   + return gas, nil
    - 436 + + 737 +
    - + - } +   + }
    - 437 + 738
    + - batchL2DataMap[batchNum] = batchL2Data +
    - 438 + 739
    + - } + // CheckPolicy checks if an address is allowed by policy name
    - 439 + 740
    + -
    + func (p *Pool) CheckPolicy(ctx context.Context, policy PolicyName, address common.Address) (bool, error) {
    - 440 + 741
    + - return batchL2DataMap, nil + return p.storage.CheckPolicy(ctx, policy, address)
    - 441 + 742
    @@ -120831,12 +195982,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/pool/pool_test.go RENAMED
    -
    @@ -872,7 +872,7 @@
    +
    @@ -1114,7 +1114,7 @@
    - 872 + 1114
      - ctx := context.Background() + stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, mtDBServerConfig)
    - 873 + 1115
      -
    + stateTree := merkletree.NewStateTree(stateDBClient)
    - 874 + 1116
      - cfg := state.Config{ +
    - 875 + 1117
    - - MaxLogsCount: 8, + st := state.NewState(stCfg, stateDb, executorClient, stateTree, eventLog, nil, nil)
    - 876 + 1118
      - MaxLogsBlockRange: 10, + return st
    - 877 + 1119
      - ForkIDIntervals: stateCfg.ForkIDIntervals, + }
    - 878 + 1120
      - } +
    -
    @@ -895,39 +895,69 @@
    +
    @@ -2032,3 +2032,69 @@
    - 895 + 2032
      - time := time.Now() + require.NoError(t, err)
    - 896 + 2033
      - blockNumber := big.NewInt(1) + return signedTx
    - 897 + 2034
    +   + } +
    +
    + + +
     
    - 898 + + -
    - - - for i := 0; i < 3; i++ { +
    +
    +   +
    - 899 + + -
    - - - tx := types.NewTx(&types.LegacyTx{ +
    +
    +   +
    - 900 + + -
    - - - Nonce: uint64(i), +
    +
    +   +
    - 901 + + -
    - - - To: nil, +
    +
    +   +
    - 902 + + -
    - - - Value: new(big.Int), +
    +
    +   +
    - 903 + + -
    - - - Gas: 0, +
    +
    +   +
    - 904 + + -
    - - - GasPrice: big.NewInt(0), +
    +
    +   +
    - 905 + + -
    - - - }) +
    +
    +   +
    - 906 + + -
    - - +
    +
    +  
    - 907 + + -
    - - - logs := []*types.Log{} +
    +
    +   +
    - 908 + + -
    - - - for j := 0; j < 4; j++ { +
    +
    +   +
    - 909 + + -
    - - - logs = append(logs, &types.Log{TxHash: tx.Hash(), Index: uint(j)}) +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    +
    +
    + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    + 1114 + +
    +   + stateDBClient, _, _ := merkletree.NewMTDBServiceClient(ctx, mtDBServerConfig) +
    +
    - 910 + 1115
      - } + stateTree := merkletree.NewStateTree(stateDBClient)
    - 911 + 1116
    @@ -121569,3348 +196814,3701 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 912 + + 1117 +
    - - - receipt := &types.Receipt{ + + + st := state.NewState(stCfg, stateDb, executorClient, stateTree, eventLog, nil)
    - 913 + + 1118 +
    - - - Type: tx.Type(), +   + return st
    - 914 + + 1119 +
    - - - PostState: state.ZeroHash.Bytes(), +   + }
    - 915 + + 1120 + +
    +   +
    +
    +
    +
     
    +
    + 2032 + +
    +   + require.NoError(t, err) +
    +
    + 2033 + +
    +   + return signedTx +
    +
    + 2034 + +
    +   + } +
    +
    + 2035 + +
    + + +
    +
    +
    + 2036 + +
    + + + func Test_PolicyAcl(t *testing.T) { +
    +
    + 2037 + +
    + + + initOrResetDB(t) +
    +
    + 2038 + +
    + + +
    +
    +
    + 2039 + +
    + + + poolSqlDB, err := db.NewSQLDB(poolDBCfg) +
    +
    + 2040 + +
    + + + require.NoError(t, err) +
    +
    + 2041 + +
    + + + defer poolSqlDB.Close() //nolint:gosec,errcheck +
    +
    + 2042 + +
    + + +
    +
    +
    + 2043 + +
    + + + ctx := context.Background() +
    +
    + 2044 + +
    + + + s, err := pgpoolstorage.NewPostgresPoolStorage(poolDBCfg) +
    +
    + 2045 + +
    + + + require.NoError(t, err) +
    +
    + 2046 + +
    + + +
    +
    +
    + 2047 + +
    + + + p := pool.NewPool(cfg, bc, s, nil, uint64(1), nil) +
    +
    + 2048 + +
    + + +
    +
    +
    + 2049 + +
    + + + randAddr := func() common.Address { +
    +
    + 2050 + +
    + + + buf := make([]byte, 20) +
    +
    + 2051 + +
    + + + _, err = rand.Read(buf) +
    +
    + 2052 + +
    + + + require.NoError(t, err) +
    +
    + 2053 + +
    + + + return common.BytesToAddress(buf) +
    +
    + 2054 + +
    + + + } +
    +
    + 2055 + +
    + + +
    +
    +
    + 2056 + +
    + + + // Policies start out as deny lists, since there are no addresses on the +
    +
    + 2057 + +
    + + + // lists, random addresses will always be allowed +
    +
    + 2058 + +
    + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +
    +
    + 2059 + +
    + + + allow, err := p.CheckPolicy(ctx, policy, randAddr()) +
    +
    + 2060 + +
    + + + require.NoError(t, err) +
    +
    + 2061 + +
    + + + require.True(t, allow) +
    +
    + 2062 + +
    + + + } +
    +
    + 2063 + +
    + + +
    +
    +
    + 2064 + +
    + + + addr := randAddr() +
    +
    + 2065 + +
    + + +
    +
    +
    + 2066 + +
    + + + // put addr on lists +
    +
    + 2067 + +
    + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} { +
    +
    + 2068 + +
    + + + ctag, err := poolSqlDB.Exec(ctx, "INSERT INTO pool.acl (policy, address) VALUES ($1,$2)", policy, addr.Hex()) +
    +
    + 2069 +
    - - - CumulativeGasUsed: 0, + + + require.NoError(t, err)
    - 916 + + 2070 +
    - - - EffectiveGasPrice: big.NewInt(0), + + + require.Equal(t, int64(1), ctag.RowsAffected())
    - 917 + + 2071 +
    - - - BlockNumber: blockNumber, + + + }
    - 918 + + 2072 +
    - - - GasUsed: tx.Gas(), + + +
    - 919 + + 2073 +
    - - - TxHash: tx.Hash(), + + + // addr should not be denied by policy
    - 920 + + 2074 +
    - - - TransactionIndex: 0, + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 921 + + 2075 +
    - - - Status: types.ReceiptStatusSuccessful, + + + allow, err := p.CheckPolicy(ctx, policy, addr)
    - 922 + + 2076 +
    - - - Logs: logs, + + + require.NoError(t, err)
    - 923 + + 2077 +
    - - - } + + + require.False(t, allow)
    - 924 + + 2078 +
    - - -
    + + + }
    - 925 + + 2079 +
    - - - transactions := []*types.Transaction{tx} + + +
    - 926 + + 2080 +
    - - - receipts := []*types.Receipt{receipt} + + + // change policies to allow by acl
    - 927 + + 2081 +
    - - - stateRoots := []common.Hash{state.ZeroHash} + + + ctag, err := poolSqlDB.Exec(ctx, "UPDATE pool.policy SET allow = true")
    - 928 + + 2082 +
    - - -
    + + + require.NoError(t, err)
    - 929 + + 2083 +
    -   - header := state.NewL2Header(&types.Header{ + + + require.Equal(t, int64(2), ctag.RowsAffected())
    - 930 + + 2084 +
    - - - Number: big.NewInt(int64(i) + 1), + + +
    - 931 + + 2085 +
    -   - ParentHash: state.ZeroHash, + + + // addr is now allowed
    - 932 + + 2086 +
    -   - Coinbase: state.ZeroAddress, + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 933 + + 2087 +
    -   - Root: state.ZeroHash, + + + allow, err := p.CheckPolicy(ctx, policy, addr)
    -
    @@ -954,6 +984,8 @@
    -
    - 954 + + 2088 +
    -   + + require.NoError(t, err)
    - 955 + + 2089 +
    -   - } + + + require.True(t, allow)
    - 956 + + 2090 +
    -   -
    + + + }
    - + + 2091 -
    -   +
    +
    + +
    - + + 2092 -
    -   -
    +
    +
    + + + // random addrs are now denied
    - 957 + + 2093 +
    -   - type testCase struct { + + + for _, policy := range []pool.PolicyName{pool.SendTx, pool.Deploy} {
    - 958 + + 2094 +
    -   - name string + + + for _, a := range []common.Address{randAddr(), randAddr()} {
    - 959 + + 2095 +
    -   - from uint64 + + + allow, err := s.CheckPolicy(ctx, policy, a)
    -
    @@ -988,20 +1020,227 @@
    -
    - 988 + + 2096 +
    -   - name: "logs returned successfully", + + + require.NoError(t, err)
    - 989 + + 2097 +
    -   - from: 1, + + + require.False(t, allow)
    - 990 + + 2098 +
    -   - to: 2, + + + }
    - 991 + + 2099 +
    - - - logCount: 8, + + + }
    - 992 + + 2100 +
    -   - expectedError: nil, + + + }
    - 993 - -
    -   - }, +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/proto/src/proto/executor/v1/executor.proto + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -10,9 +10,6 @@
    - 994 + 10
      - } + /// Processes a batch
    - 995 + 11
      -
    + rpc ProcessBatch(ProcessBatchRequest) returns (ProcessBatchResponse) {}
    - 996 + 12
      - for _, testCase := range testCases { + rpc ProcessBatchV2(ProcessBatchRequestV2) returns (ProcessBatchResponseV2) {}
    - 997 + + 13 +
    -   - t.Run(testCase.name, func(t *testing.T) { + - + rpc ProcessBatchV3(ProcessBatchRequestV3) returns (ProcessBatchResponseV3) {}
    - 998 + + 14 +
    - - logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, dbTx) + rpc ProcessBlobInnerV3(ProcessBlobInnerRequestV3) returns (ProcessBlobInnerResponseV3) {}
    - 999 + 15
    - -
    + rpc ProcessStatelessBatchV2(ProcessStatelessBatchRequestV2) returns (ProcessBatchResponseV2) {}
    - 1000 + 16
      - assert.Equal(t, testCase.logCount, len(logs)) + rpc GetFlushStatus (google.protobuf.Empty) returns (GetFlushStatusResponse) {}
    - 1001 + 17
      - assert.Equal(t, testCase.expectedError, err) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + }
    - + + 18 -
    +
    +
     
    - - -
    -   -
    -
    +
    +
    @@ -295,27 +292,7 @@
    - + + 295 -
    +
    +
      -
    + // prior to executing the call.
    - + + 296 -
    +
    +
      -
    + map<string, OverrideAccountV2> state_override = 23;
    - + + 297 -
    +
    +
      -
    + DebugV2 debug = 24;
    - + + 298 -
    -   -
    +
    +
    + - + }
    - + + 299 -
    -   +
    +
    + -
    - + + 300 -
    -   -
    +
    +
    + - + message ProcessStatelessBatchRequestV2 {
    - + + 301 -
    -   -
    +
    +
    + - + // Batch data
    - + + 302 -
    -   -
    +
    +
    + - + bytes witness = 1; // SMT partial tree, SCs, (indirectly) old state root
    - + + 303 -
    -   -
    +
    +
    + - + bytes data_stream = 2; // txs, old batch num, chain id, fork id, effective gas price, block header, index of L1 info tree (global exit root, min timestamp, ...)
    - + + 304 -
    -   +
    +
    + -
    - + + 305 -
    -   -
    +
    +
    + - + string coinbase = 3; // sequencer address
    - + + 306 -
    -   -
    +
    +
    + - + bytes old_acc_input_hash = 4; // 0 for executor, required for the prover
    - + + 307 -
    -   +
    +
    + -
    - + + 308 -
    -   -
    +
    +
    + - + // Used by injected/first batches (do not use it for regular batches)
    - + + 309 -
    -   -
    +
    +
    + - + bytes l1_info_root = 5; // 0 for executor, required for the prover
    - + + 310 -
    -   -
    +
    +
    + - + uint64 timestamp_limit = 6; // if 0, replace by now + 10 min internally
    - + + 311 -
    -   -
    +
    +
    + - + bytes forced_blockhash_l1 = 7; // we need it, 0 in regular batches, hash in forced batches, also used in injected/first batches, 0 by now
    - + + 312 -
    -   +
    +
    + -
    - + + 313 -
    -   -
    +
    +
    + - + // Debug
    - + + 314 -
    -   -
    +
    +
    + - + string context_id = 8; // batch ID to be shown in the executor traces, for your convenience: "Erigon_candidate_batch_N"
    - + + 315 -
    -   -
    +
    +
    + - + TraceConfigV2 trace_config = 9;
    - + + 316 -
    -   +
    +
    + -
    - + + 317 -
    -   -
    +
    +
    + - + // Mapping to provide minTimestamp for each l1InfoTreeIndex in a batch
    - + + 318 -
    -   -
    +
    +
    + - + map<uint64, uint64> l1_info_tree_index_min_timestamp = 10;
    - + + 319 -
    +
    +
      -
    + }
    - + + 320 -
    +
    +
     
    - + + 321 -
    +
    +
      -
    + message L1DataV2 {
    - - -
    -   -
    -
    +
    +
    @@ -327,7 +304,7 @@
    - + + 327 -
    +
    +
     
    - + + 328 -
    +
    +
      -
    + message DebugV2 {
    - + + 329 -
    +
    +
      -
    + uint64 gas_limit = 1;
    - + + 330 -
    -   -
    +
    +
    + - + bytes new_state_root = 2;
    - + + 331 -
    +
    +
      -
    + bytes new_acc_input_hash = 3;
    - + + 332 -
    +
    +
      -
    + bytes new_local_exit_root = 4;
    - + + 333 -
    +
    +
      -
    + uint64 new_batch_num = 5;
    - - -
    -   -
    -
    +
    +
    @@ -366,13 +343,6 @@
    - + + 366 -
    +
    +
      -
    + uint32 cnt_reserve_binaries = 30;
    - + + 367 -
    +
    +
      -
    + uint32 cnt_reserve_steps = 31;
    - + + 368 -
    +
    +
      -
    + uint32 cnt_reserve_sha256_hashes = 32;
    - + + 369 -
    -   -
    +
    +
    + - + bytes old_state_root = 33;
    - + + 370 -
    -   -
    +
    +
    + - + ResponseDebug debug = 34;
    - + + 371 -
    -   -
    +
    +
    + - + }
    - + + 372 -
    -   +
    +
    + -
    - + + 373 -
    -   -
    +
    +
    + - + message ResponseDebug {
    - + + 374 -
    -   -
    +
    +
    + - + string error_log = 1;
    - + + 375 -
    -   -
    +
    +
    + - + string version = 2;
    - + + 376 -
    +
    +
      -
    + }
    - + + 377 -
    +
    +
     
    - + + 378 -
    +
    +
      -
    + // Trace configuration request params
    - - -
    -   -
    -
    +
    +
    @@ -413,12 +383,6 @@
    - + + 413 -
    +
    +
      -
    + string nonce = 1;
    - + + 414 -
    +
    +
      -
    + // If balance="" then it has not been set; if set, string is in decimal (base 10)
    - + + 415 -
    +
    +
      -
    + string balance = 2;
    - + + 416 -
    -   -
    +
    +
    + - + // If sc_code="" then it has not been set; if set, string is in hexa (base 16)
    - + + 417 -
    -   -
    +
    +
    + - + string sc_code = 3;
    - + + 418 -
    -   -
    +
    +
    + - + // Both sc_storage first (key) and second (value) map elements are set in hexa (base 16)
    - + + 419 -
    -   -
    +
    +
    + - + map<string, string> sc_storage = 4;
    - + + 420 -
    -   -
    +
    +
    + - + // If sc_length="" then it has not been set; if set, string is in decimal (base 10)
    - + + 421 -
    -   -
    +
    +
    + - + string sc_length = 5;
    - + + 422 -
    +
    +
      -
    + }
    - + + 423 -
    +
    +
     
    - + + 424 -
    +
    +
      -
    + message FullTraceV2 {
    - + +
    @@ -672,8 +636,6 @@
    -
    +
    + 672 + +
      -
    + ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP = 33;
    - + + 673 -
    +
    +
      -
    + // ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP indicates that the change l2 block transaction has trigger an error during while executing
    - + + 674 -
    +
    +
      -
    + ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP = 34;
    - + + 675 -
    -   -
    +
    +
    + - + // ROM_ERROR_INVALID_L1_INFO_TREE_INDEX indicates that the l1 info tree index added is not valid since its value is 0
    - + + 676 -
    -   -
    +
    +
    + - + ROM_ERROR_INVALID_L1_INFO_TREE_INDEX = 35;
    - + + 677 -
    +
    +
      -
    + }
    - + + 678 -
    +
    +
     
    - + + 679 -
    +
    +
      -
    + enum ExecutorError {
    - + +
    @@ -913,210 +875,4 @@
    -
    +
    + 913 + +
      -
    + EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE = 116;
    - + + 914 -
    +
    +
      -
    + // EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR indicates that a TX has an invalid status-error combination
    - + + 915 -
    +
    +
      -
    + EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR = 117;
    - + + 916 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT indicates that the input parameter previous_l1_info_tree_root is invalid
    - + + 917 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT = 118;
    - + + 918 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA indicates that the input parameter forced_hash_data is invalid
    - + + 919 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA = 119;
    - + + 920 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT indicates that the input parameter forced_data.global_exit_root is invalid
    - + + 921 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT = 120;
    - + + 922 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1 indicates that the input parameter forced_data.block_hash_l1 is invalid
    - + + 923 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1 = 121;
    - + + 924 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT indicates that the input parameter L1 Data initiali_historic_root is invalid
    - + + 925 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT = 122;
    - + + 926 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT indicates that the input parameter old_blob_state_root is invalid
    - + + 927 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT = 123;
    - + + 928 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH indicates that the input parameter old_blob_acc_input_hash is invalid
    - + + 929 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH = 124;
    - + + 930 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT indicates that the input parameter last_l1_info_tree_root is invalid
    - + + 931 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT = 125;
    - + + 932 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT indicates that the input parameter new_blob_state_root is invalid
    - + + 933 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT = 126;
    - + + 934 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH indicates that the input parameter new_blob_acc_input_hash is invalid
    - + + 935 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH = 127;
    - + + 936 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_BLOB_DATA indicates that the input parameter blob_data is invalid (too long)
    - + + 937 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_BLOB_DATA = 128;
    - + + 938 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT indicates that the input parameter zk_gas_limit is invalid
    - + + 939 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT = 129;
    - + + 940 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_POINT_Z indicates that the input parameter point_z is invalid
    - + + 941 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_POINT_Z = 130;
    - + + 942 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_POINT_Y indicates that the input parameter point_y is invalid
    - + + 943 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_POINT_Y = 131;
    - + + 944 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH indicates that the input parameter point_z is different from the one calculated by the executor
    - + + 945 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH = 132;
    - + + 946 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH indicates that the input parameter blob L2 data hash is different from the one calculated by the executor
    - + + 947 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH = 133;
    - + + 948 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_BATCH_HASH_DATA_MISMATCH indicates that the input parameter batch data hash is different from the one calculated by the executor
    - + + 949 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_BATCH_HASH_DATA_MISMATCH = 134;
    - + + 950 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_INVALID_BLOB_TYPE indicates that the input parameter blob type is invalid
    - + + 951 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_INVALID_BLOB_TYPE = 135;
    - + + 952 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_UNRESTORED_SAVED_CONTEXT indicates that at least one saved context was not restored before finishing the execution
    - + + 953 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_UNRESTORED_SAVED_CONTEXT = 136;
    - + + 954 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX indicates that the memory context polynomial was assigned an invalid value
    - + + 955 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX = 137;
    - + + 956 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_VERSIONED_HASH indicates that the input parameter versioned_hash is invalid
    - + + 957 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_VERSIONED_HASH = 138;
    - + + 958 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_KZG_COMMITMENT indicates that the input parameter kzg_commitment is invalid
    - + + 959 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_KZG_COMMITMENT = 139;
    - + + 960 -
    -   -
    +
    +
    + - + // EXECUTOR_ERROR_INVALID_KZG_PROOF indicates that the input parameter kzg_proof is invalid
    - + + 961 -
    -   -
    +
    +
    + - + EXECUTOR_ERROR_INVALID_KZG_PROOF = 140;
    - + + 962 -
    -   -
    +
    +
    + - + }
    - + + 963 -
    -   +
    +
    + -
    - + + 964 -
    -   -
    +
    +
    + - + ////////////////////////////////////////////////
    - + + 965 -
    -   -
    +
    +
    + - + //////////// START V3 SECTION ////////////////
    - + + 966 -
    -   -
    +
    +
    + - + ////////////////////////////////////////////////
    - + + 967 -
    -   +
    +
    + -
    - 1002 + + 968 +
    -   - }) + - + message ProcessBatchRequestV3 {
    - + + 969 -
    -   -
    +
    +
    + - + bytes old_state_root = 1;
    - + + 970 -
    -   -
    +
    +
    + - + bytes old_acc_input_hash = 2;
    - + + 971 -
    -   -
    +
    +
    + - + bytes previous_l1_info_tree_root = 3;
    - + + 972 -
    -   -
    +
    +
    + - + uint32 previous_l1_info_tree_index = 4;
    - + + 973 -
    -   -
    +
    +
    + - + uint64 chain_id = 5;
    - + + 974 -
    -   -
    +
    +
    + - + uint64 fork_id = 6;
    - + + 975 -
    -   -
    +
    +
    + - + bytes batch_l2_data = 7;
    - + + 976 -
    -   -
    +
    +
    + - + bytes forced_hash_data = 8;
    - + + 977 -
    -   -
    +
    +
    + - + ForcedData forced_data = 9;
    - + + 978 -
    -   -
    +
    +
    + - + string coinbase = 10;
    - + + 979 -
    -   -
    +
    +
    + - + uint32 update_merkle_tree = 11;
    - + + 980 -
    -   -
    +
    +
    + - + // flag to indicate that counters should not be taken into account
    - + + 981 -
    -   -
    +
    +
    + - + uint32 no_counters = 12;
    - + + 982 -
    -   -
    +
    +
    + - + // from is used for unsigned transactions with sender
    - + + 983 -
    -   -
    +
    +
    + - + string from = 13;
    - + + 984 -
    -   -
    +
    +
    + - + // flag to skip the restriction to start a batch with a changeL2Block transaction
    - + + 985 -
    -   -
    +
    +
    + - + uint32 skip_first_change_l2_block = 14;
    - 1003 + + 986 +
    -   - } + - + // flag to skip writing the block info root in the state
    - + + 987 -
    -   -
    +
    +
    + - + uint32 skip_write_block_info_root = 15;
    - 1004 + + 988 +
    -   - require.NoError(t, dbTx.Commit(ctx)) + - + // lInfoTree information
    - + + 989 -
    -   -
    +
    +
    + - + map<uint32, L1DataV3> l1_info_tree_data = 16;
    - + + 990 -
    -   -
    +
    +
    + - + // For testing purposes only
    - + + 991 -
    -   -
    +
    +
    + - + map<string, string> db = 17;
    - + + 992 -
    -   -
    +
    +
    + - + map<string, string> contracts_bytecode = 18; // For debug/testing purpposes only. Don't fill this on production
    - + + 993 -
    -   -
    +
    +
    + - + TraceConfigV2 trace_config = 19;
    - + + 994 -
    -   -
    +
    +
    + - + string context_id = 20;
    - + + 995 -
    -   -
    +
    +
    + - + uint32 get_keys = 21; // if 1, the keys used to read or write storage values will be returned
    - + + 996 -
    -   -
    +
    +
    + - + // The state override set is an optional address-to-state mapping,
    - + + 997 -
    -   -
    +
    +
    + - + // where each entry specifies some state to be ephemerally overridden
    - + + 998 -
    -   -
    +
    +
    + - + // prior to executing the call.
    - + + 999 -
    -   -
    +
    +
    + - + map<string, OverrideAccountV2> state_override = 22;
    - + + 1000 -
    -   -
    +
    +
    + - + DebugV2 debug = 23;
    - + + 1001 -
    -   -
    +
    +
    + - + }
    - + + 1002 -
    -   +
    +
    + -
    - + + 1003 -
    -   -
    +
    +
    + - + message L1DataV3 {
    - + + 1004 -
    -   -
    +
    +
    + - + bytes global_exit_root = 1;
    - + + 1005 -
    -   -
    +
    +
    + - + bytes block_hash_l1 = 2;
    - + + 1006 -
    -   -
    +
    +
    + - + uint64 min_timestamp = 3;
    - + + 1007 -
    -   -
    +
    +
    + - + repeated bytes smt_proof_previous_index = 4;
    - + + 1008 -
    -   -
    +
    +
    + - + bytes initial_historic_root = 5;
    - + + 1009 -
    +
    +
      -
    + }
    - + + 1010 -
    -   +
    +
    + -
    - + + 1011 -
    -   -
    +
    +
    + - + message ProcessBatchResponseV3 {
    - + + 1012 -
    -   -
    +
    +
    + - + bytes new_state_root = 1;
    - + + 1013 -
    -   -
    +
    +
    + - + bytes new_acc_input_hash = 2;
    - + + 1014 -
    -   -
    +
    +
    + - + bytes new_local_exit_root = 3;
    - + + 1015 -
    -   -
    +
    +
    + - + uint64 new_last_timestamp = 4;
    - + + 1016 -
    -   -
    +
    +
    + - + bytes current_l1_info_tree_root = 5;
    - + + 1017 -
    -   -
    +
    +
    + - + uint32 current_l1_info_tree_index = 6;
    - + + 1018 -
    -   -
    +
    +
    + - + uint32 cnt_keccak_hashes = 7;
    - + + 1019 -
    -   -
    +
    +
    + - + uint32 cnt_poseidon_hashes = 8;
    - + + 1020 -
    -   -
    +
    +
    + - + uint32 cnt_poseidon_paddings = 9;
    - + + 1021 -
    -   -
    +
    +
    + - + uint32 cnt_mem_aligns = 10;
    - + + 1022 -
    -   -
    +
    +
    + - + uint32 cnt_arithmetics = 11;
    - + + 1023 -
    -   -
    +
    +
    + - + uint32 cnt_binaries = 12;
    - + + 1024 -
    -   -
    +
    +
    + - + uint32 cnt_steps = 13;
    - + + 1025 -
    -   -
    +
    +
    + - + uint32 cnt_sha256_hashes = 14;
    - + + 1026 -
    -   -
    +
    +
    + - + repeated ProcessBlockResponseV2 block_responses = 15;
    - + + 1027 -
    -   -
    +
    +
    + - + ExecutorError error = 16;
    - + + 1028 -
    -   -
    +
    +
    + - + map<string, InfoReadWriteV2> read_write_addresses = 17;
    - + + 1029 -
    -   -
    +
    +
    + - + uint64 flush_id = 18;
    - + + 1030 -
    -   -
    +
    +
    + - + uint64 stored_flush_id = 19;
    - + + 1031 -
    -   -
    +
    +
    + - + string prover_id = 20;
    - + + 1032 -
    -   -
    +
    +
    + - + uint64 gas_used = 21;
    - + + 1033 -
    -   -
    +
    +
    + - + repeated bytes smt_keys = 22;
    - + + 1034 -
    -   -
    +
    +
    + - + repeated bytes program_keys = 23;
    - + + 1035 -
    -   -
    +
    +
    + - + uint64 fork_id = 24;
    - + + 1036 -
    -   -
    +
    +
    + - + uint32 invalid_batch = 25;
    - + + 1037 -
    -   -
    +
    +
    + - + RomError error_rom = 26;
    - + + 1038 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_keccak_hashes = 27;
    - + + 1039 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_poseidon_hashes = 28;
    - + + 1040 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_poseidon_paddings = 29;
    - + + 1041 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_mem_aligns = 30;
    - + + 1042 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_arithmetics = 31;
    - + + 1043 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_binaries = 32;
    - + + 1044 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_steps = 33;
    - + + 1045 -
    -   -
    +
    +
    + - + uint32 cnt_reserve_sha256_hashes = 34;
    - + + 1046 -
    -   -
    +
    +
    + - + bytes old_state_root = 35;
    - + + 1047 -
    -   -
    +
    +
    + - + ResponseDebug debug = 36;
    - 1005 + + 1048 +
    -   + - }
    - 1006 + + 1049 +
    -   + -
    - 1007 + + 1050 +
    -   - func TestGetNativeBlockHashesInRange(t *testing.T) { + - + message ForcedData {
    -
    @@ -1132,6 +1371,108 @@
    +
    + 1051 + +
    + - + bytes global_exit_root = 1; +
    - 1132 + + 1052 +
    -   - require.NoError(t, dbTx.Commit(ctx)) + - + bytes block_hash_l1 = 2;
    - 1133 + + 1053 +
    -   - } + - + uint64 min_timestamp = 3;
    - 1134 + + 1054 +
    -   -
    + - + }
    - + + 1055 -
    -   +
    +
    + -
    - + + 1056 -
    -   -
    +
    +
    + - + message ProcessBlobInnerRequestV3 {
    - + + 1057 -
    -   -
    +
    +
    + - + // inputs
    - + + 1058 -
    -   -
    +
    +
    + - + bytes old_blob_state_root = 1;
    - + + 1059 -
    -   -
    +
    +
    + - + bytes old_blob_acc_input_hash = 2;
    - + + 1060 -
    -   -
    +
    +
    + - + uint64 old_num_blob = 3;
    - + + 1061 -
    -   -
    +
    +
    + - + bytes old_state_root = 4;
    - + + 1062 -
    -   -
    +
    +
    + - + uint64 fork_id = 5;
    - + + 1063 -
    -   -
    +
    +
    + - + // belong to blobAccInputHash
    - + + 1064 -
    -   -
    +
    +
    + - + uint32 last_l1_info_tree_index = 6;
    - + + 1065 -
    -   -
    +
    +
    + - + bytes last_l1_info_tree_root = 7;
    - + + 1066 -
    -   -
    +
    +
    + - + uint64 timestamp_limit = 8;
    - + + 1067 -
    -   -
    +
    +
    + - + string coinbase = 9;
    - + + 1068 -
    -   -
    +
    +
    + - + uint64 zk_gas_limit = 10;
    - + + 1069 -
    -   -
    +
    +
    + - + uint32 blob_type = 11;
    - + + 1070 -
    -   -
    +
    +
    + - + bytes versioned_hash = 12;
    - + + 1071 -
    -   -
    +
    +
    + - + bytes kzg_commitment = 13;
    - + + 1072 -
    -   -
    +
    +
    + - + bytes kzg_proof = 14;
    - + + 1073 -
    -   -
    +
    +
    + - + bytes point_z = 15;
    - + + 1074 -
    -   -
    +
    +
    + - + bytes point_y = 16;
    - + + 1075 -
    -   -
    +
    +
    + - + bytes blob_data = 17;
    - + + 1076 -
    -   -
    +
    +
    + - + bytes forced_hash_data = 18;
    - + + 1077 -
    -   -
    +
    +
    + - + string context_id = 19;
    - + + 1078 -
    -   -
    +
    +
    + - + DebugV3 debug = 20;
    - + + 1079 -
    -   -
    +
    +
    + - + map<string, string> db = 21;
    - + + 1080 -
    -   -
    +
    +
    + - + map<string, string> contracts_bytecode = 22; // For debug/testing purpposes only. Don't fill this on production
    - + + 1081 -
    -   -
    +
    +
    + - + }
    - + + 1082 -
    -   +
    +
    + -
    - + + 1083 -
    -   -
    +
    +
    + - + message DebugV3 {
    - + + 1084 -
    -   -
    +
    +
    + - + bytes new_blob_state_root = 1;
    - + + 1085 -
    -   -
    +
    +
    + - + bytes new_blob_acc_input_hash = 2;
    - + + 1086 -
    -   -
    +
    +
    + - + uint64 new_blob_num = 3;
    - + + 1087 -
    -   -
    +
    +
    + - + }
    - + + 1088 -
    -   +
    +
    + -
    - + + 1089 -
    -   -
    +
    +
    + - + message ProcessBlobInnerResponseV3 {
    - + + 1090 -
    -   -
    +
    +
    + - + // outputs
    - + + 1091 -
    -   -
    +
    +
    + - + bytes new_blob_state_root = 1;
    - + + 1092 -
    -   -
    +
    +
    + - + bytes new_blob_acc_input_hash = 2;
    - + + 1093 -
    -   -
    +
    +
    + - + uint64 new_num_blob = 3;
    - + + 1094 -
    -   -
    +
    +
    + - + bytes final_acc_batch_hash_data = 4;
    - + + 1095 -
    -   -
    +
    +
    + - + bytes local_exit_root_from_blob = 5;
    - + + 1096 -
    -   -
    +
    +
    + - + uint32 is_invalid = 6;
    - + + 1097 -
    -   -
    +
    +
    + - + // extra
    - + + 1098 -
    -   -
    +
    +
    + - + repeated bytes batch_data = 7;
    - + + 1099 -
    -   -
    +
    +
    + - + ExecutorError error = 8;
    - + + 1100 -
    -   -
    +
    +
    + - + RomBlobError error_rom_blob = 9;
    - + + 1101 -
    -   -
    +
    +
    + - + ResponseDebug debug = 10;
    - + + 1102 -
    -   -
    +
    +
    + - + }
    - + + 1103 -
    -   +
    +
    + -
    - + + 1104 -
    -   -
    +
    +
    + - + enum RomBlobError {
    - + + 1105 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_UNSPECIFIED = 0;
    - + + 1106 -
    -   -
    +
    +
    + - + // ROM_ERROR_NO_ERROR indicates the execution ended successfully
    - + + 1107 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_NO_ERROR = 1;
    - + + 1108 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_PARSING indicates that has been an error while parsing the blob data
    - + + 1109 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_PARSING = 2;
    - + + 1110 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_MSB_BYTE indicates that the MSB on one field element is different than zero (only for blob_type = 1)
    - + + 1111 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_MSB_BYTE = 3;
    - + + 1112 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT not enough zk_gas_limit supplied to pay for batches proofs
    - + + 1113 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT = 4;
    - + + 1114 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_BLOB_TYPE blob_type not supported
    - + + 1115 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_BLOB_TYPE = 5;
    - + + 1116 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE compression type not supported
    - + + 1117 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE = 6;
    - + + 1118 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_FORCED_BATCHES blobtype = 2 and numBatches > 1
    - + + 1119 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_FORCED_BATCHES = 7;
    - + + 1120 -
    -   -
    +
    +
    + - + // ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN totalBodyLen != blobDataLen - 1 (byte compression) - 4 (bytes totalBodyLen)
    - + + 1121 -
    -   -
    +
    +
    + - + ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN = 8;
    - + + 1122 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - @@ -124944,73 +200542,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - @@ -125215,202 +200818,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - @@ -125484,73 +201027,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -125614,73 +201152,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - @@ -125704,73 +201237,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -125989,745 +201517,466 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - -
    +
     
    - + + 10 -
    +
    +
      -
    + /// Processes a batch
    - + + 11 -
    +
    +
      -
    + rpc ProcessBatch(ProcessBatchRequest) returns (ProcessBatchResponse) {}
    - + + 12 -
    +
    +
      -
    + rpc ProcessBatchV2(ProcessBatchRequestV2) returns (ProcessBatchResponseV2) {}
    - + + 13 -
    +
    +
      -
    + rpc GetFlushStatus (google.protobuf.Empty) returns (GetFlushStatusResponse) {}
    - + + 14 -
    +
    +
      -
    + }
    - + + 15 -
    +
    +
     
    - + +
     
    -
    +
    + 292 + +
      -
    + // prior to executing the call.
    - + + 293 -
    +
    +
      -
    + map<string, OverrideAccountV2> state_override = 23;
    - + + 294 -
    +
    +
      -
    + DebugV2 debug = 24;
    - + + 295 -
    -   -
    +
    +
    + + + uint64 execution_mode = 25;
    - 1135 + 296
      - func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry { + }
    - 1136 + 297
      - exitRoot := state.L1InfoTreeExitRootStorageEntry{ +
    - 1137 + 298
      - L1InfoTreeLeaf: state.L1InfoTreeLeaf{ + message L1DataV2 {
    -
    @@ -1333,6 +1674,13 @@
    +
     
    - 1333 + 304
      - require.Equal(t, uint64(2002), fb.BlockNumber) +
    - 1334 + 305
      - require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String()) + message DebugV2 {
    - 1335 + 306
      - require.Equal(t, []byte{0xb}, fb.RawTxsData) -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + uint64 gas_limit = 1;
    - + + 307 -
    -   -
    +
    +
    + + + bytes new_state_root = 2;
    - 1336 + 308
      - } + bytes new_acc_input_hash = 3;
    - 1337 + 309
      -
    + bytes new_local_exit_root = 4;
    - 1338 + 310
      - func TestGetLastGER(t *testing.T) { + uint64 new_batch_num = 5;
    -
    @@ -1409,5 +1757,62 @@
    +
     
    - 1409 + 343
      - ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) + uint32 cnt_reserve_binaries = 30;
    - 1410 + 344
      - require.NoError(t, err) + uint32 cnt_reserve_steps = 31;
    - 1411 + 345
      - require.Equal(t, common.HexToHash("0x2").String(), ger.String()) + uint32 cnt_reserve_sha256_hashes = 32;
    - + + 346 -
    +
    +
      -
    + }
    - + + 347 -
    +
    +
     
    - + + 348 -
    +
    +
      -
    + // Trace configuration request params
    - - -
    -   -
    -
    +
    +
     
    - + + 383 -
    +
    +
      -
    + string nonce = 1;
    - + + 384 -
    +
    +
      -
    + // If balance="" then it has not been set; if set, string is in decimal (base 10)
    - + + 385 -
    +
    +
      -
    + string balance = 2;
    - + + 386 -
    +
    +
      -
    + }
    - + + 387 -
    +
    +
     
    - + + 388 -
    +
    +
      -
    + message FullTraceV2 {
    - - -
    -   -
    -
    +
    +
     
    - + + 636 -
    +
    +
      -
    + ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP = 33;
    - + + 637 -
    +
    +
      -
    + // ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP indicates that the change l2 block transaction has trigger an error during while executing
    - 1412 + 638
      -
    + ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP = 34;
    - + + 639 -
    +
    +
      -
    + }
    - + + 640 -
    +
    +
     
    - + + 641 -
    +
    +
      -
    + enum ExecutorError {
    - - -
    -   -
    -
    +
    +
     
    - + + 875 -
    +
    +
      -
    + EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE = 116;
    - + + 876 -
    +
    +
      -
    + // EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR indicates that a TX has an invalid status-error combination
    - + + 877 -
    +
    +
      -
    + EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR = 117;
    -   -
    -
    -
    - 1413 - -
    -   - } -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -127163,2148 +202412,2307 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    -
    - 872 - -
    -   - ctx := context.Background() -
    -
    - 873 - -
    -   -
    -
    -
    - 874 - -
    -   - cfg := state.Config{ -
    -
    - 875 - -
    - + - MaxLogsCount: 40, -
    -
    - 876 - -
    -   - MaxLogsBlockRange: 10, -
    -
    - 877 - -
    -   - ForkIDIntervals: stateCfg.ForkIDIntervals, -
    -
    - 878 - -
    -   - } -
    -
    -
     
    -
    - 895 - -
    -   - time := time.Now() -
    -
    - 896 - -
    -   - blockNumber := big.NewInt(1) -
    -
    - 897 - -
    -   -
    -
    -
    - 898 - -
    - + - maxBlocks := 3 -
    -
    - 899 - -
    - + - txsPerBlock := 4 -
    -
    - 900 - -
    - + - logsPerTx := 5 -
    -
    - 901 - -
    - + -
    -
    -
    - 902 - -
    - + - nonce := uint64(0) -
    -
    - 903 - -
    - + -
    -
    -
    - 904 - -
    - + - // number of blocks to be created -
    -
    - 905 - -
    - + - for b := 0; b < maxBlocks; b++ { -
    -
    - 906 - -
    - + - logIndex := uint(0) -
    -
    - 907 - -
    - + - transactions := make([]*types.Transaction, 0, txsPerBlock) -
    -
    - 908 - -
    - + - receipts := make([]*types.Receipt, 0, txsPerBlock) -
    -
    - 909 - -
    - + - stateRoots := make([]common.Hash, 0, txsPerBlock) -
    -
    - 910 - -
    - + -
    -
    -
    - 911 - -
    - + - // number of transactions in a block to be created -
    -
    - 912 - -
    - + - for t := 0; t < txsPerBlock; t++ { +   +
    - 913 + + -
    - + - nonce++ +
    +
    +   +
    - 914 + + -
    - + - txIndex := uint(t + 1) +
    +
    +   +
    - 915 + + -
    - + +
    +
    +  
    - 916 + + -
    - + - tx := types.NewTx(&types.LegacyTx{ +
    +
    +   +
    - 917 + + -
    - + - Nonce: nonce, +
    +
    +   +
    - 918 + + -
    - + - To: nil, +
    +
    +   +
    - 919 + + -
    - + - Value: new(big.Int), +
    +
    +   +
    - 920 + + -
    - + - Gas: 0, +
    +
    +   +
    - 921 + + -
    - + - GasPrice: big.NewInt(0), +
    +
    +   +
    - 922 + + -
    - + - }) +
    +
    +   +
    - 923 + + -
    - + +
    +
    +  
    - 924 + + -
    - + - logs := []*types.Log{} +
    +
    +   +
    - 925 + + -
    - + +
    +
    +  
    - 926 + + -
    - + - // if block is even logIndex follows a sequence related to the block +
    +
    +   +
    - 927 + + -
    - + - // for odd blocks logIndex follows a sequence related ot the tx +
    +
    +   +
    - 928 + + -
    - + - // this is needed to simulate a logIndex difference introduced on Etrog +
    +
    +   +
    - 929 + + -
    - + - // and we need to maintain to be able to synchronize these blocks +
    +
    +   +
    - 930 + + -
    - + - // number of logs in a transaction to be created +
    +
    +   +
    - 931 + + -
    - + - for l := 0; l < logsPerTx; l++ { +
    +
    +   +
    - 932 + + -
    - + - li := logIndex +
    +
    +   +
    - 933 + + -
    - + - if b%2 != 0 { // even block +
    +
    +   +
    - 934 + + -
    - + - li = uint(l) +
    +
    +   +
    - 935 + + -
    - + - } +
    +
    +   +
    - 936 + + -
    - + +
    +
    +  
    - 937 + + -
    - + - logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li}) +
    +
    +   +
    - 938 + + -
    - + - logIndex++ +
    +
    +   +
    - 939 + + -
    - + - } +
    +
    +   +
    - 940 + + -
    - + +
    +
    +  
    - 941 + + -
    - + - receipt := &types.Receipt{ +
    +
    +   +
    - 942 + + -
    - + - Type: tx.Type(), +
    +
    +   +
    - 943 + + -
    - + - PostState: state.ZeroHash.Bytes(), +
    +
    +   +
    - 944 + + -
    - + - CumulativeGasUsed: 0, +
    +
    +   +
    - 945 + + -
    - + - EffectiveGasPrice: big.NewInt(0), +
    +
    +   +
    - 946 + + -
    - + - BlockNumber: blockNumber, +
    +
    +   +
    - 947 + + -
    - + - GasUsed: tx.Gas(), +
    +
    +   +
    - 948 + + -
    - + - TxHash: tx.Hash(), +
    +
    +   +
    - 949 + + -
    - + - TransactionIndex: txIndex, +
    +
    +   +
    - 950 + + -
    - + - Status: types.ReceiptStatusSuccessful, +
    +
    +   +
    - 951 + + -
    - + - Logs: logs, +
    +
    +   +
    - 952 + + -
    - + - } +
    +
    +   +
    - 953 + + -
    - + +
    +
    +  
    - 954 + + -
    - + - transactions = append(transactions, tx) +
    +
    +   +
    - 955 + + -
    - + - receipts = append(receipts, receipt) +
    +
    +   +
    - 956 + + -
    - + - stateRoots = append(stateRoots, state.ZeroHash) +
    +
    +   +
    - 957 + + -
    +
    +
      - } +
    - 958 + + -
    +
    +
     
    @@ -126903,253 +202152,253 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 959 + + -
    +
    +
      - header := state.NewL2Header(&types.Header{ +
    - 960 + + -
    - + - Number: big.NewInt(int64(b) + 1), +
    +
    +   +
    - 961 + + -
    +
    +
      - ParentHash: state.ZeroHash, +
    - 962 + + -
    +
    +
      - Coinbase: state.ZeroAddress, +
    - 963 + + -
    +
    +
      - Root: state.ZeroHash, +
    -
     
    +
    + + +
    +   +
    +
    - 984 + + -
    +
    +
      - require.NoError(t, err) +
    - 985 + + -
    +
    +
      - } +
    - 986 + 878
      -
    + }
    - 987 + + -
    - + - require.NoError(t, dbTx.Commit(ctx)) +
    +
    +   +
    - 988 + + -
    - + +
    +
    +  
    - 989 + + -
    +
    +
      - type testCase struct { +
    - 990 + + -
    +
    +
      - name string +
    - 991 + + -
    +
    +
      - from uint64 +
    -
     
    -
    - 1020 + + -
    +
    +
      - name: "logs returned successfully", +
    - 1021 + + -
    +
    +
      - from: 1, +
    - 1022 + + -
    +
    +
      - to: 2, +
    - 1023 + + -
    - + - logCount: 40, +
    +
    +   +
    - 1024 + + -
    +
    +
      - expectedError: nil, +
    - 1025 + + -
    +
    +
      - }, +
    - 1026 + + -
    +
    +
      - } +
    - 1027 + + -
    +
    +
     
    - 1028 + + -
    +
    +
      - for _, testCase := range testCases { +
    - 1029 + + -
    +
    +
      - t.Run(testCase.name, func(t *testing.T) { +
    - 1030 + + -
    - + - logs, err := testState.GetLogs(ctx, testCase.from, testCase.to, []common.Address{}, [][]common.Hash{}, nil, nil, nil) +
    +
    +   +
    - 1031 + + -
    +
    +
      - assert.Equal(t, testCase.logCount, len(logs)) +
    - 1032 + + -
    +
    +
      - assert.Equal(t, testCase.expectedError, err) +
    - 1033 + + -
    - + +
    +
    +  
    - 1034 + + -
    - + - // check tx index and log index order +
    +
    +   +
    - 1035 + + -
    - + - lastBlockNumber := uint64(0) +
    +
    +   +
    - 1036 + + -
    - + - lastTxIndex := uint(0) +
    +
    +   +
    - 1037 + + -
    - + - lastLogIndex := uint(0) +
    +
    +   +
    - 1038 + + -
    - + +
    +
    +  
    - 1039 + + -
    - + - for i, l := range logs { +
    +
    +   +
    - 1040 + + -
    - + - // if block has changed and it's not the first log, reset lastTxIndex +
    +
    +   +
    - 1041 + + -
    - + - if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 { +
    +
    +   +
    - 1042 + + -
    - + - lastTxIndex = 0 +
    +
    +   +
    - 1043 + + -
    - + - } +
    +
    +   +
    - 1044 + + -
    - + +
    +
    +  
    - 1045 + + -
    - + - if l.TxIndex < lastTxIndex { +
    +
    +   +
    - 1046 + + -
    - + - t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex) +
    +
    +   +
    - 1047 + + -
    - + - } +
    +
    +   +
    - 1048 + + -
    - + - // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block +
    +
    +   +
    - 1049 + + -
    - + - // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero +
    +
    +   +
    - 1050 + + -
    - + - if l.TxIndex != lastTxIndex && l.Index == 0 { +
    +
    +   +
    - 1051 + + -
    - + - lastLogIndex = 0 +
    +
    +   +
    - 1052 + + -
    - + - } +
    +
    +   +
    - 1053 + + -
    - + +
    +
    +  
    - 1054 + + -
    - + - if l.Index < lastLogIndex { +
    +
    +   +
    - 1055 + + -
    - + - t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index) +
    +
    +   +
    - 1056 + + -
    - + - } +
    +
    +   +
    - 1057 + + -
    - + +
    +
    +  
    - 1058 + + -
    - + - lastBlockNumber = l.BlockNumber +
    +
    +   +
    - 1059 + + -
    - + - lastTxIndex = l.TxIndex +
    +
    +   +
    - 1060 + + -
    - + - lastLogIndex = l.Index +
    +
    +   +
    - 1061 + + -
    - + - } +
    +
    +   +
    - 1062 + + -
    - + - }) +
    +
    +   +
    - 1063 + + -
    - + - } +
    +
    +   +
    - 1064 + + -
    - + - } +
    +
    +   +
    - 1065 + + -
    - + +
    +
    +  
    - 1066 + + -
    - + - func TestGetLogsByBlockNumber(t *testing.T) { +
    +
    +   +
    - 1067 + + -
    - + - initOrResetDB() +
    +
    +   +
    - 1068 + + -
    - + +
    +
    +  
    - 1069 + + -
    - + - ctx := context.Background() +
    +
    +   +
    - 1070 + + -
    - + +
    +
    +  
    - 1071 + + -
    - + - cfg := state.Config{ +
    +
    +   +
    - 1072 + + -
    - + - MaxLogsCount: 40, +
    +
    +   +
    - 1073 + + -
    - + - MaxLogsBlockRange: 10, +
    +
    +   +
    - 1074 + + -
    - + - ForkIDIntervals: stateCfg.ForkIDIntervals, +
    +
    +   +
    - 1075 + + -
    - + - } +
    +
    +   +
    - 1076 + + -
    - + +
    +
    +  
    - 1077 + + -
    - + - mt, err := l1infotree.NewL1InfoTree(32, [][32]byte{}) +
    +
    +   +
    - 1078 + + -
    - + - if err != nil { +
    +
    +   +
    - 1079 + + -
    - + - panic(err) +
    +
    +   +
    - 1080 + + -
    - + - } +
    +
    +   +
    - 1081 + + -
    - + - testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) +
    +
    +   +
    - 1082 + + -
    - + +
    +
    +  
    - 1083 + + -
    - + - dbTx, err := testState.BeginStateTransaction(ctx) +
    +
    +   +
    - 1084 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1085 + + -
    - + - err = testState.AddBlock(ctx, block, dbTx) +
    +
    +   +
    - 1086 + + -
    - + - assert.NoError(t, err) +
    +
    +   +
    - 1087 + + -
    - + +
    +
    +  
    - 1088 + + -
    - + - batchNumber := uint64(1) +
    +
    +   +
    - 1089 + + -
    - + - _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num, wip) VALUES ($1, FALSE)", batchNumber) +
    +
    +   +
    - 1090 + + -
    - + - assert.NoError(t, err) +
    +
    +   +
    - 1091 + + -
    - + +
    +
    +  
    - 1092 + + -
    - + - time := time.Now() +
    +
    +   +
    - 1093 + + -
    - + - blockNumber := big.NewInt(1) +
    +
    +   +
    - 1094 + + -
    - + +
    +
    +  
    - 1095 + + -
    - + - maxBlocks := 3 +
    +
    +   +
    - 1096 + + -
    - + - txsPerBlock := 4 +
    +
    +   +
    - 1097 + + -
    - + - logsPerTx := 5 +
    +
    +   +
    - 1098 + + -
    - + +
    +
    +  
    - 1099 + + -
    - + - nonce := uint64(0) +
    +
    +   +
    - 1100 + + -
    - + +
    +
    +  
    - 1101 + + -
    - + - // number of blocks to be created +
    +
    +   +
    - 1102 + + -
    - + - for b := 0; b < maxBlocks; b++ { +
    +
    +   +
    - 1103 + + -
    - + - logIndex := uint(0) +
    +
    +   +
    - 1104 + + -
    - + - transactions := make([]*types.Transaction, 0, txsPerBlock) +
    +
    +   +
    - 1105 + + -
    - + - receipts := make([]*types.Receipt, 0, txsPerBlock) +
    +
    +   +
    - 1106 + + -
    - + - stateRoots := make([]common.Hash, 0, txsPerBlock) +
    +
    +   +
    - 1107 + + -
    - + +
    +
    +  
    - 1108 + + -
    - + - // number of transactions in a block to be created +
    +
    +   +
    - 1109 + + -
    - + - for t := 0; t < txsPerBlock; t++ { +
    +
    +   +
    - 1110 + + -
    - + - nonce++ +
    +
    +   +
    - 1111 + + -
    - + - txIndex := uint(t + 1) +
    +
    +   +
    - 1112 + + -
    - + +
    +
    +  
    - 1113 + + -
    - + - tx := types.NewTx(&types.LegacyTx{ +
    +
    +   +
    - 1114 + + -
    - + - Nonce: nonce, +
    +
    +   +
    - 1115 + + -
    - + - To: nil, +
    +
    +   +
    - 1116 + + -
    - + - Value: new(big.Int), +
    +
    +   +
    - 1117 + + -
    - + - Gas: 0, +
    +
    +   +
    - 1118 + + -
    - + - GasPrice: big.NewInt(0), +
    +
    +   +
    - 1119 + + -
    - + - }) +
    +
    +   +
    - 1120 + + -
    - + +
    +
    +  
    - 1121 + + -
    - + - logs := []*types.Log{} +
    +
    +   +
    - 1122 + + -
    - + +
    +
    +  
    - 1123 + + -
    - + - // if block is even logIndex follows a sequence related to the block +
    +
    +   +
    - 1124 + + -
    - + - // for odd blocks logIndex follows a sequence related ot the tx +
    +
    +   +
    - 1125 + + -
    - + - // this is needed to simulate a logIndex difference introduced on Etrog +
    +
    +   +
    - 1126 + + -
    - + - // and we need to maintain to be able to synchronize these blocks +
    +
    +   +
    - 1127 - -
    - + - // number of logs in a transaction to be created +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/batch.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -345,12 +344,16 @@
    - 1128 + + 345 +
    - + - for l := 0; l < logsPerTx; l++ { +   +
    - 1129 + + 346 +
    - + - li := logIndex +   + // Log batch detailed info
    - 1130 + + 347 +
    - + - if b%2 != 0 { // even block +   + log.Errorf("batch %d sanity check error: initialStateRoot: %s, expectedNewStateRoot: %s", batch.BatchNumber, initialStateRoot, expectedNewStateRoot)
    - 1131 + + 348 +
    - + - li = uint(l) + - + for i, rawL2block := range rawL2Blocks.Blocks {
    - 1132 + + 349 +
    - + - } + - + log.Infof("block[%d], txs: %d, deltaTimestamp: %d, l1InfoTreeIndex: %d", i, len(rawL2block.Transactions), rawL2block.DeltaTimestamp, rawL2block.IndexL1InfoTree)
    - 1133 + + 350 +
    - + -
    + - + for j, rawTx := range rawL2block.Transactions {
    - 1134 + + 351 +
    - + - logs = append(logs, &types.Log{TxHash: tx.Hash(), TxIndex: txIndex, Index: li}) + - + log.Infof("block[%d].tx[%d]: %s, egpPct: %d, data: %s", batch.BatchNumber, i, j, rawTx.Tx.Hash(), rawTx.EfficiencyPercentage, hex.EncodeToHex(rawTx.Data))
    - 1135 + + -
    - + - logIndex++ +
    +
    +   +
    - 1136 + + -
    - + - } +
    +
    +   +
    - 1137 + + -
    - + +
    +
    +  
    - 1138 + + 352 +
    - + - receipt := &types.Receipt{ +   + }
    - 1139 + + 353 +
    - + - Type: tx.Type(), +   + }
    - 1140 + + -
    - + - PostState: state.ZeroHash.Bytes(), +
    +
    +   +
    - 1141 + + 354 +
    - + - CumulativeGasUsed: 0, +   +
    - 1142 + + 355 +
    - + - EffectiveGasPrice: big.NewInt(0), +   + f.Halt(ctx, fmt.Errorf("batch sanity check error. Check previous errors in logs to know which was the cause"), false)
    - 1143 + + 356 +
    - + - BlockNumber: blockNumber, +   + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 1144 + + 344 +
    - + - GasUsed: tx.Gas(), +   +
    - 1145 + + 345 +
    - + - TxHash: tx.Hash(), +   + // Log batch detailed info
    - 1146 + + 346 +
    - + - TransactionIndex: txIndex, +   + log.Errorf("batch %d sanity check error: initialStateRoot: %s, expectedNewStateRoot: %s", batch.BatchNumber, initialStateRoot, expectedNewStateRoot)
    - 1147 + + 347 +
    + - Status: types.ReceiptStatusSuccessful, + batchLog := ""
    - 1148 + + 348 +
    + - Logs: logs, + totalTxs := 0
    - 1149 + + 349 +
    + - } + for blockIdx, rawL2block := range rawL2Blocks.Blocks {
    - 1150 + + 350 +
    + -
    + totalTxs += len(rawL2block.Transactions)
    - 1151 + 351
    + - transactions = append(transactions, tx) + batchLog += fmt.Sprintf("block[%d], txs: %d, deltaTimestamp: %d, l1InfoTreeIndex: %d\n", blockIdx, len(rawL2block.Transactions), rawL2block.DeltaTimestamp, rawL2block.IndexL1InfoTree)
    - 1152 + 352
    + - receipts = append(receipts, receipt) + for txIdx, rawTx := range rawL2block.Transactions {
    - 1153 + 353
    + - stateRoots = append(stateRoots, state.ZeroHash) + batchLog += fmt.Sprintf(" tx[%d]: %s, egpPct: %d\n", txIdx, rawTx.Tx.Hash(), rawTx.EfficiencyPercentage)
    - 1154 + + 354 +
    - + - } +   + }
    - 1155 + + 355 +
    - + -
    +   + }
    - 1156 + 356
    + - header := state.NewL2Header(&types.Header{ + log.Infof("DUMP batch %d, blocks: %d, txs: %d\n%s", batch.BatchNumber, len(rawL2Blocks.Blocks), totalTxs, batchLog)
    - 1157 + + 357 +
    - + - Number: big.NewInt(int64(b) + 1), +   +
    - 1158 + + 358 +
    - + - ParentHash: state.ZeroHash, +   + f.Halt(ctx, fmt.Errorf("batch sanity check error. Check previous errors in logs to know which was the cause"), false)
    - 1159 + + 359 +
    - + - Coinbase: state.ZeroAddress, +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/datastreamer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + +
    +
    @@ -42,6 +43,7 @@
    - 1160 + + 42 +
    - + - Root: state.ZeroHash, +   + l2Transactions = append(l2Transactions, l2Transaction)
    - 1161 + + 43 +
    - + - GasUsed: 1, +   + }
    - 1162 + + 44 +
    - + - GasLimit: 10, +   +
    - 1163 + + -
    - + - Time: uint64(time.Unix()), +
    +
    +   +
    - 1164 + 45
      - }) + f.dataToStream <- state.DSL2FullBlock{
    - 1165 + + 46 +
    - + -
    +   + DSL2Block: l2Block,
    - 1166 + + 47 +
    - + - st := trie.NewStackTrie(nil) +   + Txs: l2Transactions, +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + +
    +
     
    - 1167 + + 43 +
    - + - l2Block := state.NewL2Block(header, transactions, []*state.L2Header{}, receipts, st) +   + l2Transactions = append(l2Transactions, l2Transaction)
    - 1168 + + 44 +
    - + - for _, receipt := range receipts { +   + }
    - 1169 + + 45 +
    - + - receipt.BlockHash = l2Block.Hash() +   +
    - 1170 + 46
    + - } + log.Infof("sending l2block %d to datastream channel", blockResponse.BlockNumber)
    - 1171 + + 47 +
    - + -
    +   + f.dataToStream <- state.DSL2FullBlock{
    - 1172 + + 48 +
    - + - numTxs := len(transactions) +   + DSL2Block: l2Block,
    - 1173 + + 49 +
    - + - storeTxsEGPData := make([]state.StoreTxEGPData, numTxs) +   + Txs: l2Transactions, +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/finalizer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -242,15 +242,15 @@
    - 1174 + + 242 +
    - + - txsL2Hash := make([]common.Hash, numTxs) +   + return false, nil
    - 1175 + + 243 +
    - + - for i := range transactions { +   + }
    - 1176 + + 244 +
    - + - storeTxsEGPData[i] = state.StoreTxEGPData{EGPLog: nil, EffectivePercentage: state.MaxEffectivePercentage} +   +
    - 1177 + + 245 +
    - + - txsL2Hash[i] = common.HexToHash(fmt.Sprintf("0x%d", i)) + - + // Check l1InfoRootIndex and GER matches
    - 1178 + + 246 +
    - + - } + - + // We retrieve first the info of the last l1InfoTree event in the block
    - 1179 + + 247 +
    - + -
    +   + log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash)
    - 1180 + + 248 +
    - + - err = testState.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, stateRoots, dbTx) +   + blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber)
    - 1181 + + 249 +
    - + - require.NoError(t, err) +   + if err != nil {
    - 1182 + 250
      - } + return false, err
    - 1183 + + 251 +
    - + -
    +   + }
    - 1184 + 252
      - require.NoError(t, dbTx.Commit(ctx)) +
    - 1185 + + 253 +
    - + -
    + - + // Since in the case we have several l1InfoTree events in the same block, we retrieve only the GER of last one and skips the others
    - 1186 + + 254 +
    - + - type testCase struct { +   + lastGER := state.ZeroHash
    - 1187 + + 255 +
    - + - name string +   + for _, block := range blocks {
    - 1188 + + 256 +
    - + - blockNumber uint64 +   + blockEventsOrder := eventsOrder[block.BlockHash]
    - 1189 + +
    @@ -394,7 +394,8 @@
    +
    + 394 +
    - + - logCount int +   + firstTxProcess := true
    - 1190 + + 395 +
    - + - expectedError error +   +
    - 1191 + + 396 +
    - + - } +   + for {
    - 1192 + + 397 +
    - + + - + _, err := f.processTransaction(ctx, tx, firstTxProcess) +
    +
    + + +
    +  
    - 1193 + + 398 +
    - + - testCases := []testCase{ +   + if err != nil {
    - 1194 + + 399 +
    - + - { +   + if err == ErrEffectiveGasPriceReprocess {
    - 1195 + + 400 +
    - + - name: "logs returned successfully", +   + firstTxProcess = false
    - 1196 + +
    @@ -466,6 +467,7 @@
    +
    + 466 +
    - + - blockNumber: 1, +   + SkipWriteBlockInfoRoot_V2: true,
    - 1197 + + 467 +
    - + - logCount: 20, +   + SkipVerifyL1InfoRoot_V2: true,
    - 1198 + + 468 +
    - + - expectedError: nil, +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1199 + + -
    - + - }, +
    +
    +   +
    - 1200 + + 469 +
    - + - { +   + }
    - 1201 + + 470 +
    - + - name: "logs returned successfully", +   +
    - 1202 + + 471 +
    - + - blockNumber: 2, +   + txGasPrice := tx.GasPrice
    - 1203 + +
    @@ -512,7 +514,7 @@
    +
    + 512 +
    - + - logCount: 20, +   + }
    - 1204 + + 513 +
    - + - expectedError: nil, +   + }
    - 1205 + + 514 +
    - + - }, +   +
    - 1206 + + 515 +
    - + - } + - + egpPercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 1207 + + 516 +
    - + -
    +   + if err != nil {
    - 1208 + + 517 +
    - + - for _, testCase := range testCases { +   + if f.effectiveGasPrice.IsEnabled() {
    - 1209 + + 518 +
    - + - t.Run(testCase.name, func(t *testing.T) { +   + return nil, err
    - 1210 + +
    @@ -625,7 +627,7 @@
    +
    + 625 +
    - + - logs, err := testState.GetLogsByBlockNumber(ctx, testCase.blockNumber, nil) +   +
    - 1211 + + 626 +
    - + - assert.Equal(t, testCase.logCount, len(logs)) +   + // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging
    - 1212 + + 627 +
    - + - assert.Equal(t, testCase.expectedError, err) +   + if !egpEnabled {
    - 1213 + + 628 +
    - + -
    + - + effectivePercentage, err := f.effectiveGasPrice.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 1214 + + 629 +
    - + - // check tx index and log index order +   + if err != nil {
    - 1215 + + 630 +
    - + - lastBlockNumber := uint64(0) +   + log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err)
    - 1216 + + 631 +
    - + - lastTxIndex := uint(0) +   + tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - @@ -129329,27 +204737,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + - + + - - - - - - - - - - - - - - + +
    +
     
    - 1217 + + 242 +
    - + - lastLogIndex := uint(0) +   + return false, nil
    - 1218 + + 243 +
    - + -
    +   + }
    - 1219 + + 244 +
    - + - for i, l := range logs { +   +
    - 1220 + + 245 +
    + - // if block has changed and it's not the first log, reset lastTxIndex + // Check l1InfoRootIndex and GER matches. We retrieve the info of the last l1InfoTree event in the block, since in the case we have several l1InfoTree events
    - 1221 + + 246 +
    + - if uint(l.BlockNumber) != uint(lastBlockNumber) && i != 0 { + // in the same block, the function checkL1InfoTreeUpdate retrieves only the last one and skips the others
    - 1222 + + 247 +
    - + - lastTxIndex = 0 +   + log.Debugf("getting l1InfoRoot events for L1 block %d, hash: %s", l1InfoRoot.BlockNumber, l1BlockState.BlockHash)
    - 1223 + + 248 +
    - + - } +   + blocks, eventsOrder, err := f.etherman.GetRollupInfoByBlockRange(ctx, l1InfoRoot.BlockNumber, &l1InfoRoot.BlockNumber)
    - 1224 + + 249 +
    - + -
    +   + if err != nil {
    - 1225 + + 250 +
    - + - if l.TxIndex < lastTxIndex { +   + return false, err
    - 1226 + + 251 +
    - + - t.Errorf("invalid tx index, expected greater than or equal to %v, but found %v", lastTxIndex, l.TxIndex) +   + }
    - 1227 + + 252 +
    - + - } +   +
    - 1228 + + 253 +
    + - // add tolerance for log index Etrog issue that was starting log indexes from 0 for each tx within a block + //Get L1InfoTree events of the L1 block where the l1InforRoot we need to check was synced
    - 1229 + + 254 +
    - + - // if tx index has changed and the log index starts on zero, than resets the lastLogIndex to zero +   + lastGER := state.ZeroHash
    - 1230 + + 255 +
    - + - if l.TxIndex != lastTxIndex && l.Index == 0 { +   + for _, block := range blocks {
    - 1231 + + 256 +
    - + - lastLogIndex = 0 +   + blockEventsOrder := eventsOrder[block.BlockHash]
    - 1232 + +
     
    +
    + 394 +
    - + - } +   + firstTxProcess := true
    - 1233 + + 395 +
    - + +  
    - 1234 + + 396 +
    - + - if l.Index < lastLogIndex { +   + for {
    - 1235 + + 397 +
    + - t.Errorf("invalid log index, expected greater than %v, but found %v", lastLogIndex, l.Index) + var err error
    - 1236 + 398
    + - } + _, err = f.processTransaction(ctx, tx, firstTxProcess)
    - 1237 + + 399 +
    - + -
    +   + if err != nil {
    - 1238 + + 400 +
    - + - lastBlockNumber = l.BlockNumber +   + if err == ErrEffectiveGasPriceReprocess {
    - 1239 + + 401 +
    - + - lastTxIndex = l.TxIndex +   + firstTxProcess = false
    - 1240 + +
     
    +
    + 467 +
    - + - lastLogIndex = l.Index +   + SkipWriteBlockInfoRoot_V2: true,
    - 1241 + + 468 +
    - + - } +   + SkipVerifyL1InfoRoot_V2: true,
    - 1242 + + 469 +
    - + - }) +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1243 + 470
    + - } + ExecutionMode: executor.ExecutionMode0,
    - 1244 + 471
      - } + }
    - 1245 + 472
    @@ -129314,12 +204722,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1246 + 473
      - func TestGetNativeBlockHashesInRange(t *testing.T) { + txGasPrice := tx.GasPrice
    - 1371 + 514
      - require.NoError(t, dbTx.Commit(ctx)) + }
    - 1372 + 515
      - } + }
    - 1373 + 516
    @@ -129358,1018 +204766,1061 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1374 + + 517 +
    + - func TestGetBatchL2DataByNumber(t *testing.T) { + egpPercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 1375 + + 518 +
    - + - // Init database instance +   + if err != nil {
    - 1376 + + 519 +
    - + - initOrResetDB() +   + if f.effectiveGasPrice.IsEnabled() {
    - 1377 + + 520 +
    - + - ctx := context.Background() +   + return nil, err
    - 1378 + +
     
    +
    + 627 +
    - + - tx, err := testState.BeginStateTransaction(ctx) +   +
    - 1379 + + 628 +
    - + - require.NoError(t, err) +   + // If EffectiveGasPrice is disabled we will calculate the percentage and save it for later logging
    - 1380 + + 629 +
    - + - defer func() { require.NoError(t, tx.Commit(ctx)) }() +   + if !egpEnabled {
    - 1381 + + 630 +
    + -
    + effectivePercentage, err := state.CalculateEffectiveGasPricePercentage(txGasPrice, tx.EffectiveGasPrice)
    - 1382 + + 631 +
    - + - // empty case +   + if err != nil {
    - 1383 + + 632 +
    - + - var batchNum uint64 = 4 +   + log.Warnf("effectiveGasPrice is disabled, but failed to calculate effective gas price percentage (#2), error: %v", err)
    - 1384 + + 633 +
    - + - const ( +   + tx.EGPLog.Error = fmt.Sprintf("%s, CalculateEffectiveGasPricePercentage#2: %s", tx.EGPLog.Error, err)
    - 1385 +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/l2block.go + RENAMED + +
    +
    +
    +
    + + + + + + + - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
    @@ -283,6 +284,7 @@
    +
    + 283 +
    - + - openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)" +   + ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
    - 1386 + + 284 +
    - + - resetBatchesSQL = "DELETE FROM state.batch" +   + SkipVerifyL1InfoRoot_V2: true,
    - 1387 + + 285 +
    - + - ) +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1388 + + -
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil) +
    +
    +   +
    - 1389 + + 286 +
    - + - require.NoError(t, err) +   + }
    - 1390 + + 287 +
    - + - data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +   + batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
    - 1391 + + 288 +
    - + - require.NoError(t, err) +   + GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
    - 1392 + +
    @@ -310,7 +312,7 @@
    +
    + 310 +
    - + - assert.Nil(t, data) +   + }
    - 1393 + + 311 +
    - + +  
    - 1394 + + 312 +
    - + - // not empty case +   + if batchResponse.IsRomOOCError {
    - 1395 + + 313 +
    - + - expectedData := []byte("foo bar") + - + executeL2BLockError(err)
    - 1396 + + 314 +
    - + - batchNum = 5 +   + return nil, 0, ErrProcessBatchOOC
    - 1397 + + 315 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) +   + }
    - 1398 + + 316 +
    - + - require.NoError(t, err) +   +
    - 1399 - -
    - + - actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx) -
    +
    +
    @@ -411,6 +413,9 @@
    - 1400 + + 411 +
    - + - require.NoError(t, err) +   + return err
    - 1401 + + 412 +
    - + - assert.Equal(t, expectedData, actualData) +   + }
    - 1402 + + 413 +
    - + +  
    - 1403 + + -
    - + - multiGet := []uint64{uint64(4), uint64(5), uint64(6)} +
    +
    +   +
    - 1404 + + -
    - + - allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx) +
    +
    +   +
    - 1405 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1406 + + 414 +
    - + - require.Equal(t, expectedData, allData[uint64(5)]) +   + // Update txs status in the pool
    - 1407 + + 415 +
    - + -
    +   + for _, txResponse := range blockResponse.TransactionResponses {
    - 1408 + + 416 +
    - + - // Force backup +   + // Change Tx status to selected
    - 1409 + +
    @@ -420,6 +425,9 @@
    +
    + 420 +
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) +   + }
    - 1410 + + 421 +
    - + - require.NoError(t, err) +   + }
    - 1411 + + 422 +
    - + +  
    - 1412 + + -
    - + - // Get batch 4 from backup +
    +
    +   +
    - 1413 + + -
    - + - batchNum = 4 +
    +
    +   +
    - 1414 + + -
    - + - data, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +
    +
    +   +
    - 1415 + + 423 +
    - + - require.NoError(t, err) +   + // Send L2 block to data streamer
    - 1416 + + 424 +
    - + - assert.Nil(t, data) +   + err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
    - 1417 + + 425 +
    - + -
    +   + if err != nil {
    - 1418 - -
    - + - // Get batch 5 from backup -
    +
    +
    @@ -427,6 +435,9 @@
    - 1419 + + 427 +
    - + - batchNum = 5 +   + log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
    - 1420 + + 428 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +   + }
    - 1421 + + 429 +
    - + - require.NoError(t, err) +   +
    - 1422 + + -
    - + - assert.Equal(t, expectedData, actualData) +
    +
    +   +
    - 1423 + + -
    - + +
    +
    +  
    - 1424 + + -
    - + - // Update batch 5 and get it from backup +
    +
    +   +
    - 1425 + + 430 +
    - + - expectedData = []byte("new foo bar") +   + for _, tx := range l2Block.transactions {
    - 1426 + + 431 +
    - + - _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData) +   + // Delete the tx from the pending list in the worker (addrQueue)
    - 1427 + + 432 +
    - + - require.NoError(t, err) +   + f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From)
    - 1428 - -
    - + - _, err = tx.Exec(ctx, resetBatchesSQL) -
    +
    +
    @@ -582,6 +593,7 @@
    - 1429 + + 582 +
    - + - require.NoError(t, err) +   + SkipFirstChangeL2Block_V2: false,
    - 1430 + + 583 +
    - + - actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx) +   + Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
    - 1431 + + 584 +
    - + - require.NoError(t, err) +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1432 + + -
    - + - assert.Equal(t, expectedData, actualData) +
    +
    +   +
    - 1433 + + 585 +
    - + - } +   + }
    - 1434 + + 586 +
    - + +  
    - 1435 + + 587 +
    - + - func TestGetBatchL2DataByNumbers(t *testing.T) { +   + batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - + + - - - - @@ -130414,432 +205865,461 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
     
    - 1436 + + 284 +
    - + - initOrResetDB() +   + ForkID: f.stateIntf.GetForkIDByBatchNumber(f.wipBatch.batchNumber),
    - 1437 + + 285 +
    - + - ctx := context.Background() +   + SkipVerifyL1InfoRoot_V2: true,
    - 1438 + + 286 +
    - + - tx, err := testState.BeginStateTransaction(ctx) +   + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1439 + 287
    + - require.NoError(t, err) + ExecutionMode: executor.ExecutionMode0,
    - 1440 + + 288 +
    - + - defer func() { require.NoError(t, tx.Commit(ctx)) }() +   + }
    - 1441 + + 289 +
    - + -
    +   + batchRequest.L1InfoTreeData_V2[l2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{
    - 1442 + + 290 +
    - + - var i1, i2, i3, i4, i5 = uint64(1), uint64(2), uint64(3), uint64(4), uint64(5) +   + GlobalExitRoot: l2Block.l1InfoTreeExitRoot.GlobalExitRoot.GlobalExitRoot,
    - 1443 + +
     
    +
    + 312 +
    - + - var d1, d2, d4 = []byte("foobar"), []byte("dingbat"), []byte{0xb} +   + }
    - 1444 + + 313 +
    - + +  
    - 1445 + + 314 +
    - + - const insertBatch = "INSERT INTO state.batch (batch_num, raw_txs_data) VALUES ($1, $2)" +   + if batchResponse.IsRomOOCError {
    - 1446 + + 315 +
    + - _, err = tx.Exec(ctx, insertBatch, i1, d1) + executeL2BLockError(batchResponse.RomError_V2)
    - 1447 + + 316 +
    - + - require.NoError(t, err) +   + return nil, 0, ErrProcessBatchOOC
    - 1448 + + 317 +
    - + - _, err = tx.Exec(ctx, insertBatch, i2, d2) +   + }
    - 1449 + + 318 +
    - + - require.NoError(t, err) +   +
    - 1450 - -
    - + - _, err = tx.Exec(ctx, insertBatch, i3, nil) -
    +
    +
     
    - 1451 + + 413 +
    - + - require.NoError(t, err) +   + return err
    - 1452 + + 414 +
    - + -
    +   + }
    - 1453 + + 415 +
    - + - // Add a forced batch too, needs a block +   +
    - 1454 + 416
    + - block1 := *block + //TODO: remove this log
    - 1455 + 417
    + - block1.BlockNumber = 1000 + log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum)
    - 1456 + 418
    + - err = testState.AddBlock(ctx, &block1, tx) +
    - 1457 + + 419 +
    - + - require.NoError(t, err) +   + // Update txs status in the pool
    - 1458 + + 420 +
    - + - err = tx.Commit(ctx) +   + for _, txResponse := range blockResponse.TransactionResponses {
    - 1459 + + 421 +
    - + - require.NoError(t, err) +   + // Change Tx status to selected
    - 1460 - -
    - + -
    -
    +
    +
     
    - 1461 + + 425 +
    - + - tx, err = testState.BeginStateTransaction(ctx) +   + }
    - 1462 + + 426 +
    - + - require.NoError(t, err) +   + }
    - 1463 + + 427 +
    - + +  
    - 1464 + 428
    + - const insertForcedBatch = "INSERT INTO state.forced_batch (forced_batch_num, timestamp, raw_txs_data, block_num) VALUES (4, now(),'0b', 1000)" + //TODO: remove this log
    - 1465 + 429
    + - _, err = testState.Exec(ctx, insertForcedBatch) + log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum)
    - 1466 + 430
    + - require.NoError(t, err) +
    - 1467 + + 431 +
    - + -
    +   + // Send L2 block to data streamer
    - 1468 + + 432 +
    - + - allData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{i4}, tx) +   + err = f.DSSendL2Block(f.wipBatch.batchNumber, blockResponse, l2Block.getL1InfoTreeIndex())
    - 1469 + + 433 +
    - + - require.NoError(t, err) +   + if err != nil {
    - 1470 + +
     
    +
    + 435 +
    - + - assert.Equal(t, d4, allData[i4]) +   + log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err)
    - 1471 + + 436 +
    - + -
    +   + }
    - 1472 + + 437 +
    - + - _, ok := allData[i5] +   +
    - 1473 + 438
    + - assert.False(t, ok) + //TODO: remove this log
    - 1474 + 439
    + - } + log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum)
    - 1475 + 440
    @@ -130379,32 +205830,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1476 + 441
      - func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry { + for _, tx := range l2Block.transactions {
    - 1477 + 442
      - exitRoot := state.L1InfoTreeExitRootStorageEntry{ + // Delete the tx from the pending list in the worker (addrQueue)
    - 1478 + 443
      - L1InfoTreeLeaf: state.L1InfoTreeLeaf{ + f.workerIntf.DeletePendingTxToStore(tx.Hash, tx.From)
    - 1674 + 593
      - require.Equal(t, uint64(2002), fb.BlockNumber) + SkipFirstChangeL2Block_V2: false,
    - 1675 + 594
      - require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String()) + Transactions: f.stateIntf.BuildChangeL2Block(f.wipL2Block.deltaTimestamp, f.wipL2Block.getL1InfoTreeIndex()),
    - 1676 + 595
      - require.Equal(t, []byte{0xb}, fb.RawTxsData) + L1InfoTreeData_V2: map[uint32]state.L1DataV2{},
    - 1677 + 596
    + -
    + ExecutionMode: executor.ExecutionMode0,
    - 1678 + + 597 +
    - + - // also check data retrieval +   + }
    - 1679 + + 598 +
    - + - fbData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{1}, dbTx) +   +
    - 1680 + + 599 +
    - + - require.NoError(t, err) +   + batchRequest.L1InfoTreeData_V2[f.wipL2Block.l1InfoTreeExitRoot.L1InfoTreeIndex] = state.L1DataV2{ +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencer/sequencer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -131172,21 +206637,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    @@ -256,6 +256,8 @@
    - 1681 + + 256 +
    - + - var expected = make(map[uint64][]byte) +   + case state.DSL2FullBlock:
    - 1682 + + 257 +
    - + - expected[uint64(1)] = []byte{0xb} +   + l2Block := data
    - 1683 + + 258 +
    - + - require.Equal(t, expected, fbData) +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 1684 + 259
      - } + err = s.streamServer.StartAtomicOp()
    - 1685 + 260
      -
    + if err != nil {
    - 1686 + 261
      - func TestGetLastGER(t *testing.T) { + log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    -
     
    +
    @@ -267,6 +269,8 @@
    - 1757 + 267
      - ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) + Value: l2Block.L2BlockNumber,
    - 1758 + 268
      - require.NoError(t, err) + }
    - 1759 + 269
      - require.Equal(t, common.HexToHash("0x2").String(), ger.String()) -
    -
    - 1760 - -
    - + - } +
    - 1761 + + -
    - + +
    +
    +  
    - 1762 + + -
    - + - func TestGetFirstUncheckedBlock(t *testing.T) { +
    +
    +   +
    - 1763 + + 270 +
    - + - var err error +   + _, err = s.streamServer.AddStreamBookmark(bookMark.Encode())
    - 1764 + + 271 +
    - + - blockNumber := uint64(51001) +   + if err != nil {
    - 1765 + + 272 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) +   + log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 1766 - -
    - + - require.NoError(t, err) -
    +
    +
    @@ -281,6 +285,8 @@
    - 1767 + + 281 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) +   + Value: l2Block.L2BlockNumber - 1,
    - 1768 + + 282 +
    - + - require.NoError(t, err) +   + }
    - 1769 + + 283 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) +   +
    - 1770 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1771 + + -
    - + +
    +
    +  
    - 1772 + + 284 +
    - + - block, err := testState.GetFirstUncheckedBlock(context.Background(), blockNumber, nil) +   + previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
    - 1773 + + 285 +
    - + - require.NoError(t, err) +   + if err != nil {
    - 1774 + + 286 +
    - + - require.Equal(t, uint64(blockNumber+1), block.BlockNumber) +   + log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err)
    - 1775 - -
    - + - } -
    +
    +
    @@ -303,12 +309,16 @@
    - 1776 + + 303 +
    - + -
    +   + ChainID: uint32(chainID),
    - 1777 + + 304 +
    - + - func TestUpdateCheckedBlockByNumber(t *testing.T) { +   + }
    - 1778 + + 305 +
    - + - var err error +   +
    - 1779 + + -
    - + - blockNumber := uint64(54001) +
    +
    +   +
    - 1780 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) +
    +
    +   +
    - 1781 + + 306 +
    - + - require.NoError(t, err) +   + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode())
    - 1782 + + 307 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) +   + if err != nil {
    - 1783 + + 308 +
    - + - require.NoError(t, err) +   + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 1784 + + 309 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) +   + continue
    - 1785 + + 310 +
    - + - require.NoError(t, err) +   + }
    - 1786 + 311
    @@ -130848,323 +206328,308 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1787 - -
    - + - b1, err := testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) -
    -
    - 1788 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1789 + + -
    - + - require.True(t, b1.Checked) +
    +
    +   +
    - 1790 + + 312 +
    - + -
    +   + for _, l2Transaction := range l2Block.Txs {
    - 1791 + + 313 +
    - + - err = testState.UpdateCheckedBlockByNumber(context.Background(), uint64(blockNumber), false, nil) +   + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode())
    - 1792 + + 314 +
    - + - require.NoError(t, err) +   + if err != nil {
    - 1793 - -
    - + -
    -
    +
    +
    @@ -323,18 +333,25 @@
    - 1794 + + 323 +
    - + - b1, err = testState.GetBlockByNumber(context.Background(), uint64(blockNumber), nil) +   + StateRoot: l2Block.StateRoot,
    - 1795 + + 324 +
    - + - require.NoError(t, err) +   + }
    - 1796 + + 325 +
    - + - require.False(t, b1.Checked) +   +
    - 1797 + + -
    - + - } +
    +
    +   +
    - 1798 + + -
    - + +
    +
    +  
    - 1799 + + 326 +
    - + - func TestGetUncheckedBlocks(t *testing.T) { +   + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode())
    - 1800 + + 327 +
    - + - var err error +   + if err != nil {
    - 1801 + + 328 +
    - + - blockNumber := uint64(61001) +   + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 1802 + + 329 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber, Checked: true}, nil) +   + continue
    - 1803 + + 330 +
    - + - require.NoError(t, err) +   + }
    - 1804 + + 331 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 1, Checked: false}, nil) +   +
    - 1805 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1806 + + -
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 2, Checked: true}, nil) +
    +
    +   +
    - 1807 + + 332 +
    - + - require.NoError(t, err) +   + err = s.streamServer.CommitAtomicOp()
    - 1808 + + 333 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 3, Checked: false}, nil) +   + if err != nil {
    - 1809 + + 334 +
    - + - require.NoError(t, err) +   + log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - 1810 + + 335 +
    - + - err = testState.AddBlock(context.Background(), &state.Block{BlockNumber: blockNumber + 4, Checked: false}, nil) +   + continue
    - 1811 + + 336 +
    - + - require.NoError(t, err) +   + }
    - 1812 + + 337 +
    - + +  
    - 1813 + + -
    - + - blocks, err := testState.GetUncheckedBlocks(context.Background(), blockNumber, blockNumber+3, nil) +
    +
    +   +
    - 1814 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1815 + + -
    - + - require.Equal(t, 2, len(blocks)) +
    +
    +   +
    - 1816 + + 338 +
    - + - require.Equal(t, uint64(blockNumber+1), blocks[0].BlockNumber) +   + // Stream a bookmark
    - 1817 + + 339 +
    - + - require.Equal(t, uint64(blockNumber+3), blocks[1].BlockNumber) +   + case state.DSBookMark:
    - 1818 + 340
      - } + bookmark := data
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go - RENAMED - -
    -
    @@ -131194,728 +206644,641 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
    @@ -13,12 +14,19 @@
    +
     
    - 13 + 256
      - // - VerifiedBatches + case state.DSL2FullBlock:
    - 14 + 257
      - // - Entries in exit_root table + l2Block := data
    - 15 + 258
      - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) -
    -
    - 16 - -
    - - - if err == nil { -
    -
    - 17 - -
    - - - // Discard L1InfoTree cache -
    -
    - 18 - -
    - - - // We can't rebuild cache, because we are inside a transaction, so we dont known -
    -
    - 19 - -
    - - - // is going to be a commit or a rollback. So is going to be rebuild on the next +
    - 20 + + 259 +
    - - - // request that needs it. + + + //TODO: remove this log
    - 21 + + 260 +
    - - - s.l1InfoTree = nil + + + log.Infof("start atomic op for l2block %d", l2Block.L2BlockNumber)
    - 22 + 261
      - } + err = s.streamServer.StartAtomicOp()
    - 23 + + 262 +
    - - - return err -
    -
    - - -
      -
    + if err != nil {
    - + + 263 -
    +
    +
      -
    + log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - - -
    -   -
    -
    +
    +
     
    - + + 269 -
    +
    +
      -
    + Value: l2Block.L2BlockNumber,
    - + + 270 -
    +
    +
      -
    + }
    - + + 271 -
    +
    +
     
    - + + 272 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 273 -
    -   -
    +
    +
    + + + log.Infof("add stream bookmark for l2block %d", l2Block.L2BlockNumber)
    - + + 274 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamBookmark(bookMark.Encode())
    - + + 275 -
    +
    +
      -
    + if err != nil {
    - 24 + 276
      - } + log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    -
    -
    -
    -
    - - - + - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - -
     
    - 14 + 285
      - // - VerifiedBatches + Value: l2Block.L2BlockNumber - 1,
    - 15 + 286
      - // - Entries in exit_root table + }
    - 16 + 287
      - err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx) +
    - 17 + + 288 +
    + - if err != nil { + //TODO: remove this log
    - 18 + + 289 +
    + - log.Error("error resetting L1BlockNumber. Error: ", err) + log.Infof("get previous l2block %d", l2Block.L2BlockNumber-1)
    - 19 + + 290 +
    - + - return err +   + previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
    - + + 291 -
    +
    +
      -
    + if err != nil {
    - + + 292 -
    +
    +
      -
    + log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err)
    - + +
     
    -
    +
    + 309 + +
      -
    + ChainID: uint32(chainID),
    - 20 + 310
      - } + }
    - 21 + + 311 +
    - + - s.ResetL1InfoTree() +   +
    - 22 + 312
    + - return nil + //TODO: remove this log
    - 23 + 313
    + - } + log.Infof("add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber)
    - 24 + + 314 +
    - + -
    +   + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode())
    - 25 + + 315 +
    - + - // ResetL1InfoTree resets the L1InfoTree +   + if err != nil {
    - 26 + + 316 +
    - + - func (s *State) ResetL1InfoTree() { +   + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 27 + + 317 +
    - + - // Discard L1InfoTree cache +   + continue
    - 28 + + 318 +
    - + - // We can't rebuild cache, because we are inside a transaction, so we dont known +   + }
    - 29 + + 319 +
    - + - // is going to be a commit or a rollback. So is going to be rebuild on the next +   +
    - 30 + 320
    + - // request that needs it. + //TODO: remove this log
    - 31 + 321
    + - s.l1InfoTree = nil + log.Infof("adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber)
    - 32 + 322
      - } -
    -
    -
    + for _, l2Transaction := range l2Block.Txs {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go - RENAMED - -
    -
    -
    -
    - - - - - + + + - - - - - - - - - - - - - - - - -
    -
    @@ -10,6 +10,13 @@
    - 10 + 323
      - "google.golang.org/grpc/credentials/insecure" + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode())
    - 11 + 324
      - ) + if err != nil {
    +
     
    +
    - 12 + 333
      -
    + StateRoot: l2Block.StateRoot,
    - + + 334 -
    +
    +
      -
    + }
    - + + 335 -
    +
    +
     
    - + + 336 -
    -   -
    +
    +
    + + + //TODO: remove this log
    - + + 337 -
    -   -
    +
    +
    + + + log.Infof("add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber)
    - + + 338 -
    +
    +
      -
    + _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode())
    - + + 339 -
    +
    +
      -
    + if err != nil {
    - + + 340 -
    +
    +
      -
    + log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err)
    - 13 + 341
      - // NewExecutorClient is the executor client constructor. + continue
    - 14 + 342
      - func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) { + }
    - 15 + 343
      - opts := []grpc.DialOption{ +
    -
    + + + 344 + + +
    + + + //TODO: remove this log
    -
    -
    - - - - - - - - - - - - - - - @@ -131960,12 +207323,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/config.go RENAMED
    @@ -132033,203 +207396,231 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + +
    -
     
    - 10 + + 345 +
    -   - "google.golang.org/grpc/credentials/insecure" + + + log.Infof("commit atomic op for l2block %d", l2Block.L2BlockNumber)
    - 11 + 346
      - ) + err = s.streamServer.CommitAtomicOp()
    - 12 + 347
      -
    + if err != nil {
    - 13 + + 348 +
    - + - const ( +   + log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err)
    - 14 + + 349 +
    - + - // ExecutionMode0 is the execution mode for the sequencer and RPC, default one +   + continue
    - 15 + + 350 +
    - + - ExecutionMode0 = uint64(0) +   + }
    - 16 + + 351 +
    - + - // ExecutionMode1 is the execution mode for the synchronizer +   +
    - 17 + 352
    + - ExecutionMode1 = uint64(1) + //TODO: remove this log
    - 18 + 353
    + - ) + log.Infof("l2block %d sent to datastream", l2Block.L2BlockNumber)
    - 19 + 354
    @@ -131925,32 +207288,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 20 + 355
      - // NewExecutorClient is the executor client constructor. + // Stream a bookmark
    - 21 + 356
      - func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) { + case state.DSBookMark:
    - 22 + 357
      - opts := []grpc.DialOption{ + bookmark := data
    -
    @@ -62,13 +62,37 @@
    +
    @@ -41,4 +41,6 @@
    - 62 + 41
      - return state + // gas offset: 100
    - 63 + 42
      - } + // final gas: 1100
    - 64 + 43
      -
    + GasOffset uint64 `mapstructure:"GasOffset"`
    - + + 44 -
    +
    +
      -
    + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - + + +
    +
     
    - + + 41 -
    +
    +
      -
    + // gas offset: 100
    - + + 42 -
    +
    +
      -
    + // final gas: 1100
    - + + 43 -
    +
    +
      -
    + GasOffset uint64 `mapstructure:"GasOffset"`
    - 65 + + 44 +
    -   - // BeginStateTransaction starts a state transaction + + + // MaxBatchesForL1 is the maximum amount of batches to be sequenced in a single L1 tx
    - 66 + + 45 +
    -   - func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) { + + + MaxBatchesForL1 uint64 `mapstructure:"MaxBatchesForL1"`
    - 67 + 46
      - tx, err := s.Begin(ctx) + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + - - - - - - @@ -132272,547 +207663,562 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
    @@ -17,8 +17,8 @@
    - 68 + 17
      - if err != nil { +
    - 69 + 18
      - return nil, err + // etherman contains the methods required to interact with ethereum.
    - 70 + 19
      - } + type etherman interface {
    - 71 + 20
    - - return tx, nil + BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (to *common.Address, data []byte, err error)
    - + + 21 -
    -   -
    +
    +
    + - + EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address) (*types.Transaction, error)
    - + + 22 -
    +
    +
      -
    + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - + + 23 -
    +
    +
      -
    + GetLatestBatchNumber() (uint64, error)
    - + + 24 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -41,3 +41,7 @@
    - + + 41 -
    +
    +
      -
    + Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
    - + + 42 -
    +
    +
      -
    + ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
    - + + 43 -
    +
    +
      -
    + }
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - -
    +
     
    +
    - + + 17 -
    +
    +
     
    - + + 18 -
    +
    +
      -
    + // etherman contains the methods required to interact with ethereum.
    - + + 19 -
    +
    +
      -
    + type etherman interface {
    - + + 20 -
    -   -
    +
    +
    + + + BuildSequenceBatchesTxData(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (to *common.Address, data []byte, err error)
    - + + 21 -
    -   -
    +
    +
    + + + EstimateGasSequenceBatches(sender common.Address, sequences []ethmanTypes.Sequence, maxSequenceTimestamp uint64, initSequenceBatchNumber uint64, l2Coinbase common.Address, committeeSignaturesAndAddrs []byte) (*types.Transaction, error)
    - 72 + 22
      - } + GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
    - 73 + 23
      -
    + GetLatestBatchNumber() (uint64, error)
    - 74 + 24
      - // GetBalance from a given address + }
    -
    -
    -
    -
    - - - + + + +
     
    - 62 + 41
      - return state + Add(ctx context.Context, owner, id string, from common.Address, to *common.Address, value *big.Int, data []byte, gasOffset uint64, dbTx pgx.Tx) error
    - 63 + 42
      - } + ProcessPendingMonitoredTxs(ctx context.Context, owner string, failedResultHandler ethtxmanager.ResultHandler, dbTx pgx.Tx)
    - 64 + 43
      -
    + }
    - 65 + 44
    + - // StateTx is the state transaction that extends the database tx +
    - 66 + 45
    + - type StateTx struct { + type dataAbilitier interface {
    - 67 + 46
    + - pgx.Tx + PostSequence(ctx context.Context, sequences []ethmanTypes.Sequence) ([]byte, error)
    - 68 + 47
    + - stateInstance *State + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - + - + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -6,13 +6,11 @@
    - 69 + + 6 +
    - + - L1InfoTreeModified bool +   + "fmt"
    - 70 + + 7 +
    - + - } +   + "time"
    - 71 + + 8 +
    - + +  
    - 72 + + 9 +
    -   - // BeginStateTransaction starts a state transaction + - + ethman "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 73 + 10
      - func (s *State) BeginStateTransaction(ctx context.Context) (pgx.Tx, error) { + "github.com/0xPolygonHermez/zkevm-node/etherman/types"
    - 74 + 11
      - tx, err := s.Begin(ctx) + "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
    - 75 + 12
      - if err != nil { + "github.com/0xPolygonHermez/zkevm-node/event"
    - 76 + 13
      - return nil, err + "github.com/0xPolygonHermez/zkevm-node/log"
    - 77 + 14
      - } + "github.com/0xPolygonHermez/zkevm-node/state"
    - 78 + + 15 +
    - + - res := &StateTx{ + - + ethTypes "github.com/ethereum/go-ethereum/core/types"
    - 79 + + 16 +
    - + - Tx: tx, +   + "github.com/jackc/pgx/v4"
    - 80 + + 17 +
    - + - stateInstance: s, +   + )
    - 81 + + 18 +
    - + - } +   +
    - 82 + +
    @@ -41,16 +39,18 @@
    +
    + 41 +
    - + - return res, nil +   + ethTxManager ethTxManager
    - 83 + + 42 +
    - + - } +   + etherman etherman
    - 84 + + 43 +
    - + +   + eventLog *event.EventLog +
    +
    + + +
    +  
    - 85 + + 44 +
    - + - // Rollback do the dbTx rollback + modifications in cache mechanism +   + }
    - 86 + + 45 +
    - + - func (tx *StateTx) Rollback(ctx context.Context) error { +   +
    - 87 + + 46 +
    - + - if tx.L1InfoTreeModified { +   + // New inits sequence sender
    - 88 + + 47 +
    - + - tx.stateInstance.ResetL1InfoTree() + - + func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog) (*SequenceSender, error) {
    - 89 + + 48 +
    - + - } +   + return &SequenceSender{
    - 90 + + 49 +
    - + - return tx.Tx.Rollback(ctx) +   + cfg: cfg,
    - 91 + + 50 +
    - + - } +   + state: state,
    - 92 + + 51 +
    - + -
    +   + etherman: etherman,
    - 93 + + 52 +
    - + - // SetL1InfoTreeModified sets the flag to true to save that the L1InfoTree has been modified +   + ethTxManager: manager,
    - 94 + + 53 +
    - + - func (tx *StateTx) SetL1InfoTreeModified() { +   + eventLog: eventLog,
    - 95 + + -
    - + - tx.L1InfoTreeModified = true +
    +
    +   +
    - 96 + 54
      - } + }, nil
    - 97 + 55
      -
    + }
    - 98 + 56
      - // GetBalance from a given address +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go - RENAMED - -
    -
    -
    -
    - - - + - - - @@ -132856,23 +208262,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -132887,191 +208293,102 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -78,7 +78,15 @@
    +
    @@ -185,9 +185,14 @@
    - 78 + 185
      - var effectivePercentage []uint8 + }
    - 79 + 186
      - for i := 0; i <= count; i++ { +
    - 80 + 187
      - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) + // add sequence to be monitored
    - 81 + 188
    - - effectivePercentage = append(effectivePercentage, MaxEffectivePercentage) -
    -
    - - -
    -   -
    + firstSequence := sequences[0]
    - + + 189 -
    +
    +
     
    - + + 190 -
    -   -
    +
    +
    + - + to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
    - 82 + 191
      - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + if err != nil {
    - 83 + 192
      - } + log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
    - 84 + 193
      -
    + return
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -208,7 +213,7 @@
    - 78 + 208
      - var effectivePercentage []uint8 + func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequence, error) {
    - 79 + 209
      - for i := 0; i <= count; i++ { + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 80 + 210
      - txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) -
    -
    - 81 - -
    - + - txGasPrice := tx.GasPrice() -
    -
    - 82 - -
    - + - effectiveGasPrice := receipt.EffectiveGasPrice -
    -
    - 83 - -
    - + - egpPercentage, err := CalculateEffectiveGasPricePercentage(txGasPrice, effectiveGasPrice) -
    -
    - 84 - -
    - + - if errors.Is(err, ErrEffectiveGasPriceEmpty) { -
    -
    - 85 - -
    - + - egpPercentage = MaxEffectivePercentage -
    -
    - 86 - -
    - + - } else if err != nil { -
    -
    - 87 - -
    - + - return nil, err -
    -
    - 88 - -
    - + - } + if err != nil {
    - 89 + + 211 +
    - + - effectivePercentage = append(effectivePercentage, egpPercentage) + - + return nil, fmt.Errorf("failed to get last virtual batch num, err: %w", err)
    - 90 + 212
      - log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String()) + }
    - 91 + 213
      - } + log.Debugf("last virtual batch number: %d", lastVirtualBatchNum)
    - 92 + 214
    @@ -133079,70 +208396,56 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go - RENAMED - -
    -
    -
    -
    - - - + - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - -
    -
    @@ -141,7 +141,7 @@
    +
    @@ -218,8 +223,6 @@
    - 141 + 218
      - } + sequences := []types.Sequence{}
    - 142 + 219
      -
    + // var estimatedGas uint64
    - 143 + 220
      - // firstTxToInsert := len(existingTxs) +
    - 144 + + 221 + +
    + - + var tx *ethTypes.Transaction +
    +
    + 222 +
    -
    @@ -133150,1286 +208453,1277 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 145 + 223
      - for i := 0; i < len(processedTxs); i++ { + // Add sequences until too big for a single L1 tx or last batch is reached
    - 146 + 224
      - processedTx := processedTxs[i] + for {
    - 147 + 225
      - // if the transaction has an intrinsic invalid tx error it means + //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
    -
    @@ -169,7 +169,7 @@
    +
    @@ -234,14 +237,14 @@
    - 169 + 234
      - header.BlockInfoRoot = processedBlock.BlockInfoRoot + if err == state.ErrNotFound {
    - 170 + 235
      - transactions := []*types.Transaction{&processedTx.Tx} + break
    - 171 + 236
      -
    + }
    - 172 + 237
    - - receipt := GenerateReceipt(header.Number, processedTx, uint(i), forkID) + log.Debugf("failed to get batch by number %d, err: %w", currentBatchNumToSequence, err)
    - 173 + 238
      - if !CheckLogOrder(receipt.Logs) { + return nil, err
    - 174 + 239
      - return fmt.Errorf("error: logs received from executor are not in order") + }
    - 175 + 240
      - } +
    -
    @@ -193,6 +193,7 @@
    -
    - 193 + 241
      - if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil { + // Check if batch is closed and checked (sequencer sanity check was successful)
    - 194 + 242
      - return err + isChecked, err := s.state.IsBatchChecked(ctx, currentBatchNumToSequence, nil)
    - 195 + 243
      - } + if err != nil {
    - + + 244 -
    -   -
    +
    +
    + - + log.Debugf("failed to check if batch %d is closed and checked, err: %w", currentBatchNumToSequence, err)
    - 196 + 245
      - } + return nil, err
    - 197 + 246
      - } + }
    - 198 + 247
      - return nil +
    -
    @@ -509,8 +510,7 @@
    +
    @@ -288,31 +291,11 @@
    - 509 + 288
      - } +
    - 510 + 289
      - nonce := loadedNonce.Uint64() + sequences = append(sequences, seq)
    - 511 + 290
      -
    + // Check if can be send
    - 512 + 291
    - - deltaTimestamp := uint32(uint64(time.Now().Unix()) - l2Block.Time()) + firstSequence := sequences[0]
    - 513 + + 292 +
    - - transactions := s.BuildChangeL2Block(deltaTimestamp, uint32(0)) + lastSequence := sequences[len(sequences)-1]
    - 514 + + 293 +
    -   -
    + - + tx, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
    - 515 + + 294 +
    -   - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) + - + if err == nil && tx.Size() > s.cfg.MaxTxSizeForL1 {
    - 516 + + 295 +
    -   - if err != nil { + - + log.Infof("oversized Data on TX oldHash %s (txSize %d > %d)", tx.Hash(), tx.Size(), s.cfg.MaxTxSizeForL1)
    -
    @@ -535,22 +535,24 @@
    -
    - 535 + + 296 +
    -   -
    + - + err = ErrOversizedData
    - 536 + + 297 +
    -   - // v2 fields + - + }
    - 537 + + 298 +
    -   - L1InfoRoot: l2Block.BlockInfoRoot().Bytes(), + - + if err != nil {
    - 538 + + 299 +
    - - TimestampLimit: uint64(time.Now().Unix()), + log.Infof("Handling estimage gas send sequence error: %v", err)
    - 539 + + 300 +
    -   - SkipFirstChangeL2Block: cFalse, + - + sequences, err = s.handleEstimateGasSendSequenceErr(ctx, sequences, currentBatchNumToSequence, err)
    - 540 + + 301 +
    -   - SkipWriteBlockInfoRoot: cTrue, + - + if sequences != nil {
    - + + 302 -
    -   -
    +
    +
    + - + if len(sequences) > 0 {
    - 541 + + 303 +
    -   - } + - + // Handling the error gracefully, re-processing the sequence as a sanity check
    - 542 + + 304 +
    -   - if noZKEVMCounters { + - + lastSequence = sequences[len(sequences)-1]
    - 543 + + 305 +
    -   - processBatchRequestV2.NoCounters = cTrue + - + _, err = s.etherman.EstimateGasSequenceBatches(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase)
    - 544 + + 306 +
    -   - } + - + return sequences, err
    - 545 + + 307 +
    -   -
    + - + }
    - 546 + 308
    - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + }
    - 547 + + 309 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum) + - + return sequences, err
    - 548 + + 310 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot)) + - + }
    - 549 + + 311 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash)) + - + // estimatedGas = tx.Gas()
    - + + 312 -
    -   +
    +
    + -
    - 550 + + 313 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase) + - + //Check if the current batch is the last before a change to a new forkid, in this case we need to close and send the sequence to L1
    - 551 + 314
    - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId) + if (s.cfg.ForkUpgradeBatchNumber != 0) && (currentBatchNumToSequence == (s.cfg.ForkUpgradeBatchNumber)) {
    - 552 + 315
    - - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId) + log.Infof("sequence should be sent to L1, as we have reached the batch %d from which a new forkid is applied (upgrade)", s.cfg.ForkUpgradeBatchNumber)
    - 553 + 316
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree) + return sequences, nil
    - + + 317 -
    +
    +
      -
    + }
    - + + 318 -
    +
    +
     
    - - -
    -   -
    -
    +
    +
    @@ -343,78 +326,6 @@
    - 554 + 343
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId) + return nil, nil
    - 555 + 344
      -
    + }
    - 556 + 345
      - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot)) +
    -
    @@ -1015,6 +1017,7 @@
    -
    - 1015 + + 346 +
    -   - TimestampLimit: uint64(time.Now().Unix()), + - + // handleEstimateGasSendSequenceErr handles an error on the estimate gas. It will return:
    - 1016 + + 347 +
    -   - SkipFirstChangeL2Block: cTrue, + - + // nil, error: impossible to handle gracefully
    - 1017 + + 348 +
    -   - SkipWriteBlockInfoRoot: cTrue, + - + // sequence, nil: handled gracefully. Potentially manipulating the sequences
    - + + 349 -
    -   -
    +
    +
    + - + // nil, nil: a situation that requires waiting
    - 1018 + + 350 +
    -   - } + - + func (s *SequenceSender) handleEstimateGasSendSequenceErr(
    - 1019 + + 351 +
    -   -
    + - + ctx context.Context,
    - 1020 + + 352 +
    -   - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) -
    -
    -
    + - + sequences []types.Sequence,
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - @@ -134437,21 +209731,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 141 + + 353 +
    -   - } + - + currentBatchNumToSequence uint64,
    - 142 + + 354 +
    -   -
    + - + err error,
    - 143 + + 355 +
    -   - // firstTxToInsert := len(existingTxs) + - + ) ([]types.Sequence, error) {
    - 144 + + 356 +
    - + - txIndex := 0 + - + // Insufficient allowance
    - 145 + + 357 +
    -   - for i := 0; i < len(processedTxs); i++ { + - + if errors.Is(err, ethman.ErrInsufficientAllowance) {
    - 146 + + 358 +
    -   - processedTx := processedTxs[i] + - + return nil, err
    - 147 + + 359 +
    -   - // if the transaction has an intrinsic invalid tx error it means + - + }
    -
     
    +
    + 360 + +
    + - + if isDataForEthTxTooBig(err) { +
    - 169 + + 361 +
    -   - header.BlockInfoRoot = processedBlock.BlockInfoRoot + - + // Remove the latest item and send the sequences
    - 170 + + 362 +
    -   - transactions := []*types.Transaction{&processedTx.Tx} + - + log.Infof(
    - 171 + + 363 +
    -   -
    + - + "Done building sequences, selected batches to %d. Batch %d caused the L1 tx to be too big",
    - 172 + + 364 +
    - + - receipt := GenerateReceipt(header.Number, processedTx, uint(txIndex), forkID) + - + currentBatchNumToSequence-1, currentBatchNumToSequence,
    - 173 + + 365 +
    -   - if !CheckLogOrder(receipt.Logs) { + - + )
    - 174 + + 366 +
    -   - return fmt.Errorf("error: logs received from executor are not in order") + - + sequences = sequences[:len(sequences)-1]
    - 175 + + 367 +
    -   - } + - + return sequences, nil
    -
     
    +
    + 368 + +
    + - + } +
    - 193 + + 369 +
    -   - if err := s.AddL2Block(ctx, batchNumber, l2Block, receipts, txsL2Hash, storeTxsEGPData, imStateRoots, dbTx); err != nil { + - +
    - 194 + + 370 +
    -   - return err + - + // while estimating gas a new block is not created and the POE SC may return
    - 195 + + 371 +
    -   - } + - + // an error regarding timestamp verification, this must be handled
    - 196 + + 372 +
    - + - txIndex++ + - + // if errors.Is(err, ethman.ErrTimestampMustBeInsideRange) {
    - 197 + + 373 +
    -   - } + - + // // query the sc about the value of its lastTimestamp variable
    - 198 + + 374 +
    -   - } + - + // lastTimestamp, err := s.etherman.GetLastBatchTimestamp()
    - 199 + + 375 +
    -   - return nil + - + // if err != nil {
    -
     
    +
    + 376 + +
    + - + // return nil, err +
    - 510 + + 377 +
    -   - } + - + // }
    - 511 + + 378 +
    -   - nonce := loadedNonce.Uint64() + - + // // check POE SC lastTimestamp against sequences' one
    - 512 + + 379 +
    -   -
    + - + // for _, seq := range sequences {
    - 513 + + 380 +
    - + - transactions := s.BuildChangeL2Block(uint32(0), uint32(0)) + - + // if seq.Timestamp < int64(lastTimestamp) {
    - + + 381 -
    -   -
    +
    +
    + - + // // TODO: gracefully handle this situation by creating an L2 reorg
    - 514 + + 382 +
    -   -
    + - + // log.Fatalf("sequence timestamp %d is < POE SC lastTimestamp %d", seq.Timestamp, lastTimestamp)
    - 515 + + 383 +
    -   - batchL2Data, err := EncodeUnsignedTransaction(*tx, s.cfg.ChainID, &nonce, forkID) + - + // }
    - 516 + + 384 +
    -   - if err != nil { + - + // lastTimestamp = uint64(seq.Timestamp)
    -
     
    +
    + 385 + +
    + - + // } +
    - 535 + + 386 +
    -   -
    + - + // blockTimestamp, err := s.etherman.GetLatestBlockTimestamp(ctx)
    - 536 + + 387 +
    -   - // v2 fields + - + // if err != nil {
    - 537 + + 388 +
    -   - L1InfoRoot: l2Block.BlockInfoRoot().Bytes(), + - + // log.Error("error getting block timestamp: ", err)
    - 538 + + 389 +
    - + - TimestampLimit: l2Block.Time(), + - + // }
    - 539 + + 390 +
    -   - SkipFirstChangeL2Block: cFalse, + - + // log.Debugf("block.timestamp: %d is smaller than seq.Timestamp: %d. A new block must be mined in L1 before the gas can be estimated.", blockTimestamp, sequences[0].Timestamp)
    - 540 + + 391 +
    -   - SkipWriteBlockInfoRoot: cTrue, + - + // return nil, nil
    - 541 + + 392 +
    - + - ExecutionMode: executor.ExecutionMode0, + - + // }
    - 542 + + 393 +
    -   - } + - +
    - 543 + + 394 +
    -   - if noZKEVMCounters { + - + // Unknown error
    - 544 + + 395 +
    -   - processBatchRequestV2.NoCounters = cTrue + - + if len(sequences) == 1 {
    - 545 + + 396 +
    -   - } + - + // TODO: gracefully handle this situation by creating an L2 reorg
    - 546 + + 397 +
    -   -
    + - + log.Errorf(
    - + + 398 -
    -   -
    +
    +
    + - + "Error when estimating gas for BatchNum %d (alone in the sequences): %v",
    - 547 + + 399 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldBatchNum]: %v", processBatchRequestV2.OldBatchNum) + - + currentBatchNumToSequence, err,
    - 548 + + 400 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldStateRoot]: %v", hex.EncodeToHex(processBatchRequestV2.OldStateRoot)) + - + )
    - 549 + + 401 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.OldAccInputHash]: %v", hex.EncodeToHex(processBatchRequestV2.OldAccInputHash)) + - + }
    - 550 + + 402 +
    - + -
    + - + // Remove the latest item and send the sequences
    - 551 + + 403 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.Coinbase]: %v", processBatchRequestV2.Coinbase) + - + log.Infof(
    - + + 404 -
    -   -
    +
    +
    + - + "Done building sequences, selected batches to %d. Batch %d excluded due to unknown error: %v",
    - + + 405 -
    -   -
    +
    +
    + - + currentBatchNumToSequence, currentBatchNumToSequence+1, err,
    - 552 + + 406 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.UpdateMerkleTree]: %v", processBatchRequestV2.UpdateMerkleTree) + - + )
    - 553 + + 407 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ChainId]: %v", processBatchRequestV2.ChainId) + - + sequences = sequences[:len(sequences)-1]
    - 554 + + 408 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ForkId]: %v", processBatchRequestV2.ForkId) + - +
    - 555 + + 409 +
    - + - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + - + return sequences, nil
    - 556 + + 410 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.ContextId]: %v", processBatchRequestV2.ContextId) + - + }
    - 557 + + 411 +
    -   + -
    - 558 + + 412 +
    -   - log.Debugf("internalProcessUnsignedTransactionV2[processBatchRequestV2.L1InfoRoot]: %v", hex.EncodeToHex(processBatchRequestV2.L1InfoRoot)) + - + func isDataForEthTxTooBig(err error) bool {
    -
     
    +
    + 413 + +
    + - + return errors.Is(err, ethman.ErrGasRequiredExceedsAllowance) || +
    - 1017 + + 414 +
    -   - TimestampLimit: uint64(time.Now().Unix()), + - + errors.Is(err, ErrOversizedData) ||
    - 1018 + + 415 +
    -   - SkipFirstChangeL2Block: cTrue, + - + errors.Is(err, ethman.ErrContentLengthTooLarge)
    - 1019 + + 416 +
    -   - SkipWriteBlockInfoRoot: cTrue, + - + }
    - 1020 + + 417 +
    - + - ExecutionMode: executor.ExecutionMode0, + - +
    - 1021 + 418
      - } + func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
    - 1022 + 419
      -
    + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 1023 + 420
      - log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From) + if err != nil && err != state.ErrNotFound {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - RENAMED - -
    -
    @@ -134459,7 +209738,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -134492,43 +209771,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -134538,7 +209817,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -134548,92 +209827,62 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - + - - @@ -134643,7 +209892,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -134653,17 +209902,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -134673,7 +209922,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -134683,27 +209932,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -134713,7 +209962,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -134723,87 +209972,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -6,9 +6,9 @@
    +
     
    @@ -134478,7 +209757,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - "math/big" + "time"
    - 9 + + -
    - - - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" +
    +
    +   +
    - 10 + 9
      - "github.com/0xPolygonHermez/zkevm-node/log" + "github.com/0xPolygonHermez/zkevm-node/etherman/types"
    - 11 + 10
      - "github.com/0xPolygonHermez/zkevm-node/state" + "github.com/0xPolygonHermez/zkevm-node/ethtxmanager"
    - + + 11 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/event"
      - "github.com/jackc/pgx/v4" + "github.com/0xPolygonHermez/zkevm-node/log"
      - ) + "github.com/0xPolygonHermez/zkevm-node/state"
    - 14 + + -
    +
    +
     
    -
    @@ -36,13 +36,16 @@
    -
    - 36 + 14
      - func NewCheckL2BlockHash(state stateGetL2Block, + "github.com/jackc/pgx/v4"
    - 37 + 15
      - trustedClient trustedRPCGetL2Block, + )
    - 38 + 16
    -   - initialL2BlockNumber uint64, -
    -
    - 39 - -
    - - - modulusBlockNumber uint64) *CheckL2BlockHash { -
    -
    - - -
     
    - - -
    -   -
    -
    +
    +
     
    - + + 39 -
    +
    +
      -
    + ethTxManager ethTxManager
      - return &CheckL2BlockHash{ + etherman etherman
      - state: state, + eventLog *event.EventLog
    + 42 +
    -   - trustedClient: trustedClient, + + + da dataAbilitier
      - lastL2BlockChecked: initialL2BlockNumber, + }
      - modulusL2BlockToCheck: modulusBlockNumber, +
    + 45 +
    - - - } +   + // New inits sequence sender
    + 46 +
    -   - } + + + func New(cfg Config, state stateInterface, etherman etherman, manager ethTxManager, eventLog *event.EventLog, da dataAbilitier) (*SequenceSender, error) {
      -
    + return &SequenceSender{
      - // CheckL2Block checks the L2Block hash between the local and the trusted + cfg: cfg,
    -
    @@ -74,6 +77,9 @@
    -
    - 74 + 49
      - log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber) + state: state,
    - 75 + 50
      - return false, 0 + etherman: etherman,
    - 76 + 51
      - } -
    -
    - - -
    -   -
    + ethTxManager: manager,
    - + + 52 -
    +
    +
      -
    + eventLog: eventLog,
    - + + 53 -
    -   -
    +
    +
    + + + da: da,
    - 77 + 54
      - return true, l2BlockNumber + }, nil
    - 78 + 55
    @@ -134813,7 +210047,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 79 + 56
    @@ -134824,21 +210058,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -129,11 +135,14 @@
    +
     
    - 129 + 185
      - } + }
    - 130 + 186
    @@ -134848,231 +210082,227 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 131 + 187
      - func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error { + // add sequence to be monitored
    - 132 + + 188 +
    - - - if localL2Block == nil || trustedL2Block == nil || trustedL2Block.Hash == nil { + + + dataAvailabilityMessage, err := s.da.PostSequence(ctx, sequences)
    - 133 + + 189 +
    - - - return fmt.Errorf("%s localL2Block or trustedL2Block or trustedHash are nil", prefixLogs) + + + if err != nil {
    - + + 190 -
    -   -
    +
    +
    + + + log.Error("error posting sequences to the data availability protocol: ", err)
    - + + 191 -
    -   -
    +
    +
    + + + return
    - + + 192 -
    -   -
    +
    +
    + + + }
    - 134 + 193
      - } +
    - 135 + + 194 +
    - - - if localL2Block.Hash() != *trustedL2Block.Hash { + + + firstSequence := sequences[0]
    - 136 + + 195 +
    - - - return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), (*trustedL2Block.Hash).String()) + + + to, data, err := s.etherman.BuildSequenceBatchesTxData(s.cfg.SenderAddress, sequences, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber-1, s.cfg.L2Coinbase, dataAvailabilityMessage)
    - 137 + 196
      - } + if err != nil {
    - 138 + 197
      - return nil + log.Error("error estimating new sequenceBatches to add to eth tx manager: ", err)
    - 139 + 198
      - } + return
    -
    -
    -
    -
    - - - + - - - - + + + - - + + + + - + - + + - - - - - - + + + @@ -135252,311 +210512,332 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - + + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
    - 6 + 213
      - "fmt" + func (s *SequenceSender) getSequencesToSend(ctx context.Context) ([]types.Sequence, error) {
    - 7 + 214
      - "math/big" + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 8 + 215
      -
    + if err != nil {
    - + + 216 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("failed to get last virtual batch num, err: %v", err)
    - 9 + 217
      - "github.com/0xPolygonHermez/zkevm-node/log" + }
    - 10 + 218
      - "github.com/0xPolygonHermez/zkevm-node/state" + log.Debugf("last virtual batch number: %d", lastVirtualBatchNum)
    - 11 + + 219 +
    - + - "github.com/ethereum/go-ethereum/core/types" +   +
    +
     
    +
    - 12 + 223
      - "github.com/jackc/pgx/v4" + sequences := []types.Sequence{}
    - 13 + 224
      - ) + // var estimatedGas uint64
    - 14 + 225
    @@ -135081,168 +210311,198 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    - 36 + 226
      - func NewCheckL2BlockHash(state stateGetL2Block, + // Add sequences until too big for a single L1 tx or last batch is reached
    - 37 + 227
      - trustedClient trustedRPCGetL2Block, + for {
    - 38 + 228
      - initialL2BlockNumber uint64, + //Check if the next batch belongs to a new forkid, in this case we need to stop sequencing as we need to
    - 39 + +
     
    +
    + 237 +
    - + - modulusBlockNumber uint64) (*CheckL2BlockHash, error) { +   + if err == state.ErrNotFound {
    - 40 + + 238 +
    - + - if modulusBlockNumber == 0 { +   + break
    - 41 + + 239 +
    - + - return nil, fmt.Errorf("error: modulusBlockNumber is zero") +   + }
    - 42 + + 240 +
    + - } + log.Debugf("failed to get batch by number %d, err: %v", currentBatchNumToSequence, err)
    - 43 + 241
      - return &CheckL2BlockHash{ + return nil, err
    - 44 + 242
      - state: state, + }
    - 45 + 243
      - trustedClient: trustedClient, +
    - 46 + 244
      - lastL2BlockChecked: initialL2BlockNumber, + // Check if batch is closed and checked (sequencer sanity check was successful)
    - 47 + 245 + +
    +   + isChecked, err := s.state.IsBatchChecked(ctx, currentBatchNumToSequence, nil) +
    +
    + 246
      - modulusL2BlockToCheck: modulusBlockNumber, + if err != nil {
    - 48 + 247
    + - }, nil + log.Debugf("failed to check if batch %d is closed and checked, err: %v", currentBatchNumToSequence, err)
    - 49 + 248
      - } + return nil, err
    - 50 + 249
      -
    + }
    - 51 + 250
      - // CheckL2Block checks the L2Block hash between the local and the trusted +
    - 77 + 291
      - log.Infof("checkL2block: skip check L2block (next to check: %d) currently LastL2BlockNumber: %d", minL2BlockNumberToCheck, lastLocalL2BlockNumber) +
    - 78 + 292
      - return false, 0 + sequences = append(sequences, seq)
    - 79 + 293
      - } + // Check if can be send
    - 80 + + 294 +
    + - if l2BlockNumber%p.modulusL2BlockToCheck != 0 { + if len(sequences) == int(s.cfg.MaxBatchesForL1) {
    - 81 + + 295 +
    + - return false, 0 + log.Info(
    - 82 + + 296 +
    + - } + "sequence should be sent to L1, because MaxBatchesForL1 (%d) has been reached",
    - 83 + + 297 +
    -   - return true, l2BlockNumber + + + s.cfg.MaxBatchesForL1,
    - 84 + + 298 +
    + + + ) +
    +
    + + +
      - } +
    - 85 + + -
    +
    +
     
    -
     
    +
    + + +
    +   +
    +
    - 135 + + -
    +
    +
      - } +
    - 136 + + -
    +
    +
     
    - 137 + + -
    +
    +
      - func compareL2Blocks(prefixLogs string, localL2Block *state.L2Block, trustedL2Block *types.Block) error { +
    - 138 + + -
    - + - if localL2Block == nil || trustedL2Block == nil { +
    +
    +   +
    - 139 + + -
    - + - return fmt.Errorf("%s localL2Block or trustedL2Block are nil", prefixLogs) +
    +
    +   +
    - 140 + + -
    - + - } +
    +
    +   +
    - 141 + + -
    - + - if localL2Block.Hash() != trustedL2Block.Hash() { +
    +
    +   +
    - 142 + + -
    - + - return fmt.Errorf("%s localL2Block.Hash %s and trustedL2Block.Hash %s are different", prefixLogs, localL2Block.Hash().String(), trustedL2Block.Hash().String()) +
    +
    +   +
    - 143 + + -
    +
    +
      - } +
    - 144 + + -
    - + - if localL2Block.ParentHash() != trustedL2Block.ParentHash() { +
    +
    +   +
    - 145 + + -
    - + - return fmt.Errorf("%s localL2Block.ParentHash %s and trustedL2Block.ParentHash %s are different", prefixLogs, localL2Block.ParentHash().String(), trustedL2Block.ParentHash().String()) +
    +
    +   +
    - 146 + + -
    +
    +
      - } +
    - 147 + + -
    +
    +
      - return nil +
    - 148 + + -
    +
    +
      - } +
    -
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block_test.go - RENAMED - -
    -
    -
    -
    - - - - - - + - + + - - - - + - - - - - - - - - - - - @@ -135670,33 +210956,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -135710,98 +210996,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - + + + + + + @@ -135825,78 +211136,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - @@ -135910,193 +211216,183 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -136110,23 +211406,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -136170,238 +211466,242 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -19,7 +18,7 @@
    - 19 + 299
      - type CheckL2BlocksTestData struct { + return sequences, nil
    - 20 + 300
      - sut *actions.CheckL2BlockHash + }
    - 21 + 301
      - mockState *mock_syncinterfaces.StateFullInterface +
    - 22 + +
     
    +
    + 326 +
    - - - zKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +   + return nil, nil
    - 23 + 327
    @@ -135566,7 +210847,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 24 + 328
    @@ -135575,78 +210856,83 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 25 + + -
    +
    +
      - func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) { +
    -
    @@ -33,12 +32,15 @@
    +
    + + +
    +   +
    +
    - 33 + + -
    +
    +
      - {1, 10, 10}, +
    - 34 + + -
    +
    +
      - {9, 10, 10}, +
    - 35 + + -
    +
    +
      - {10, 10, 20}, +
    - 36 + + -
    - - - {0, 0, 1}, +
    +
    +   +
    - 37 + + -
    - - - {1, 0, 2}, +
    +
    +   +
    - 38 + + -
    +
    +
      - } +
    - 39 + + -
    +
    +
      - for _, data := range values { +
    - 40 + + -
    +
    +
      - // Call the GetNextL2BlockToCheck method +
    - 41 + + -
    - - - checkL2Block := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus) +
    +
    +   +
    - 42 + + -
    +
    +
      - nextL2Block := checkL2Block.GetMinimumL2BlockToCheck() +
    - 43 + + -
    +
    +
     
    - 44 + + -
    +
    +
      - // Assert the expected result +
    -
    @@ -57,9 +59,11 @@
    +
    + + +
    +   +
    +
    - 57 + + -
    +
    +
      - func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData { +
    - 58 + + -
    +
    +
      - res := CheckL2BlocksTestData{ +
    - 59 + + -
    +
    +
      - mockState: mock_syncinterfaces.NewStateFullInterface(t), +
    - 60 + + -
    - - - zKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    +   +
    - 61 + + -
    +
    +
      - } +
    - 62 + + -
    - - - res.sut = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus) +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 63 + + -
    +
    +
      - return res +
    - 64 + + -
    +
    +
      - } +
    - 65 + + -
    +
    +
      - func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) { +
    -
    @@ -78,7 +82,8 @@
    -
    - 78 + + -
    +
    +
      - } +
    - 79 + + -
    +
    +
     
    - 80 + + -
    +
    +
      - for _, data := range values { +
    - 81 + + -
    - - - checkL2Block := actions.NewCheckL2BlockHash(nil, nil, 0, 0) +
    +
    +   +
    - 82 + + -
    +
    +
      - shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck) +
    - 83 + + -
    +
    +
     
    - 84 + + -
    +
    +
      - assert.Equal(t, data.expectedShouldCheck, shouldCheck, data) +
    -
    @@ -87,7 +92,7 @@
    -
    - 87 + + -
    +
    +
      - } +
    - 88 + + -
    +
    +
     
    - 89 + + -
    +
    +
      - func TestCheckL2BlockHashMatch(t *testing.T) { +
    - 90 + + -
    - - - data := newCheckL2BlocksTestData(t, 1, 10) +
    +
    +   +
    - 91 + + -
    +
    +
      - lastL2Block := uint64(14) +
    - 92 + + -
    +
    +
      - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) +
    - 93 + + -
    +
    +
      - gethHeader := types.Header{ +
    -
    @@ -97,19 +102,24 @@
    -
    - 97 + + -
    +
    +
     
    - 98 + + -
    +
    +
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) +
    - 99 + + -
    +
    +
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) +
    - 100 + + -
    - - - l2blockHash := stateBlock.Hash() +
    +
    +   +
    - 101 + + -
    - - - rpcL2Block := rpctypes.Block{ +
    +
    +   +
    - 102 + + -
    - - - Hash: &l2blockHash, +
    +
    +   +
    - 103 + + -
    - - - Number: rpctypes.ArgUint64(lastL2Block), +
    +
    +   +
    - 104 + + -
    - - - } +
    +
    +   +
    - 105 + + -
    +
    +
     
    - 106 + + -
    - - - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil) +
    +
    +   +
    - 107 + + -
    +
    +
      - err := data.sut.CheckL2Block(context.Background(), nil) +
    - 108 + + -
    +
    +
      - require.NoError(t, err) +
    - 109 + + -
    +
    +
      - } +
    - 110 + + -
    +
    +
     
    - 111 + + -
    - - - func TestCheckL2BlockHashMissmatch(t *testing.T) { +
    +
    +   +
    - 112 + + -
    - - - data := newCheckL2BlocksTestData(t, 1, 10) +
    +
    +   +
    - 113 + + -
    +
    +
      - lastL2Block := uint64(14) +
    - 114 + + -
    +
    +
      - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) +
    - 115 + + -
    +
    +
      - gethHeader := types.Header{ +
    -
    @@ -119,13 +129,14 @@
    -
    - 119 + + -
    +
    +
     
    - 120 + + -
    +
    +
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) +
    - 121 + 329
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) + func (s *SequenceSender) isSynced(ctx context.Context, retries int, waitRetry time.Duration) (bool, error) {
    - 122 + + 330 +
    - - - l2blockHash := common.HexToHash("0x1234") +   + lastVirtualBatchNum, err := s.state.GetLastVirtualBatchNum(ctx, nil)
    - 123 + + 331 +
    - - - rpcL2Block := rpctypes.Block{ +   + if err != nil && err != state.ErrNotFound {
    - 124 - -
    - - - Hash: &l2blockHash, +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sequencesender/sequencesender_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - @@ -136420,57 +211720,57 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + +
    +
    @@ -30,7 +30,7 @@
    - 125 + + 30 +
    - - - Number: rpctypes.ArgUint64(lastL2Block), +   + stateMock := new(StateMock)
    - 126 + + 31 +
    - - - } -
    -
    - - -
      -
    + ethermanMock := new(EthermanMock)
    - 127 + 32
      -
    + ethTxManagerMock := new(EthTxManagerMock)
    - 128 + 33
    - - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(&rpcL2Block, nil) + ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil)
    - 129 + 34
      - err := data.sut.CheckL2Block(context.Background(), nil) + assert.NoError(t, err)
    - 130 + 35
      - require.Error(t, err) +
    - 131 + 36
      - } + testCases := []IsSyncedTestCase{
    - 18 + 30
      - type CheckL2BlocksTestData struct { + stateMock := new(StateMock)
    - 19 + 31
      - sut *actions.CheckL2BlockHash + ethermanMock := new(EthermanMock)
    - 20 + 32
      - mockState *mock_syncinterfaces.StateFullInterface + ethTxManagerMock := new(EthTxManagerMock)
    - 21 + 33
    + - zKEVMClient *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface + ssender, err := New(Config{}, stateMock, ethermanMock, ethTxManagerMock, nil, nil)
    - 22 + 34
      - } + assert.NoError(t, err)
    - 23 + 35
    @@ -136480,916 +211780,1002 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 24 + 36
      - func TestCheckL2BlockHash_GetMinimumL2BlockToCheck(t *testing.T) { + testCases := []IsSyncedTestCase{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/sonar-project.properties + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - + + + - + + +
    -
     
    +
    @@ -1,15 +1,10 @@
    - 32 + + 1 +
    -   - {1, 10, 10}, + - + sonar.projectKey=0xPolygonHermez_zkevm-node
    - 33 + + 2 +
    -   - {9, 10, 10}, + - + sonar.organization=0xpolygonhermez
    - 34 + 3
      - {10, 10, 20}, -
    -
    - 35 - -
    - + - {0, 1, 1}, +
    - 36 + + 4 +
    - + - {1, 1, 2}, +   + sonar.sources=.
    - 37 + 5
      - } + sonar.exclusions=**/*_test.go
    - 38 + + 6 +
    - + - _, err := actions.NewCheckL2BlockHash(nil, nil, 1, 0) + - + sonar.exclusions=**/mock_*.go, **/mock/**
    - 39 + + 7 +
    - + - require.Error(t, err) +   +
    - 40 + 8
      - for _, data := range values { + sonar.tests=.
    - 41 + 9
      - // Call the GetNextL2BlockToCheck method + sonar.test.inclusions=**/*_test.go
    - 42 + + 10 +
    - + - checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, data.initial, data.modulus) + - + sonar.test.exclusions=**/mock_*.go, **/mock/**
    - 43 + + 11 +
    - + - require.NoError(t, err) + - +
    - 44 + 12
      - nextL2Block := checkL2Block.GetMinimumL2BlockToCheck() + sonar.go.coverage.reportPaths=coverage.out
    - 45 + + 13 +
    -   -
    + - + #sonar.coverageReportPaths=coverage.out +
    +
    + 14 + +
    + - + #onar.testExecutionReportPaths=report.json
    - 46 + 15
      - // Assert the expected result + sonar.go.tests.reportPaths=report.json
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - + + +
     
    - 59 + + 1 +
    -   - func newCheckL2BlocksTestData(t *testing.T, initialL2Block, modulus uint64) CheckL2BlocksTestData { + + + sonar.projectKey=zkevm-node
    - 60 + + -
    +
    +
      - res := CheckL2BlocksTestData{ +
    - 61 + 2
      - mockState: mock_syncinterfaces.NewStateFullInterface(t), +
    - 62 + + 3 +
    - + - zKEVMClient: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t), +   + sonar.sources=.
    - 63 + 4
      - } + sonar.exclusions=**/*_test.go
    - 64 + 5
    + - var err error -
    -
    - 65 - -
    - + - res.sut, err = actions.NewCheckL2BlockHash(res.mockState, res.zKEVMClient, initialL2Block, modulus) -
    -
    - 66 - -
    - + - require.NoError(t, err) + sonar.exclusions=**/mock_*.go
    - 67 + 6
      - return res +
    - 68 + 7
      - } + sonar.tests=.
    - 69 + 8
      - func TestCheckL2BlockHash_GetNextL2BlockToCheck(t *testing.T) { + sonar.test.inclusions=**/*_test.go
    -
     
    -
    - 82 + + -
    +
    +
      - } +
    - 83 + + -
    +
    +
     
    - 84 + 9
      - for _, data := range values { + sonar.go.coverage.reportPaths=coverage.out
    - 85 + + -
    - + - checkL2Block, err := actions.NewCheckL2BlockHash(nil, nil, 0, 1) +
    +
    +   +
    - 86 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 87 + 10
      - shouldCheck, nextL2Block := checkL2Block.GetNextL2BlockToCheck(data.lastLocalL2BlockNumber, data.minL2BlockNumberToCheck) + sonar.go.tests.reportPaths=report.json +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batch_pending.go + RENAMED + +
    +
    +
    +
    + + + + + + + + - - - - - - + - - - - - - - - - - - - - - - + + +
    +
    @@ -1,11 +0,0 @@
    +
    + 1 + +
    + - + package state
    - 88 + + 2 +
    -   + -
    - 89 + + 3 +
    -   - assert.Equal(t, data.expectedShouldCheck, shouldCheck, data) + - + import "time"
    -
     
    +
    + 4 + +
    + - +
    +
    - 92 + + 5 +
    -   - } + - + // PendingBatch represents a batch pending to be executed
    - 93 + + 6 +
    -   -
    + - + type PendingBatch struct {
    - 94 + + 7 +
    -   - func TestCheckL2BlockHashMatch(t *testing.T) { + - + BatchNumber uint64
    - 95 + + 8 +
    - + - data := newCheckL2BlocksTestData(t, 1, 14) + - + BlobInnerNum uint64
    - 96 + + 9 +
    -   - lastL2Block := uint64(14) + - + CreatedAt time.Time
    - 97 + + 10 +
    -   - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) + - + Processed bool
    - 98 + + 11 +
    -   - gethHeader := types.Header{ + - + }
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - + + + +
     
    - 102 + + -
    +
    +
     
    - 103 + + -
    +
    +
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) +
    - 104 + + -
    +
    +
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) +
    - 105 + + -
    - + - //l2blockHash := stateBlock.Hash() +
    +
    +   +
    - 106 + + -
    - + - // rpcL2Block := rpctypes.Block{ +
    +
    +   +
    - 107 + + -
    - + - // Hash: &l2blockHash, +
    +
    +   +
    - 108 + + -
    - + - // Number: rpctypes.ArgUint64(lastL2Block), +
    +
    +   +
    - 109 + + -
    - + - // } +
    +
    +   +
    - 110 + + -
    - + - // create a types.Block object +
    +
    +   +
    - 111 + + -
    +
    +
     
    - 112 + + + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2.go + RENAMED + +
    +
    +
    +
    + + + + + + + - - - - - - - - - + + + - - - - - - - - - - - - - + - + + - - - - - - -
    +
    @@ -33,6 +33,7 @@
    +
    + 33 +
    - + - rpcL2Block := types.NewBlock(&types.Header{ +   + ForcedBlockHashL1 *common.Hash
    - 113 + + 34 +
    - + - Number: big.NewInt(int64(lastL2Block)), +   + SkipVerifyL1InfoRoot uint32
    - 114 + + 35 +
    - + - }, nil, nil, nil, nil) +   + GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB)
    - 115 + + -
    - + +
    +
    +  
    - 116 + + 36 +
    - + - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil) +   + ClosingReason ClosingReason
    - 117 + 37
      - err := data.sut.CheckL2Block(context.Background(), nil) + }
    - 118 + 38
      - require.NoError(t, err) +
    +
    @@ -68,6 +69,7 @@
    +
    - 119 + 68
      - } + ChainId: s.cfg.ChainID,
    - 120 + 69
      -
    + ForkId: request.ForkID,
    - 121 + + 70 +
    - + - func TestCheckL2BlockHashMismatch(t *testing.T) { +   + ContextId: uuid.NewString(),
    - 122 + + -
    - + - data := newCheckL2BlocksTestData(t, 1, 14) +
    +
    +   +
    - 123 + 71
      - lastL2Block := uint64(14) + }
    - 124 + 72
      - lastL2BlockBigInt := big.NewInt(int64(lastL2Block)) +
    - 125 + 73
      - gethHeader := types.Header{ + if request.SkipFirstChangeL2Block_V2 {
    -
     
    +
    @@ -130,6 +132,7 @@
    - 129 + 130
      -
    + ForkId: forkId,
    - 130 + 131
      - data.mockState.EXPECT().GetLastL2BlockNumber(mock.Anything, mock.Anything).Return(lastL2Block, nil) + ContextId: uuid.NewString(),
    - 131 + 132
      - data.mockState.EXPECT().GetL2BlockByNumber(mock.Anything, lastL2Block, mock.Anything).Return(stateBlock, nil) + SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
    - 132 + + -
    - + - //l2blockHash := common.HexToHash("0x1234") +
    +
    +   +
    + 133 +
    - + -
    +   + }
    + 134 +
    - + - rpcL2Block := types.NewBlock(&types.Header{ +   +
    + 135 +
    - + - Number: big.NewInt(int64(lastL2Block)), +   + if forcedBlockHashL1 != nil {
    - 136 + +
    @@ -168,7 +171,7 @@
    +
    + 168 +
    - + - ParentHash: common.HexToHash("0x1234"), +   + return nil, err
    - 137 + + 169 +
    - + - }, nil, nil, nil, nil) +   + } else if processBatchResponse != nil && processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 138 + 170
      -
    + err = executor.ExecutorErr(processBatchResponse.Error)
    - 139 + + 171 +
    - + - data.zKEVMClient.EXPECT().BlockByNumber(mock.Anything, lastL2BlockBigInt).Return(rpcL2Block, nil) + - + s.eventLog.LogExecutorError(ctx, processBatchResponse.Error, processBatchRequest)
    - 140 + 172
      - err := data.sut.CheckL2Block(context.Background(), nil) + }
    - 141 + 173
      - require.Error(t, err) +
    - 142 + 174
      - } + return processBatchResponse, err
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - + - - - - + + + - - + + + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -138028,72 +213404,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -138103,1014 +213479,782 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - + + + - - -
    -
    @@ -3,7 +3,6 @@
    +
    @@ -230,6 +233,7 @@
    - 3 + 230
      - import ( + ContextId: uuid.NewString(),
    - 4 + 231
      - "context" + SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
    - 5 + 232
      - "errors" + L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
    - 6 + + -
    - - - "fmt" +
    +
    +   +
    - 7 + 233
      - "time" + }
    - 8 + 234
    @@ -137399,402 +212785,417 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 9 + 235
      - "github.com/0xPolygonHermez/zkevm-node/etherman" + if processingCtx.ForcedBlockHashL1 != nil {
    -
    @@ -60,58 +59,12 @@
    +
    @@ -299,12 +303,12 @@
    - 60 + 299
      -
    + log.Errorf("error executor ProcessBatchV2: %s", err.Error())
    - 61 + 300
      - sbatch := l1Block.SequencedBatches[order.Pos][0] + log.Errorf("error executor ProcessBatchV2 response: %v", batchResponse)
    - 62 + 301
      -
    + } else {
    - + + 302 -
    +
    +
    + - + batchResponseToString := processBatchResponseV2ToString(newBatchNum, batchResponse, elapsed) +
    +
    + 303 + +
      -
    + if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 63 + 304
      - if sbatch.SequencedBatchElderberryData == nil { + err = executor.ExecutorErr(batchResponse.Error)
    - 64 + + 305 +
    - - - log.Errorf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber) +   + log.Warnf("executor batch %d response, executor error: %v", newBatchNum, err) +
    +
    + 306 + +
    +   + log.Warn(batchResponseToString)
    - 65 + 307
    - - return fmt.Errorf("no elderberry sequenced batch data for batch %d", sbatch.BatchNumber) + s.eventLog.LogExecutorError(ctx, batchResponse.Error, batchRequest)
    - + + 308 -
    +
    +
      -
    + } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
    - 66 + 309
      - } + err = executor.RomErr(batchResponse.ErrorRom)
    - 67 + + 310 +
    - - - // We need to check that the sequence match +   + log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
    - 68 - -
    - - - err := g.sanityCheckExpectedSequence(sbatch.SequencedBatchElderberryData.InitSequencedBatchNumber, dbTx) -
    +
    +
    @@ -321,32 +325,32 @@
    - 69 + + 321 +
    - - - if err != nil { +   + return batchResponse, err
    - 70 + + 322 +
    - - - return err +   + }
    - 71 + + 323 +
    - - - } +   +
    - 72 + + 324 +
    - - // We known that the MaxSequenceTimestamp is the same for all the batches so we can use the first one + func processBatchResponseV2ToString(batchNum uint64, batchResponse *executor.ProcessBatchResponseV2, executionTime time.Duration) string {
    - 73 + + 325 +
    - - - err = g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0), dbTx) +   + batchResponseLog := "executor batch %d response, Time: %v, NewStateRoot: %v, NewAccInputHash: %v, NewLocalExitRoot: %v, NewBatchNumber: %v, GasUsed: %v, FlushId: %v, StoredFlushId: %v, ProverId:%v, ForkId:%v, Error: %v\n"
    - 74 + + 326 +
    - - - // The last L2block timestamp must match MaxSequenceTimestamp +   + batchResponseLog = fmt.Sprintf(batchResponseLog, batchNum, executionTime, hex.EncodeToHex(batchResponse.NewStateRoot), hex.EncodeToHex(batchResponse.NewAccInputHash), hex.EncodeToHex(batchResponse.NewLocalExitRoot),
    - 75 + + 327 +
    - - - if err != nil { +   + batchResponse.NewBatchNum, batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error)
    - 76 + + 328 +
    - - - return err +   +
    - 77 + + 329 +
    - - - } +   + for blockIndex, block := range batchResponse.BlockResponses {
    - 78 + + 330 +
    - - - // It checks the timestamp of the last L2 block, but it's just log an error instead of refusing the event +   + prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex)
    - 79 + + 331 +
    - - _ = g.sanityCheckTstampLastL2Block(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp, dbTx) + batchResponseLog += blockResponseV2ToString(block, prefix)
    - 80 + + 332 +
    - - - return nil +   + }
    - 81 + + 333 +
    - - - } +   +
    - 82 + + 334 +
    - - -
    +   + return batchResponseLog
    - 83 + + 335 +
    - - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckExpectedSequence(initialBatchNumber uint64, dbTx pgx.Tx) error { +   + }
    - 84 + + 336 +
    - - // We need to check that the sequence match + func blockResponseV2ToString(blockResponse *executor.ProcessBlockResponseV2, prefix string) string {
    - 85 + + 337 +
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) +   + blockResponseLog := prefix + "ParentHash: %v, Coinbase: %v, GasLimit: %v, BlockNumber: %v, Timestamp: %v, GlobalExitRoot: %v, BlockHashL1: %v, GasUsed: %v, BlockInfoRoot: %v, BlockHash: %v\n"
    - 86 + + 338 +
    - - - if err != nil { +   + blockResponseLog = fmt.Sprintf(blockResponseLog, common.BytesToHash(blockResponse.ParentHash), blockResponse.Coinbase, blockResponse.GasLimit, blockResponse.BlockNumber, blockResponse.Timestamp,
    - 87 + + 339 +
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +   + common.BytesToHash(blockResponse.Ger), common.BytesToHash(blockResponse.BlockHashL1), blockResponse.GasUsed, common.BytesToHash(blockResponse.BlockInfoRoot), common.BytesToHash(blockResponse.BlockHash))
    - 88 + + 340 +
    - - - return err +   +
    - 89 + + 341 +
    - - - } +   + for txIndex, tx := range blockResponse.Responses {
    - 90 + + 342 +
    - - - if lastVirtualBatchNum != initialBatchNumber { +   + prefix := " " + fmt.Sprintf("tx[%v]: ", txIndex)
    - 91 + + 343 +
    - - log.Errorf("The last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event)", lastVirtualBatchNum+1, initialBatchNumber) + blockResponseLog += transactionResponseV2ToString(tx, prefix)
    - 92 + + 344 +
    - - - return fmt.Errorf("the last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event) err:%w", lastVirtualBatchNum+1, initialBatchNumber, ErrInvalidInitialBatchNumber) +   + }
    - 93 + + 345 +
    - - - } +   +
    - 94 + + 346 +
    - - - return nil +   + return blockResponseLog
    - 95 + + 347 +
    - - +   }
    - 96 + 348
    @@ -137804,147 +213205,142 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 97 + 349
    - - func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckTstampLastL2Block(timeLimit uint64, dbTx pgx.Tx) error { + func transactionResponseV2ToString(txResponse *executor.ProcessTransactionResponseV2, prefix string) string {
    - 98 + + 350 +
    - - - lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx) +   + txResponseLog := prefix + "TxHash: %v, TxHashL2: %v, Type: %v, StateRoot:%v, GasUsed: %v, GasLeft: %v, GasRefund: %v, Error: %v\n"
    - 99 + + 351 +
    - - - if err != nil { +   + txResponseLog = fmt.Sprintf(txResponseLog, common.BytesToHash(txResponse.TxHash), common.BytesToHash(txResponse.TxHashL2), txResponse.Type,
    - 100 + + 352 +
    - - - log.Errorf("Error getting last virtual batch number: %s", err) +   + common.BytesToHash(txResponse.StateRoot), txResponse.GasUsed, txResponse.GasLeft, txResponse.GasRefunded, txResponse.Error)
    - 101 - -
    - - - return err -
    +
    +
    @@ -416,14 +420,3 @@
    - 102 + + 416 +
    - - - } +   + ClosingReason: processingCtx.ClosingReason,
    - 103 + + 417 +
    - - - lastL2Block, err := g.state.GetLastL2BlockByBatchNumber(context.Background(), lastVirtualBatchNum, dbTx) +   + }, dbTx)
    - 104 + + 418 +
    - - - if err != nil { +   + }
    - 105 + 419
    - - log.Errorf("Error getting last virtual batch number: %s", err) +
    - 106 + 420
    - - return err + // BuildChangeL2Block returns a changeL2Block tx to use in the BatchL2Data
    - 107 + 421
    - - } + func (p *State) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte {
    - 108 + 422
    - - if lastL2Block == nil { + l2block := ChangeL2BlockHeader{
    - 109 + 423
    - - //TODO: find the previous batch until we find a L2 block to check the timestamp + DeltaTimestamp: deltaTimestamp,
    - 110 + 424
    - - return nil + IndexL1InfoTree: l1InfoTreeIndex,
    - 111 + 425
    @@ -137954,61 +213350,41 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 112 - -
    - - - if uint64(lastL2Block.ReceivedAt.Unix()) > timeLimit { -
    -
    - 113 + 426
    - - log.Errorf("The last L2 block timestamp can't be greater than timeLimit. Expected: %d (L1 event), got: %d (last L2Block)", timeLimit, lastL2Block.ReceivedAt.Unix()) + var data []byte
    - 114 + 427
    - - return fmt.Errorf("wrong timestamp of last L2 block timestamp with L1 event timestamp") + data = l2block.Encode(data)
    - 115 + 428
    - - } + return data
    - 116 + 429
    - - return nil -
    -
    - 117 - -
    -   }
    - 3 + 33
      - import ( + ForcedBlockHashL1 *common.Hash
    - 4 + 34
      - "context" + SkipVerifyL1InfoRoot uint32
    - 5 + 35
      - "errors" + GlobalExitRoot common.Hash // GlobalExitRoot is not use for execute but use to OpenBatch (data on DB)
    - + + 36 -
    -   -
    +
    +
    + + + ExecutionMode uint64
    - 6 + 37
      - "time" + ClosingReason ClosingReason
    - 7 + 38
      -
    + }
    - 8 + 39
      - "github.com/0xPolygonHermez/zkevm-node/etherman" +
    - 59 + 69
      -
    + ChainId: s.cfg.ChainID,
    - 60 + 70
      - sbatch := l1Block.SequencedBatches[order.Pos][0] + ForkId: request.ForkID,
    - 61 + 71
      -
    + ContextId: uuid.NewString(),
    - 62 + 72
    + - executionTime := l1Block.ReceivedAt + ExecutionMode: request.ExecutionMode,
    - 63 + 73
      - if sbatch.SequencedBatchElderberryData == nil { -
    -
    - 64 - -
    - + - log.Warnf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber) -
    -
    - 65 - -
    - + - } else { -
    -
    - 66 - -
    - + - executionTime = time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0) + }
    - 67 + 74
    -   - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
     
    - + + 75 -
    +
    +
      -
    + if request.SkipFirstChangeL2Block_V2 {
    - - -
    -   -
    -
    +
    +
     
    - + + 132 -
    +
    +
      -
    + ForkId: forkId,
    - + + 133 -
    +
    +
      -
    + ContextId: uuid.NewString(),
    - + + 134 -
    +
    +
      -
    + SkipVerifyL1InfoRoot: skipVerifyL1InfoRoot,
    - + + 135 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode1,
    - + + 136 -
    +
    +
      -
    + }
    - + + 137 -
    +
    +
     
    - + + 138 -
    +
    +
      -
    + if forcedBlockHashL1 != nil {
    - + +
     
    -
    +
    + 171 + +
      -
    + return nil, err
    - + + 172 -
    +
    +
      -
    + } else if processBatchResponse != nil && processBatchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 68 + 173
      -
    + err = executor.ExecutorErr(processBatchResponse.Error)
    - 69 + 174
    + - return g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, executionTime, dbTx) + s.eventLog.LogExecutorErrorV2(ctx, processBatchResponse.Error, processBatchRequest)
    - + + 175 -
    +
    +
      -
    + }
    - + + 176 -
    +
    +
     
    - + + 177 -
    +
    +
      -
    + return processBatchResponse, err
    - + +
     
    -
    +
    + 233 + +
      -
    + ContextId: uuid.NewString(),
    - + + 234 -
    +
    +
      -
    + SkipVerifyL1InfoRoot: processingCtx.SkipVerifyL1InfoRoot,
    - + + 235 -
    +
    +
      -
    + L1InfoRoot: processingCtx.L1InfoRoot.Bytes(),
    - + + 236 -
    -   -
    +
    +
    + + + ExecutionMode: processingCtx.ExecutionMode,
    - + + 237 -
    +
    +
      -
    + }
    - + + 238 -
    +
    +
     
    - + + 239 -
    +
    +
      -
    + if processingCtx.ForcedBlockHashL1 != nil {
    - + +
     
    -
    +
    + 303 + +
      -
    + log.Errorf("error executor ProcessBatchV2: %s", err.Error())
    - + + 304 -
    +
    +
      -
    + log.Errorf("error executor ProcessBatchV2 response: %v", batchResponse)
    - + + 305 -
    +
    +
      -
    + } else {
    - + + 306 -
    -   -
    +
    +
    + + + batchResponseToString := processBatchResponseToString(newBatchNum, batchResponse, elapsed)
    - + + 307 -
    +
    +
      -
    + if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - + + 308 -
    +
    +
      -
    + err = executor.ExecutorErr(batchResponse.Error)
    - + + 309 -
    +
    +
      -
    + log.Warnf("executor batch %d response, executor error: %v", newBatchNum, err)
    - + + 310 -
    +
    +
      -
    + log.Warn(batchResponseToString)
    - + + 311 -
    +
    +
    + + + s.eventLog.LogExecutorErrorV2(ctx, batchResponse.Error, batchRequest) +
    +
    + 312 + +
      -
    + } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
    - 70 + 313
      - } + err = executor.RomErr(batchResponse.ErrorRom)
    -
    + + + 314 + + +
    +   + log.Warnf("executor batch %d response, ROM OOC, error: %v", newBatchNum, err)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go - RENAMED - -
    -
    -
    -
    - - - + + - - - - -
    -
    @@ -391,7 +391,7 @@
    +
     
    - 391 + 325
      - reason := reorgReasons.String() + return batchResponse, err
    - 392 + 326
      -
    + }
    - 393 + 327
      - if p.sync.IsTrustedSequencer() { +
    - 394 + + 328 +
    - - - log.Errorf("TRUSTED REORG DETECTED! Batch: %d reson:%s", batch.BatchNumber, reason) + + + func processBatchResponseToString(batchNum uint64, batchResponse *executor.ProcessBatchResponseV2, executionTime time.Duration) string {
    - 395 + 329
      - // Halt function never have to return! it must blocks the process + batchResponseLog := "executor batch %d response, Time: %v, NewStateRoot: %v, NewAccInputHash: %v, NewLocalExitRoot: %v, NewBatchNumber: %v, GasUsed: %v, FlushId: %v, StoredFlushId: %v, ProverId:%v, ForkId:%v, Error: %v\n"
    - 396 + 330
      - p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber)) + batchResponseLog = fmt.Sprintf(batchResponseLog, batchNum, executionTime, hex.EncodeToHex(batchResponse.NewStateRoot), hex.EncodeToHex(batchResponse.NewAccInputHash), hex.EncodeToHex(batchResponse.NewLocalExitRoot),
    - 397 + 331
      - log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process") -
    -
    -
    + batchResponse.NewBatchNum, batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error)
    -
    -
    - - - - - - - -
    -
     
    - 391 + 332
      - reason := reorgReasons.String() +
    - 392 + 333
      -
    + for blockIndex, block := range batchResponse.BlockResponses {
    - 393 + 334
      - if p.sync.IsTrustedSequencer() { + prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex)
    - 394 + 335
    + - log.Errorf("TRUSTED REORG DETECTED! Batch: %d reason:%s", batch.BatchNumber, reason) + batchResponseLog += blockResponseToString(block, prefix)
    - 395 + 336
      - // Halt function never have to return! it must blocks the process + }
    - 396 + 337
      - p.halt(ctx, fmt.Errorf("TRUSTED REORG DETECTED! Batch: %d", batch.BatchNumber)) +
    - 397 + 338
      - log.Errorf("CRITICAL!!!: Never have to execute this code. Halt function never have to return! it must blocks the process") + return batchResponseLog
    -
    + + + 339 + + +
    +   + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/reorg_error.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -139223,134 +214367,178 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    -
    @@ -0,0 +1,44 @@
    - + + 340 -
    -   -
    +
    +
    + + + func blockResponseToString(blockResponse *executor.ProcessBlockResponseV2, prefix string) string {
    - + + 341 -
    +
    +
      -
    + blockResponseLog := prefix + "ParentHash: %v, Coinbase: %v, GasLimit: %v, BlockNumber: %v, Timestamp: %v, GlobalExitRoot: %v, BlockHashL1: %v, GasUsed: %v, BlockInfoRoot: %v, BlockHash: %v\n"
    - + + 342 -
    +
    +
      -
    + blockResponseLog = fmt.Sprintf(blockResponseLog, common.BytesToHash(blockResponse.ParentHash), blockResponse.Coinbase, blockResponse.GasLimit, blockResponse.BlockNumber, blockResponse.Timestamp,
    - + + 343 -
    +
    +
      -
    + common.BytesToHash(blockResponse.Ger), common.BytesToHash(blockResponse.BlockHashL1), blockResponse.GasUsed, common.BytesToHash(blockResponse.BlockInfoRoot), common.BytesToHash(blockResponse.BlockHash))
    - + + 344 -
    +
    +
     
    - + + 345 -
    +
    +
      -
    + for txIndex, tx := range blockResponse.Responses {
    - + + 346 -
    +
    +
      -
    + prefix := " " + fmt.Sprintf("tx[%v]: ", txIndex)
    - + + 347 -
    -   -
    +
    +
    + + + blockResponseLog += transactionResponseToString(tx, prefix)
    - + + 348 -
    +
    +
      -
    + }
    - + + 349 -
    +
    +
     
    - + + 350 -
    +
    +
      -
    + return blockResponseLog
    - + + 351 -
    +
    +
      -
    + }
    - + + 352 -
    +
    +
     
    - + + 353 -
    -   -
    +
    +
    + + + func transactionResponseToString(txResponse *executor.ProcessTransactionResponseV2, prefix string) string {
    - + + 354 -
    +
    +
      -
    + txResponseLog := prefix + "TxHash: %v, TxHashL2: %v, Type: %v, StateRoot:%v, GasUsed: %v, GasLeft: %v, GasRefund: %v, Error: %v\n"
    - + + 355 -
    +
    +
      -
    + txResponseLog = fmt.Sprintf(txResponseLog, common.BytesToHash(txResponse.TxHash), common.BytesToHash(txResponse.TxHashL2), txResponse.Type,
    - + + 356 -
    +
    +
      -
    + common.BytesToHash(txResponse.StateRoot), txResponse.GasUsed, txResponse.GasLeft, txResponse.GasRefunded, txResponse.Error)
    - + +
     
    -
    +
    + 420 + +
      -
    + ClosingReason: processingCtx.ClosingReason,
    - + + 421 -
    +
    +
      -
    + }, dbTx)
    - + + 422 -
    +
    +
      -
    + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV2_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - @@ -139368,1589 +214556,1547 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -44,7 +44,7 @@
    +
    - + + 44 -
    +
    +
      -
    + ctx := context.Background()
    - + + 45 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 46 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 47 -
    -   -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil, nil)
    - + + 48 -
    +
    +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 49 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 50 -
    +
    +
      -
    + require.NoError(t, err)
    - + +
    @@ -122,7 +122,7 @@
    -
    +
    + 122 + +
      -
    + ctx := context.Background()
    - + + 123 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 124 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 125 -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil, nil) +
    +
    + 126 + +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 127 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 128 -
    +
    +
      -
    + require.NoError(t, err)
    - 1 + + 44 +
    - + - package common +   + ctx := context.Background()
    - 2 + + 45 +
    - + -
    +   + mockStorage := mocks.NewStorageMock(t)
    - 3 + + 46 +
    - + - import "fmt" +   + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - 4 + + 47 +
    + -
    + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil)
    - 5 + + 48 +
    - + - // ReorgError is an error that is raised when a reorg is detected +   + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - 6 + + 49 +
    - + - type ReorgError struct { +   + dbTx, err := testState.BeginStateTransaction(ctx)
    - 7 + + 50 +
    - + - // BlockNumber is the block number that caused the reorg +   + require.NoError(t, err)
    - 8 + +
     
    +
    + 122 +
    - + - BlockNumber uint64 +   + ctx := context.Background()
    - 9 + + 123 +
    - + - Err error +   + mockStorage := mocks.NewStorageMock(t)
    - 10 + + 124 +
    - + - } +   + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - 11 + + 125 +
    + -
    + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil)
    - 12 + + 126 +
    - + - // NewReorgError creates a new ReorgError +   + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - 13 + + 127 +
    - + - func NewReorgError(blockNumber uint64, err error) *ReorgError { +   + dbTx, err := testState.BeginStateTransaction(ctx)
    - 14 + + 128 +
    - + - return &ReorgError{ +   + require.NoError(t, err) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/batchV3.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -1,137 +0,0 @@
    - 15 + + 1 +
    - + - BlockNumber: blockNumber, + - + package state
    - 16 + + 2 +
    - + - Err: err, + - +
    - 17 + + 3 +
    - + - } + - + import (
    - 18 + + 4 +
    - + - } + - + "context"
    - 19 + + 5 +
    - + -
    + - + "fmt"
    - 20 + + 6 +
    - + - func (e *ReorgError) Error() string { + - + "time"
    - 21 + + 7 +
    - + - return fmt.Sprintf("%s blockNumber: %d", e.Err.Error(), e.BlockNumber) + - +
    - 22 + + 8 +
    - + - } + - + "github.com/0xPolygonHermez/zkevm-node/hex"
    - 23 + + 9 +
    - + -
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 24 + + 10 +
    - + - // IsReorgError checks if an error is a ReorgError + - + "github.com/0xPolygonHermez/zkevm-node/state/metrics"
    - 25 + + 11 +
    - + - func IsReorgError(err error) bool { + - + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
    - 26 + + 12 +
    - + - _, ok := err.(*ReorgError) + - + "github.com/google/uuid"
    - 27 + + 13 +
    - + - return ok + - + )
    - 28 + + 14 +
    - + - } + - +
    - 29 + + 15 +
    - + -
    + - + // ProcessBatchV3 processes a batch for forkID >= FEIJOA
    - 30 + + 16 +
    - + - // GetReorgErrorBlockNumber returns the block number that caused the reorg + - + func (s *State) ProcessBatchV3(ctx context.Context, request ProcessRequest, updateMerkleTree bool) (*ProcessBatchResponse, error) {
    - 31 + + 17 +
    - + - func GetReorgErrorBlockNumber(err error) uint64 { + - + updateMT := uint32(cFalse)
    - 32 + + 18 +
    - + - if reorgErr, ok := err.(*ReorgError); ok { + - + if updateMerkleTree {
    - 33 + + 19 +
    - + - return reorgErr.BlockNumber + - + updateMT = cTrue
    - 34 + + 20 +
    - + + - }
    - 35 + + 21 +
    - + - return 0 + - +
    - 36 + + 22 +
    - + - } + - + l1InfoTreeData := make(map[uint32]*executor.L1DataV3)
    - 37 + + 23 +
    - + + -
    - 38 + + 24 +
    - + - // GetReorgError returns the error that caused the reorg + - + for k, v := range request.L1InfoTreeData_V3 {
    - 39 + + 25 +
    - + - func GetReorgError(err error) error { + - + l1InfoTreeData[k] = &executor.L1DataV3{
    - 40 + + 26 +
    - + - if reorgErr, ok := err.(*ReorgError); ok { + - + GlobalExitRoot: v.GlobalExitRoot.Bytes(),
    - 41 + + 27 +
    - + - return reorgErr.Err + - + BlockHashL1: v.BlockHashL1.Bytes(),
    - 42 + + 28 +
    - + - } + - + MinTimestamp: v.MinTimestamp,
    - 43 + + 29 +
    - + - return nil + - + SmtProofPreviousIndex: v.SmtProofPreviousIndex,
    - 44 + + 30 +
    - + - } -
    -
    -
    + - + InitialHistoricRoot: v.InitialHistoricRoot.Bytes(),
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/async_l1_block_checker.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,40 @@
    - + + 31 -
    -   -
    +
    +
    + - + }
    - + + 32 -
    -   -
    +
    +
    + - + }
    - + + 33 -
    -   +
    +
    + -
    - + + 34 -
    -   -
    +
    +
    + - + // Create Batch
    - + + 35 -
    -   -
    +
    +
    + - + var processBatchRequest = &executor.ProcessBatchRequestV3{
    - + + 36 -
    -   -
    +
    +
    + - + OldStateRoot: request.OldStateRoot.Bytes(),
    - + + 37 -
    -   -
    +
    +
    + - + OldAccInputHash: request.OldAccInputHash.Bytes(),
    - + + 38 -
    -   -
    +
    +
    + - + PreviousL1InfoTreeRoot: request.PreviousL1InfoTreeRoot_V3.Bytes(),
    - + + 39 -
    -   -
    +
    +
    + - + PreviousL1InfoTreeIndex: request.PreviousL1InfoTreeIndex_V3,
    - + + 40 -
    -   -
    +
    +
    + - + ChainId: s.cfg.ChainID,
    - + + 41 -
    -   -
    +
    +
    + - + ForkId: request.ForkID,
    - + + 42 -
    -   -
    +
    +
    + - + BatchL2Data: request.Transactions,
    - + + 43 -
    -   -
    +
    +
    + - + Coinbase: request.Coinbase.String(),
    - + + 44 -
    -   -
    +
    +
    + - + UpdateMerkleTree: updateMT,
    - + + 45 -
    -   -
    +
    +
    + - + L1InfoTreeData: l1InfoTreeData,
    - + + 46 -
    -   -
    +
    +
    + - + ContextId: uuid.NewString(),
    - + + 47 -
    -   -
    +
    +
    + - + }
    - + + 48 -
    -   +
    +
    + -
    - + + 49 -
    -   -
    +
    +
    + - + if request.SkipFirstChangeL2Block_V2 {
    - + + 50 -
    -   -
    +
    +
    + - + processBatchRequest.SkipFirstChangeL2Block = cTrue
    - + + 51 -
    -   -
    +
    +
    + - + }
    - + + 52 -
    -   +
    +
    + -
    - + + 53 -
    -   -
    +
    +
    + - + if request.SkipWriteBlockInfoRoot_V2 {
    - + + 54 -
    -   -
    +
    +
    + - + processBatchRequest.SkipWriteBlockInfoRoot = cTrue
    - + + 55 -
    -   -
    +
    +
    + - + }
    - + + 56 -
    -   +
    +
    + -
    - + + 57 -
    -   -
    +
    +
    + - + res, err := s.sendBatchRequestToExecutorV3(ctx, processBatchRequest, request.Caller)
    - + + 58 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 59 -
    -   -
    +
    +
    + - + return nil, err
    - + + 60 -
    -   -
    +
    +
    + - + }
    - + + 61 -
    -   +
    +
    + -
    - + + 62 -
    -   -
    +
    +
    + - + var result *ProcessBatchResponse
    - + + 63 -
    -   -
    +
    +
    + - + result, err = s.convertToProcessBatchResponseV3(res)
    - + + 64 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 65 -
    -   -
    +
    +
    + - + return nil, err
    - + + 66 -
    -   -
    +
    +
    + - + }
    - + + 67 -
    -   +
    +
    + -
    - + + 68 -
    -   -
    +
    +
    + - + return result, nil
    - + + 69 -
    -   -
    +
    +
    + - + }
    - + + 70 -
    -   +
    +
    + -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 1 + + 71 +
    - + - package syncinterfaces + - + func (s *State) sendBatchRequestToExecutorV3(ctx context.Context, batchRequest *executor.ProcessBatchRequestV3, caller metrics.CallerLabel) (*executor.ProcessBatchResponseV3, error) {
    - 2 + + 72 +
    - + -
    + - + if s.executorClient == nil {
    - 3 + + 73 +
    - + - import ( + - + return nil, ErrExecutorNil
    - 4 + + 74 +
    - + - "context" + - + }
    - 5 + + 75 +
    - + - "fmt" + - +
    - 6 + + 76 +
    - + -
    + - + l1DataStr := ""
    - 7 + + 77 +
    - + - "github.com/0xPolygonHermez/zkevm-node/state" + - + for i, l1Data := range batchRequest.L1InfoTreeData {
    - 8 + + 78 +
    - + - ) + - + l1DataStr += fmt.Sprintf("[%d]{GlobalExitRoot: %v, BlockHashL1: %v, MinTimestamp: %v},", i, hex.EncodeToHex(l1Data.GlobalExitRoot), hex.EncodeToHex(l1Data.BlockHashL1), l1Data.MinTimestamp)
    - 9 + + 79 +
    - + -
    + - + }
    - 10 + + 80 +
    - + - type IterationResult struct { + - + if l1DataStr != "" {
    - 11 + + 81 +
    - + - Err error + - + l1DataStr = l1DataStr[:len(l1DataStr)-1]
    - 12 + + 82 +
    - + - ReorgDetected bool + - + }
    - 13 + + 83 +
    - + - BlockNumber uint64 + - +
    - 14 + + 84 +
    - + - ReorgMessage string + - + // Log the batch request
    - 15 + + 85 +
    - + - } + - + batchRequestLog := "OldStateRoot: %v, OldAccInputHash: %v, PreviousL1InfoTreeRoot: %v, PreviousL1InfoTreeIndex: %v, ChainId: %v, ForkId: %v, BatchL2Data: %v, Coinbase: %v, UpdateMerkleTree: %v, L1InfoTreeData: %+v, ContextId: %v, SkipFirstChangeL2Block: %v, SkipWriteBlockInfoRoot: %v"
    - 16 + + 86 +
    - + -
    + - + batchRequestLog = fmt.Sprintf(batchRequestLog, hex.EncodeToHex(batchRequest.OldStateRoot), hex.EncodeToHex(batchRequest.OldAccInputHash), hex.EncodeToHex(batchRequest.PreviousL1InfoTreeRoot), batchRequest.PreviousL1InfoTreeIndex, batchRequest.ChainId, batchRequest.ForkId, len(batchRequest.BatchL2Data), batchRequest.Coinbase, batchRequest.UpdateMerkleTree, l1DataStr, batchRequest.ContextId, batchRequest.SkipFirstChangeL2Block, batchRequest.SkipWriteBlockInfoRoot)
    - 17 + + 87 +
    - + - func (ir *IterationResult) String() string { + - +
    - 18 + + 88 +
    - + - if ir.Err == nil { + - + log.Debugf("executor batch request, %s", batchRequestLog)
    - 19 + + 89 +
    - + - if ir.ReorgDetected { + - +
    - 20 + + 90 +
    - + - return fmt.Sprintf("IterationResult{ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage) + - + now := time.Now()
    - 21 + + 91 +
    - + - } else { + - + batchResponse, err := s.executorClient.ProcessBatchV3(ctx, batchRequest)
    - 22 + + 92 +
    - + - return "IterationResult{None}" + - + elapsed := time.Since(now)
    - 23 + + 93 +
    - + - } + - +
    - 24 + + 94 +
    - + - } else { + - + // workarroundDuplicatedBlock(res)
    - 25 + + 95 +
    - + - return fmt.Sprintf("IterationResult{Err: %s, ReorgDetected: %v, BlockNumber: %d ReorgMessage:%s}", ir.Err.Error(), ir.ReorgDetected, ir.BlockNumber, ir.ReorgMessage) + - + if caller != metrics.DiscardCallerLabel {
    - 26 + + 96 +
    - + - } + - + metrics.ExecutorProcessingTime(string(caller), elapsed)
    - 27 + + 97 +
    - + - } + - + }
    - 28 + + 98 +
    - + + -
    - 29 + + 99 +
    - + - type AsyncL1BlockChecker interface { + - + if err != nil {
    - 30 + + 100 +
    - + - Run(ctx context.Context, onFinish func()) + - + log.Errorf("error executor ProcessBatchV3: %v", err)
    - 31 + + 101 +
    - + - RunSynchronous(ctx context.Context) IterationResult + - + log.Errorf("error executor ProcessBatchV3: %s", err.Error())
    - 32 + + 102 +
    - + - Stop() + - + log.Errorf("error executor ProcessBatchV3 response: %v", batchResponse)
    - 33 + + 103 +
    - + - GetResult() *IterationResult + - + } else {
    - 34 + + 104 +
    - + - } + - + batchResponseToString := processBatchResponseV3ToString(batchResponse, elapsed)
    - 35 + + 105 +
    - + -
    + - + if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 36 + + 106 +
    - + - type L1BlockCheckerIntegrator interface { + - + err = executor.ExecutorErr(batchResponse.Error)
    - 37 + + 107 +
    - + - OnStart(ctx context.Context) error + - + log.Warnf("executor batch response, executor error: %v", err)
    - 38 + + 108 +
    - + - OnResetState(ctx context.Context) + - + log.Warn(batchResponseToString)
    - 39 + + 109 +
    - + - CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) + - + s.eventLog.LogExecutorError(ctx, batchResponse.Error, batchRequest)
    - 40 + + 110 +
    - + - } -
    -
    -
    + - + } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR && executor.IsROMOutOfCountersError(batchResponse.ErrorRom) {
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -14,10 +14,12 @@
    - 14 + + 111 +
    -   - HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error) + - + err = executor.RomErr(batchResponse.ErrorRom)
    - 15 + + 112 +
    -   - GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error) + - + log.Warnf("executor batch response, ROM OOC, error: %v", err)
    - 16 + + 113 +
    -   - EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error) + - + log.Warn(batchResponseToString)
    - 17 + 114
    - - GetLatestBatchNumber() (uint64, error) + } else if batchResponse.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR {
    - 18 + + 115 +
    -   - GetTrustedSequencerURL() (string, error) + - + err = executor.RomErr(batchResponse.ErrorRom)
    - 19 + + 116 +
    -   - VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) + - + log.Warnf("executor batch response, ROM error: %v", err)
    - 20 + + 117 +
    -   - GetLatestVerifiedBatchNum() (uint64, error) + - + log.Warn(batchResponseToString)
    - + + 118 -
    -   -
    +
    +
    + - + } else {
    - + + 119 -
    -   -
    +
    +
    + - + log.Debug(batchResponseToString)
    - + + 120 -
    -   -
    +
    +
    + - + }
    - 21 + + 121 +
    -   - } + - + }
    - 22 + + 122 +
    -   + -
    - 23 + + 123 +
    -   - type EthermanGetLatestBatchNumber interface { + - + return batchResponse, err
    -
    + + + 124 + + +
    + - + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -140958,21 +216104,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 14 + + 125 +
    -   - HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error) + - +
    - 15 + + 126 +
    -   - GetRollupInfoByBlockRange(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error) + - + func processBatchResponseV3ToString(batchResponse *executor.ProcessBatchResponseV3, executionTime time.Duration) string {
    - 16 + + 127 +
    -   - EthBlockByNumber(ctx context.Context, blockNumber uint64) (*ethTypes.Block, error) + - + batchResponseLog := "executor batch response, Time: %v, NewStateRoot: %v, NewAccInputHash: %v, NewLocalExitRoot: %v, GasUsed: %v, FlushId: %v, StoredFlushId: %v, ProverId:%v, ForkId:%v, Error: %v\n"
    - + + 128 -
    -   -
    +
    +
    + - + batchResponseLog = fmt.Sprintf(batchResponseLog, executionTime, hex.EncodeToHex(batchResponse.NewStateRoot), hex.EncodeToHex(batchResponse.NewAccInputHash), hex.EncodeToHex(batchResponse.NewLocalExitRoot),
    - 17 + + 129 +
    -   - GetTrustedSequencerURL() (string, error) + - + batchResponse.GasUsed, batchResponse.FlushId, batchResponse.StoredFlushId, batchResponse.ProverId, batchResponse.ForkId, batchResponse.Error)
    - 18 + + 130 +
    -   - VerifyGenBlockNumber(ctx context.Context, genBlockNumber uint64) (bool, error) + - +
    - 19 + + 131 +
    -   - GetLatestVerifiedBatchNum() (uint64, error) + - + for blockIndex, block := range batchResponse.BlockResponses {
    - 20 + + 132 +
    - + -
    + - + prefix := " " + fmt.Sprintf("block[%v]: ", blockIndex)
    - 21 + + 133 +
    - + - EthermanGetLatestBatchNumber + - + batchResponseLog += blockResponseV2ToString(block, prefix)
    - 22 + + 134 +
    - + - GetFinalizedBlockNumber(ctx context.Context) (uint64, error) + - + }
    - 23 + + 135 +
    -   - } + - +
    - 24 + + 136 +
    -   -
    + - + return batchResponseLog
    - 25 + + 137 +
    -   - type EthermanGetLatestBatchNumber interface { + - + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go - RENAMED - -
    -
    @@ -140980,36 +216111,36 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -141023,13 +216154,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -141053,68 +216184,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -141138,222 +216264,174 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - -
    -
    @@ -28,7 +28,10 @@
    +
     
    - 28 + + -
    +
    +
      - AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, dbTx pgx.Tx) error +
    - 29 + + -
    +
    +
      - AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error +
    - 30 + + -
    +
    +
      - Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error +
    - 31 + + -
    +
    +
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) +
    - 32 + + -
    +
    +
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) +
    - 33 + + -
    +
    +
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    - 34 + + -
    +
    +
      - ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    -
    @@ -73,4 +76,6 @@
    -
    - 73 + + -
    +
    +
      - UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error +
    - 74 + + -
    +
    +
      - GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) +
    - 75 + + -
    +
    +
      - GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error) +
    - 76 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 28 + + -
    +
    +
      - AddForcedBatch(ctx context.Context, forcedBatch *state.ForcedBatch, dbTx pgx.Tx) error +
    - 29 + + -
    +
    +
      - AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error +
    - 30 + + -
    +
    +
      - Reset(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) error +
    - 31 + + -
    - + - GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    +   +
    - 32 + + -
    +
    +
      - GetPreviousBlock(ctx context.Context, offset uint64, dbTx pgx.Tx) (*state.Block, error) +
    - 33 + + -
    - + - GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    +   +
    - 34 + + -
    - + - UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error +
    +
    +   +
    - 35 + + -
    +
    +
      - GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) +
    - 36 + + -
    +
    +
      - GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) +
    - 37 + + -
    +
    +
      - ResetTrustedState(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error +
    -
     
    -
    - 76 + + -
    +
    +
      - UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error +
    - 77 + + -
    +
    +
      - GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) +
    - 78 + + -
    +
    +
      - GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error) +
    - 79 + + -
    - + - GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) +
    +
    +   +
    - 80 + + -
    - + - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    +   +
    - 81 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/zkevm_ethereum_compatible_client.go - RENAMED - -
    -
    -
    -
    - - - - - - - -
    -
    @@ -0,0 +1,21 @@
    @@ -141565,287 +216643,264 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + -
    - + - package syncinterfaces +
    +
    +   +
    - 2 + + -
    - + +
    +
    +  
    - 3 + + -
    - + - import ( +
    +
    +   +
    - 4 + + -
    - + - "context" +
    +
    +   +
    - 5 + + -
    - + - "math/big" +
    +
    +   +
    - 6 + + -
    - + +
    +
    +  
    - 7 + + -
    - + - "github.com/ethereum/go-ethereum/core/types" +
    +
    +   +
    - 8 + + -
    - + - ) +
    +
    +   +
    - 9 + + -
    - + +
    +
    +  
    - 10 + + -
    - + - // ZKEVMClientEthereumCompatibleInterface contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible +
    +
    +   +
    - 11 + + -
    - + - // +
    +
    +   +
    - 12 + + -
    - + - // Reason behind: the zkEVMClient have some extensions to ethereum-API that are not compatible with all nodes. So if you need to maximize +
    +
    +   +
    - 13 + + -
    - + - // the compatibility the idea is to use a regular ethereum-API compatible client +
    +
    +   +
    - 14 + + -
    - + - type ZKEVMClientEthereumCompatibleInterface interface { +
    +
    +   +
    - 15 + + -
    - + - ZKEVMClientEthereumCompatibleL2BlockGetter +
    +
    +   +
    - 16 + + -
    - + - } +
    +
    +   +
    - 17 + + -
    - + +
    +
    +  
    - 18 + + -
    - + - // ZKEVMClientEthereumCompatibleL2BlockGetter contains the methods required to interact with zkEVM-RPC as a ethereum-API compatible for obtain Block information +
    +
    +   +
    - 19 + + -
    - + - type ZKEVMClientEthereumCompatibleL2BlockGetter interface { +
    +
    +   +
    - 20 + + -
    - + - BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) +
    +
    +   +
    - 21 + + -
    - + - } +
    +
    +   +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -141869,68 +216924,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -141954,66 +217014,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -142418,6 +217488,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -1,6 +1,8 @@
    - 1 + + -
    +
    +
      - package synchronizer +
    - 2 + + -
    +
    +
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/config/types" +
    - 5 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync" +
    - 6 + + -
    +
    +
      - ) +
    -
    @@ -13,6 +15,8 @@
    +
    + + +
    +   +
    +
    - 13 + + -
    +
    +
      - SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` +
    - 14 + + -
    +
    +
      - // TrustedSequencerURL is the rpc url to connect and sync the trusted state +
    - 15 + + -
    +
    +
      - TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` +
    - 16 + + -
    +
    +
     
    - 17 + + -
    +
    +
      - // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) +
    - 18 + + -
    +
    +
      - L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` +
    -
    @@ -20,6 +24,7 @@
    +
    + + +
    +   +
    +
    - 20 + + -
    +
    +
      - // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) +
    - 21 + + -
    +
    +
      - L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` +
    - 22 + + -
    +
    +
     
    @@ -142029,66 +217094,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 23 + + -
    +
    +
      - // L1SynchronizationMode define how to synchronize with L1: +
    - 24 + + -
    +
    +
      - // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data +
    - 25 + + -
    +
    +
      - // - sequential: Request data to L1 and execute +
    -
    @@ -30,6 +35,35 @@
    +
    + + +
    +   +
    +
    - 30 + + -
    +
    +
      - L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` +
    - 31 + + -
    +
    +
      - } +
    - 32 + + -
    +
    +
     
    @@ -142384,33 +217454,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 33 + + -
    +
    +
      - // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') +
    - 34 + + -
    +
    +
      - type L1ParallelSynchronizationConfig struct { +
    - 35 + + -
    +
    +
      - // MaxClients Number of clients used to synchronize with L1 +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_in.go + RENAMED + +
    +
    @@ -142425,1091 +217510,1031 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - + + + + + + + + + - - + - + + + + + + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -1,101 +0,0 @@
    + 1 +
    -   - package synchronizer + - + package state
    + 2 +
    -   + -
    + 3 +
    -   + - import (
    + 4 +
    - + - "fmt" + - + "context"
    + 5 +
    - + -
    + - + "fmt"
    + 6 +
    -   - "github.com/0xPolygonHermez/zkevm-node/config/types" + - + "time"
    + 7 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync" + - +
    + 8 +
    -   + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 9 + +
    + - + "github.com/ethereum/go-ethereum/crypto/kzg4844" +
    +
    + 10 + +
    + - + "github.com/jackc/pgx/v4" +
    +
    + 11 + +
    + - )
    -
     
    +
    + 12 + +
    + - +
    +
    + + 13 + +
    + - + // BlobType is the type of the blob type +
    +
    + 14 + +
    + - + type BlobType uint8 +
    +
    15 +
    -   - SyncChunkSize uint64 `mapstructure:"SyncChunkSize"` + - +
    + 16 +
    -   - // TrustedSequencerURL is the rpc url to connect and sync the trusted state + - + const (
    + 17 +
    -   - TrustedSequencerURL string `mapstructure:"TrustedSequencerURL"` + - + // TypeCallData The data is stored on call data directly
    + 18 +
    - + - // SyncBlockProtection specify the state to sync (lastest, finalized or safe) + - + TypeCallData BlobType = 0
    + 19 +
    - + - SyncBlockProtection string `mapstructure:"SyncBlockProtection"` + - + // TypeBlobTransaction The data is stored on a blob
    + 20 +
    -   -
    + - + TypeBlobTransaction BlobType = 1
    + 21 +
    -   - // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless) + - + // TypeForcedBlob The data is a forced Blob
    + 22 +
    -   - L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"` + - + TypeForcedBlob BlobType = 2
    -
     
    +
    + 23 + +
    + - + ) +
    + 24 +
    -   - // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...) + - +
    + 25 +
    -   - L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` + - + func (b BlobType) String() string {
    + 26 +
    -   -
    + - + switch b {
    + 27 +
    - + - L1BlockCheck L1BlockCheckConfig `mapstructure:"L1BlockCheck"` + - + case TypeCallData:
    + 28 +
    -   - // L1SynchronizationMode define how to synchronize with L1: + - + return "call_data"
    + 29 +
    -   - // - parallel: Request data to L1 in parallel, and process sequentially. The advantage is that executor is not blocked waiting for L1 data + - + case TypeBlobTransaction:
    + 30 +
    -   - // - sequential: Request data to L1 and execute + - + return "blob"
    -
     
    +
    + 31 + +
    + - + case TypeForcedBlob: +
    + + 32 + +
    + - + return "forced" +
    +
    + 33 + +
    + - + default: +
    +
    + 34 + +
    + - + return "Unknown" +
    +
    35 +
    -   - L2Synchronization l2_sync.Config `mapstructure:"L2Synchronization"` + - + }
    + 36 +
    -   + - }
    + 37 +
    -   + -
    + 38 +
    - + - // L1BlockCheckConfig Configuration for L1 Block Checker + - + // BlobBlobTypeParams is the data for a SequenceBlob stored as a Blob
    + 39 +
    - + - type L1BlockCheckConfig struct { + - + type BlobBlobTypeParams struct {
    + 40 +
    - + - // Enable if is true then the check l1 Block Hash is active + - + BlobIndex uint64
    + 41 +
    - + - Enable bool `mapstructure:"Enable"` + - + Z []byte
    + 42 +
    - + - // L1SafeBlockPoint is the point that a block is considered safe enough to be checked + - + Y []byte
    + 43 +
    - + - // it can be: finalized, safe,pending or latest + - + Commitment kzg4844.Commitment
    + 44 +
    - + - L1SafeBlockPoint string `mapstructure:"L1SafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` + - + Proof kzg4844.Proof
    + 45 +
    - + - // L1SafeBlockOffset is the offset to add to L1SafeBlockPoint as a safe point + - + }
    + 46 +
    - + - // it can be positive or negative + - +
    + 47 +
    - + - // Example: L1SafeBlockPoint= finalized, L1SafeBlockOffset= -10, then the safe block ten blocks before the finalized block + - + // BlobInner struct
    + 48 +
    - + - L1SafeBlockOffset int `mapstructure:"L1SafeBlockOffset"` + - + type BlobInner struct {
    + 49 +
    - + - // ForceCheckBeforeStart if is true then the first time the system is started it will force to check all pending blocks + - + BlobSequenceIndex uint64 // Index of the blobSequence in DB (is a internal number)
    + 50 +
    - + - ForceCheckBeforeStart bool `mapstructure:"ForceCheckBeforeStart"` + - + BlobInnerNum uint64 // Incremental value, starts from 1
    + 51 +
    - + -
    + - + Type BlobType // Type of the blob
    + 52 +
    - + - // PreCheckEnable if is true then the pre-check is active, will check blocks between L1SafeBlock and L1PreSafeBlock + - + MaxSequenceTimestamp time.Time // it comes from SequenceBlobs call to contract
    + 53 +
    - + - PreCheckEnable bool `mapstructure:"PreCheckEnable"` + - + ZkGasLimit uint64 // it comes from SequenceBlobs call to contract
    + 54 +
    - + - // L1PreSafeBlockPoint is the point that a block is considered safe enough to be checked + - + L1InfoLeafIndex uint32 // it comes from SequenceBlobs call to contract
    + 55 +
    - + - // it can be: finalized, safe,pending or latest + - + L1InfoTreeRoot common.Hash // obtained from the L1InfoTree
    + 56 +
    - + - L1PreSafeBlockPoint string `mapstructure:"L1PreSafeBlockPoint" jsonschema:"enum=finalized,enum=safe, enum=pending,enum=latest"` + - + BlobDataHash common.Hash // Hash of the data
    + 57 +
    - + - // L1PreSafeBlockOffset is the offset to add to L1PreSafeBlockPoint as a safe point + - + BlobBlobTypeParams *BlobBlobTypeParams // Field only valid if BlobType == BlobTransaction
    + 58 +
    - + - // it can be positive or negative + - + //HowManyBatches uint64 // Number of batches in the blob
    + 59 +
    - + - // Example: L1PreSafeBlockPoint= finalized, L1PreSafeBlockOffset= -10, then the safe block ten blocks before the finalized block + - + //FirstBatchNumber uint64 // First batch number of the blob
    + 60 +
    - + - L1PreSafeBlockOffset int `mapstructure:"L1PreSafeBlockOffset"` + - + //LastBatchNumber uint64 // Last batch number of the blob
    + 61 +
    - + - } + - + // We don't need blockNumber because is in BlobSequence
    + 62 +
    - + -
    + - + //BlockNumber uint64
    + 63 +
    - + - func (c *L1BlockCheckConfig) String() string { + - + //PreviousL1InfoTreeIndex uint32 // ?? we need that?
    + 64 +
    - + - return fmt.Sprintf("Enable: %v, L1SafeBlockPoint: %s, L1SafeBlockOffset: %d, ForceCheckBeforeStart: %v", c.Enable, c.L1SafeBlockPoint, c.L1SafeBlockOffset, c.ForceCheckBeforeStart) + - + //PreviousL1InfoTreeRoot common.Hash // ?? we need that?
    + 65 +
    - + + - }
    + 66 +
    - + + -
    + 67 +
    -   - // L1ParallelSynchronizationConfig Configuration for parallel mode (if UL1SynchronizationMode equal to 'parallel') + - + func (b *BlobInner) String() string {
    + 68 +
    -   - type L1ParallelSynchronizationConfig struct { + - + res := fmt.Sprintf("BlobInner{BlobSequenceIndex:%d, BlobInnerNum:%d, Type:%s, MaxSequenceTimestamp:%s, ZkGasLimit:%d, L1InfoLeafIndex:%d, L1InfoTreeRoot:%s, BlobDataHash:%s",
    + 69 +
    -   - // MaxClients Number of clients used to synchronize with L1 -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + +
    -
    @@ -0,0 +1,183 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + - + b.BlobSequenceIndex, b.BlobInnerNum, b.Type.String(), b.MaxSequenceTimestamp.String(), b.ZkGasLimit, b.L1InfoLeafIndex, b.L1InfoTreeRoot.String(), b.BlobDataHash.String())
    - + + 70 -
    -   -
    +
    +
    + - + if b.BlobBlobTypeParams != nil {
    - + + 71 -
    -   -
    +
    +
    + - + res += ", BlobBlobTypeParams: " + b.BlobBlobTypeParams.String()
    - + + 72 -
    -   -
    +
    +
    + - + }
    - + + 73 -
    -   -
    +
    +
    + - + res += "}"
    - + + 74 -
    -   -
    +
    +
    + - + return res
    - + + 75 -
    -   -
    +
    +
    + - + }
    - + + 76 -
    -   +
    +
    + -
    - + + 77 -
    -   -
    +
    +
    + - + func (b *BlobBlobTypeParams) String() string {
    - + + 78 -
    -   -
    +
    +
    + - + return "BlobBlobTypeParams{" +
    - + + 79 -
    -   -
    +
    +
    + - + "BlobIndex: " + fmt.Sprintf("%d", b.BlobIndex) +
    - + + 80 -
    -   -
    +
    +
    + - + ", Z: " + common.Bytes2Hex(b.Z) +
    - + + 81 -
    -   -
    +
    +
    + - + ", Y: " + common.Bytes2Hex(b.Y) +
    - + + 82 -
    -   -
    +
    +
    + - + ", Commitment: " + common.Bytes2Hex(b.Commitment[:]) +
    - + + 83 -
    -   -
    +
    +
    + - + ", Proof: " + common.Bytes2Hex(b.Proof[:]) +
    - + + 84 -
    -   -
    +
    +
    + - + "}"
    - + + 85 -
    -   -
    +
    +
    + - + }
    - + + 86 -
    -   +
    +
    + -
    - + + 87 -
    -   -
    +
    +
    + - + // IsEqual compares two BlobInner
    - + + 88 -
    -   -
    +
    +
    + - + func (b *BlobInner) IsEqual(other *BlobInner) bool {
    - + + 89 -
    -   -
    +
    +
    + - + if b == nil && other == nil {
    - + + 90 -
    -   -
    +
    +
    + - + return true
    - + + 91 -
    -   -
    +
    +
    + - + }
    - + + 92 -
    -   -
    +
    +
    + - + if b == nil || other == nil {
    - + + 93 -
    -   -
    +
    +
    + - + return false
    - + + 94 -
    -   -
    +
    +
    + - + }
    - + + 95 -
    -   -
    +
    +
    + - + return b.String() == other.String()
    - + + 96 -
    -   -
    +
    +
    + - + }
    - - -
    -   +
    + 97 + +
    + -
    - + + 98 -
    -   -
    +
    +
    + - + // AddBlobInner adds a blob inner to the database, currently is just a call to storage
    - + + 99 -
    -   -
    +
    +
    + - + func (s *State) AddBlobInner(ctx context.Context, blobInner *BlobInner, dbTx pgx.Tx) error {
    - + + 100 -
    -   -
    +
    +
    + - + return s.storage.AddBlobInner(ctx, blobInner, dbTx)
    - + + 101 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -144521,185 +219546,228 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_process.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,18 +0,0 @@
    +
    - + + 1 -
    -   -
    +
    +
    + - + package state
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   +
    +
    + -
    - + + 6 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 7 -
    -   -
    +
    +
    + - + )
    - + + 8 -
    -   +
    +
    + -
    - + + 9 -
    -   -
    +
    +
    + - + // ProcessBlobInner processes a blobInner and returns the splitted batches
    - + + 10 -
    -   -
    +
    +
    + - + func (s *State) ProcessBlobInner(ctx context.Context, request ProcessBlobInnerProcessRequest, data []byte) (*ProcessBlobInnerResponse, error) {
    - + + 11 -
    -   -
    +
    +
    + - + requestExecutor := convertBlobInnerProcessRequestToExecutor(request, data)
    - + + 12 -
    -   -
    +
    +
    + - + processResponse, err := s.executorClient.ProcessBlobInnerV3(ctx, requestExecutor)
    - + + 13 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 14 -
    -   -
    +
    +
    + - + log.Errorf("Error processing blobInner: %v", err)
    - + + 15 -
    -   -
    +
    +
    + - + return nil, err
    - + + 16 -
    -   -
    +
    +
    + - + }
    - + + 17 -
    -   -
    +
    +
    + - + return newProcessBlobInnerProcessResponse(processResponse), nil
    - + + 18 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + +
    +
     
    @@ -144886,6 +219954,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_request.go + RENAMED + +
    +
    @@ -144893,2396 +219976,2824 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    +
    @@ -1,81 +0,0 @@
    + 1 +
    - + - package l1_check_block + - + package state
    + 2 +
    - + + -
    + 3 +
    - + + - import (
    + 4 +
    - + - "context" + - + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
    + 5 +
    - + - "sync" + - + "github.com/ethereum/go-ethereum/common"
    + 6 +
    - + - "time" + - + )
    + 7 +
    - + + -
    + 8 +
    - + - "github.com/0xPolygonHermez/zkevm-node/log" + - + // ProcessBlobInnerProcessRequest is the request to process a blob
    + 9 +
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + - + // you must use the builder to create the request
    + 10 +
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + - + type ProcessBlobInnerProcessRequest struct {
    + 11 +
    - + - ) + - + oldBlobStateRoot common.Hash
    + 12 +
    - + -
    + - + oldBlobAccInputHash common.Hash
    + 13 +
    - + - // L1BlockChecker is an interface that defines the method to check L1 blocks + - + oldNumBlob uint64
    + 14 +
    - + - type L1BlockChecker interface { + - + oldStateRoot common.Hash
    + 15 +
    - + - Step(ctx context.Context) error + - + forkId uint64
    + 16 +
    - + - } + - + lastL1InfoTreeIndex uint32
    + 17 +
    - + -
    + - + lastL1InfoTreeRoot common.Hash
    + 18 +
    - + - const ( + - + timestampLimit uint64
    + 19 +
    - + - defaultPeriodTime = time.Second + - + coinbase common.Address
    + 20 +
    - + - ) + - + zkGasLimit uint64
    + 21 +
    - + -
    + - + blobType BlobType
    + 22 +
    - + - // AsyncCheck is a wrapper for L1BlockChecker to become asynchronous + - + }
    + 23 +
    - + - type AsyncCheck struct { + - +
    + 24 +
    - + - checker L1BlockChecker + - + // NewProcessBlobInnerProcessRequest creates a new ProcessBlobInnerProcessRequest
    + 25 +
    - + - mutex sync.Mutex + - + func NewProcessBlobInnerProcessRequest(forkid uint64, blob *BlobInner,
    + 26 +
    - + - lastResult *syncinterfaces.IterationResult + - + previousSequence *BlobSequence,
    + 27 +
    - + - onFinishCall func() + - + currentSequence BlobSequence) (*ProcessBlobInnerProcessRequest, error) {
    + 28 +
    - + - periodTime time.Duration + - + res := &ProcessBlobInnerProcessRequest{
    + 29 +
    - + - // Wg is a wait group to wait for the result + - + forkId: forkid,
    + 30 +
    - + - Wg sync.WaitGroup + - + blobType: blob.Type,
    + 31 +
    - + - ctx context.Context + - + oldBlobStateRoot: ZeroHash, // Is always zero!
    + 32 +
    - + - cancelCtx context.CancelFunc + - + }
    + 33 +
    - + - isRunning bool + - + if previousSequence == nil {
    + 34 +
    - + - } + - + res.setAsFirstBlob()
    + 35 +
    - + -
    + - + } else {
    + 36 +
    - + - // NewAsyncCheck creates a new AsyncCheck + - + res.setPreviousSequence(*previousSequence)
    + 37 +
    - + - func NewAsyncCheck(checker L1BlockChecker) *AsyncCheck { + - + }
    + 38 +
    - + - return &AsyncCheck{ + - + res.setBlob(blob)
    + 39 +
    - + - checker: checker, + - + res.setCurrentSequence(currentSequence)
    + 40 +
    - + - periodTime: defaultPeriodTime, + - + return res, nil
    + 41 +
    - + - } + - + }
    + 42 +
    - + + - +
    +
    +
    + 43 + +
    + - + func (p *ProcessBlobInnerProcessRequest) setAsFirstBlob() { +
    +
    + 44 + +
    + - + p.oldBlobStateRoot = ZeroHash +
    +
    + 45 + +
    + - + p.oldBlobAccInputHash = ZeroHash +
    +
    + 46 + +
    + - + p.oldNumBlob = 0 +
    +
    + 47 + +
    + - + p.oldStateRoot = ZeroHash +
    +
    + 48 + +
    + - + } +
    +
    + 49 + +
    + - +
    +
    +
    + 50 + +
    + - + func (p *ProcessBlobInnerProcessRequest) setCurrentSequence(seq BlobSequence) { +
    +
    + 51 + +
    + - + p.coinbase = seq.L2Coinbase +
    +
    + 52 + +
    + - + } +
    +
    + 53 + +
    + - +
    +
    +
    + 54 + +
    + - + func (p *ProcessBlobInnerProcessRequest) setPreviousSequence(previousSequence BlobSequence) { +
    +
    + 55 + +
    + - + p.oldBlobAccInputHash = previousSequence.FinalAccInputHash +
    +
    + 56 + +
    + - + p.oldNumBlob = previousSequence.LastBlobSequenced +
    +
    + 57 + +
    + - + } +
    +
    + 58 + +
    + - +
    +
    +
    + 59 + +
    + - + func (p *ProcessBlobInnerProcessRequest) setBlob(blob *BlobInner) { +
    +
    + 60 + +
    + - + p.lastL1InfoTreeIndex = blob.L1InfoLeafIndex +
    +
    + 61 + +
    + - + p.lastL1InfoTreeRoot = blob.L1InfoTreeRoot +
    +
    + 62 + +
    + - + p.timestampLimit = uint64(blob.MaxSequenceTimestamp.Unix()) // Convert time.Time to uint64 +
    +
    + 63 + +
    + - + p.zkGasLimit = blob.ZkGasLimit +
    +
    + 64 + +
    + - + } +
    +
    + 65 + +
    + - +
    +
    +
    + 66 + +
    + - + func convertBlobInnerProcessRequestToExecutor(request ProcessBlobInnerProcessRequest, data []byte) *executor.ProcessBlobInnerRequestV3 { +
    +
    + 67 + +
    + - + return &executor.ProcessBlobInnerRequestV3{ +
    +
    + 68 + +
    + - + OldBlobStateRoot: request.oldBlobStateRoot.Bytes(), +
    +
    + 69 + +
    + - + OldBlobAccInputHash: request.oldBlobAccInputHash.Bytes(), +
    +
    + 70 + +
    + - + OldNumBlob: request.oldNumBlob, +
    +
    + 71 + +
    + - + OldStateRoot: request.oldStateRoot.Bytes(), +
    +
    + 72 + +
    + - + ForkId: request.forkId, +
    +
    + 73 + +
    + - + LastL1InfoTreeIndex: request.lastL1InfoTreeIndex, +
    +
    + 74 + +
    + - + LastL1InfoTreeRoot: request.lastL1InfoTreeRoot.Bytes(), +
    +
    + 75 + +
    + - + TimestampLimit: request.timestampLimit, +
    +
    + 76 + +
    + - + Coinbase: request.coinbase.String(), +
    +
    + 77 + +
    + - + ZkGasLimit: request.zkGasLimit, +
    +
    + 78 + +
    + - + BlobType: uint32(request.blobType), +
    +
    + 79 + +
    + - + BlobData: data, +
    +
    + 80 + +
    + - + } +
    +
    + 81 + +
    + - }
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    - 43 + + -
    - + +
    +
    +  
    - 44 + + -
    - + - // SetPeriodTime sets the period time between relaunch checker.Step +
    +
    +   +
    - 45 + + -
    - + - func (a *AsyncCheck) SetPeriodTime(periodTime time.Duration) { +
    +
    +   +
    - 46 + + -
    - + - a.periodTime = periodTime +
    +
    +   +
    - 47 + + -
    - + - } +
    +
    +   +
    - 48 + + -
    - + +
    +
    +  
    - 49 + + -
    - + - // Run is a method that starts the async check +
    +
    +   +
    - 50 + + -
    - + - func (a *AsyncCheck) Run(ctx context.Context, onFinish func()) { +
    +
    +   +
    - 51 + + -
    - + - a.mutex.Lock() +
    +
    +   +
    - 52 + + -
    - + - defer a.mutex.Unlock() +
    +
    +   +
    - 53 + + -
    - + - a.onFinishCall = onFinish +
    +
    +   +
    - 54 + + -
    - + - if a.isRunning { +
    +
    +   +
    - 55 + + -
    - + - log.Infof("%s L1BlockChecker: already running, changing onFinish call", logPrefix) +
    +
    +   +
    - 56 + + -
    - + - return +
    +
    +   +
    - 57 + + -
    - + - } +
    +
    +   +
    - 58 + + -
    - + - a.lastResult = nil +
    +
    +   +
    - 59 + + -
    - + - a.ctx, a.cancelCtx = context.WithCancel(ctx) +
    +
    +   +
    - 60 + + -
    - + - a.launchChecker(a.ctx) +
    +
    +   +
    - 61 + + -
    - + - } +
    +
    +   +
    - 62 + + -
    - + +
    +
    +  
    - 63 + + -
    - + - // Stop is a method that stops the async check +
    +
    +   +
    - 64 + + -
    - + - func (a *AsyncCheck) Stop() { +
    +
    +   +
    - 65 + + -
    - + - a.cancelCtx() +
    +
    +   +
    - 66 + + -
    - + - a.Wg.Wait() +
    +
    +   +
    - 67 + + -
    - + - } +
    +
    +   +
    - 68 + + -
    - + +
    +
    +  
    - 69 + + -
    - + - // RunSynchronous is a method that forces the check to be synchronous before starting the async check +
    +
    +   +
    - 70 + + -
    - + - func (a *AsyncCheck) RunSynchronous(ctx context.Context) syncinterfaces.IterationResult { +
    +
    +   +
    - 71 + + -
    - + - return a.executeIteration(ctx) +
    +
    +   +
    - 72 + + -
    - + - } +
    +
    +   +
    - 73 + + -
    - + +
    +
    +  
    - 74 + + -
    - + - // GetResult returns the last result of the check: +
    +
    +   +
    - 75 + + -
    - + - // - Nil -> still running +
    +
    +   +
    - 76 + + -
    - + - // - Not nil -> finished, and this is the result. You must call again Run to start a new check +
    +
    +   +
    - 77 + + -
    - + - func (a *AsyncCheck) GetResult() *syncinterfaces.IterationResult { +
    +
    +   +
    - 78 + + -
    - + - a.mutex.Lock() +
    +
    +   +
    - 79 + + -
    - + - defer a.mutex.Unlock() +
    +
    +   +
    - 80 + + -
    - + - return a.lastResult +
    +
    +   +
    - 81 + + -
    - + - } +
    +
    +   +
    - 82 + + -
    - + +
    +
    +  
    - 83 + + -
    - + - // https://stackoverflow.com/questions/32840687/timeout-for-waitgroup-wait +
    +
    +   +
    - 84 + + -
    - + - // waitTimeout waits for the waitgroup for the specified max timeout. +
    +
    +   +
    - 85 + + -
    - + - // Returns true if waiting timed out. +
    +
    +   +
    - 86 + + -
    - + - func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { +
    +
    +   +
    - 87 + + -
    - + - c := make(chan struct{}) +
    +
    +   +
    - 88 + + -
    - + - go func() { +
    +
    +   +
    - 89 + + -
    - + - defer close(c) +
    +
    +   +
    - 90 + + -
    - + - wg.Wait() +
    +
    +   +
    - 91 + + -
    - + - }() +
    +
    +   +
    - 92 + + -
    - + - select { +
    +
    +   +
    - 93 + + -
    - + - case <-c: +
    +
    +   +
    - 94 + + -
    - + - return false // completed normally +
    +
    +   +
    - 95 + + -
    - + - case <-time.After(timeout): +
    +
    +   +
    - 96 + + -
    - + - return true // timed out +
    +
    +   +
    - 97 + + -
    - + - } +
    +
    +   +
    - 98 + + -
    - + - } +
    +
    +   +
    - 99 + + -
    - + +
    +
    +  
    - 100 + + -
    - + - // GetResultBlockingUntilAvailable wait the time specific in timeout, if reach timeout returns current +
    +
    +   +
    - 101 + + -
    - + - // result, if not, wait until the result is available. +
    +
    +   +
    - 102 + + -
    - + - // if timeout is 0, it waits indefinitely +
    +
    +   +
    - 103 + + -
    - + - func (a *AsyncCheck) GetResultBlockingUntilAvailable(timeout time.Duration) *syncinterfaces.IterationResult { +
    +
    +   +
    - 104 + + -
    - + - if timeout == 0 { +
    +
    +   +
    - 105 + + -
    - + - a.Wg.Wait() +
    +
    +   +
    - 106 + + -
    - + - } else { +
    +
    +   +
    - 107 + + -
    - + - waitTimeout(&a.Wg, timeout) +
    +
    +   +
    - 108 + + -
    - + - } +
    +
    +   +
    - 109 + + -
    - + - return a.GetResult() +
    +
    +   +
    - 110 + + -
    - + - } +
    +
    +   +
    - 111 + + -
    - + +
    +
    +  
    - 112 + + -
    - + - func (a *AsyncCheck) setResult(result syncinterfaces.IterationResult) { +
    +
    +   +
    - 113 + + -
    - + - a.mutex.Lock() +
    +
    +   +
    - 114 + + -
    - + - defer a.mutex.Unlock() +
    +
    +   +
    - 115 + + -
    - + - a.lastResult = &result +
    +
    +   +
    - 116 + + -
    - + - } +
    +
    +   +
    - 117 + + -
    - + +
    +
    +  
    - 118 + + -
    - + - func (a *AsyncCheck) launchChecker(ctx context.Context) { +
    +
    +   +
    - 119 - -
    - + - // add waitGroup to wait for a result +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_inner_response.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -1,114 +0,0 @@
    - 120 + + 1 +
    - + - a.Wg.Add(1) + - + package state
    - 121 + + 2 +
    - + - a.isRunning = true + - +
    - 122 + + 3 +
    - + - go func() { + - + import (
    - 123 + + 4 +
    - + - log.Infof("%s L1BlockChecker: starting background process", logPrefix) + - + "fmt"
    - 124 + + 5 +
    - + - for { + - +
    - 125 + + 6 +
    - + - result := a.step(ctx) + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 126 + + 7 +
    - + - if result != nil { + - + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
    - 127 + + 8 +
    - + - a.setResult(*result) + - + "github.com/ethereum/go-ethereum/common"
    - 128 + + 9 +
    - + - // Result is set wg is done + - + "github.com/ethereum/go-ethereum/crypto"
    - 129 + + 10 +
    - + - break + - + )
    - 130 + + 11 +
    - + - } + - +
    - 131 + + 12 +
    - + - } + - + // ProcessBlobInnerResponse is the response of the process of a blob
    - 132 + + 13 +
    - + - log.Infof("%s L1BlockChecker: finished background process", logPrefix) + - + // the fields are private, so you need the function to access the data
    - 133 + + 14 +
    - + - a.Wg.Done() + - + // To get the outcome of the execution you must use GetSuccesfulData() it will return a nil if the execution was not successful
    - 134 + + 15 +
    - + - a.mutex.Lock() + - + // This is for forcing by interface don't access to results fields is it have an error
    - 135 + + 16 +
    - + - onFinishCall := a.onFinishCall + - + type ProcessBlobInnerResponse struct {
    - 136 + + 17 +
    - + - a.isRunning = false + - + succesfulData ProcessBlobInnerResponseSuccesful // Here is the outcome of the execution
    - 137 + + 18 +
    - + - a.mutex.Unlock() + - + isInvalid bool // Is a variable of the ROM
    - 138 + + 19 +
    - + - // call onFinish function with no mutex + - + generalError error
    - 139 + + 20 +
    - + - if onFinishCall != nil { + - + romBlobError error
    - 140 + + 21 +
    - + - onFinishCall() + - + executorVersion string // Version of the executor e.g. "v7.0.0"
    - 141 + + 22 +
    - + - } + - + errorDebugLog string // This is debug.ErrorLog that is a debug string with context data of error
    - 142 + + 23 +
    - + - }() + - + }
    - 143 + + 24 +
    - + - } + - +
    - 144 + + 25 +
    - + -
    + - + // ProcessBlobInnerResponseSuccesful is the data after a successful call to ProcessBlobInner
    - 145 + + 26 +
    - + - // step is a method that executes until executeItertion + - + type ProcessBlobInnerResponseSuccesful struct {
    - 146 + + 27 +
    - + - // returns an error or a reorg + - + newBlobStateRoot common.Hash
    - 147 + + 28 +
    - + - func (a *AsyncCheck) step(ctx context.Context) *syncinterfaces.IterationResult { + - + newBlobAccInputHash common.Hash
    - 148 + + 29 +
    - + - select { + - + newNumBlob uint64
    - 149 + + 30 +
    - + - case <-ctx.Done(): + - + finalAccBatchHashData common.Hash
    - 150 + + 31 +
    - + - log.Debugf("%s L1BlockChecker: context done", logPrefix) + - + batchData [][]byte
    - 151 + + 32 +
    - + - return &syncinterfaces.IterationResult{Err: ctx.Err()} + - + }
    - 152 + + 33 +
    - + - default: + - +
    - 153 + + 34 +
    - + - result := a.executeIteration(ctx) + - + func (p *ProcessBlobInnerResponseSuccesful) String() string {
    - 154 + + 35 +
    - + - if result.ReorgDetected { + - + res := fmt.Sprintf("newBlobStateRoot: %s newBlobAccInputHash:%s newNumBlob:%d\n", p.newBlobStateRoot.String(), p.newBlobAccInputHash.String(), p.newNumBlob)
    - 155 + + 36 +
    - + - return &result + - + res += fmt.Sprintf("finalAccBatchHashData: %s\n", p.finalAccBatchHashData.String())
    - 156 + + 37 +
    - + - } + - + res += fmt.Sprintf("HowManyBatches: %d\n", p.HowManyBatches())
    - 157 + + 38 +
    - + - log.Debugf("%s L1BlockChecker:returned %s waiting %s to relaunch", logPrefix, result.String(), a.periodTime) + - + for i := 0; i < p.HowManyBatches(); i++ {
    - 158 + + 39 +
    - + - time.Sleep(a.periodTime) + - + res += fmt.Sprintf(" Batch %d: Hash:%s\n", i, p.GetBatchHash(i).String())
    - 159 + + 40 +
    - + + - }
    - 160 + + 41 +
    - + - return nil + - + return res
    - 161 + + 42 +
    - + + - }
    - 162 + + 43 +
    - + + -
    - 163 + + 44 +
    - + - // executeIteration executes a single iteration of the checker + - + func (p *ProcessBlobInnerResponse) String() string {
    - 164 + + 45 +
    - + - func (a *AsyncCheck) executeIteration(ctx context.Context) syncinterfaces.IterationResult { + - + res := fmt.Sprintf("isInvalid: %t\n", p.isInvalid)
    - 165 + + 46 +
    - + - res := syncinterfaces.IterationResult{} + - + if p.generalError != nil {
    - 166 + + 47 +
    - + - log.Debugf("%s calling checker.Step(...)", logPrefix) + - + res += fmt.Sprintf("generalError: %s\n", p.generalError.Error())
    - 167 + + 48 +
    - + - res.Err = a.checker.Step(ctx) + - + }
    - 168 + + 49 +
    - + - log.Debugf("%s returned checker.Step(...) %w", logPrefix, res.Err) + - + if p.romBlobError != nil {
    - 169 + + 50 +
    - + - if res.Err != nil { + - + res += fmt.Sprintf("romBlobError: %s\n", p.romBlobError.Error())
    - 170 + + 51 +
    - + - log.Errorf("%s Fail check L1 Blocks: %w", logPrefix, res.Err) + - + }
    - 171 + + 52 +
    - + - if common.IsReorgError(res.Err) { + - + if p.IsSuccessfulExecution() {
    - 172 + + 53 +
    - + - // log error + - + res += p.succesfulData.String()
    - 173 + + 54 +
    - + - blockNumber := common.GetReorgErrorBlockNumber(res.Err) + - + }
    - 174 + + 55 +
    - + - log.Infof("%s Reorg detected at block %d", logPrefix, blockNumber) + - + return res
    - 175 + + 56 +
    - + - // It keeps blocked until the channel is read + - + }
    - 176 + + 57 +
    - + - res.BlockNumber = blockNumber + - +
    - 177 + + 58 +
    - + - res.ReorgDetected = true + - + // GetUnifiedError returns the combinations of errors of the execution
    - 178 + + 59 +
    - + - res.ReorgMessage = res.Err.Error() + - + func (p *ProcessBlobInnerResponse) GetUnifiedError() error {
    - 179 + + 60 +
    - + - res.Err = nil + - + if p.IsSuccessfulExecution() {
    - 180 + + 61 +
    - + - } + - + return nil
    - 181 + + 62 +
    - + + - }
    - 182 + + 63 +
    - + - return res + - + return fmt.Errorf("ProcessBlobInnerV3 fails:version:%s isInvalid: %t general:%w romBlob:%w errorLog:%s",
    - 183 + + 64 +
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/async_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -0,0 +1,138 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + - + p.executorVersion, p.isInvalid, p.generalError, p.romBlobError, p.errorDebugLog)
    - + + 65 -
    -   -
    +
    +
    + - + }
    - + + 66 -
    -   +
    +
    + -
    - + + 67 -
    -   -
    +
    +
    + - + // IsSuccessfulExecution returns true if the execution was successful
    - + + 68 -
    -   -
    +
    +
    + - + func (p *ProcessBlobInnerResponse) IsSuccessfulExecution() bool {
    - + + 69 -
    -   -
    +
    +
    + - + return !p.isInvalid && p.generalError == nil && p.romBlobError == nil
    - + + 70 -
    -   -
    +
    +
    + - + }
    - + + 71 -
    -   +
    +
    + -
    - + + 72 -
    -   -
    +
    +
    + - + // GetSuccesfulData returns the outcome data of the execution
    - + + 73 -
    -   -
    +
    +
    + - + func (p *ProcessBlobInnerResponse) GetSuccesfulData() *ProcessBlobInnerResponseSuccesful {
    - + + 74 -
    -   -
    +
    +
    + - + if !p.IsSuccessfulExecution() {
    - + + 75 -
    -   -
    +
    +
    + - + log.Error("Trying to get successful data from a failed execution")
    - + + 76 -
    -   -
    +
    +
    + - + return nil
    - + + 77 -
    -   -
    +
    +
    + - + }
    - + + 78 -
    -   -
    +
    +
    + - + return &p.succesfulData
    - + + 79 -
    -   -
    +
    +
    + - + }
    - + + 80 -
    -   +
    +
    + -
    - + + 81 -
    -   -
    +
    +
    + - + // HowManyBatches returns the number of batches
    - + + 82 -
    -   -
    +
    +
    + - + func (p *ProcessBlobInnerResponseSuccesful) HowManyBatches() int {
    - + + 83 -
    -   -
    +
    +
    + - + return len(p.batchData)
    - + + 84 -
    -   -
    +
    +
    + - + }
    - + + 85 -
    -   +
    +
    + -
    - + + 86 -
    -   -
    +
    +
    + - + // GetBatchData returns the data of the batch
    - + + 87 -
    -   -
    +
    +
    + - + func (p *ProcessBlobInnerResponseSuccesful) GetBatchData(index int) []byte {
    - + + 88 -
    -   -
    +
    +
    + - + return p.batchData[index]
    - + + 89 -
    -   -
    +
    +
    + - + }
    - + + 90 -
    -   +
    +
    + -
    - + + 91 -
    -   -
    +
    +
    + - + // GetBatchHash returns the hash of the batch data
    - + + 92 -
    -   -
    +
    +
    + - + func (p *ProcessBlobInnerResponseSuccesful) GetBatchHash(index int) common.Hash {
    - + + 93 -
    -   -
    +
    +
    + - + return crypto.Keccak256Hash(p.GetBatchData(index))
    - + + 94 -
    -   -
    +
    +
    + - + }
    - + + 95 -
    -   +
    +
    + -
    - + + 96 -
    -   -
    +
    +
    + - + func newProcessBlobInnerProcessResponse(response *executor.ProcessBlobInnerResponseV3) *ProcessBlobInnerResponse {
    - + + 97 -
    -   -
    +
    +
    + - + res := &ProcessBlobInnerResponse{
    - + + 98 -
    -   -
    +
    +
    + - + succesfulData: ProcessBlobInnerResponseSuccesful{
    - + + 99 -
    -   -
    +
    +
    + - + newBlobStateRoot: common.BytesToHash(response.NewBlobStateRoot),
    - + + 100 -
    -   -
    +
    +
    + - + newBlobAccInputHash: common.BytesToHash(response.NewBlobAccInputHash),
    - + + 101 -
    -   -
    +
    +
    + - + newNumBlob: response.NewNumBlob,
    - + + 102 -
    -   -
    +
    +
    + - + finalAccBatchHashData: common.BytesToHash(response.FinalAccBatchHashData),
    - + + 103 -
    -   -
    +
    +
    + - + batchData: response.BatchData,
    - + + 104 -
    -   -
    +
    +
    + - + },
    - + + 105 -
    -   -
    +
    +
    + - + isInvalid: response.IsInvalid == cTrue,
    - + + 106 -
    -   -
    +
    +
    + - + generalError: executor.ExecutorErr(response.Error),
    - + + 107 -
    -   -
    +
    +
    + - + romBlobError: executor.RomBlobErr(response.ErrorRomBlob),
    - + + 108 -
    -   -
    +
    +
    + - + }
    - + + 109 -
    -   -
    +
    +
    + - + if response.Debug != nil {
    - + + 110 -
    -   -
    +
    +
    + - + res.executorVersion = response.Debug.Version
    - + + 111 -
    -   -
    +
    +
    + - + res.errorDebugLog = response.Debug.ErrorLog
    - + + 112 -
    -   -
    +
    +
    + - + }
    - + + 113 -
    -   -
    +
    +
    + - + return res
    - + + 114 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - -
    +
     
    @@ -148134,1428 +223645,1198 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    -
    - 1 - -
    - + - package l1_check_block_test -
    -
    - 2 + + -
    - + +
    +
    +  
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + - "fmt" -
    -
    - 6 - -
    - + - "sync" -
    -
    - 7 - -
    - + - "testing" -
    -
    - 8 - -
    - + - "time" -
    -
    - 9 + + -
    - + +
    +
    +  
    - 10 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" -
    -
    - 11 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" -
    -
    - 12 - -
    - + - "github.com/stretchr/testify/require" -
    -
    - 13 - -
    - + - ) -
    -
    - 14 + + -
    - + +
    +
    +  
    - 15 - -
    - + - var ( -
    -
    - 16 - -
    - + - errGenericToTestAsync = fmt.Errorf("error_async") -
    -
    - 17 - -
    - + - errReorgToTestAsync = common.NewReorgError(uint64(1234), fmt.Errorf("fake reorg to test")) -
    -
    - 18 - -
    - + - timeoutContextForAsyncTests = time.Second -
    -
    - 19 - -
    - + - ) -
    -
    - 20 + + -
    - + +
    +
    +  
    - 21 - -
    - + - type mockChecker struct { -
    -
    - 22 - -
    - + - Wg *sync.WaitGroup -
    -
    - 23 - -
    - + - ErrorsToReturn []error -
    -
    - 24 - -
    - + - } -
    -
    - 25 + + -
    - + +
    +
    +  
    - 26 - -
    - + - func (m *mockChecker) Step(ctx context.Context) error { -
    -
    - 27 - -
    - + - defer m.Wg.Done() -
    -
    - 28 + + -
    - + - err := m.ErrorsToReturn[0] +
    +
    +   +
    - 29 + + -
    - + - if len(m.ErrorsToReturn) > 0 { +
    +
    +   +
    - 30 + + -
    - + - m.ErrorsToReturn = m.ErrorsToReturn[1:] +
    +
    +   +
    - 31 + + -
    - + - } +
    +
    +   +
    - 32 + + -
    - + - return err +
    +
    +   +
    - 33 + + -
    - + - } +
    +
    +   +
    - 34 + + -
    - + +
    +
    +  
    - 35 + + -
    - + - // If checker.step() returns ok, the async object will relaunch the call +
    +
    +   +
    - 36 + + -
    - + - func TestAsyncRelaunchCheckerUntilReorgDetected(t *testing.T) { +
    +
    +   +
    - 37 + + -
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    +   +
    - 38 + + -
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    +   +
    - 39 + + -
    - + - sut.SetPeriodTime(0) +
    +
    +   +
    - 40 + + -
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    +   +
    - 41 + + -
    - + - defer cancel() +
    +
    +   +
    - 42 + + -
    - + - mockChecker.Wg.Add(4) +
    +
    +   +
    - 43 + + -
    - + +
    +
    +  
    - 44 + + -
    - + - sut.Run(ctx, nil) +
    +
    +   +
    - 45 + + -
    - + +
    +
    +  
    - 46 + + -
    - + - mockChecker.Wg.Wait() +
    +
    +   +
    - 47 + + -
    - + - result := sut.GetResultBlockingUntilAvailable(0) +
    +
    +   +
    - 48 + + -
    - + - require.NotNil(t, result) +
    +
    +   +
    - 49 + + -
    - + - require.Equal(t, uint64(1234), result.BlockNumber) +
    +
    +   +
    - 50 + + -
    - + - require.Equal(t, true, result.ReorgDetected) +
    +
    +   +
    - 51 + + -
    - + - require.Equal(t, nil, result.Err) +
    +
    +   +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/blob_sequences.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -1,69 +0,0 @@
    +
    - 52 + + 1 +
    - + - } + - + package state
    - 53 + + 2 +
    - + + -
    - 54 + + 3 +
    - + - func TestAsyncGetResultIsNilUntilStops(t *testing.T) { + - + import (
    - 55 + + 4 +
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + - + "context"
    - 56 + + 5 +
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) + - + "errors"
    - 57 + + 6 +
    - + - sut.SetPeriodTime(0) + - + "fmt"
    - 58 + + 7 +
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + - + "time"
    - 59 + + 8 +
    - + - defer cancel() + - +
    - 60 + + 9 +
    - + - mockChecker.Wg.Add(4) + - + "github.com/ethereum/go-ethereum/common"
    - 61 + + 10 +
    - + - require.Nil(t, sut.GetResult(), "before start result is Nil") + - + "github.com/jackc/pgx/v4"
    - 62 + + 11 +
    - + -
    + - + )
    - 63 + + 12 +
    - + - sut.Run(ctx, nil) + - +
    - 64 + + 13 +
    - + -
    + - + var (
    - 65 + + 14 +
    - + - require.Nil(t, sut.GetResult(), "after start result is Nil") + - + // ErrBlobSequenceIndex is returned when the blob sequence index is not correct
    - 66 + + 15 +
    - + - mockChecker.Wg.Wait() + - + ErrBlobSequenceIndex = errors.New("blob sequence index is not correct")
    - 67 + + 16 +
    - + - result := sut.GetResultBlockingUntilAvailable(0) + - + // ErrBlobSequenceTime is returned when the blob sequence time is not correct
    - 68 + + 17 +
    - + - require.NotNil(t, result) + - + ErrBlobSequenceTime = errors.New("blob sequence time is not correct")
    - 69 + + 18 +
    - + - } + - + )
    - 70 + + 19 +
    - + + -
    - 71 + + 20 +
    - + - // RunSynchronous it returns the first result, doesnt mind if a reorg or not + - + // BlobSequence represents a blob sequence.
    - 72 + + 21 +
    - + - func TestAsyncGRunSynchronousReturnTheFirstResult(t *testing.T) { + - + type BlobSequence struct {
    - 73 + + 22 +
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} + - + BlobSequenceIndex uint64
    - 74 + + 23 +
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) + - + L2Coinbase common.Address
    - 75 + + 24 +
    - + - sut.SetPeriodTime(0) + - + FinalAccInputHash common.Hash
    - 76 + + 25 +
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + - + FirstBlobSequenced uint64 // Is calculated from previous blob sequence
    - 77 + + 26 +
    - + - defer cancel() + - + LastBlobSequenced uint64 // That comes from the event
    - 78 + + 27 +
    - + - mockChecker.Wg.Add(1) + - + CreateAt time.Time // time of the L1block
    - 79 + + 28 +
    - + -
    + - + ReceivedAt time.Time // time when the blob sequence is received (typically Now())
    - 80 + + 29 +
    - + - result := sut.RunSynchronous(ctx) + - + BlockNumber uint64 // L1BlockNumber where appears this event
    - 81 + + 30 +
    - + -
    + - + }
    - 82 + + 31 +
    - + - require.NotNil(t, result) + - +
    - 83 + + 32 +
    - + - require.Equal(t, uint64(0), result.BlockNumber) + - + // AddBlobSequence adds a new blob sequence to the state.
    - 84 + + 33 +
    - + - require.Equal(t, false, result.ReorgDetected) + - + // it override pgstorage.AddBlobSequence to add sanity checks
    - 85 + + 34 +
    - + - require.Equal(t, errGenericToTestAsync, result.Err) + - + func (s *State) AddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error {
    - 86 + + 35 +
    - + - } + - + err := s.sanityCheckAddBlobSequence(ctx, blobSequence, dbTx)
    - 87 + + 36 +
    - + -
    + - + if err != nil {
    - 88 + + 37 +
    - + - func TestAsyncGRunSynchronousDontAffectGetResult(t *testing.T) { + - + return err
    - 89 + + 38 +
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{errGenericToTestAsync}, Wg: &sync.WaitGroup{}} + - + }
    - 90 + + 39 +
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) + - + return s.storage.AddBlobSequence(ctx, blobSequence, dbTx)
    - 91 + + 40 +
    - + - sut.SetPeriodTime(0) + - + }
    - 92 + + 41 +
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + - +
    - 93 + + 42 +
    - + - defer cancel() + - + func (s *State) sanityCheckAddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error {
    - 94 + + 43 +
    - + - mockChecker.Wg.Add(1) + - + previousBlobSequence, err := s.GetLastBlobSequence(ctx, dbTx)
    - 95 + + 44 +
    - + -
    + - + if err != nil {
    - 96 + + 45 +
    - + - result := sut.RunSynchronous(ctx) + - + return err
    - 97 + + 46 +
    - + -
    + - + }
    - 98 + + 47 +
    - + - require.NotNil(t, result) + - + if previousBlobSequence == nil {
    - 99 + + 48 +
    - + - require.Nil(t, sut.GetResult()) + - + // Is the first one
    - 100 + + 49 +
    - + - } + - + if blobSequence.BlobSequenceIndex != 1 {
    - 101 + + 50 +
    - + -
    + - + return fmt.Errorf("TThe firstBlobSequence index must be 1, not %d. Err: %w", blobSequence.BlobSequenceIndex, ErrBlobSequenceIndex)
    - 102 + + 51 +
    - + - func TestAsyncStop(t *testing.T) { + - + }
    - 103 + + 52 +
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} + - + return nil
    - 104 + + 53 +
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) + - + }
    - 105 + + 54 +
    - + - sut.SetPeriodTime(0) + - + // The index must be the previous index + 1
    - 106 + + 55 +
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) + - + if previousBlobSequence.BlobSequenceIndex+1 != blobSequence.BlobSequenceIndex {
    - 107 + + 56 +
    - + - defer cancel() + - + return fmt.Errorf("last_index_on_db:%d try_to_insert:%d. Err: %w",
    - 108 + + 57 +
    - + - require.Nil(t, sut.GetResult(), "before start result is Nil") + - + previousBlobSequence.BlobSequenceIndex,
    - 109 + + 58 +
    - + - mockChecker.Wg.Add(4) + - + blobSequence.BlobSequenceIndex,
    - 110 + + 59 +
    - + - sut.Run(ctx, nil) + - + ErrBlobSequenceIndex)
    - 111 + + 60 +
    - + - sut.Stop() + - + }
    - 112 + + 61 +
    - + - sut.Stop() + - + // The new blob must be newer than the previous one
    - 113 + + 62 +
    - + -
    + - + if previousBlobSequence.CreateAt.After(blobSequence.CreateAt) {
    - 114 + + 63 +
    - + - result := sut.GetResultBlockingUntilAvailable(0) + - + return fmt.Errorf("last_create_at_on_db:%d try_to_insert:%d. Err: %w",
    - 115 + + 64 +
    - + - require.NotNil(t, result) + - + previousBlobSequence.CreateAt.Unix(),
    - 116 + + 65 +
    - + - mockChecker.Wg = &sync.WaitGroup{} + - + blobSequence.CreateAt.Unix(),
    - 117 + + 66 +
    - + - mockChecker.Wg.Add(4) + - + ErrBlobSequenceTime)
    - 118 + + 67 +
    - + - mockChecker.ErrorsToReturn = []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync} + - + }
    - 119 + + 68 +
    - + - sut.Run(ctx, nil) + - + return nil
    - 120 + + 69 +
    - + - mockChecker.Wg.Wait() + - + }
    - 121 - -
    - + - result = sut.GetResultBlockingUntilAvailable(0) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 122 + + -
    - + - require.NotNil(t, result) +
    +
    +   +
    - 123 + + -
    - + - } +
    +
    +   +
    - 124 + + -
    - + +
    +
    +  
    - 125 + + -
    - + - func TestAsyncMultipleRun(t *testing.T) { +
    +
    +   +
    - 126 + + -
    - + - mockChecker := &mockChecker{ErrorsToReturn: []error{nil, nil, errGenericToTestAsync, errReorgToTestAsync}, Wg: &sync.WaitGroup{}} +
    +
    +   +
    - 127 + + -
    - + - sut := l1_check_block.NewAsyncCheck(mockChecker) +
    +
    +   +
    - 128 + + -
    - + - sut.SetPeriodTime(0) +
    +
    +   +
    - 129 + + -
    - + - ctx, cancel := context.WithTimeout(context.Background(), timeoutContextForAsyncTests) +
    +
    +   +
    - 130 + + -
    - + - defer cancel() +
    +
    +   +
    - 131 + + -
    - + - require.Nil(t, sut.GetResult(), "before start result is Nil") +
    +
    +   +
    - 132 + + -
    - + - mockChecker.Wg.Add(4) +
    +
    +   +
    - 133 + + -
    - + - sut.Run(ctx, nil) +
    +
    +   +
    - 134 + + -
    - + - sut.Run(ctx, nil) +
    +
    +   +
    - 135 + + -
    - + - sut.Run(ctx, nil) +
    +
    +   +
    - 136 + + -
    - + - result := sut.GetResultBlockingUntilAvailable(0) +
    +
    +   +
    - 137 + + -
    - + - require.NotNil(t, result) +
    +
    +   +
    - 138 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block.go - RENAMED - -
    -
    -
    -
    - - - - - + + +
    -
    @@ -0,0 +1,146 @@
    @@ -150077,6 +225358,149 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV2.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -66,7 +66,6 @@
    +
    + 66 + +
    +   + ForkID: batchResponse.ForkId, +
    +
    + 67 + +
    +   + InvalidBatch_V2: batchResponse.InvalidBatch != 0, +
    +
    + 68 + +
    +   + RomError_V2: executor.RomErr(batchResponse.ErrorRom), +
    +
    + 69 + +
    + - + OldStateRoot_V2: common.BytesToHash(batchResponse.OldStateRoot), +
    +
    + 70 + +
    +   + }, nil +
    +
    + 71 + +
    +   + } +
    +
    + 72 + +
    +   +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
    +
    + 66 + +
    +   + ForkID: batchResponse.ForkId, +
    +
    + 67 + +
    +   + InvalidBatch_V2: batchResponse.InvalidBatch != 0, +
    +
    + 68 + +
    +   + RomError_V2: executor.RomErr(batchResponse.ErrorRom), +
    +
    @@ -150087,6 +225511,869 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 69 + +
    +   + }, nil +
    +
    + 70 + +
    +   + } +
    +
    + 71 + +
    +   +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/convertersV3.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -1,79 +0,0 @@
    +
    + 1 + +
    + - + package state +
    +
    + 2 + +
    + - +
    +
    +
    + 3 + +
    + - + import ( +
    +
    + 4 + +
    + - + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor" +
    +
    + 5 + +
    + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 6 + +
    + - + ) +
    +
    + 7 + +
    + - +
    +
    +
    + 8 + +
    + - + // TestConvertToProcessBatchResponseV3 for test purposes +
    +
    + 9 + +
    + - + func (s *State) TestConvertToProcessBatchResponseV3(batchResponse *executor.ProcessBatchResponseV3) (*ProcessBatchResponse, error) { +
    +
    + 10 + +
    + - + return s.convertToProcessBatchResponseV3(batchResponse) +
    +
    + 11 + +
    + - + } +
    +
    + 12 + +
    + - +
    +
    +
    + 13 + +
    + - + func (s *State) convertToProcessBatchResponseV3(batchResponse *executor.ProcessBatchResponseV3) (*ProcessBatchResponse, error) { +
    +
    + 14 + +
    + - + blockResponses, isRomLevelError, isRomOOCError, err := s.convertToProcessBlockResponseV2(batchResponse.BlockResponses) +
    +
    + 15 + +
    + - + if err != nil { +
    +
    + 16 + +
    + - + return nil, err +
    +
    + 17 + +
    + - + } +
    +
    + 18 + +
    + - + isRomOOCError = isRomOOCError || executor.IsROMOutOfCountersError(batchResponse.ErrorRom) +
    +
    + 19 + +
    + - + readWriteAddresses, err := convertToReadWriteAddressesV2(batchResponse.ReadWriteAddresses) +
    +
    + 20 + +
    + - + if err != nil { +
    +
    + 21 + +
    + - + return nil, err +
    +
    + 22 + +
    + - + } +
    +
    + 23 + +
    + - +
    +
    +
    + 24 + +
    + - + return &ProcessBatchResponse{ +
    +
    + 25 + +
    + - + NewStateRoot: common.BytesToHash(batchResponse.NewStateRoot), +
    +
    + 26 + +
    + - + NewAccInputHash: common.BytesToHash(batchResponse.NewAccInputHash), +
    +
    + 27 + +
    + - + NewLocalExitRoot: common.BytesToHash(batchResponse.NewLocalExitRoot), +
    +
    + 28 + +
    + - + UsedZkCounters: convertToUsedZKCountersV3(batchResponse), +
    +
    + 29 + +
    + - + ReservedZkCounters: convertToReservedZKCountersV3(batchResponse), +
    +
    + 30 + +
    + - + BlockResponses: blockResponses, +
    +
    + 31 + +
    + - + ExecutorError: executor.ExecutorErr(batchResponse.Error), +
    +
    + 32 + +
    + - + ReadWriteAddresses: readWriteAddresses, +
    +
    + 33 + +
    + - + FlushID: batchResponse.FlushId, +
    +
    + 34 + +
    + - + StoredFlushID: batchResponse.StoredFlushId, +
    +
    + 35 + +
    + - + ProverID: batchResponse.ProverId, +
    +
    + 36 + +
    + - + IsExecutorLevelError: batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR, +
    +
    + 37 + +
    + - + IsRomLevelError: isRomLevelError, +
    +
    + 38 + +
    + - + IsRomOOCError: isRomOOCError, +
    +
    + 39 + +
    + - + GasUsed_V2: batchResponse.GasUsed, +
    +
    + 40 + +
    + - + SMTKeys_V2: convertToKeys(batchResponse.SmtKeys), +
    +
    + 41 + +
    + - + ProgramKeys_V2: convertToKeys(batchResponse.ProgramKeys), +
    +
    + 42 + +
    + - + ForkID: batchResponse.ForkId, +
    +
    + 43 + +
    + - + InvalidBatch_V2: batchResponse.InvalidBatch != 0, +
    +
    + 44 + +
    + - + RomError_V2: executor.RomErr(batchResponse.ErrorRom), +
    +
    + 45 + +
    + - + OldStateRoot_V2: common.BytesToHash(batchResponse.OldStateRoot), +
    +
    + 46 + +
    + - + NewLastTimestamp_V3: batchResponse.NewLastTimestamp, +
    +
    + 47 + +
    + - + CurrentL1InfoTreeRoot_V3: common.BytesToHash(batchResponse.CurrentL1InfoTreeRoot), +
    +
    + 48 + +
    + - + CurrentL1InfoTreeIndex_V3: batchResponse.CurrentL1InfoTreeIndex, +
    +
    + 49 + +
    + - + }, nil +
    +
    + 50 + +
    + - + } +
    +
    + 51 + +
    + - +
    +
    +
    + 52 + +
    + - + func convertToUsedZKCountersV3(resp *executor.ProcessBatchResponseV3) ZKCounters { +
    +
    + 53 + +
    + - + return ZKCounters{ +
    +
    + 54 + +
    + - + GasUsed: resp.GasUsed, +
    +
    + 55 + +
    + - + KeccakHashes: resp.CntKeccakHashes, +
    +
    + 56 + +
    + - + PoseidonHashes: resp.CntPoseidonHashes, +
    +
    + 57 + +
    + - + PoseidonPaddings: resp.CntPoseidonPaddings, +
    +
    + 58 + +
    + - + MemAligns: resp.CntMemAligns, +
    +
    + 59 + +
    + - + Arithmetics: resp.CntArithmetics, +
    +
    + 60 + +
    + - + Binaries: resp.CntBinaries, +
    +
    + 61 + +
    + - + Steps: resp.CntSteps, +
    +
    + 62 + +
    + - + Sha256Hashes_V2: resp.CntSha256Hashes, +
    +
    + 63 + +
    + - + } +
    +
    + 64 + +
    + - + } +
    +
    + 65 + +
    + - +
    +
    +
    + 66 + +
    + - + func convertToReservedZKCountersV3(resp *executor.ProcessBatchResponseV3) ZKCounters { +
    +
    + 67 + +
    + - + return ZKCounters{ +
    +
    + 68 + +
    + - + // There is no "ReserveGasUsed" in the response, so we use "GasUsed" as it will make calculations easier +
    +
    + 69 + +
    + - + GasUsed: resp.GasUsed, +
    +
    + 70 + +
    + - + KeccakHashes: resp.CntReserveKeccakHashes, +
    +
    + 71 + +
    + - + PoseidonHashes: resp.CntReservePoseidonHashes, +
    +
    + 72 + +
    + - + PoseidonPaddings: resp.CntReservePoseidonPaddings, +
    +
    + 73 + +
    + - + MemAligns: resp.CntReserveMemAligns, +
    +
    + 74 + +
    + - + Arithmetics: resp.CntReserveArithmetics, +
    +
    + 75 + +
    + - + Binaries: resp.CntReserveBinaries, +
    +
    + 76 + +
    + - + Steps: resp.CntReserveSteps, +
    +
    + 77 + +
    + - + Sha256Hashes_V2: resp.CntReserveSha256Hashes, +
    +
    + 78 + +
    + - + } +
    +
    + 79 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    +
    @@ -150877,34 +227164,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/datastream.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -150918,63 +227234,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -150988,31 +227309,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
    @@ -80,6 +80,7 @@
    +
    - + + 80 -
    +
    +
      -
    + Coinbase common.Address // 20 bytes
    - + + 81 -
    +
    +
      -
    + ForkID uint16 // 2 bytes
    - + + 82 -
    +
    +
      -
    + ChainID uint32 // 4 bytes
    - + + 83 -
    +
    +
      -
    + }
    - + + 84 -
    +
    +
     
    - + + 85 -
    +
    +
      -
    + // Encode returns the encoded DSL2BlockStart as a byte slice
    - + +
    @@ -110,6 +111,7 @@
    -
    +
    + 110 + +
      -
    + b.Coinbase = common.BytesToAddress(data[96:116])
    - + + 111 -
    +
    +
      -
    + b.ForkID = binary.BigEndian.Uint16(data[116:118])
    - + + 112 -
    +
    +
      -
    + b.ChainID = binary.BigEndian.Uint32(data[118:122])
    - + + 113 -
    +
    +
      -
    + return b
    - + + 114 -
    +
    +
      -
    + }
    - + + 115 -
    +
    +
     
    @@ -151032,528 +227353,696 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - 1 + + 80 +
    - + - package l1_check_block +   + Coinbase common.Address // 20 bytes
    - 2 + + 81 +
    - + -
    +   + ForkID uint16 // 2 bytes
    - 3 + + 82 +
    - + - import ( +   + ChainID uint32 // 4 bytes
    - 4 + 83
    + - "context" +
    - 5 + + 84 +
    - + - "errors" +   + }
    - 6 + + 85 +
    - + - "fmt" +   +
    - 7 + + 86 +
    - + - "math/big" +   + // Encode returns the encoded DSL2BlockStart as a byte slice
    - 8 + +
     
    +
    + 111 +
    - + - "time" +   + b.Coinbase = common.BytesToAddress(data[96:116])
    - 9 + + 112 +
    - + -
    +   + b.ForkID = binary.BigEndian.Uint16(data[116:118])
    - 10 + + 113 +
    - + - "github.com/0xPolygonHermez/zkevm-node/log" +   + b.ChainID = binary.BigEndian.Uint32(data[118:122])
    - 11 + 114
    + - "github.com/0xPolygonHermez/zkevm-node/state" +
    - 12 + + 115 +
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +   + return b
    - 13 + + 116 +
    - + - "github.com/ethereum/go-ethereum/core/types" +   + }
    - 14 + + 117 +
    - + - "github.com/jackc/pgx/v4" +   +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/effectivegasprice.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,44 @@
    +
    - 15 + + -
    - + - ) +
    +
    +   +
    - 16 + + -
    - + +
    +
    +  
    - 17 + + -
    - + - // This object check old L1block to double-check that the L1block hash is correct +
    +
    +   +
    - 18 + + -
    - + - // - Get first not checked block +
    +
    +   +
    - 19 + + -
    - + - // - Get last block on L1 (safe/finalized/ or minus -n) +
    +
    +   +
    - 20 + + -
    - + +
    +
    +  
    - 21 + + -
    - + - // L1Requester is an interface for GETH client +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 22 + + -
    - + - type L1Requester interface { +
    +
    +   +
    - 23 + + -
    - + - HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) +
    +
    +   +
    - 24 + + -
    - + - } +
    +
    +   +
    - 25 + + -
    - + +
    +
    +  
    - 26 + + -
    - + - // StateInterfacer is an interface for the state +
    +
    +   +
    - 27 + + -
    - + - type StateInterfacer interface { +
    +
    +   +
    - 28 + + -
    - + - GetFirstUncheckedBlock(ctx context.Context, fromBlockNumber uint64, dbTx pgx.Tx) (*state.Block, error) +
    +
    +   +
    - 29 + + -
    - + - UpdateCheckedBlockByNumber(ctx context.Context, blockNumber uint64, newCheckedStatus bool, dbTx pgx.Tx) error +
    +
    +   +
    - 30 + + -
    - + - } +
    +
    +   +
    - 31 + + -
    - + +
    +
    +  
    - 32 + + -
    - + - // SafeL1BlockNumberFetcher is an interface for fetching the L1 block number reference point (safe, finalized,...) +
    +
    +   +
    - 33 + + -
    - + - type SafeL1BlockNumberFetcher interface { +
    +
    +   +
    - 34 + + -
    - + - GetSafeBlockNumber(ctx context.Context, l1Client L1Requester) (uint64, error) +
    +
    +   +
    - 35 + + -
    - + - Description() string +
    +
    +   +
    - 36 + + -
    - + - } +
    +
    +   +
    - 37 + + -
    - + +
    +
    +  
    - 38 + + -
    - + - // CheckL1BlockHash is a struct that implements a checker of L1Block hash +
    +
    +   +
    - 39 + + -
    - + - type CheckL1BlockHash struct { +
    +
    +   +
    - 40 + + -
    - + - L1Client L1Requester +
    +
    +   +
    - 41 + + -
    - + - State StateInterfacer +
    +
    +   +
    - 42 + + -
    - + - SafeBlockNumberFetcher SafeL1BlockNumberFetcher +
    +
    +   +
    - 43 + + -
    - + - } +
    +
    +   +
    - 44 + + -
    - + +
    +
    +  
    - 45 + + -
    - + - // NewCheckL1BlockHash creates a new CheckL1BlockHash +
    +
    +   +
    - 46 + + -
    - + - func NewCheckL1BlockHash(l1Client L1Requester, state StateInterfacer, safeBlockNumberFetcher SafeL1BlockNumberFetcher) *CheckL1BlockHash { +
    +
    +   +
    +
    +
    +
    +
    +
    + + + + + - - - + +
    +
     
    - 47 + 1
    + - return &CheckL1BlockHash{ + package state
    - 48 + 2
    + - L1Client: l1Client, +
    - 49 + 3
    + - State: state, + import (
    - 50 + 4
    + - SafeBlockNumberFetcher: safeBlockNumberFetcher, + "errors"
    - 51 + 5
    + - } + "math/big"
    - 52 + 6
    + - } + )
    - 53 + 7
    @@ -151563,47 +228052,47 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 54 + 8
    + - // Name is a method that returns the name of the checker + const (
    - 55 + 9
    + - func (p *CheckL1BlockHash) Name() string { + // MaxEffectivePercentage is the maximum value that can be used as effective percentage
    - 56 + 10
    + - return logPrefix + " main_checker: " + MaxEffectivePercentage = uint8(255)
    - 57 + 11
    + - } + )
    - 58 + 12
    @@ -151613,217 +228102,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 59 + 13
    + - // Step is a method that checks the L1 block hash, run until all blocks are checked and returns + var (
    - 60 + 14
    + - func (p *CheckL1BlockHash) Step(ctx context.Context) error { + // ErrEffectiveGasPriceEmpty happens when the effectiveGasPrice or gasPrice is nil or zero
    - 61 + 15
    + - stateBlock, err := p.State.GetFirstUncheckedBlock(ctx, uint64(0), nil) + ErrEffectiveGasPriceEmpty = errors.New("effectiveGasPrice or gasPrice cannot be nil or zero")
    - 62 + 16
    + - if errors.Is(err, state.ErrNotFound) { +
    - 63 + 17
    + - log.Debugf("%s: No unchecked blocks to check", p.Name()) + // ErrEffectiveGasPriceIsZero happens when the calculated EffectiveGasPrice is zero
    - 64 + 18
    + - return nil + ErrEffectiveGasPriceIsZero = errors.New("effectiveGasPrice cannot be zero")
    - 65 + 19
    + - } + )
    - 66 + 20
    + - if err != nil { +
    - 67 + 21
    + - return err + // CalculateEffectiveGasPricePercentage calculates the gas price's effective percentage
    - 68 + 22
    + - } + func CalculateEffectiveGasPricePercentage(gasPrice *big.Int, effectiveGasPrice *big.Int) (uint8, error) {
    - 69 + 23
    + - if stateBlock == nil { + const bits = 256
    - 70 + 24
    + - log.Warnf("%s: function CheckL1Block receive a nil pointer", p.Name()) + var bitsBigInt = big.NewInt(bits)
    - 71 + 25
    + - return nil +
    - 72 + 26
    + - } + if effectiveGasPrice == nil || gasPrice == nil ||
    - 73 + 27
    + - safeBlockNumber, err := p.SafeBlockNumberFetcher.GetSafeBlockNumber(ctx, p.L1Client) + gasPrice.Cmp(big.NewInt(0)) == 0 || effectiveGasPrice.Cmp(big.NewInt(0)) == 0 {
    - 74 + 28
    + - if err != nil { + return 0, ErrEffectiveGasPriceEmpty
    - 75 + 29
    + - return err + }
    - 76 + 30
    + - } +
    - 77 + 31
    + - log.Debugf("%s: checking from block (%s) %d first block to check: %d....", p.Name(), p.SafeBlockNumberFetcher.Description(), safeBlockNumber, stateBlock.BlockNumber) + if gasPrice.Cmp(effectiveGasPrice) <= 0 {
    - 78 + 32
    + - return p.doAllBlocks(ctx, *stateBlock, safeBlockNumber) + return MaxEffectivePercentage, nil
    - 79 + 33
    + - } + }
    - 80 + 34
    @@ -151833,871 +228322,881 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 81 + 35
    + - func (p *CheckL1BlockHash) doAllBlocks(ctx context.Context, firstStateBlock state.Block, safeBlockNumber uint64) error { + // Simulate Ceil with integer division
    - 82 + 36
    + - var err error + b := new(big.Int).Mul(effectiveGasPrice, bitsBigInt)
    - 83 + 37
    + - startTime := time.Now() + b = b.Add(b, gasPrice)
    - 84 + 38
    + - stateBlock := &firstStateBlock + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd
    - 85 + 39
    + - numBlocksChecked := 0 + b = b.Div(b, gasPrice)
    - 86 + 40
    + - for { + // At this point we have a percentage between 1-256, we need to sub 1 to have it between 0-255 (byte)
    - 87 + 41
    + - lastStateBlockNumber := stateBlock.BlockNumber + b = b.Sub(b, big.NewInt(1)) //nolint:gomnd
    - 88 + 42
    + - if stateBlock.BlockNumber > safeBlockNumber { +
    - 89 + 43
    + - log.Debugf("%s: block %d to check is not still safe enough (%s) %d ", p.Name(), stateBlock.BlockNumber, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, logPrefix) + return uint8(b.Uint64()), nil
    - 90 + 44
    + - return nil + }
    - 91 - -
    - + - } +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/encoding_batch_v2.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -2,13 +2,7 @@
    - 92 + + 2 +
    - + - err = p.doBlock(ctx, stateBlock) +   + This file provide functions to work with ETROG batches:
    - 93 + + 3 +
    - + - if err != nil { +   + - EncodeBatchV2 (equivalent to EncodeTransactions)
    - 94 + + 4 +
    - + - return err +   + - DecodeBatchV2 (equivalent to DecodeTxs)
    - 95 + + 5 +
    - + - } + - + - DecodeForcedBatchV2
    - 96 + + 6 +
    - + - numBlocksChecked++ + - +
    - 97 + + 7 +
    - + - stateBlock, err = p.State.GetFirstUncheckedBlock(ctx, lastStateBlockNumber, nil) + - + Also provide a builder class to create batches (BatchV2Encoder):
    - 98 + + 8 +
    - + - if errors.Is(err, state.ErrNotFound) { + - + This method doesnt check anything, so is more flexible but you need to know what you are doing
    - 99 + + 9 +
    - + - diff := time.Since(startTime) + - + - `builder := NewBatchV2Encoder()` : Create a new `BatchV2Encoder``
    - 100 + + 10 +
    - + - log.Infof("%s: checked all blocks (%d) (using as safe Block Point(%s): %d) time:%s", p.Name(), numBlocksChecked, p.SafeBlockNumberFetcher.Description(), safeBlockNumber, diff) + - + - You can call to `AddBlockHeader` or `AddTransaction` to add a block header or a transaction as you wish
    - 101 + + 11 +
    - + - return nil + - + - You can call to `GetResult` to get the batch data
    - 102 + + 12 +
    - + - } +   +
    - 103 + + 13 +
    - + - } +   +
    - 104 + + 14 +
    - + - } +   + // batch data format:
    - 105 + +
    @@ -33,25 +27,11 @@
    +
    + 33 +
    - + -
    +   + // 0x00 | 32 | V
    - 106 + + 34 +
    - + - func (p *CheckL1BlockHash) doBlock(ctx context.Context, stateBlock *state.Block) error { +   + // 0x00 | 1 | efficiencyPercentage
    - 107 + + 35 +
    - + - err := CheckBlockHash(ctx, stateBlock, p.L1Client, p.Name()) +   + // Repeat Transaction
    - 108 + + 36 +
    - + - if err != nil { + - + //
    - 109 + + 37 +
    - + - return err + - + // Usage:
    - 110 + + 38 +
    - + - } + - + // There are 2 ways of use this module, direct calls or a builder class:
    - 111 + + 39 +
    - + - log.Infof("%s: L1Block: %d hash: %s is correct marking as checked", p.Name(), stateBlock.BlockNumber, + - + // 1) Direct calls:
    - 112 + + 40 +
    - + - stateBlock.BlockHash.String()) + - + // - EncodeBatchV2: Encode a batch of transactions
    - 113 + + 41 +
    - + - err = p.State.UpdateCheckedBlockByNumber(ctx, stateBlock.BlockNumber, true, nil) + - + // - DecodeBatchV2: Decode a batch of transactions
    - 114 + + 42 +
    - + - if err != nil { + - + //
    - 115 + + 43 +
    - + - log.Errorf("%s: Error updating block %d as checked. err: %s", p.Name(), stateBlock.BlockNumber, err.Error()) + - + // 2) Builder class:
    - 116 + + 44 +
    - + - return err + - + // This method doesnt check anything, so is more flexible but you need to know what you are doing
    - 117 + + 45 +
    - + - } + - + // - builder := NewBatchV2Encoder(): Create a new BatchV2Encoder
    - 118 + + 46 +
    - + - return nil + - + // - You can call to `AddBlockHeader` or `AddTransaction` to add a block header or a transaction as you wish
    - 119 + + 47 +
    - + - } + - + // - You can call to `GetResult` to get the batch data
    - 120 + + 48 +
    - + + -
    - 121 + + 49 +
    - + - // CheckBlockHash is a method that checks the L1 block hash +   + */
    - 122 + + 50 +
    - + - func CheckBlockHash(ctx context.Context, stateBlock *state.Block, L1Client L1Requester, checkerName string) error { +   +
    - 123 + + 51 +
    - + - if stateBlock == nil { +   + package state
    - 124 + + 52 +
    - + - log.Warn("%s function CheckL1Block receive a nil pointer", checkerName) +   +
    - 125 + + 53 +
    - + - return nil +   + import (
    - 126 + + 54 +
    - + - } + - + "encoding/binary"
    - 127 + + 55 +
    - + - l1Block, err := L1Client.HeaderByNumber(ctx, big.NewInt(int64(stateBlock.BlockNumber))) +   + "errors"
    - 128 + + 56 +
    - + - if err != nil { +   + "fmt"
    - 129 + + 57 +
    - + - return err +   + "strconv"
    - 130 + +
    @@ -62,16 +42,11 @@
    +
    + 62 +
    - + - } +   + "github.com/ethereum/go-ethereum/rlp"
    - 131 + + 63 +
    - + - if l1Block == nil { +   + )
    - 132 + + 64 +
    - + - err = fmt.Errorf("%s request of block: %d to L1 returns a nil", checkerName, stateBlock.BlockNumber) +   +
    - 133 + + 65 +
    - + - log.Error(err.Error()) + - + // ChangeL2BlockHeader is the header of a L2 block.
    - 134 + + 66 +
    - + - return err + - + type ChangeL2BlockHeader struct {
    - 135 + + 67 +
    - + - } + - + DeltaTimestamp uint32
    - 136 + + 68 +
    - + - if l1Block.Hash() != stateBlock.BlockHash { + - + IndexL1InfoTree uint32
    - 137 + + 69 +
    - + - msg := fmt.Sprintf("%s Reorg detected at block %d l1Block.Hash=%s != stateBlock.Hash=%s. ", checkerName, stateBlock.BlockNumber, + - + }
    - 138 + + 70 +
    - + - l1Block.Hash().String(), stateBlock.BlockHash.String()) + - +
    - 139 + + 71 +
    - + - if l1Block.ParentHash != stateBlock.ParentHash { +   + // L2BlockRaw is the raw representation of a L2 block.
    - 140 + + 72 +
    - + - msg += fmt.Sprintf(" ParentHash are also different. l1Block.ParentHash=%s != stateBlock.ParentHash=%s", l1Block.ParentHash.String(), stateBlock.ParentHash.String()) +   + type L2BlockRaw struct {
    - 141 + + 73 +
    - + - } + - + ChangeL2BlockHeader
    - 142 + + 74 +
    - + - log.Errorf(msg) + - + Transactions []L2TxRaw
    - 143 + + -
    - + - return common.NewReorgError(stateBlock.BlockNumber, fmt.Errorf(msg)) +
    +
    +   +
    - 144 + + 75 +
    - + - } +   + }
    - 145 + + 76 +
    - + - return nil +   +
    - 146 + + 77 +
    - + - } +   + // BatchRawV2 is the representation of a batch of transactions.
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/check_l1block_test.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -152721,43 +229220,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -152771,743 +229270,743 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -153521,41 +230020,41 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - + + + - - - - -
    -
    @@ -0,0 +1,128 @@
    +
    @@ -86,15 +61,12 @@
    - + + 86 -
    +
    +
     
    - + + 87 -
    +
    +
      -
    + // L2TxRaw is the raw representation of a L2 transaction inside a L2 block.
    - + + 88 -
    +
    +
      -
    + type L2TxRaw struct {
    - - -
    -   -
    +
    + 89 + +
    + - + EfficiencyPercentage uint8 // valid always
    - + + 90 -
    -   -
    +
    +
    + - + TxAlreadyEncoded bool // If true the tx is already encoded (data field is used)
    - + + 91 -
    -   -
    +
    +
    + - + Tx types.Transaction // valid if TxAlreadyEncoded == false
    - + + 92 -
    -   -
    +
    +
    + - + Data []byte // valid if TxAlreadyEncoded == true
    - + + 93 -
    +
    +
      -
    + }
    - + + 94 -
    +
    +
     
    - + + 95 -
    +
    +
      -
    + const (
    - + + 96 -
    +
    +
      -
    + changeL2Block = uint8(0x0b)
    - + + 97 -
    -   -
    +
    +
    + - + sizeUInt32 = 4
    - + + 98 -
    +
    +
      -
    + )
    - + + 99 -
    +
    +
     
    - + + 100 -
    +
    +
      -
    + var (
    - + +
    @@ -120,88 +92,57 @@
    -
    +
    + 120 + +
     
    - + + 121 -
    +
    +
      -
    + // EncodeBatchV2 encodes a batch of transactions into a byte slice.
    - + + 122 -
    +
    +
      -
    + func EncodeBatchV2(batch *BatchRawV2) ([]byte, error) {
    - + + 123 -
    +
    +
      -
    + if batch == nil {
    - + + 124 -
    +
    +
      -
    + return nil, fmt.Errorf("batch is nil: %w", ErrInvalidBatchV2)
    - + + 125 -
    +
    +
      -
    + }
    - + + 126 -
    -   -
    +
    +
    + - + if len(batch.Blocks) == 0 {
    - + + 127 -
    +
    +
      -
    + return nil, fmt.Errorf("a batch need minimum a L2Block: %w", ErrInvalidBatchV2)
    - + + 128 -
    +
    +
      -
    + }
    - + + 129 -
    -   +
    +
    + -
    - + + 130 -
    -   -
    +
    +
    + - + encoder := NewBatchV2Encoder()
    - + + 131 -
    -   -
    +
    +
    + - + for _, block := range batch.Blocks {
    - + + 132 -
    -   -
    +
    +
    + - + encoder.AddBlockHeader(block.ChangeL2BlockHeader)
    - + + 133 -
    -   -
    +
    +
    + - + err := encoder.AddTransactions(block.Transactions)
    - + + 134 -
    +
    +
      -
    + if err != nil {
    - + + 135 -
    -   -
    +
    +
    + - + return nil, fmt.Errorf("can't encode tx: %w", err)
    - + + 136 -
    +
    +
      -
    + }
    - + + 137 -
    -   -
    +
    +
    + - + }
    - + + 138 -
    -   -
    +
    +
    + - + return encoder.GetResult(), nil
    - + + 139 -
    -   -
    +
    +
    + - + }
    - + + 140 -
    -   +
    +
    + -
    - + + 141 -
    -   -
    +
    +
    + - + // BatchV2Encoder is a builder of the batchl2data used by EncodeBatchV2
    - + + 142 -
    -   -
    +
    +
    + - + type BatchV2Encoder struct {
    - + + 143 -
    -   -
    +
    +
    + - + batchData []byte
    - + + 144 -
    -   -
    +
    +
    + - + }
    - + + 145 -
    -   +
    +
    + -
    - + + 146 -
    -   -
    +
    +
    + - + // NewBatchV2Encoder creates a new BatchV2Encoder.
    - + + 147 -
    -   -
    +
    +
    + - + func NewBatchV2Encoder() *BatchV2Encoder {
    - + + 148 -
    -   -
    +
    +
    + - + return &BatchV2Encoder{}
    - + + 149 -
    -   -
    +
    +
    + - + }
    - + + 150 -
    -   +
    +
    + -
    - + + 151 -
    -   -
    +
    +
    + - + // AddBlockHeader adds a block header to the batch.
    - + + 152 -
    -   -
    +
    +
    + - + func (b *BatchV2Encoder) AddBlockHeader(l2BlockHeader ChangeL2BlockHeader) {
    - + + 153 -
    -   -
    +
    +
    + - + b.batchData = l2BlockHeader.Encode(b.batchData)
    - + + 154 -
    -   -
    +
    +
    + - + }
    - + + 155 -
    -   +
    +
    + -
    - + + 156 -
    -   -
    +
    +
    + - + // AddTransactions adds a set of transactions to the batch.
    - + + 157 -
    -   -
    +
    +
    + - + func (b *BatchV2Encoder) AddTransactions(transactions []L2TxRaw) error {
    - + + 158 -
    -   -
    +
    +
    + - + for _, tx := range transactions {
    - + + 159 -
    -   -
    +
    +
    + - + err := b.AddTransaction(tx)
    - + + 160 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 161 -
    -   -
    +
    +
    + - + return fmt.Errorf("can't encode tx: %w", err)
    - + + 162 -
    +
    +
      -
    + }
    - + + 163 -
    +
    +
      -
    + }
    - + + 164 -
    -   -
    +
    +
    + - + return nil
    - + + 165 -
    -   -
    +
    +
    + - + }
    - + + 166 -
    -   +
    +
    + -
    - + + 167 -
    -   -
    +
    +
    + - + // AddTransaction adds a transaction to the batch.
    - + + 168 -
    -   -
    +
    +
    + - + func (b *BatchV2Encoder) AddTransaction(transaction L2TxRaw) error {
    - + + 169 -
    -   -
    +
    +
    + - + var err error
    - + + 170 -
    -   -
    +
    +
    + - + b.batchData, err = transaction.Encode(b.batchData)
    - + + 171 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 172 -
    -   -
    +
    +
    + - + return fmt.Errorf("can't encode tx: %w", err)
    - + + 173 -
    -   -
    +
    +
    + - + }
    - + + 174 -
    -   -
    +
    +
    + - + return nil
    - + + 175 -
    -   -
    +
    +
    + - + }
    - + + 176 -
    -   +
    +
    + -
    - + + 177 -
    -   -
    +
    +
    + - + // GetResult returns the batch data.
    - + + 178 -
    -   -
    +
    +
    + - + func (b *BatchV2Encoder) GetResult() []byte {
    - + + 179 -
    -   -
    +
    +
    + - + return b.batchData
    - + + 180 -
    +
    +
      -
    + }
    - + + 181 -
    +
    +
     
    - + + 182 -
    -   -
    +
    +
    + - + // Encode encodes a batch of l2blocks header into a byte slice.
    - + + 183 -
    -   -
    +
    +
    + - + func (c ChangeL2BlockHeader) Encode(batchData []byte) []byte {
    - + + 184 -
    +
    +
      -
    + batchData = append(batchData, changeL2Block)
    - + + 185 -
    -   -
    +
    +
    + - + batchData = append(batchData, encodeUint32(c.DeltaTimestamp)...)
    - + + 186 -
    -   -
    +
    +
    + - + batchData = append(batchData, encodeUint32(c.IndexL1InfoTree)...)
    - + + 187 -
    -   -
    +
    +
    + - + return batchData
    - + + 188 -
    +
    +
      -
    + }
    - + + 189 -
    +
    +
     
    - + + 190 -
    -   -
    +
    +
    + - + // Encode encodes a transaction into a byte slice.
    - + + 191 -
    -   -
    +
    +
    + - + func (tx L2TxRaw) Encode(batchData []byte) ([]byte, error) {
    - + + 192 -
    -   -
    +
    +
    + - + if tx.TxAlreadyEncoded {
    - + + 193 -
    -   -
    +
    +
    + - + batchData = append(batchData, tx.Data...)
    - + + 194 -
    -   -
    +
    +
    + - + } else {
    - + + 195 -
    -   -
    +
    +
    + - + rlpTx, err := prepareRLPTxData(tx.Tx)
    - + + 196 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 197 -
    -   -
    +
    +
    + - + return nil, fmt.Errorf("can't encode tx to RLP: %w", err)
    - + + 198 -
    -   -
    +
    +
    + - + }
    - + + 199 -
    -   -
    +
    +
    + - + batchData = append(batchData, rlpTx...)
    - + + 200 -
    +
    +
      -
    + }
    - + + 201 -
    +
    +
      -
    + batchData = append(batchData, tx.EfficiencyPercentage)
    - + + 202 -
    +
    +
      -
    + return batchData, nil
    - + + 203 -
    +
    +
      -
    + }
    - + + 204 -
    +
    +
     
    @@ -153651,1477 +230150,1558 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 205 -
    +
    +
      -
    + // DecodeBatchV2 decodes a batch of transactions from a byte slice.
    - + + 206 -
    +
    +
      -
    + func DecodeBatchV2(txsData []byte) (*BatchRawV2, error) {
    - + + 207 -
    +
    +
      -
    + // The transactions is not RLP encoded. Is the raw bytes in this form: 1 byte for the transaction type (always 0b for changeL2Block) + 4 bytes for deltaTimestamp + for bytes for indexL1InfoTree
    - + +
    @@ -223,7 +164,7 @@
    -
    +
    + 223 + +
      -
    + // is a tx
    - + + 224 -
    +
    +
      -
    + default:
    - + + 225 -
    +
    +
      -
    + if currentBlock == nil {
    - + + 226 -
    -   -
    +
    +
    + - + _, _, err := DecodeTxRLP(txsData, pos)
    - + + 227 -
    +
    +
      -
    + if err == nil {
    - + + 228 -
    +
    +
      -
    + // There is no changeL2Block but have a valid RLP transaction
    - + + 229 -
    +
    +
      -
    + return nil, ErrBatchV2DontStartWithChangeL2Block
    - + +
    @@ -233,7 +174,7 @@
    -
    +
    + 233 + +
      -
    + }
    - + + 234 -
    +
    +
      -
    + }
    - + + 235 -
    +
    +
      -
    + var tx *L2TxRaw
    - + + 236 -
    +
    +
    + - + pos, tx, err = DecodeTxRLP(txsData, pos) +
    +
    + 237 + +
      -
    + if err != nil {
    - + + 238 -
    +
    +
      -
    + return nil, fmt.Errorf("can't decode transactions: %w", err)
    -
    + + + 239 + + +
    +   + }
    -
    -
    - - - + + - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -274,11 +215,11 @@
    - 1 + + 274 +
    - + - package l1_check_block_test +   + func decodeBlockHeader(txsData []byte, pos int) (int, *L2BlockRaw, error) {
    - 2 + + 275 +
    - + -
    +   + var err error
    - 3 + + 276 +
    - + - import ( +   + currentBlock := &L2BlockRaw{}
    - 4 + + 277 +
    - + - "context" + - + pos, currentBlock.DeltaTimestamp, err = decodeUint32(txsData, pos)
    - 5 + + 278 +
    - + - "fmt" +   + if err != nil {
    - 6 + + 279 +
    - + - "math/big" +   + return 0, nil, fmt.Errorf("can't get deltaTimestamp: %w", err)
    - 7 + + 280 +
    - + - "testing" +   + }
    - 8 + + 281 +
    - + -
    + - + pos, currentBlock.IndexL1InfoTree, err = decodeUint32(txsData, pos)
    - 9 + + 282 +
    - + - "github.com/0xPolygonHermez/zkevm-node/state" +   + if err != nil {
    - 10 + + 283 +
    - + - commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +   + return 0, nil, fmt.Errorf("can't get leafIndex: %w", err)
    - 11 + + 284 +
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +   + }
    - 12 + +
    @@ -286,8 +227,7 @@
    +
    + 286 +
    - + - mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +   + return pos, currentBlock, nil
    - 13 + + 287 +
    - + - "github.com/ethereum/go-ethereum/common" +   + }
    - 14 + + 288 +
    - + - "github.com/ethereum/go-ethereum/core/types" +   +
    - 15 + + 289 +
    - + - "github.com/stretchr/testify/mock" + - + // DecodeTxRLP decodes a transaction from a byte slice.
    - 16 + + 290 +
    - + - "github.com/stretchr/testify/require" + - + func DecodeTxRLP(txsData []byte, offset int) (int, *L2TxRaw, error) {
    - 17 + + 291 +
    - + - ) +   + var err error
    - 18 + + 292 +
    - + -
    +   + length, err := decodeRLPListLengthFromOffset(txsData, offset)
    - 19 + + 293 +
    - + - type testData struct { +   + if err != nil {
    - 20 + +
    @@ -325,6 +265,13 @@
    +
    + 325 +
    - + - mockL1Client *mock_l1_check_block.L1Requester +   + return int(endPos), l2Tx, err
    - 21 + + 326 +
    - + - mockState *mock_l1_check_block.StateInterfacer +   + }
    - 22 + + 327 +
    - + - mockBlockNumberFetch *mock_l1_check_block.SafeL1BlockNumberFetcher +   +
    - 23 + + -
    - + - sut *l1_check_block.CheckL1BlockHash +
    +
    +   +
    - 24 + + -
    - + - ctx context.Context +
    +
    +   +
    - 25 + + -
    - + - stateBlock *state.Block +
    +
    +   +
    - 26 + + -
    - + - } +
    +
    +   +
    - 27 + + -
    - + +
    +
    +  
    - 28 + + -
    - + - func newTestData(t *testing.T) *testData { +
    +
    +   +
    - 29 + + -
    - + - mockL1Client := mock_l1_check_block.NewL1Requester(t) +
    +
    +   +
    - 30 + + 328 +
    - + - mockState := mock_l1_check_block.NewStateInterfacer(t) +   + // It returns the length of data from the param offset
    - 31 + + 329 +
    - + - mockBlockNumberFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) +   + // ex:
    - 32 + + 330 +
    - + - mockBlockNumberFetch.EXPECT().Description().Return("mock").Maybe() +   + // 0xc0 -> empty data -> 1 byte because it include the 0xc0
    - 33 + +
    @@ -355,16 +302,3 @@
    +
    + 355 +
    - + - sut := l1_check_block.NewCheckL1BlockHash(mockL1Client, mockState, mockBlockNumberFetch) +   + }
    - 34 + + 356 +
    - + - require.NotNil(t, sut) +   + return length + headerByteLength, nil
    - 35 + + 357 +
    - + - ctx := context.Background() +   + }
    - 36 + + 358 +
    - + - return &testData{ + - +
    - 37 + + 359 +
    - + - mockL1Client: mockL1Client, + - + func encodeUint32(value uint32) []byte {
    - 38 + + 360 +
    - + - mockState: mockState, + - + data := make([]byte, sizeUInt32)
    - 39 + + 361 +
    - + - mockBlockNumberFetch: mockBlockNumberFetch, + - + binary.BigEndian.PutUint32(data, value)
    - 40 + + 362 +
    - + - sut: sut, + - + return data
    - 41 + + 363 +
    - + - ctx: ctx, + - + }
    - 42 + + 364 +
    - + - stateBlock: &state.Block{ + - +
    - 43 + + 365 +
    - + - BlockNumber: 1234, + - + func decodeUint32(txsData []byte, pos int) (int, uint32, error) {
    - 44 + + 366 +
    - + - BlockHash: common.HexToHash("0xb07e1289b32edefd8f3c702d016fb73c81d5950b2ebc790ad9d2cb8219066b4c"), + - + if len(txsData)-pos < sizeUInt32 {
    - 45 + + 367 +
    - + - }, + - + return 0, 0, fmt.Errorf("can't get u32 because not enough data: %w", ErrInvalidBatchV2)
    - 46 + + 368 +
    - + + - }
    - 47 + + 369 +
    - + - } + - + return pos + sizeUInt32, binary.BigEndian.Uint32(txsData[pos : pos+sizeUInt32]), nil
    - 48 + + 370 +
    - + -
    + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - + - + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 49 + + 2 +
    - + - func TestCheckL1BlockHashNoBlocksOnDB(t *testing.T) { +   + This file provide functions to work with ETROG batches:
    - 50 + + 3 +
    - + - data := newTestData(t) +   + - EncodeBatchV2 (equivalent to EncodeTransactions)
    - 51 + + 4 +
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, state.ErrNotFound) +   + - DecodeBatchV2 (equivalent to DecodeTxs)
    - 52 + + 5 +
    + - res := data.sut.Step(data.ctx) + - DecodeForcedBatchV2)
    - 53 + + -
    - + - require.NoError(t, res) +
    +
    +   +
    - 54 + + -
    - + - } +
    +
    +   +
    - 55 + + -
    - + +
    +
    +  
    - 56 + + -
    - + - func TestCheckL1BlockHashErrorGettingFirstUncheckedBlockFromDB(t *testing.T) { +
    +
    +   +
    - 57 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + 6 +
    - + - data := newTestData(t) +   +
    - 58 + + 7 +
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(nil, fmt.Errorf("error")) +   +
    - 59 + + 8 +
    - + - res := data.sut.Step(data.ctx) +   + // batch data format:
    - 60 + +
     
    +
    + 27 +
    - + - require.Error(t, res) +   + // 0x00 | 32 | V
    - 61 + + 28 +
    - + - } +   + // 0x00 | 1 | efficiencyPercentage
    - 62 + + 29 +
    - + +   + // Repeat Transaction +
    +
    + + +
    +  
    - 63 + + -
    - + - func TestCheckL1BlockHashErrorGettingGetSafeBlockNumber(t *testing.T) { +
    +
    +   +
    - 64 + + -
    - + - data := newTestData(t) +
    +
    +   +
    - 65 + + -
    - + +
    +
    +  
    - 66 + + -
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    +   +
    - 67 + + -
    - + - data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(0), fmt.Errorf("error")) +
    +
    +   +
    - 68 + + -
    - + - res := data.sut.Step(data.ctx) +
    +
    +   +
    - 69 + + -
    - + - require.Error(t, res) +
    +
    +   +
    - 70 + + -
    - + - } +
    +
    +   +
    - 71 + + -
    - + +
    +
    +  
    - 72 + + -
    - + - // The first block to check is below the safe point, nothing to do +
    +
    +   +
    - 73 + + -
    - + - func TestCheckL1BlockHashSafePointIsInFuture(t *testing.T) { +
    +
    +   +
    - 74 + + + +
    +   +
    +
    +
    + 30 +
    - + - data := newTestData(t) +   + */
    - 75 + + 31 +
    - + +  
    - 76 + + 32 +
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +   + package state
    - 77 + + 33 +
    - + - data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber-1, nil) +   +
    - 78 + + 34 +
    - + +   + import ( +
    +
    + + +
    +  
    - 79 + + 35 +
    - + - res := data.sut.Step(data.ctx) +   + "errors"
    - 80 + + 36 +
    - + - require.NoError(t, res) +   + "fmt"
    - 81 + + 37 + +
    +   + "strconv" +
    +
    +
     
    +
    + 42 +
    - + - } +   + "github.com/ethereum/go-ethereum/rlp"
    - 82 + + 43 +
    - + -
    +   + )
    - 83 + + 44 +
    - + - func TestCheckL1BlockHashL1ClientReturnsANil(t *testing.T) { +   +
    - 84 + + -
    - + - data := newTestData(t) +
    +
    +   +
    - 85 + + -
    - + +
    +
    +  
    - 86 + + -
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +
    +
    +   +
    - 87 + + -
    - + - data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber+10, nil) +
    +
    +   +
    - 88 + + -
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(nil, nil) +
    +
    +   +
    - 89 + + -
    - + - res := data.sut.Step(data.ctx) +
    +
    +   +
    - 90 + + 45 +
    - + - require.Error(t, res) +   + // L2BlockRaw is the raw representation of a L2 block.
    - 91 + + 46 +
    - + - } +   + type L2BlockRaw struct {
    - 92 + + 47 +
    + -
    + DeltaTimestamp uint32
    - 93 + + 48 +
    + - // Check a block that is OK + IndexL1InfoTree uint32
    - 94 + 49
    + - func TestCheckL1BlockHashMatchHashUpdateCheckMarkOnDB(t *testing.T) { + Transactions []L2TxRaw
    - 95 + + 50 +
    - + - data := newTestData(t) +   + }
    - 96 + + 51 +
    - + +  
    - 97 + + 52 +
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +   + // BatchRawV2 is the representation of a batch of transactions.
    - 98 - -
    - + - data.mockBlockNumberFetch.EXPECT().Description().Return("mock") -
    +
    +
     
    - 99 + + 61 +
    - + - data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) +   +
    - 100 + + 62 +
    - + - l1Block := &types.Header{ +   + // L2TxRaw is the raw representation of a L2 transaction inside a L2 block.
    - 101 + + 63 +
    - + - Number: big.NewInt(100), +   + type L2TxRaw struct {
    - 102 + + 64 +
    + - } + Tx types.Transaction
    - 103 + + 65 +
    + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) + EfficiencyPercentage uint8
    - 104 + + -
    - + - data.mockState.EXPECT().UpdateCheckedBlockByNumber(data.ctx, data.stateBlock.BlockNumber, true, nil).Return(nil) +
    +
    +   +
    - 105 + + -
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, mock.Anything, nil).Return(nil, state.ErrNotFound) +
    +
    +   +
    - 106 + + 66 +
    - + -
    +   + }
    - 107 + + 67 +
    - + - res := data.sut.Step(data.ctx) +   +
    - 108 + + 68 +
    - + - require.NoError(t, res) +   + const (
    - 109 + + 69 +
    - + - } +   + changeL2Block = uint8(0x0b)
    - 110 + + -
    - + +
    +
    +  
    - 111 + + 70 +
    - + - // The first block to check is equal to the safe point, must be processed +   + )
    - 112 + + 71 +
    - + - func TestCheckL1BlockHashMismatch(t *testing.T) { +   +
    - 113 + + 72 +
    - + - data := newTestData(t) +   + var (
    - 114 - -
    - + -
    -
    +
    +
     
    - 115 + + 92 +
    - + - data.mockState.EXPECT().GetFirstUncheckedBlock(data.ctx, uint64(0), nil).Return(data.stateBlock, nil) +   +
    - 116 + + 93 +
    - + - data.stateBlock.BlockHash = common.HexToHash("0x1234") // Wrong hash to trigger a mismatch +   + // EncodeBatchV2 encodes a batch of transactions into a byte slice.
    - 117 + + 94 +
    - + - data.mockBlockNumberFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(data.stateBlock.BlockNumber, nil) +   + func EncodeBatchV2(batch *BatchRawV2) ([]byte, error) {
    - 118 + 95
    + - l1Block := &types.Header{ + var err error
    - 119 + 96
    + - Number: big.NewInt(100), + var batchData []byte
    - 120 + + 97 +
    - + - } +   + if batch == nil {
    - 121 + + 98 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlock.BlockNumber))).Return(l1Block, nil) +   + return nil, fmt.Errorf("batch is nil: %w", ErrInvalidBatchV2)
    - 122 + + 99 +
    - + -
    +   + }
    - 123 + + 100 +
    + - res := data.sut.Step(data.ctx) + blocks := batch.Blocks
    - 124 + 101
    + - require.Error(t, res) + if len(blocks) == 0 {
    - 125 + + 102 +
    - + - resErr, ok := res.(*commonsync.ReorgError) +   + return nil, fmt.Errorf("a batch need minimum a L2Block: %w", ErrInvalidBatchV2)
    - 126 + + 103 +
    - + - require.True(t, ok) +   + }
    - 127 + + 104 +
    + - require.Equal(t, data.stateBlock.BlockNumber, resErr.BlockNumber) + for _, block := range blocks {
    - 128 + + 105 +
    + - } -
    -
    -
    + batchData, err = EncodeBlockHeaderV2(batchData, block)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/common.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - -
    -
    @@ -0,0 +1,5 @@
    @@ -155154,117 +231734,84 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 106 -
    +
    +
      -
    + if err != nil {
    - + + 107 -
    -   -
    +
    +
    + + + return nil, fmt.Errorf("can't encode block header: %w", err)
    -
    + + + 108 + + +
    +   + }
    -
    -
    - - - - - - - - - - - - - - - - - -
    -
     
    - 1 + + 109 +
    + - package l1_check_block + for _, tx := range block.Transactions {
    - 2 + + 110 +
    + -
    + batchData, err = encodeTxRLP(batchData, tx)
    - 3 + + 111 +
    + - const ( + if err != nil {
    - 4 + + 112 +
    + - logPrefix = "checkL1block:" + return nil, fmt.Errorf("can't encode tx: %w", err)
    - 5 + + 113 +
    + - ) -
    -
    -
    + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - + + + @@ -155637,55 +232194,145 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + - - - - + + + - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + - - - - - - - - @@ -155907,193 +232894,203 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - @@ -156226,614 +233223,662 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    -
    @@ -0,0 +1,205 @@
    @@ -155467,23 +232014,33 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 114 -
    +
    +
      -
    + }
    - + + 115 -
    +
    +
      -
    + } +
    +
    + 116 + +
    + + + return batchData, nil
    - + + 117 -
    +
    +
      -
    + }
    - + + 118 -
    +
    +
     
    - + + 119 -
    +
    +
    + + + // EncodeBlockHeaderV2 encodes a batch of l2blocks header into a byte slice. +
    +
    + 120 + +
    + + + func EncodeBlockHeaderV2(batchData []byte, block L2BlockRaw) ([]byte, error) { +
    +
    + 121 + +
      -
    + batchData = append(batchData, changeL2Block)
    - + + 122 -
    +
    +
    + + + batchData = append(batchData, serializeUint32(block.DeltaTimestamp)...) +
    +
    + 123 + +
    + + + batchData = append(batchData, serializeUint32(block.IndexL1InfoTree)...) +
    +
    + 124 + +
    + + + return batchData, nil +
    +
    + 125 + +
      -
    + }
    - + + 126 -
    +
    +
     
    + 127 + +
    + + + func encodeTxRLP(batchData []byte, tx L2TxRaw) ([]byte, error) { +
    +
    + 128 + +
    + + + rlpTx, err := prepareRPLTxData(tx.Tx) +
    +
    + 129 + +
    + + + if err != nil { +
    +
    + 130 + +
    + + + return nil, fmt.Errorf("can't encode tx to RLP: %w", err) +
    +
    @@ -155747,153 +232394,493 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 131 -
    +
    +
      -
    + }
    - + + 132 -
    +
    +
    + + + batchData = append(batchData, rlpTx...) +
    +
    + 133 + +
      -
    + batchData = append(batchData, tx.EfficiencyPercentage)
    - + + 134 -
    +
    +
    +   + return batchData, nil +
    +
    + 135 + +
    +   + } +
    +
    + 136 + +
     
    - + + 137 + +
    + + + func serializeUint32(value uint32) []byte { +
    +
    + 138 + +
    + + + return []byte{ +
    +
    + 139 + +
    + + + byte(value >> 24), // nolint:gomnd +
    +
    + 140 + +
    + + + byte(value >> 16), // nolint:gomnd +
    +
    + 141 + +
    + + + byte(value >> 8), // nolint:gomnd +
    +
    + 142 + +
    + + + byte(value), +
    +
    + 143 + +
    + + + } // nolint:gomnd +
    +
    + 144 + +
    + + + } +
    +
    + 145 + +
    + + +
    +
    +
    + 146 + +
    +   + // DecodeBatchV2 decodes a batch of transactions from a byte slice. +
    +
    + 147 + +
    +   + func DecodeBatchV2(txsData []byte) (*BatchRawV2, error) { +
    +
    + 148 + +
    +   + // The transactions is not RLP encoded. Is the raw bytes in this form: 1 byte for the transaction type (always 0b for changeL2Block) + 4 bytes for deltaTimestamp + for bytes for indexL1InfoTree +
    +
    +
     
    +
    + 164 + +
    +   + // is a tx +
    +
    + 165 + +
    +   + default: +
    +
    + 166 + +
    +   + if currentBlock == nil { +
    +
    + 167 + +
    + + + _, _, err := decodeTxRLP(txsData, pos) +
    +
    + 168 + +
    +   + if err == nil { +
    +
    + 169 + +
    +   + // There is no changeL2Block but have a valid RLP transaction +
    +
    + 170 + +
    +   + return nil, ErrBatchV2DontStartWithChangeL2Block +
    +
    +
     
    +
    + 174 + +
    +   + } +
    +
    + 175 + +
    +   + } +
    +
    + 176 + +
    +   + var tx *L2TxRaw +
    +
    + 177 + +
    + + + pos, tx, err = decodeTxRLP(txsData, pos) +
    +
    + 178 + +
    +   + if err != nil { +
    +
    + 179 + +
    +   + return nil, fmt.Errorf("can't decode transactions: %w", err) +
    +
    + 180 + +
    +   + } +
    +
    +
     
    +
    + 215 + +
    +   + func decodeBlockHeader(txsData []byte, pos int) (int, *L2BlockRaw, error) { +
    +
    + 216 + +
    +   + var err error +
    +
    + 217 + +
    +   + currentBlock := &L2BlockRaw{} +
    +
    + 218 + +
    + + + pos, currentBlock.DeltaTimestamp, err = deserializeUint32(txsData, pos) +
    +
    + 219 -
    +
    +
      -
    + if err != nil {
    - + + 220 -
    +
    +
      -
    + return 0, nil, fmt.Errorf("can't get deltaTimestamp: %w", err)
    - + + 221 -
    +
    +
      -
    + }
    - + + 222 -
    -   -
    +
    +
    + + + pos, currentBlock.IndexL1InfoTree, err = deserializeUint32(txsData, pos)
    - + + 223 -
    +
    +
      -
    + if err != nil {
    - + + 224 -
    +
    +
      -
    + return 0, nil, fmt.Errorf("can't get leafIndex: %w", err)
    - + + 225 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
     
    - + + 227 -
    +
    +
      -
    + return pos, currentBlock, nil
    - + + 228 -
    +
    +
      -
    + }
    - + + 229 -
    +
    +
     
    - + + 230 -
    -   -
    +
    +
    + + + func decodeTxRLP(txsData []byte, offset int) (int, *L2TxRaw, error) {
    - + + 231 -
    +
    +
      -
    + var err error
    - + + 232 -
    +
    +
      -
    + length, err := decodeRLPListLengthFromOffset(txsData, offset)
    - + + 233 -
    +
    +
      -
    + if err != nil {
    - + +
     
    -
    +
    + 265 + +
      -
    + return int(endPos), l2Tx, err
    - + + 266 -
    +
    +
      -
    + }
    - + + 267 -
    +
    +
     
    - + + 268 -
    -   -
    +
    +
    + + + func deserializeUint32(txsData []byte, pos int) (int, uint32, error) {
    - + + 269 -
    -   -
    +
    +
    + + + if len(txsData)-pos < 4 { // nolint:gomnd
    - + + 270 -
    -   -
    +
    +
    + + + return 0, 0, fmt.Errorf("can't get u32 because not enough data: %w", ErrInvalidBatchV2)
    - + + 271 -
    -   -
    +
    +
    + + + }
    - + + 272 -
    -   -
    +
    +
    + + + return pos + 4, uint32(txsData[pos])<<24 | uint32(txsData[pos+1])<<16 | uint32(txsData[pos+2])<<8 | uint32(txsData[pos+3]), nil // nolint:gomnd
    - + + 273 -
    -   -
    +
    +
    + + + }
    - + + 274 -
    -   +
    +
    + +
    - + + 275 -
    +
    +
      -
    + // It returns the length of data from the param offset
    - + + 276 -
    +
    +
      -
    + // ex:
    - + + 277 -
    +
    +
      -
    + // 0xc0 -> empty data -> 1 byte because it include the 0xc0
    - + +
     
    -
    +
    + 302 + +
      -
    + }
    - + + 303 -
    +
    +
      -
    + return length + headerByteLength, nil
    - + + 304 -
    +
    +
      -
    + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/encoding_batch_v2_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -186,19 +186,14 @@
    +
    - + + 186 -
    +
    +
     
    - + + 187 -
    +
    +
      -
    + func TestEncodeBatchV2(t *testing.T) {
    - + + 188 -
    +
    +
      -
    + block1 := L2BlockRaw{
    - + + 189 -
    -   -
    +
    +
    + - + ChangeL2BlockHeader: ChangeL2BlockHeader{
    - + + 190 -
    -   -
    +
    +
    + - + DeltaTimestamp: 123,
    - + + 191 -
    -   -
    +
    +
    + - + IndexL1InfoTree: 456,
    - + + 192 -
    -   -
    +
    +
    + - + },
    - + + 193 -
    -   -
    +
    +
    + - + Transactions: []L2TxRaw{},
    - + + 194 -
    +
    +
      -
    + }
    - + + 195 -
    -   +
    +
    + -
    - + + 196 -
    +
    +
      -
    + block2 := L2BlockRaw{
    - + + 197 -
    -   -
    +
    +
    + - + ChangeL2BlockHeader: ChangeL2BlockHeader{
    - + + 198 -
    -   -
    +
    +
    + - + DeltaTimestamp: 789,
    - + + 199 -
    -   -
    +
    +
    + - + IndexL1InfoTree: 101112,
    - + + 200 -
    -   -
    +
    +
    + - + },
    - + + 201 -
    -   -
    +
    +
    + - + Transactions: []L2TxRaw{},
    - + + 202 -
    +
    +
      -
    + }
    - + + 203 -
    +
    +
      -
    + blocks := []L2BlockRaw{block1, block2}
    - + + 204 -
    +
    +
     
    - + +
    @@ -244,36 +239,3 @@
    -
    +
    + 244 + +
      -
    + _, err = DecodeForcedBatchV2(batchL2Data)
    - + + 245 -
    +
    +
      -
    + require.Error(t, err)
    - + + 246 -
    +
    +
      -
    + }
    - + + 247 -
    -   +
    +
    + -
    - + + 248 -
    -   -
    +
    +
    + - + func TestEncodeBatchV2WithTxInBinary(t *testing.T) {
    - + + 249 -
    -   -
    +
    +
    + - + block1 := L2BlockRaw{
    - + + 250 -
    -   -
    +
    +
    + - + ChangeL2BlockHeader: ChangeL2BlockHeader{
    - + + 251 -
    -   -
    +
    +
    + - + DeltaTimestamp: 123,
    - + + 252 -
    -   -
    +
    +
    + - + IndexL1InfoTree: 456,
    - + + 253 -
    -   -
    +
    +
    + - + },
    - + + 254 -
    -   -
    +
    +
    + - + Transactions: []L2TxRaw{
    - + + 255 -
    -   -
    +
    +
    + - + {
    - + + 256 -
    -   -
    +
    +
    + - + EfficiencyPercentage: 255,
    - + + 257 -
    -   -
    +
    +
    + - + TxAlreadyEncoded: true,
    - + + 258 -
    -   -
    +
    +
    + - + Data: []byte{0x01, 0x02, 0x03},
    - + + 259 -
    -   -
    +
    +
    + - + },
    - + + 260 -
    -   -
    +
    +
    + - + },
    - + + 261 -
    -   -
    +
    +
    + - + }
    - + + 262 -
    -   +
    +
    + -
    - + + 263 -
    -   -
    +
    +
    + - + block2 := L2BlockRaw{
    - + + 264 -
    -   -
    +
    +
    + - + ChangeL2BlockHeader: ChangeL2BlockHeader{
    - + + 265 -
    -   -
    +
    +
    + - + DeltaTimestamp: 789,
    - + + 266 -
    -   -
    +
    +
    + - + IndexL1InfoTree: 101112,
    - + + 267 -
    -   -
    +
    +
    + - + },
    - + + 268 -
    -   -
    +
    +
    + - + Transactions: []L2TxRaw{},
    - + + 269 -
    -   -
    +
    +
    + - + }
    - + + 270 -
    -   -
    +
    +
    + - + blocks := []L2BlockRaw{block1, block2}
    - + + 271 -
    -   +
    +
    + -
    - + + 272 -
    -   -
    +
    +
    + - + expectedBatchData := []byte{
    - + + 273 -
    -   -
    +
    +
    + - + 0xb, 0x0, 0x0, 0x0, 0x7b, 0x0, 0x0, 0x1, 0xc8, 0x1, 0x2, 0x3, 0xff, 0xb, 0x0, 0x0, 0x3, 0x15, 0x0, 0x1, 0x8a, 0xf8,
    - + + 274 -
    -   -
    +
    +
    + - + }
    - + + 275 -
    -   +
    +
    + -
    - + + 276 -
    -   -
    +
    +
    + - + batchData, err := EncodeBatchV2(&BatchRawV2{Blocks: blocks})
    - + + 277 -
    -   -
    +
    +
    + - + require.NoError(t, err)
    - + + 278 -
    -   -
    +
    +
    + - + require.Equal(t, expectedBatchData, batchData)
    - + + 279 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -156857,13 +233902,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -156877,33 +233922,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + @@ -156927,63 +233982,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -157321,6 +234381,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
     
    - + + 186 -
    +
    +
     
    - + + 187 -
    +
    +
      -
    + func TestEncodeBatchV2(t *testing.T) {
    - + + 188 -
    +
    +
      -
    + block1 := L2BlockRaw{
    - + + 189 -
    -   -
    +
    +
    + + + DeltaTimestamp: 123,
    - + + 190 -
    -   -
    +
    +
    + + + IndexL1InfoTree: 456,
    - + + 191 -
    -   -
    +
    +
    + + + Transactions: []L2TxRaw{},
    - + + 192 -
    +
    +
      -
    + }
    - + + 193 -
    +
    +
      -
    + block2 := L2BlockRaw{
    - + + 194 -
    -   -
    +
    +
    + + + DeltaTimestamp: 789,
    - + + 195 -
    -   -
    +
    +
    + + + IndexL1InfoTree: 101112, +
    +
    + 196 + +
    + + + Transactions: []L2TxRaw{},
    - + + 197 -
    +
    +
      -
    + }
    - + + 198 -
    +
    +
      -
    + blocks := []L2BlockRaw{block1, block2}
    - + + 199 -
    +
    +
     
    - + +
     
    -
    +
    + 239 + +
      -
    + _, err = DecodeForcedBatchV2(batchL2Data)
    - + + 240 -
    +
    +
      -
    + require.Error(t, err)
    - + + 241 -
    +
    +
      -
    + }
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/forkid.go + RENAMED + +
    +
    @@ -157328,2125 +234403,2019 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    -
    - 1 - -
    - + - package l1_check_block -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + - "time" -
    -
    - 6 - -
    - + -
    -
    -
    - 7 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/log" -
    -
    - 8 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 9 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" -
    -
    - 10 - -
    - + - "github.com/jackc/pgx/v4" -
    -
    - 11 - -
    - + - ) -
    -
    - 12 - -
    - + -
    -
    -
    - 13 - -
    - + - // StateForL1BlockCheckerIntegration is an interface for the state -
    -
    - 14 - -
    - + - type StateForL1BlockCheckerIntegration interface { -
    -
    - 15 - -
    - + - GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error) -
    -
    - 16 - -
    - + - } -
    +
    @@ -17,10 +17,8 @@
    + 17 +
    - + -
    +   + FORKID_ETROG = 7
    + 18 +
    - + - // L1BlockCheckerIntegration is a struct that integrates the L1BlockChecker with the synchronizer +   + // FORKID_ELDERBERRY is the fork id 8
    + 19 +
    - + - type L1BlockCheckerIntegration struct { +   + FORKID_ELDERBERRY = 8
    + 20 +
    - + - forceCheckOnStart bool + - + // FORKID_ELDERBERRY_2 is the fork id 9
    + 21 +
    - + - checker syncinterfaces.AsyncL1BlockChecker + - + FORKID_ELDERBERRY_2 = 9
    + 22 +
    - + - preChecker syncinterfaces.AsyncL1BlockChecker + - + // FORKID_FEIJOA is the fork id 10
    + 23 +
    - + - state StateForL1BlockCheckerIntegration + - + FORKID_FEIJOA = 10
    + 24 +
    - + - sync SyncCheckReorger +   + )
    + 25 +
    - + - timeBetweenRetries time.Duration +   +
    + 26 +
    - + - } +   + // ForkIDInterval is a fork id interval
    - 27 - -
    - + -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - 28 + + 17 +
    - + - // SyncCheckReorger is an interface that defines the methods required from Synchronizer object +   + FORKID_ETROG = 7
    - 29 + + 18 +
    - + - type SyncCheckReorger interface { +   + // FORKID_ELDERBERRY is the fork id 8
    - 30 + + 19 +
    - + - ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error +   + FORKID_ELDERBERRY = 8
    - 31 + + 20 +
    + - OnDetectedMismatchL1BlockReorg() + // FORKID_9 is the fork id 9
    - 32 + + 21 +
    + - } + FORKID_9 = 9
    - 33 + + -
    - + +
    +
    +  
    - 34 + + -
    - + - // NewL1BlockCheckerIntegration creates a new L1BlockCheckerIntegration +
    +
    +   +
    - 35 + + 22 +
    - + - func NewL1BlockCheckerIntegration(checker syncinterfaces.AsyncL1BlockChecker, preChecker syncinterfaces.AsyncL1BlockChecker, state StateForL1BlockCheckerIntegration, sync SyncCheckReorger, forceCheckOnStart bool, timeBetweenRetries time.Duration) *L1BlockCheckerIntegration { +   + )
    - 36 + + 23 +
    - + - return &L1BlockCheckerIntegration{ +   +
    - 37 + + 24 +
    - + - forceCheckOnStart: forceCheckOnStart, +   + // ForkIDInterval is a fork id interval
    - 38 - -
    - + - checker: checker, +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/genesis.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -19,8 +19,10 @@
    - 39 + + 19 +
    - + - preChecker: preChecker, +   +
    - 40 + + 20 +
    - + - state: state, +   + // Genesis contains the information to populate state on creation
    - 41 + + 21 +
    - + - sync: sync, +   + type Genesis struct {
    - 42 + + 22 +
    - + - timeBetweenRetries: timeBetweenRetries, + - + // BlockNumber is the block number where the polygonZKEVM smc was deployed on L1
    - 43 + + 23 +
    - + - } + - + BlockNumber uint64
    - 44 + + -
    - + - } +
    +
    +   +
    - 45 + + -
    - + +
    +
    +  
    - 46 + + 24 +
    - + - // OnStart is a method that is called before starting the synchronizer +   + // Root hash of the genesis block
    - 47 + + 25 +
    - + - func (v *L1BlockCheckerIntegration) OnStart(ctx context.Context) error { +   + Root common.Hash
    - 48 + + 26 +
    - + - if v.forceCheckOnStart { +   + // Actions is the data to populate into the state trie
    - 49 - -
    - + - log.Infof("%s Forcing L1BlockChecker check before start", logPrefix) +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - + +
    +
     
    - 50 + + 19 +
    - + - result := v.runCheckerSync(ctx, v.checker) +   +
    - 51 + + 20 +
    - + - if result.ReorgDetected { +   + // Genesis contains the information to populate state on creation
    - 52 + + 21 +
    - + - v.executeResult(ctx, result) +   + type Genesis struct {
    - 53 + + 22 +
    + - } else { + // RollupBlockNumber is the block number where the polygonZKEVM smc was deployed on L1
    - 54 + + 23 +
    + - log.Infof("%s Forcing L1BlockChecker check:OK ", logPrefix) + RollupBlockNumber uint64
    - 55 + 24
    + - if v.preChecker != nil { + // RollupManagerBlockNumber is the block number where the RollupManager smc was deployed on L1
    - 56 + 25
    + - log.Infof("%s Forcing L1BlockChecker preCheck before start", logPrefix) + RollupManagerBlockNumber uint64
    - 57 + + 26 +
    - + - result = v.runCheckerSync(ctx, v.preChecker) +   + // Root hash of the genesis block
    - 58 + + 27 +
    - + - if result.ReorgDetected { +   + Root common.Hash
    - 59 + + 28 +
    - + - v.executeResult(ctx, result) +   + // Actions is the data to populate into the state trie
    - 60 - -
    - + - } else { +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/helper.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    +
    @@ -18,8 +18,6 @@
    - 61 + + 18 +
    - + - log.Infof("%s Forcing L1BlockChecker preCheck:OK", logPrefix) +   + double = 2
    - 62 + + 19 +
    - + - } +   + ether155V = 27
    - 63 + + 20 +
    - + - } +   + etherPre155V = 35
    - 64 + + 21 +
    - + - } + - + // MaxEffectivePercentage is the maximum value that can be used as effective percentage
    - 65 + + 22 +
    - + - } + - + MaxEffectivePercentage = uint8(255)
    - 66 + + 23 +
    - + - v.launch(ctx) +   + // Decoding constants
    - 67 + + 24 +
    - + - return nil +   + headerByteLength uint64 = 1
    - 68 + + 25 +
    - + - } +   + sLength uint64 = 32
    - 69 - -
    - + -
    -
    +
    +
    @@ -39,7 +37,7 @@
    - 70 + + 39 +
    - + - func (v *L1BlockCheckerIntegration) runCheckerSync(ctx context.Context, checker syncinterfaces.AsyncL1BlockChecker) syncinterfaces.IterationResult { +   + var batchL2Data []byte
    - 71 + + 40 +
    - + - for { +   +
    - 72 + + 41 +
    - + - result := checker.RunSynchronous(ctx) +   + for i, tx := range txs {
    - 73 + + 42 +
    - + - if result.Err == nil { + - + txData, err := prepareRLPTxData(tx)
    - 74 + + 43 +
    - + - return result +   + if err != nil {
    - 75 + + 44 +
    - + - } else { +   + return nil, err
    - 76 + + 45 +
    - + - time.Sleep(v.timeBetweenRetries) +   + }
    - 77 - -
    - + - } -
    +
    +
    @@ -57,7 +55,7 @@
    - 78 + + 57 +
    - + - } +   + return batchL2Data, nil
    - 79 + + 58 +
    - + +   }
    - 80 + + 59 +
    - + +  
    - 81 - -
    - + - // OnStartL1Sync is a method that is called before starting the L1 sync -
    -
    - 82 + + 60 +
    - + - func (v *L1BlockCheckerIntegration) OnStartL1Sync(ctx context.Context) bool { + - + func prepareRLPTxData(tx types.Transaction) ([]byte, error) {
    - 83 + + 61 +
    - + - return v.checkBackgroundResult(ctx, "before start L1 sync") +   + v, r, s := tx.RawSignatureValues()
    - 84 + + 62 +
    - + - } +   + sign := 1 - (v.Uint64() & 1)
    - 85 + + 63 +
    - + +  
    - 86 - -
    - + - // OnStartL2Sync is a method that is called before starting the L2 sync -
    -
    - 87 - -
    - + - func (v *L1BlockCheckerIntegration) OnStartL2Sync(ctx context.Context) bool { -
    -
    - 88 - -
    - + - return v.checkBackgroundResult(ctx, "before start 2 sync") -
    +
    +
    @@ -99,7 +97,7 @@
    - 89 + + 99 +
    - + - } +   + var batchL2Data []byte
    - 90 + + 100 +
    - + +  
    - 91 + + 101 +
    - + - // OnResetState is a method that is called after a resetState +   + for _, tx := range txs {
    - 92 + + 102 +
    - + - func (v *L1BlockCheckerIntegration) OnResetState(ctx context.Context) { + - + txData, err := prepareRLPTxData(tx)
    - 93 + + 103 +
    - + - log.Infof("%s L1BlockChecker: after a resetState relaunch background process", logPrefix) +   + if err != nil {
    - 94 + + 104 +
    - + - v.launch(ctx) +   + return nil, err
    - 95 + + 105 +
    - + - } +   + }
    - 96 - -
    - + -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + +
    +
     
    - 97 + + 18 +
    - + - // CheckReorgWrapper is a wrapper over reorg function of synchronizer. +   + double = 2
    - 98 + + 19 +
    - + - // it checks the result of the function and the result of background process and decides which return +   + ether155V = 27
    - 99 + + 20 +
    - + - func (v *L1BlockCheckerIntegration) CheckReorgWrapper(ctx context.Context, reorgFirstBlockOk *state.Block, errReportedByReorgFunc error) (*state.Block, error) { +   + etherPre155V = 35
    - 100 + + -
    - + - resultBackground := v.getMergedResults() +
    +
    +   +
    - 101 + + -
    - + - if resultBackground != nil && resultBackground.ReorgDetected { +
    +
    +   +
    - 102 + + 21 +
    - + - // Background process detected a reorg, decide which return +   + // Decoding constants
    - 103 + + 22 +
    - + - firstOkBlockBackgroundCheck, err := v.state.GetPreviousBlockToBlockNumber(ctx, resultBackground.BlockNumber, nil) +   + headerByteLength uint64 = 1
    - 104 + + 23 +
    - + - if err != nil { +   + sLength uint64 = 32
    - 105 - -
    - + - log.Warnf("%s Error getting previous block to block number where a reorg have been detected %d: %s. So we reorgFunc values", logPrefix, resultBackground.BlockNumber, err) -
    +
    +
     
    - 106 + + 37 +
    - + - return reorgFirstBlockOk, errReportedByReorgFunc +   + var batchL2Data []byte
    - 107 + + 38 +
    - + - } +   +
    - 108 + + 39 +
    - + - if reorgFirstBlockOk == nil || errReportedByReorgFunc != nil { +   + for i, tx := range txs {
    - 109 + + 40 +
    + - log.Infof("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function no. Returning it", logPrefix, + txData, err := prepareRPLTxData(tx)
    - 110 + + 41 +
    - + - resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) +   + if err != nil {
    - 111 + + 42 +
    - + - return firstOkBlockBackgroundCheck, nil +   + return nil, err
    - 112 + + 43 +
    - + +   }
    - 113 - -
    - + - if firstOkBlockBackgroundCheck.BlockNumber < reorgFirstBlockOk.BlockNumber { -
    +
    +
     
    - 114 + + 55 +
    - + - // Background process detected a reorg at oldest block +   + return batchL2Data, nil
    - 115 + + 56 +
    - + - log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Returning from %d", +   + }
    - 116 + + 57 +
    - + - logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber) +   +
    - 117 + + 58 +
    + - return firstOkBlockBackgroundCheck, nil + func prepareRPLTxData(tx types.Transaction) ([]byte, error) {
    - 118 + + 59 +
    - + - } else { +   + v, r, s := tx.RawSignatureValues()
    - 119 + + 60 +
    - + - // Regular reorg function detected a reorg at oldest block +   + sign := 1 - (v.Uint64() & 1)
    - 120 + + 61 +
    - + - log.Warnf("%s Background checker detects bad block at block %d (first block ok %d) and regular reorg function first block ok: %d. Executing from %d", +   +
    - 121 - -
    - + - logPrefix, resultBackground.BlockNumber, firstOkBlockBackgroundCheck.BlockNumber, reorgFirstBlockOk.BlockNumber, reorgFirstBlockOk.BlockNumber) -
    +
    +
     
    - 122 + + 97 +
    - + - return reorgFirstBlockOk, errReportedByReorgFunc +   + var batchL2Data []byte
    - 123 + + 98 +
    - + - } +   +
    - 124 + + 99 +
    - + - } +   + for _, tx := range txs {
    - 125 + + 100 +
    + - if resultBackground != nil && !resultBackground.ReorgDetected { + txData, err := prepareRPLTxData(tx)
    - 126 + + 101 +
    - + - // Relaunch checker, if there is a reorg, It is going to be relaunched after (OnResetState) +   + if err != nil {
    - 127 + + 102 +
    - + - v.launch(ctx) +   + return nil, err
    - 128 + + 103 +
    - + - } +   + }
    - 129 - -
    - + - // Background process doesnt have anything to we return the regular reorg function result +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/interfaces.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -103,14 +103,14 @@
    - 130 + + 103 +
    - + - return reorgFirstBlockOk, errReportedByReorgFunc +   + GetSequences(ctx context.Context, lastVerifiedBatchNumber uint64, dbTx pgx.Tx) ([]Sequence, error)
    - 131 + + 104 +
    - + - } +   + GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*Batch, error)
    - 132 + + 105 +
    - + -
    +   + CheckProofContainsCompleteSequences(ctx context.Context, proof *Proof, dbTx pgx.Tx) (bool, error)
    - 133 + + 106 +
    - + - func (v *L1BlockCheckerIntegration) checkBackgroundResult(ctx context.Context, positionMessage string) bool { + - + GetProofReadyForFinal(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*Proof, error)
    - 134 + + 107 +
    - + - log.Debugf("%s Checking L1BlockChecker %s", logPrefix, positionMessage) + - + GetBatchProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*Proof, *Proof, error)
    - 135 + + 108 +
    - + - result := v.getMergedResults() + - + AddBatchProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error
    - 136 + + 109 +
    - + - if result != nil { + - + UpdateBatchProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error
    - 137 + + 110 +
    - + - if result.ReorgDetected { + - + DeleteBatchProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error
    - 138 + + 111 +
    - + - log.Warnf("%s Checking L1BlockChecker %s: reorg detected %s", logPrefix, positionMessage, result.String()) + - + CleanupBatchProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - 139 + + 112 +
    - + - v.executeResult(ctx, *result) + - + CleanupLockedBatchProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error)
    - 140 + + 113 +
    - + - } + - + DeleteUngeneratedBatchProofs(ctx context.Context, dbTx pgx.Tx) error
    - 141 + + 114 +
    - + - v.launch(ctx) +   + GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*Batch, error)
    - 142 + + 115 +
    - + - return result.ReorgDetected +   + GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 143 + + 116 +
    - + - } +   + UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error
    - 144 - -
    - + - return false -
    +
    +
    @@ -145,6 +145,7 @@
    + 145 +
    - + - } +   + GetForkIDByBlockNumber(blockNumber uint64) uint64
    + 146 +
    - + -
    +   + GetForkIDByBatchNumber(batchNumber uint64) uint64
    + 147 +
    - + - func (v *L1BlockCheckerIntegration) getMergedResults() *syncinterfaces.IterationResult { +   + GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error)
    + + + +
    +   +
    +
    +
    148 +
    - + - result := v.checker.GetResult() +   + GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error)
    + 149 +
    - + - var preResult *syncinterfaces.IterationResult +   + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    + 150 +
    - + - preResult = nil +   + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 151 - -
    - + - if v.preChecker != nil { -
    +
    +
    @@ -152,6 +153,9 @@
    + 152 +
    - + - preResult = v.preChecker.GetResult() +   + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    + 153 +
    - + - } +   + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
    + 154 +
    - + - if preResult == nil { +   + GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
    - 155 + + -
    - + - return result +
    +
    +   +
    - 156 + + -
    - + - } +
    +
    +   +
    - 157 + + -
    - + - if result == nil { +
    +
    +   +
    - 158 + + 155 +
    - + - return preResult +   + GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
    - 159 + + 156 +
    - + - } +   + GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
    - 160 + + 157 +
    - + - // result and preResult have values +   + GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error)
    - 161 - -
    - + - if result.ReorgDetected && preResult.ReorgDetected { -
    +
    +
    @@ -162,20 +166,4 @@
    + 162 +
    - + - // That is the common case, checker must detect oldest blocks than preChecker +   + GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error)
    + 163 +
    - + - if result.BlockNumber < preResult.BlockNumber { +   + GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error)
    + 164 +
    - + - return result +   + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    + 165 +
    - + - } + - + AddL1InfoTreeRecursiveRootToExitRoot(ctx context.Context, exitRoot *L1InfoTreeRecursiveExitRootStorageEntry, dbTx pgx.Tx) error
    + 166 +
    - + - return preResult + - + GetAllL1InfoTreeRecursiveRootEntries(ctx context.Context, dbTx pgx.Tx) ([]L1InfoTreeRecursiveExitRootStorageEntry, error)
    + 167 +
    - + - } + - + GetLatestL1InfoTreeRecursiveRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (L1InfoTreeRecursiveExitRootStorageEntry, error)
    + 168 +
    - + - if preResult.ReorgDetected { + - + GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    + 169 +
    - + - return preResult + - +
    + 170 +
    - + - } + - + storeblobsequences
    + 171 +
    - + - return result + - + storeblobinner
    + 172 +
    - + + - }
    + 173 +
    - + + -
    + 174 +
    - + - func (v *L1BlockCheckerIntegration) onFinishChecker() { + - + type storeblobsequences interface {
    + 175 +
    - + - log.Infof("%s L1BlockChecker: finished background process, calling to synchronizer", logPrefix) + - + AddBlobSequence(ctx context.Context, blobSequence *BlobSequence, dbTx pgx.Tx) error
    + 176 +
    - + - // Stop both processes + - + GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*BlobSequence, error)
    + 177 +
    - + - v.checker.Stop() + - + }
    + 178 +
    - + - if v.preChecker != nil { + - +
    + 179 +
    - + - v.preChecker.Stop() + - + type storeblobinner interface {
    + 180 +
    - + - } + - + AddBlobInner(ctx context.Context, blobInner *BlobInner, dbTx pgx.Tx) error
    + 181 +
    - + - v.sync.OnDetectedMismatchL1BlockReorg() +   + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - + + + + + + + + + + + + - - -
    +
     
    - 182 + + 103 +
    - + - } +   + GetSequences(ctx context.Context, lastVerifiedBatchNumber uint64, dbTx pgx.Tx) ([]Sequence, error)
    - 183 + + 104 +
    - + -
    +   + GetVirtualBatchToProve(ctx context.Context, lastVerfiedBatchNumber uint64, maxL1Block uint64, dbTx pgx.Tx) (*Batch, error)
    - 184 + + 105 +
    - + - func (v *L1BlockCheckerIntegration) launch(ctx context.Context) { +   + CheckProofContainsCompleteSequences(ctx context.Context, proof *Proof, dbTx pgx.Tx) (bool, error)
    - 185 + + 106 +
    + - log.Infof("%s L1BlockChecker: starting background process...", logPrefix) + GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*Proof, error)
    - 186 + + 107 +
    + - v.checker.Run(ctx, v.onFinishChecker) + GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*Proof, *Proof, error)
    - 187 + + 108 +
    + - if v.preChecker != nil { + AddGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error
    - 188 + + 109 +
    + - log.Infof("%s L1BlockChecker: starting background precheck process...", logPrefix) + UpdateGeneratedProof(ctx context.Context, proof *Proof, dbTx pgx.Tx) error
    - 189 + + 110 +
    + - v.preChecker.Run(ctx, v.onFinishChecker) + DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error
    - 190 + + 111 +
    + - } + CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error
    - 191 + + 112 +
    + - } + CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error)
    - 192 + + 113 +
    + -
    + DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error
    - 193 + + 114 +
    - + - func (v *L1BlockCheckerIntegration) executeResult(ctx context.Context, result syncinterfaces.IterationResult) bool { +   + GetLastClosedBatch(ctx context.Context, dbTx pgx.Tx) (*Batch, error)
    - 194 + + 115 +
    - + - if result.ReorgDetected { +   + GetLastClosedBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - 195 + + 116 +
    - + - for { +   + UpdateBatchL2Data(ctx context.Context, batchNumber uint64, batchL2Data []byte, dbTx pgx.Tx) error
    - 196 + +
     
    +
    + 145 +
    - + - err := v.sync.ExecuteReorgFromMismatchBlock(result.BlockNumber, result.ReorgMessage) +   + GetForkIDByBlockNumber(blockNumber uint64) uint64
    - 197 + + 146 +
    - + - if err == nil { +   + GetForkIDByBatchNumber(batchNumber uint64) uint64
    - 198 + + 147 +
    - + - return true +   + GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error)
    - 199 + 148
    + - } + BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte
    - 200 + + 149 +
    - + - log.Errorf("%s Error executing reorg: %s", logPrefix, err) +   + GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error)
    - 201 + + 150 +
    - + - time.Sleep(v.timeBetweenRetries) +   + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error)
    - 202 + + 151 +
    - + - } +   + GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (L1InfoTreeExitRootStorageEntry, error) +
    +
    +
     
    +
    + 153 + +
    +   + GetBlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error) +
    +
    + 154 + +
    +   + GetVirtualBatchParentHash(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (common.Hash, error) +
    +
    + 155 + +
    +   + GetForcedBatchParentHash(ctx context.Context, forcedBatchNumber uint64, dbTx pgx.Tx) (common.Hash, error)
    - 203 + 156
    + - } + GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error)
    - 204 + 157
    + - return false + GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    - 205 + 158
    + - } + GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error)
    -
    + + + 159 + + +
    +   + GetLatestBatchGlobalExitRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error)
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/integration_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - + + + + + + - - - - @@ -159610,844 +236579,887 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + +
    -
    @@ -0,0 +1,298 @@
    - + + 160 -
    +
    +
      -
    + GetL2TxHashByTxHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*common.Hash, error)
    - + + 161 -
    +
    +
    +   + GetSyncInfoData(ctx context.Context, dbTx pgx.Tx) (SyncInfoDataOnStorage, error) +
    +
    +
     
    +
    + 166 + +
      -
    + GetNotCheckedBatches(ctx context.Context, dbTx pgx.Tx) ([]*Batch, error)
    - + + 167 -
    +
    +
      -
    + GetLastL2BlockByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*L2Block, error)
    - + + 168 -
    +
    +
      -
    + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*Block, error)
    - + + 169 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree_recursive.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,83 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package state
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   -
    +
    +
    + - + "errors"
    - + + 6 -
    -   -
    +
    +
    + - + "fmt"
    - + + 7 -
    -   +
    +
    + -
    - + + 8 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/l1infotree"
    - + + 9 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 10 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/common"
    - + + 11 -
    -   -
    +
    +
    + - + "github.com/jackc/pgx/v4"
    - + + 12 -
    -   -
    +
    +
    + - + )
    - + + 13 -
    -   +
    +
    + -
    - + + 14 -
    -   -
    +
    +
    + - + // L1InfoTreeRecursiveExitRootStorageEntry leaf of the L1InfoTreeRecursive
    - + + 15 -
    -   -
    +
    +
    + - + type L1InfoTreeRecursiveExitRootStorageEntry L1InfoTreeExitRootStorageEntry
    - + + 16 -
    -   +
    +
    + -
    - + + 17 -
    -   -
    +
    +
    + - + func (s *State) buildL1InfoTreeRecursiveCacheIfNeed(ctx context.Context, dbTx pgx.Tx) error {
    - + + 18 -
    -   -
    +
    +
    + - + if s.l1InfoTreeRecursive != nil {
    - + + 19 -
    -   -
    +
    +
    + - + return nil
    - + + 20 -
    -   -
    +
    +
    + - + }
    - + + 21 -
    -   -
    +
    +
    + - + log.Debugf("Building L1InfoTree cache")
    - + + 22 -
    -   -
    +
    +
    + - + allLeaves, err := s.GetAllL1InfoTreeRecursiveRootEntries(ctx, dbTx)
    - + + 23 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 24 -
    -   -
    +
    +
    + - + log.Error("error getting all leaves. Error: ", err)
    - + + 25 -
    -   -
    +
    +
    + - + return fmt.Errorf("error getting all leaves. Error: %w", err)
    - + + 26 -
    -   -
    +
    +
    + - + }
    - + + 27 -
    -   +
    +
    + -
    - + + 28 -
    -   -
    +
    +
    + - + var leaves [][32]byte
    - + + 29 -
    -   -
    +
    +
    + - + for _, leaf := range allLeaves {
    - + + 30 -
    -   -
    +
    +
    + - + leaves = append(leaves, leaf.Hash())
    - + + 31 -
    -   -
    +
    +
    + - + }
    - + + 32 -
    -   -
    +
    +
    + - + mt, err := l1infotree.NewL1InfoTreeRecursiveFromLeaves(uint8(32), leaves) //nolint:gomnd
    - + + 33 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 34 -
    -   -
    +
    +
    + - + log.Error("error creating L1InfoTree. Error: ", err)
    - + + 35 -
    -   -
    +
    +
    + - + return fmt.Errorf("error creating L1InfoTree. Error: %w", err)
    - + + 36 -
    -   -
    +
    +
    + - + }
    - + + 37 -
    -   -
    +
    +
    + - + s.l1InfoTreeRecursive = mt
    - + + 38 -
    -   -
    +
    +
    + - + return nil
    - + + 39 -
    -   -
    +
    +
    + - + }
    - + + 40 -
    -   +
    +
    + -
    - + + 41 -
    -   -
    +
    +
    + - + // AddL1InfoTreeRecursiveLeaf adds a new leaf to the L1InfoTree and returns the entry and error
    - + + 42 -
    -   -
    +
    +
    + - + func (s *State) AddL1InfoTreeRecursiveLeaf(ctx context.Context, l1InfoTreeLeaf *L1InfoTreeLeaf, dbTx pgx.Tx) (*L1InfoTreeExitRootStorageEntry, error) {
    - + + 43 -
    -   -
    +
    +
    + - + var newIndex uint32
    - + + 44 -
    -   -
    +
    +
    + - + gerIndex, err := s.GetLatestIndex(ctx, dbTx)
    - + + 45 -
    -   -
    +
    +
    + - + if err != nil && !errors.Is(err, ErrNotFound) {
    - + + 46 -
    -   -
    +
    +
    + - + log.Error("error getting latest L1InfoTreeRecursive index. Error: ", err)
    - + + 47 -
    -   -
    +
    +
    + - + return nil, err
    - + + 48 -
    -   -
    +
    +
    + - + } else if err == nil {
    - + + 49 -
    -   -
    +
    +
    + - + newIndex = gerIndex + 1
    - + + 50 -
    -   -
    +
    +
    + - + }
    - + + 51 -
    -   -
    +
    +
    + - + err = s.buildL1InfoTreeCacheIfNeed(ctx, dbTx)
    - + + 52 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 53 -
    -   -
    +
    +
    + - + log.Error("error building L1InfoTreeRecursive cache. Error: ", err)
    - + + 54 -
    -   -
    +
    +
    + - + return nil, err
    - + + 55 -
    -   -
    +
    +
    + - + }
    - + + 56 -
    -   -
    +
    +
    + - + log.Debug("latestIndex: ", gerIndex)
    - + + 57 -
    -   -
    +
    +
    + - + l1InfoTreeRoot, err := s.l1InfoTreeRecursive.AddLeaf(newIndex, l1InfoTreeLeaf.Hash())
    - + + 58 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 59 -
    -   -
    +
    +
    + - + log.Error("error add new leaf to the L1InfoTreeRecursive. Error: ", err)
    - + + 60 -
    -   -
    +
    +
    + - + return nil, err
    - + + 61 -
    -   -
    +
    +
    + - + }
    - + + 62 -
    -   -
    +
    +
    + - + entry := L1InfoTreeExitRootStorageEntry{
    - + + 63 -
    -   -
    +
    +
    + - + L1InfoTreeLeaf: *l1InfoTreeLeaf,
    - + + 64 -
    -   -
    +
    +
    + - + L1InfoTreeRoot: l1InfoTreeRoot,
    - + + 65 -
    -   -
    +
    +
    + - + L1InfoTreeIndex: newIndex,
    - + + 66 -
    -   -
    +
    +
    + - + }
    - + + 67 -
    -   -
    +
    +
    + - + err = s.AddL1InfoRootToExitRoot(ctx, &entry, dbTx)
    - + + 68 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 69 -
    -   -
    +
    +
    + - + log.Error("error adding L1InfoRoot to ExitRoot. Error: ", err)
    - + + 70 -
    -   -
    +
    +
    + - + return nil, err
    - + + 71 -
    -   -
    +
    +
    + - + }
    - + + 72 -
    -   -
    +
    +
    + - + return &entry, nil
    - + + 73 -
    -   -
    +
    +
    + - + }
    - + + 74 -
    -   +
    +
    + -
    - + + 75 -
    -   -
    +
    +
    + - + // GetCurrentL1InfoTreeRecursiveRoot Return current L1InfoRoot
    - + + 76 -
    -   -
    +
    +
    + - + func (s *State) GetCurrentL1InfoTreeRecursiveRoot(ctx context.Context, dbTx pgx.Tx) (common.Hash, error) {
    - + + 77 -
    -   -
    +
    +
    + - + err := s.buildL1InfoTreeRecursiveCacheIfNeed(ctx, dbTx)
    - + + 78 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 79 -
    -   -
    +
    +
    + - + log.Error("error building L1InfoTree cache. Error: ", err)
    - + + 80 -
    -   -
    +
    +
    + - + return ZeroHash, err
    - + + 81 -
    -   -
    +
    +
    + - + }
    - + + 82 -
    -   -
    +
    +
    + - + return s.l1InfoTreeRecursive.GetRoot(), nil
    - + + 83 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -161279,274 +238291,452 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/l1infotree_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + + + + + + + + + + + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - + + + - - + + + + + + + + + - - - - - + - + + - - - - - - + + + - - - - + + +
    +
    @@ -45,11 +45,7 @@
    +
    - + + 45 -
    +
    +
      -
    + if err != nil {
    - + + 46 -
    +
    +
      -
    + panic(err)
    - + + 47 -
    +
    +
      -
    + }
    - + + 48 -
    +
    +
    + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32) +
    +
    + 49 + +
    + - + if err != nil { +
    +
    + 50 + +
    + - + panic(err) +
    +
    + 51 + +
    + - + } +
    +
    + 52 + +
    + - + testState := state.NewState(stateCfg, storage, nil, nil, nil, mt, mtr) +
    +
    + 53 + +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 54 -
    +
    +
      -
    + defer func() {
    - + + 55 -
    +
    +
      -
    + _ = dbTx.Rollback(ctx)
    - + +
    @@ -86,7 +82,7 @@
    -
    +
    + 86 + +
      -
    + }},
    - + + 87 -
    +
    +
      -
    + }
    - + + 88 -
    +
    +
      -
    + ctx := context.Background()
    - + + 89 -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, nil, nil) +
    +
    + 90 + +
     
    - + + 91 -
    +
    +
      -
    + mockStorage.EXPECT().GetAllL1InfoRootEntries(ctx, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil)
    - + + 92 -
    +
    +
     
    - + +
    @@ -112,10 +108,7 @@
    -
    +
    + 112 + +
      -
    + ctx := context.Background()
    - + + 113 -
    +
    +
      -
    + l1InfoTree, err := l1infotree.NewL1InfoTree(uint8(32), nil)
    - + + 114 -
    +
    +
      + require.NoError(t, err) +
    +
    + 115 + +
    + -
    - + + 116 -
    +
    +
    + - + l1InfoTreeRecursive, err := l1infotree.NewL1InfoTreeRecursive(32) +
    +
    + 117 + +
    + - + require.NoError(t, err) +
    +
    + 118 + +
    + - + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, l1InfoTree, l1InfoTreeRecursive) +
    +
    + 119 + +
     
    - + + 120 -
    +
    +
      -
    + // GetCurrentL1InfoRoot use the cache value in state.l1InfoTree
    - + + 121 -
    +
    +
      -
    + l1InfoRoot, err := testState.GetCurrentL1InfoRoot(ctx, nil)
    - + +
    @@ -138,7 +131,7 @@
    -
    +
    + 138 + +
      -
    + }},
    - + + 139 -
    +
    +
      -
    + }
    - + + 140 -
    +
    +
      -
    + ctx := context.Background()
    - + + 141 -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, nil, nil) +
    +
    + 142 + +
     
    - + + 143 -
    +
    +
      -
    + mockStorage.EXPECT().GetLatestIndex(ctx, mock.Anything).Return(uint32(0), state.ErrNotFound)
    - + + 144 -
    +
    +
      -
    + mockStorage.EXPECT().AddL1InfoRootToExitRoot(ctx, mock.Anything, mock.Anything).Return(nil)
    +
    +
    +
    +
    + + + + + - - - - - - + + + @@ -161590,123 +238780,153 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - + + + @@ -161740,123 +238960,167 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - + + + - - - - + + +
    +
     
    +
    - + + 45 -
    +
    +
      -
    + if err != nil {
    - + + 46 -
    +
    +
      -
    + panic(err)
    - + + 47 -
    +
    +
      -
    + } +
    +
    + 48 + +
    + + + testState := state.NewState(stateCfg, storage, nil, nil, nil, mt)
    - + + 49 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 50 -
    +
    +
      -
    + defer func() {
    - + + 51 -
    +
    +
      -
    + _ = dbTx.Rollback(ctx)
    - + +
     
    -
    +
    + 82 + +
      -
    + }},
    - + + 83 -
    +
    +
      -
    + }
    - + + 84 -
    +
    +
      -
    + ctx := context.Background()
    - + + 85 -
    +
    +
    + + + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, nil) +
    +
    + 86 + +
     
    - + + 87 -
    +
    +
      -
    + mockStorage.EXPECT().GetAllL1InfoRootEntries(ctx, nil).Return([]state.L1InfoTreeExitRootStorageEntry{}, nil)
    - + + 88 -
    +
    +
     
    - + +
     
    -
    +
    + 108 + +
      -
    + ctx := context.Background()
    - + + 109 -
    +
    +
      -
    + l1InfoTree, err := l1infotree.NewL1InfoTree(uint8(32), nil)
    - + + 110 -
    +
    +
      -
    + require.NoError(t, err) +
    +
    + 111 + +
    + + + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, l1InfoTree)
    - + + 112 -
    +
    +
     
    - + + 113 -
    +
    +
      -
    + // GetCurrentL1InfoRoot use the cache value in state.l1InfoTree
    - + + 114 -
    +
    +
      -
    + l1InfoRoot, err := testState.GetCurrentL1InfoRoot(ctx, nil)
    - + +
     
    -
    +
    + 131 + +
      -
    + }},
    - + + 132 -
    +
    +
      -
    + }
    - + + 133 -
    +
    +
      -
    + ctx := context.Background()
    - + + 134 -
    +
    +
    + + + testState := state.NewState(stateCfg, mockStorage, nil, nil, nil, nil) +
    +
    + 135 + +
     
    - + + 136 -
    +
    +
      -
    + mockStorage.EXPECT().GetLatestIndex(ctx, mock.Anything).Return(uint32(0), state.ErrNotFound)
    - + + 137 -
    +
    +
      -
    + mockStorage.EXPECT().AddL1InfoRootToExitRoot(ctx, mock.Anything, mock.Anything).Return(nil) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -161870,151 +239134,141 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + +
    +
    @@ -2,6 +2,7 @@
    - + + 2 -
    +
    +
     
    - + + 3 -
    +
    +
      -
    + import (
    - + + 4 -
    +
    +
      -
    + "context"
    - + + 5 -
    +
    +
      -
    + "encoding/json"
    - + + 6 -
    +
    +
      -
    + "errors"
    - + + 7 -
    +
    +
      -
    + "fmt"
    - - -
    -   -
    -
    +
    +
    @@ -785,7 +786,7 @@
    - + + 785 -
    +
    +
      -
    + b.batch_num > $1 AND b.batch_num = v.batch_num AND
    - + + 786 -
    +
    +
      -
    + v.block_num <= $2 AND
    - + + 787 -
    +
    +
      -
    + NOT EXISTS (
    - + + 788 -
    -   -
    +
    +
    + - + SELECT p.batch_num FROM state.batch_proof p
    - + + 789 -
    +
    +
      -
    + WHERE v.batch_num >= p.batch_num AND v.batch_num <= p.batch_num_final
    - + + 790 -
    +
    +
      -
    + )
    - + + 791 -
    +
    +
      -
    + ORDER BY b.batch_num ASC LIMIT 1
    - - -
    -   -
    -
    +
    +
    @@ -956,6 +957,25 @@
    - + + 956 -
    +
    +
      -
    + return blockNum, nil
    - + + 957 -
    +
    +
      -
    + }
    - + + 958 -
    +
    +
     
    @@ -162210,272 +239464,272 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 959 -
    +
    +
      -
    + // GetRawBatchTimestamps returns the timestamp of the batch with the given number.
    - + + 960 -
    +
    +
      -
    + // it returns batch_num.tstamp and virtual_batch.batch_timestamp
    - + + 961 -
    +
    +
      -
    + func (p *PostgresStorage) GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) {
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    +
     
    - + + 2 -
    +
    +
     
    - + + 3 -
    +
    +
      -
    + import (
    - + + 4 -
    +
    +
      -
    + "context"
    - + + 5 -
    -   -
    +
    +
    + + + "encoding/binary"
    - + + 6 -
    +
    +
      -
    + "encoding/json"
    - + + 7 -
    +
    +
      -
    + "errors"
    - + + 8 -
    +
    +
      -
    + "fmt"
    - + +
     
    -
    +
    + 786 + +
      -
    + b.batch_num > $1 AND b.batch_num = v.batch_num AND
    - + + 787 -
    +
    +
      -
    + v.block_num <= $2 AND
    - + + 788 -
    +
    +
      -
    + NOT EXISTS (
    - + + 789 -
    -   -
    +
    +
    + + + SELECT p.batch_num FROM state.proof p
    - + + 790 -
    +
    +
      -
    + WHERE v.batch_num >= p.batch_num AND v.batch_num <= p.batch_num_final
    - + + 791 -
    +
    +
      -
    + )
    - + + 792 -
    +
    +
      -
    + ORDER BY b.batch_num ASC LIMIT 1
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - + + +
     
    - 1 + + 957 +
    - + - package l1_check_block_test +   + return blockNum, nil
    - 2 + + 958 +
    - + -
    +   + }
    - 3 + + 959 +
    - + - import ( +   +
    - 4 + 960
    + - "context" + // BuildChangeL2Block returns a changeL2Block tx to use in the BatchL2Data
    - 5 + 961
    + - "fmt" + func (p *PostgresStorage) BuildChangeL2Block(deltaTimestamp uint32, l1InfoTreeIndex uint32) []byte {
    - 6 + 962
    + - "testing" + changeL2BlockMark := []byte{0x0B}
    - 7 + 963
    + - "time" + changeL2Block := []byte{}
    - 8 + 964
    @@ -162485,3971 +239739,4215 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 9 + 965
    + - "github.com/0xPolygonHermez/zkevm-node/state" + // changeL2Block transaction mark
    - 10 + 966
    + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + changeL2Block = append(changeL2Block, changeL2BlockMark...)
    - 11 + 967
    + - mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" + // changeL2Block deltaTimeStamp
    - 12 + 968
    + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + deltaTimestampBytes := make([]byte, 4) //nolint:gomnd
    - 13 + 969
    + - mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + binary.BigEndian.PutUint32(deltaTimestampBytes, deltaTimestamp)
    - 14 + 970
    + - "github.com/stretchr/testify/mock" + changeL2Block = append(changeL2Block, deltaTimestampBytes...)
    - 15 + 971
    + - "github.com/stretchr/testify/require" + // changeL2Block l1InfoTreeIndexBytes
    - 16 + 972
    + - ) + l1InfoTreeIndexBytes := make([]byte, 4) //nolint:gomnd
    - 17 + 973
    + -
    + binary.BigEndian.PutUint32(l1InfoTreeIndexBytes, l1InfoTreeIndex)
    - 18 + 974
    + - var ( + changeL2Block = append(changeL2Block, l1InfoTreeIndexBytes...)
    - 19 + 975
    + - genericErrorToTest = fmt.Errorf("error") +
    - 20 + 976
    + - ) + return changeL2Block
    - 21 + 977
    + -
    + }
    - 22 + 978
    + - type testDataIntegration struct { +
    - 23 + + 979 +
    - + - mockChecker *mock_syncinterfaces.AsyncL1BlockChecker +   + // GetRawBatchTimestamps returns the timestamp of the batch with the given number.
    - 24 + + 980 +
    - + - mockPreChecker *mock_syncinterfaces.AsyncL1BlockChecker +   + // it returns batch_num.tstamp and virtual_batch.batch_timestamp
    - 25 + + 981 +
    - + - mockState *mock_l1_check_block.StateForL1BlockCheckerIntegration +   + func (p *PostgresStorage) GetRawBatchTimestamps(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*time.Time, *time.Time, error) { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/batch_pending.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + +
    +
    @@ -1 +0,0 @@
    - 26 + + 1 +
    - + - mockSync *mock_l1_check_block.SyncCheckReorger + - + package pgstatestorage +
    +
    +
    +
    +
    + + + + + - - + + +
    +
     
    - 27 + + -
    - + - sut *l1_check_block.L1BlockCheckerIntegration +
    +
    +   +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_inner_in.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,41 +0,0 @@
    - 28 + + 1 +
    - + - ctx context.Context + - + package pgstatestorage
    - 29 + + 2 +
    - + - resultOk syncinterfaces.IterationResult + - +
    - 30 + + 3 +
    - + - resultError syncinterfaces.IterationResult + - + import (
    - 31 + + 4 +
    - + - resultReorg syncinterfaces.IterationResult + - + "context"
    - 32 + + 5 +
    - + - } + - + "time"
    - 33 + + 6 +
    - + + -
    - 34 + + 7 +
    - + - func newDataIntegration(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 35 + + 8 +
    - + - return newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) + - + "github.com/ethereum/go-ethereum/common"
    - 36 + + 9 +
    - + - } + - + "github.com/jackc/pgx/v4"
    - 37 + + 10 +
    - + -
    + - + )
    - 38 + + 11 +
    - + - func newDataIntegrationWithPreChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + - +
    - 39 + + 12 +
    - + - res := newDataIntegrationOnlyMainChecker(t, forceCheckOnStart) + - + const blobInnerFields = "blob_sequence_index, blob_inner_num, blob_type, max_sequence_timestamp, zk_gas_limit, l1_info_tree_leaf_index, l1_info_tree_root,blob_data_hash, updated_at"
    - 40 + + 13 +
    - + - res.mockPreChecker = mock_syncinterfaces.NewAsyncL1BlockChecker(t) + - + const blobInnerFieldsTypeBlob = "blob_type_index,blob_type_z, blob_type_y,blob_type_commitment,blob_type_proof"
    - 41 + + 14 +
    - + - res.sut = l1_check_block.NewL1BlockCheckerIntegration(res.mockChecker, res.mockPreChecker, res.mockState, res.mockSync, forceCheckOnStart, time.Millisecond) + - +
    - 42 + + 15 +
    - + - return res + - + func (p *PostgresStorage) AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error {
    - 43 + + 16 +
    - + - } + - + sql := "INSERT INTO state.blob_inner_in (" + blobInnerFields
    - 44 + + 17 +
    - + -
    + - + if blobInner.Type == state.TypeBlobTransaction {
    - 45 + + 18 +
    - + - func newDataIntegrationOnlyMainChecker(t *testing.T, forceCheckOnStart bool) *testDataIntegration { + - + sql += "," + blobInnerFieldsTypeBlob
    - 46 + + 19 +
    - + - mockChecker := mock_syncinterfaces.NewAsyncL1BlockChecker(t) + - + }
    - 47 + + 20 +
    - + - mockSync := mock_l1_check_block.NewSyncCheckReorger(t) + - + sql += ") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9"
    - 48 + + 21 +
    - + - mockState := mock_l1_check_block.NewStateForL1BlockCheckerIntegration(t) + - + if blobInner.Type == state.TypeBlobTransaction {
    - 49 + + 22 +
    - + - sut := l1_check_block.NewL1BlockCheckerIntegration(mockChecker, nil, mockState, mockSync, forceCheckOnStart, time.Millisecond) + - + sql += ",$10,$11,$12,$13,$14"
    - 50 + + 23 +
    - + - return &testDataIntegration{ + - + }
    - 51 + + 24 +
    - + - mockChecker: mockChecker, + - + sql += ")"
    - 52 + + 25 +
    - + - mockPreChecker: nil, + - + e := p.getExecQuerier(dbTx)
    - 53 + + 26 +
    - + - mockSync: mockSync, + - + arguments := []interface{}{blobInner.BlobSequenceIndex, blobInner.BlobInnerNum, blobInner.Type.String(), blobInner.MaxSequenceTimestamp, blobInner.ZkGasLimit, blobInner.L1InfoLeafIndex, blobInner.L1InfoTreeRoot.String(), blobInner.BlobDataHash.String(), time.Now()}
    - 54 + + 27 +
    - + - mockState: mockState, + - + if blobInner.Type == state.TypeBlobTransaction {
    - 55 + + 28 +
    - + - sut: sut, + - + commitment, err := blobInner.BlobBlobTypeParams.Commitment.MarshalText()
    - 56 + + 29 +
    - + - ctx: context.Background(), + - + if err != nil {
    - 57 + + 30 +
    - + - resultReorg: syncinterfaces.IterationResult{ + - + return err
    - 58 + + 31 +
    - + - ReorgDetected: true, + - + }
    - 59 + + 32 +
    - + - BlockNumber: 1234, + - + proof, err := blobInner.BlobBlobTypeParams.Proof.MarshalText()
    - 60 + + 33 +
    - + - }, + - + if err != nil {
    - 61 + + 34 +
    - + - resultOk: syncinterfaces.IterationResult{ + - + return err
    - 62 + + 35 +
    - + - ReorgDetected: false, + - + }
    - 63 + + 36 +
    - + - }, + - + arguments = append(arguments, blobInner.BlobBlobTypeParams.BlobIndex, common.Bytes2Hex(blobInner.BlobBlobTypeParams.Z), common.Bytes2Hex(blobInner.BlobBlobTypeParams.Y), commitment, proof)
    - 64 + + 37 +
    - + - resultError: syncinterfaces.IterationResult{ + - + }
    - 65 + + 38 +
    - + - Err: genericErrorToTest, + - + _, err := e.Exec(ctx, sql, arguments...)
    - 66 + + 39 +
    - + - ReorgDetected: false, + - + return err
    - 67 + + 40 +
    - + - }, + - +
    - 68 + + 41 +
    - + - } + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - 69 + + -
    - + - } +
    +
    +   +
    - 70 + + -
    - + +
    +
    +  
    - 71 + + -
    - + - func TestIntegrationIfNoForceCheckOnlyLaunchBackgroudChecker(t *testing.T) { +
    +
    +   +
    - 72 + + -
    - + - data := newDataIntegration(t, false) +
    +
    +   +
    - 73 + + -
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 74 + + -
    - + - err := data.sut.OnStart(data.ctx) +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 75 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 76 + + -
    - + - } +
    +
    +   +
    - 77 + + -
    - + +
    +
    +  
    - 78 + + -
    - + - func TestIntegrationIfForceCheckRunsSynchronousOneTimeAndAfterLaunchBackgroudChecker(t *testing.T) { +
    +
    +   +
    - 79 + + -
    - + - data := newDataIntegration(t, true) +
    +
    +   +
    - 80 + + -
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) +
    +
    +   +
    - 81 + + -
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 82 + + -
    - + - err := data.sut.OnStart(data.ctx) +
    +
    +   +
    - 83 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 84 + + -
    - + - } +
    +
    +   +
    - 85 + + -
    - + +
    +
    +  
    - 86 + + -
    - + - func TestIntegrationIfSyncCheckReturnsReorgExecuteIt(t *testing.T) { +
    +
    +   +
    - 87 + + -
    - + - data := newDataIntegration(t, true) +
    +
    +   +
    - 88 + + -
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    +   +
    - 89 + + -
    - + - data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), "").Return(nil) +
    +
    +   +
    - 90 + + -
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 91 + + -
    - + - err := data.sut.OnStart(data.ctx) +
    +
    +   +
    - 92 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 93 + + -
    - + - } +
    +
    +   +
    - 94 + + -
    - + +
    +
    +  
    - 95 + + -
    - + - func TestIntegrationIfSyncCheckReturnErrorRetry(t *testing.T) { +
    +
    +   +
    - 96 + + -
    - + - data := newDataIntegration(t, true) +
    +
    +   +
    - 97 + + -
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultError).Once() +
    +
    +   +
    - 98 + + -
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk).Once() +
    +
    +   +
    - 99 + + -
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 100 + + -
    - + - err := data.sut.OnStart(data.ctx) +
    +
    +   +
    - 101 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 102 + + -
    - + - } +
    +
    +   +
    - 103 + + -
    - + +
    +
    +  
    - 104 + + -
    - + - func TestIntegrationIfSyncCheckReturnsReorgExecuteItAndFailsRetry(t *testing.T) { +
    +
    +   +
    - 105 + + -
    - + - data := newDataIntegration(t, true) +
    +
    +   +
    - 106 + + -
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) +
    +
    +   +
    - 107 + + -
    - + - data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(genericErrorToTest).Once() +
    +
    +   +
    - 108 - -
    - + - data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/blob_sequences.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,48 +0,0 @@
    - 109 + + 1 +
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - + package pgstatestorage
    - 110 + + 2 +
    - + - err := data.sut.OnStart(data.ctx) + - +
    - 111 + + 3 +
    - + - require.NoError(t, err) + - + import (
    - 112 + + 4 +
    - + - } + - + "context"
    - 113 + + 5 +
    - + -
    + - + "errors"
    - 114 + + 6 +
    - + - // OnStart if check and preCheck execute both, and launch both in background + - + "time"
    - 115 + + 7 +
    - + - func TestIntegrationCheckAndPreCheckOnStartForceCheck(t *testing.T) { + - +
    - 116 + + 8 +
    - + - data := newDataIntegrationWithPreChecker(t, true) + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 117 + + 9 +
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + - + "github.com/ethereum/go-ethereum/common"
    - 118 + + 10 +
    - + - data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + - + "github.com/jackc/pgx/v4"
    - 119 + + 11 +
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - + )
    - 120 + + 12 +
    - + - data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - +
    - 121 + + 13 +
    - + - err := data.sut.OnStart(data.ctx) + - + // AddBlobSequence adds a new blob sequence to the state.
    - 122 + + 14 +
    - + - require.NoError(t, err) + - + // TODO: Add support to ReceivedAt
    - 123 + + 15 +
    - + - } + - + func (p *PostgresStorage) AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error {
    - 124 + + 16 +
    - + -
    + - + const addBlobSequenceSQL = "INSERT INTO state.blob_sequence (index, block_num, coinbase, final_acc_input_hash, first_blob_sequenced, last_blob_sequenced, created_at) VALUES ($1, $2, $3, $4, $5, $6, $7)"
    - 125 + + 17 +
    - + - // OnStart if mainChecker returns reorg doesnt need to run preCheck + - +
    - 126 + + 18 +
    - + - func TestIntegrationCheckAndPreCheckOnStartMainCheckerReturnReorg(t *testing.T) { + - + e := p.getExecQuerier(dbTx)
    - 127 + + 19 +
    - + - data := newDataIntegrationWithPreChecker(t, true) + - + _, err := e.Exec(ctx, addBlobSequenceSQL, blobSequence.BlobSequenceIndex, blobSequence.BlockNumber, blobSequence.L2Coinbase.String(), blobSequence.FinalAccInputHash.String(), blobSequence.FirstBlobSequenced, blobSequence.LastBlobSequenced, blobSequence.CreateAt)
    - 128 + + 20 +
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + - + return err
    - 129 + + 21 +
    - + - data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() + - + }
    - 130 + + 22 +
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - +
    - 131 + + 23 +
    - + - data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - + // GetLastBlobSequence returns the last blob sequence stored in the state.
    - 132 + + 24 +
    - + - err := data.sut.OnStart(data.ctx) + - + // TODO: Add support to ReceivedAt
    - 133 + + 25 +
    - + - require.NoError(t, err) + - + func (p *PostgresStorage) GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error) {
    - 134 + + 26 +
    - + - } + - + var (
    - 135 + + 27 +
    - + -
    + - + coinbase string
    - 136 + + 28 +
    - + - // If mainCheck is OK, but preCheck returns reorg, it should execute reorg + - + finalAccInputHash string
    - 137 + + 29 +
    - + - func TestIntegrationCheckAndPreCheckOnStartPreCheckerReturnReorg(t *testing.T) { + - + createAt time.Time
    - 138 + + 30 +
    - + - data := newDataIntegrationWithPreChecker(t, true) + - + blobSequence state.BlobSequence
    - 139 + + 31 +
    - + - data.mockChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultOk) + - + )
    - 140 + + 32 +
    - + - data.mockPreChecker.EXPECT().RunSynchronous(data.ctx).Return(data.resultReorg) + - + const getLastBlobSequenceSQL = "SELECT index, coinbase, final_acc_input_hash, first_blob_sequenced, last_blob_sequenced, created_at FROM state.blob_sequence ORDER BY index DESC LIMIT 1"
    - 141 + + 33 +
    - + - data.mockSync.EXPECT().ExecuteReorgFromMismatchBlock(uint64(1234), mock.Anything).Return(nil).Once() + - +
    - 142 + + 34 +
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - + q := p.getExecQuerier(dbTx)
    - 143 + + 35 +
    - + - data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() + - +
    - 144 + + 36 +
    - + - err := data.sut.OnStart(data.ctx) + - + err := q.QueryRow(ctx, getLastBlobSequenceSQL).Scan(&blobSequence.BlobSequenceIndex, &coinbase, &finalAccInputHash, &blobSequence.FirstBlobSequenced, &blobSequence.LastBlobSequenced, &createAt)
    - 145 + + 37 +
    - + - require.NoError(t, err) + - + if errors.Is(err, pgx.ErrNoRows) {
    - 146 + + 38 +
    - + - } + - + // If none on database return a nil object
    - 147 + + 39 +
    - + -
    + - + return nil, nil
    - 148 + + 40 +
    - + - // The process is running on background, no results yet + - + }
    - 149 + + 41 +
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgRunningOnBackground(t *testing.T) { + - + if err != nil {
    - 150 + + 42 +
    - + - data := newDataIntegrationWithPreChecker(t, true) + - + return nil, err
    - 151 + + 43 +
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) + - + }
    - 152 + + 44 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(nil) + - + blobSequence.L2Coinbase = common.HexToAddress(coinbase)
    - 153 + + 45 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) + - + blobSequence.FinalAccInputHash = common.HexToHash(finalAccInputHash)
    - 154 + + 46 +
    - + - require.Nil(t, block) + - + blobSequence.CreateAt = createAt
    - 155 + + 47 +
    - + - require.NoError(t, err) + - + return &blobSequence, nil
    - 156 + + 48 +
    - + + - }
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - 157 + + -
    - + +
    +
    +  
    - 158 + + -
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgOneProcessHaveResultOK(t *testing.T) { +
    +
    +   +
    - 159 + + -
    - + - data := newDataIntegrationWithPreChecker(t, true) +
    +
    +   +
    - 160 + + -
    - + - data.mockChecker.EXPECT().GetResult().Return(&data.resultOk) +
    +
    +   +
    - 161 + + -
    - + - data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    +   +
    - 162 + + -
    - + - // One have been stopped, so must relaunch both +
    +
    +   +
    - 163 + + -
    - + - data.mockChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 164 + + -
    - + - data.mockPreChecker.EXPECT().Run(data.ctx, mock.Anything).Return() +
    +
    +   +
    - 165 + + -
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    +   +
    - 166 + + -
    - + - require.Nil(t, block) +
    +
    +   +
    - 167 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 168 + + -
    - + - } +
    +
    +   +
    - 169 + + -
    - + +
    +
    +  
    - 170 + + -
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgMainCheckerReorg(t *testing.T) { +
    +
    +   +
    - 171 + + -
    - + - data := newDataIntegrationWithPreChecker(t, true) +
    +
    +   +
    - 172 + + -
    - + - data.mockChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    +   +
    - 173 + + -
    - + - data.mockPreChecker.EXPECT().GetResult().Return(nil) +
    +
    +   +
    - 174 + + -
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    +   +
    - 175 + + -
    - + - BlockNumber: data.resultReorg.BlockNumber - 1, +
    +
    +   +
    - 176 + + -
    - + - }, nil) +
    +
    +   +
    - 177 + + -
    - + - // One have been stopped,but is going to be launched OnResetState call after the reset +
    +
    +   +
    - 178 + + -
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    +   +
    - 179 + + -
    - + - require.NotNil(t, block) +
    +
    +   +
    - 180 + + -
    - + - require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) +
    +
    +   +
    - 181 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 182 + + -
    - + - } +
    +
    +   +
    - 183 + + -
    - + +
    +
    +  
    - 184 + + -
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgPreCheckerReorg(t *testing.T) { +
    +
    +   +
    - 185 + + -
    - + - data := newDataIntegrationWithPreChecker(t, true) +
    +
    +   +
    - 186 + + -
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) +
    +
    +   +
    - 187 + + -
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +
    +
    +   +
    - 188 + + -
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +
    +
    +   +
    - 189 + + -
    - + - BlockNumber: data.resultReorg.BlockNumber - 1, +
    +
    +   +
    - 190 + + -
    - + - }, nil) +
    +
    +   +
    - 191 + + -
    - + - // One have been stopped,but is going to be launched OnResetState call after the reset +
    +
    +   +
    - 192 + + -
    - + +
    +
    +  
    - 193 + + -
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +
    +
    +   +
    - 194 + + -
    - + - require.NotNil(t, block) +
    +
    +   +
    - 195 + + -
    - + - require.Equal(t, data.resultReorg.BlockNumber-1, block.BlockNumber) +
    +
    +   +
    - 196 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 197 + + -
    - + - } +
    +
    +   +
    - 198 + + -
    - + +
    +
    +  
    - 199 + + -
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest1(t *testing.T) { +
    +
    +   +
    - 200 + + -
    - + - data := newDataIntegrationWithPreChecker(t, true) +
    +
    +   +
    - 201 + + -
    - + - reorgMain := data.resultReorg +
    +
    +   +
    - 202 + + -
    - + - reorgMain.BlockNumber = 1235 +
    +
    +   +
    - 203 + + -
    - + - data.mockChecker.EXPECT().GetResult().Return(&reorgMain) +
    +
    +   +
    - 204 + + -
    - + - reorgPre := data.resultReorg +
    +
    +   +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_external_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -17,7 +17,7 @@
    - 205 + + 17 +
    - + - reorgPre.BlockNumber = 1236 +   + panic(err)
    - 206 + + 18 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) +   + }
    - 207 + + 19 +
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ +   + pgStateStorage = pgstatestorage.NewPostgresStorage(state.Config{}, stateDb)
    - 208 + + 20 +
    - + - BlockNumber: 1234, + - + testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil, nil)
    - 209 + + 21 +
    - + - }, nil) +   +
    - 210 + + 22 +
    - + -
    +   + for i := 1; i <= 6; i++ {
    - 211 + + 23 +
    - + - // Both have been stopped,but is going to be launched OnResetState call after the reset +   + err = testState.AddForkID(ctx, state.ForkIDInterval{ForkId: uint64(i), BlockNumber: uint64(i * 100), FromBatchNumber: uint64(i * 10), ToBatchNumber: uint64(i*10) + 9}, nil)
    - 212 + +
    @@ -76,13 +76,13 @@
    +
    + 76 +
    - + -
    +   + panic(err)
    - 213 + + 77 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +   + }
    - 214 + + 78 +
    - + - require.NotNil(t, block) +   + pgStateStorage = pgstatestorage.NewPostgresStorage(stateCfg, stateDb)
    - 215 + + 79 +
    - + - require.Equal(t, uint64(1234), block.BlockNumber) + - + testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil, nil)
    - 216 + + 80 +
    - + - require.NoError(t, err) + - + st := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, nil, nil, nil)
    - 217 + + 81 +
    - + - } +   +
    - 218 + + 82 +
    - + -
    +   + avoidMemoryStateCfg := stateCfg
    - 219 + + 83 +
    - + - func TestIntegrationCheckAndPreCheckOnOnCheckReorgBothReorgWinOldest2(t *testing.T) { +   + avoidMemoryStateCfg.AvoidForkIDInMemory = true
    - 220 + + 84 +
    - + - data := newDataIntegrationWithPreChecker(t, true) +   + pgStateStorageAvoidMemory := pgstatestorage.NewPostgresStorage(avoidMemoryStateCfg, stateDb)
    - 221 + + 85 +
    - + - reorgMain := data.resultReorg + - + stAvoidMemory := state.NewState(avoidMemoryStateCfg, pgStateStorageAvoidMemory, executorClient, stateTree, nil, nil, nil)
    - 222 + + 86 +
    - + - reorgMain.BlockNumber = 1236 +   +
    - 223 + + 87 +
    - + - data.mockChecker.EXPECT().GetResult().Return(&reorgMain) +   + // persist forkID intervals
    - 224 + + 88 +
    - + - reorgPre := data.resultReorg +   + forkIdIntervals := []state.ForkIDInterval{} +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 225 + + 17 +
    - + - reorgPre.BlockNumber = 1235 +   + panic(err)
    - 226 + + 18 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&reorgPre) +   + }
    - 227 + + 19 +
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1235), nil).Return(&state.Block{ +   + pgStateStorage = pgstatestorage.NewPostgresStorage(state.Config{}, stateDb)
    - 228 + + 20 +
    + - BlockNumber: 1234, + testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil)
    - 229 + + 21 +
    - + - }, nil) +   +
    - 230 + + 22 +
    - + - // Both have been stopped,but is going to be launched OnResetState call after the reset +   + for i := 1; i <= 6; i++ {
    - 231 + + 23 +
    - + -
    +   + err = testState.AddForkID(ctx, state.ForkIDInterval{ForkId: uint64(i), BlockNumber: uint64(i * 100), FromBatchNumber: uint64(i * 10), ToBatchNumber: uint64(i*10) + 9}, nil)
    - 232 + +
     
    +
    + 76 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, nil, nil) +   + panic(err)
    - 233 + + 77 +
    - + - require.NotNil(t, block) +   + }
    - 234 + + 78 +
    - + - require.Equal(t, uint64(1234), block.BlockNumber) +   + pgStateStorage = pgstatestorage.NewPostgresStorage(stateCfg, stateDb)
    - 235 + + 79 +
    + - require.NoError(t, err) + testState = state.NewState(stateCfg, pgStateStorage, executorClient, stateTree, nil, nil)
    - 236 + + 80 +
    + - } + st := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, nil, nil)
    - 237 + + 81 +
    - + +  
    - 238 + + 82 +
    - + - func TestIntegrationCheckReorgWrapperBypassReorgFuncIfNoBackgroundData(t *testing.T) { +   + avoidMemoryStateCfg := stateCfg
    - 239 + + 83 +
    - + - data := newDataIntegrationWithPreChecker(t, true) +   + avoidMemoryStateCfg.AvoidForkIDInMemory = true
    - 240 + + 84 +
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) +   + pgStateStorageAvoidMemory := pgstatestorage.NewPostgresStorage(avoidMemoryStateCfg, stateDb)
    - 241 + + 85 +
    + - data.mockPreChecker.EXPECT().GetResult().Return(nil) + stAvoidMemory := state.NewState(avoidMemoryStateCfg, pgStateStorageAvoidMemory, executorClient, stateTree, nil, nil)
    - 242 + + 86 +
    - + - reorgFuncBlock := &state.Block{ +   +
    - 243 + + 87 +
    - + - BlockNumber: 1234, +   + // persist forkID intervals
    - 244 + + 88 +
    - + - } +   + forkIdIntervals := []state.ForkIDInterval{} +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/forkid_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -93,7 +93,7 @@
    - 245 + + 93 +
    - + - reorgFuncErr := fmt.Errorf("error") +   + }
    - 246 + + 94 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) +   + storage := NewPostgresStorage(cfg, nil)
    - 247 + + 95 +
    - + - require.Equal(t, reorgFuncBlock, block) +   + // Create a new State instance with test data
    - 248 + + 96 +
    - + - require.Equal(t, reorgFuncErr, err) + - + state := state.NewState(cfg, storage, nil, nil, nil, nil, nil)
    - 249 + + 97 +
    - + - } +   +
    - 250 + + 98 +
    - + -
    +   + // Call the function being tested
    - 251 + + 99 +
    - + - func TestIntegrationCheckReorgWrapperChooseOldestReorgFunc(t *testing.T) { +   + actual := state.GetForkIDByBlockNumber(tc.blockNumber) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - 252 + + 93 +
    - + - data := newDataIntegrationWithPreChecker(t, true) +   + }
    - 253 + + 94 +
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) +   + storage := NewPostgresStorage(cfg, nil)
    - 254 + + 95 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +   + // Create a new State instance with test data
    - 255 + + 96 +
    + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + state := state.NewState(cfg, storage, nil, nil, nil, nil)
    - 256 + + 97 +
    - + - BlockNumber: 1233, +   +
    - 257 + + 98 +
    - + - }, nil) +   + // Call the function being tested
    - 258 + + 99 +
    - + -
    +   + actual := state.GetForkIDByBlockNumber(tc.blockNumber) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -3,48 +3,33 @@
    - 259 + + 3 +
    - + - reorgFuncBlock := &state.Block{ +   + import (
    - 260 + + 4 +
    - + - BlockNumber: 1230, +   + "context"
    - 261 + + 5 +
    - + - } +   + "errors"
    - 262 + + 6 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) + - + "fmt"
    - 263 + + 7 +
    - + - require.Equal(t, reorgFuncBlock, block) +   +
    - 264 + + 8 +
    - + - require.NoError(t, err) +   + "github.com/0xPolygonHermez/zkevm-node/state"
    - 265 + + 9 +
    - + - } +   + "github.com/ethereum/go-ethereum/common"
    - 266 + + 10 +
    - + -
    +   + "github.com/jackc/pgx/v4"
    - 267 + + 11 +
    - + - func TestIntegrationCheckReorgWrapperChooseOldestBackgroundCheck(t *testing.T) { +   + )
    - 268 + + 12 +
    - + - data := newDataIntegrationWithPreChecker(t, true) +   +
    - 269 + + 13 +
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) + - + const (
    - 270 + + 14 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) + - + l1InfoTreeIndexFieldName = "l1_info_tree_index"
    - 271 + + 15 +
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ + - + )
    - 272 + + 16 +
    - + - BlockNumber: 1233, + - +
    - 273 + + 17 +
    - + - }, nil) +   + // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error
    - 274 + + 18 +
    - + -
    +   + func (p *PostgresStorage) AddL1InfoRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx) error {
    - 275 + + 19 +
    - + - reorgFuncBlock := &state.Block{ + - + return p.addL1InfoRootToExitRootVx(ctx, exitRoot, dbTx, l1InfoTreeIndexFieldName)
    - 276 + + 20 +
    - + - BlockNumber: 1240, + - + }
    - 277 + + 21 +
    - + - } + - +
    - 278 + + 22 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, nil) + - + func (p *PostgresStorage) addL1InfoRootToExitRootVx(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx, indexFieldName string) error {
    - 279 + + 23 +
    - + - require.Equal(t, uint64(1233), block.BlockNumber) +   + const addGlobalExitRootSQL = `
    - 280 + + 24 +
    - + - require.NoError(t, err) + - + INSERT INTO state.exit_root(block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s)
    - 281 + + 25 +
    - + - } +   + VALUES ($1, $2, $3, $4, $5, $6, $7, $8);
    - 282 + + 26 +
    - + -
    +   + `
    - 283 + + 27 +
    - + - func TestIntegrationCheckReorgWrapperIgnoreReorgFuncIfError(t *testing.T) { + - + sql := fmt.Sprintf(addGlobalExitRootSQL, indexFieldName)
    - 284 + + 28 +
    - + - data := newDataIntegrationWithPreChecker(t, true) +   + e := p.getExecQuerier(dbTx)
    - 285 + + 29 +
    - + - data.mockChecker.EXPECT().GetResult().Return(nil) + - + _, err := e.Exec(ctx, sql,
    - 286 + + 30 +
    - + - data.mockPreChecker.EXPECT().GetResult().Return(&data.resultReorg) +   + exitRoot.BlockNumber, exitRoot.Timestamp, exitRoot.MainnetExitRoot, exitRoot.RollupExitRoot,
    - 287 + + 31 +
    - + - data.mockState.EXPECT().GetPreviousBlockToBlockNumber(data.ctx, uint64(1234), nil).Return(&state.Block{ +   + exitRoot.GlobalExitRoot.GlobalExitRoot, exitRoot.PreviousBlockHash, exitRoot.L1InfoTreeRoot, exitRoot.L1InfoTreeIndex)
    - 288 + + 32 +
    - + - BlockNumber: 1233, +   + return err
    - 289 + + 33 +
    - + - }, nil) +   + }
    - 290 + + 34 +
    - + +  
    - 291 + + 35 +
    - + - reorgFuncBlock := &state.Block{ +   + func (p *PostgresStorage) GetAllL1InfoRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - 292 + + 36 +
    - + - BlockNumber: 1230, + - + return p.GetAllL1InfoRootEntriesVx(ctx, dbTx, l1InfoTreeIndexFieldName)
    - 293 + + 37 +
    - + - } + - + }
    - 294 + + 38 +
    - + - reorgFuncErr := fmt.Errorf("error") + - +
    - 295 + + 39 +
    - + - block, err := data.sut.CheckReorgWrapper(data.ctx, reorgFuncBlock, reorgFuncErr) + - + func (p *PostgresStorage) GetAllL1InfoRootEntriesVx(ctx context.Context, dbTx pgx.Tx, indexFieldName string) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - 296 + + 40 +
    - + - require.Equal(t, uint64(1233), block.BlockNumber) + - + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s
    - 297 + + 41 +
    - + - require.NoError(t, err) +   + FROM state.exit_root
    - 298 + + 42 +
    - + - } -
    -
    -
    + - + WHERE %s IS NOT NULL
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -0,0 +1,139 @@
    - + + 43 -
    -   -
    +
    +
    + - + ORDER BY %s`
    - + + 44 -
    +
    +
     
    - + + 45 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName)
    - + + 46 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 47 -
    -   -
    +
    +
    + - + rows, err := e.Query(ctx, sql)
    - + + 48 -
    +
    +
      -
    + if err != nil {
    - + + 49 -
    +
    +
      -
    + return nil, err
    - + + 50 -
    +
    +
      -
    + }
    - - -
    -   -
    -
    +
    +
    @@ -65,22 +50,15 @@
    - + + 65 -
    +
    +
     
    - + + 66 -
    +
    +
      -
    + // GetLatestL1InfoRoot is used to get the latest L1InfoRoot
    - + + 67 -
    +
    +
      -
    + func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 68 -
    -   -
    +
    +
    + - + return p.GetLatestL1InfoRootVx(ctx, maxBlockNumber, nil, l1InfoTreeIndexFieldName)
    - + + 69 -
    -   -
    +
    +
    + - + }
    - + + 70 -
    -   +
    +
    + -
    - + + 71 -
    -   -
    +
    +
    + - + // GetLatestL1InfoRoot is used to get the latest L1InfoRoot
    - + + 72 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetLatestL1InfoRootVx(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 73 -
    -   -
    +
    +
    + - + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s
    - + + 74 -
    +
    +
      -
    + FROM state.exit_root
    - + + 75 -
    -   -
    +
    +
    + - + WHERE %s IS NOT NULL AND block_num <= $1
    - + + 76 -
    -   -
    +
    +
    + - + ORDER BY %s DESC LIMIT 1`
    - + + 77 -
    -   +
    +
    + -
    - + + 78 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName)
    - + + 79 -
    +
    +
     
    - + + 80 -
    +
    +
      -
    + entry := state.L1InfoTreeExitRootStorageEntry{}
    - + + 81 -
    +
    +
     
    - + + 82 -
    -   -
    +
    +
    + - + e := p.getExecQuerier(dbTx)
    - + + 83 -
    -   -
    +
    +
    + - + err := e.QueryRow(ctx, sql, maxBlockNumber).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - + + 84 -
    +
    +
      -
    + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - + + 85 -
    +
    +
     
    - + + 86 -
    +
    +
      -
    + if !errors.Is(err, pgx.ErrNoRows) {
    - - -
    -   -
    -
    +
    +
    @@ -90,16 +68,11 @@
    - + + 90 -
    +
    +
      -
    + return entry, nil
    - + + 91 -
    +
    +
      -
    + }
    - + + 92 -
    +
    +
      -
    + func (p *PostgresStorage) GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) {
    - + + 93 -
    -   -
    +
    +
    + - + return p.GetLatestIndexVx(ctx, dbTx, l1InfoTreeIndexFieldName)
    - + + 94 -
    -   -
    +
    +
    + - + }
    - + + 95 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetLatestIndexVx(ctx context.Context, dbTx pgx.Tx, indexFieldName string) (uint32, error) {
    - + + 96 -
    -   -
    +
    +
    + - + const getLatestIndexSQL = `SELECT max(%s) as %s FROM state.exit_root
    - + + 97 -
    -   -
    +
    +
    + - + WHERE %s IS NOT NULL`
    - + + 98 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getLatestIndexSQL, indexFieldName, indexFieldName, indexFieldName)
    - + + 99 -
    -   +
    +
    + -
    - + + 100 -
    +
    +
      -
    + var l1InfoTreeIndex *uint32
    - + + 101 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 102 -
    -   -
    +
    +
    + - + err := e.QueryRow(ctx, sql).Scan(&l1InfoTreeIndex)
    - + + 103 -
    +
    +
      -
    + if err != nil {
    - + + 104 -
    +
    +
      -
    + return 0, err
    - + + 105 -
    +
    +
      -
    + }
    - + +
    @@ -110,17 +83,13 @@
    -
    +
    + 110 + +
      -
    + }
    - + + 111 -
    +
    +
     
    - + + 112 -
    +
    +
      -
    + func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 113 -
    -   -
    +
    +
    + - + return p.GetL1InfoRootLeafByL1InfoRootVx(ctx, l1InfoRoot, dbTx, l1InfoTreeIndexFieldName)
    - + + 114 -
    -   -
    +
    +
    + - + }
    - + + 115 -
    -   +
    +
    + -
    - + + 116 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRootVx(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 117 -
    -   -
    +
    +
    + - + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s
    - + + 118 -
    +
    +
      -
    + FROM state.exit_root
    - + + 119 -
    -   -
    +
    +
    + - + WHERE %s IS NOT NULL AND l1_info_root=$1`
    - + + 120 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getL1InfoRootSQL, indexFieldName, indexFieldName)
    - + + 121 -
    +
    +
      -
    + var entry state.L1InfoTreeExitRootStorageEntry
    - + + 122 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 123 -
    -   -
    +
    +
    + - + err := e.QueryRow(ctx, sql, l1InfoRoot).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - + + 124 -
    +
    +
      -
    + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - + + 125 -
    +
    +
      -
    + if !errors.Is(err, pgx.ErrNoRows) {
    - + + 126 -
    +
    +
      -
    + return entry, err
    - + +
    @@ -129,17 +98,13 @@
    -
    +
    + 129 + +
      -
    + }
    - + + 130 -
    +
    +
     
    - + + 131 -
    +
    +
      -
    + func (p *PostgresStorage) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 132 -
    -   -
    +
    +
    + - + return p.GetL1InfoRootLeafByIndexVx(ctx, l1InfoTreeIndex, dbTx, l1InfoTreeIndexFieldName)
    - + + 133 -
    -   -
    +
    +
    + - + }
    - + + 134 -
    -   +
    +
    + -
    - + + 135 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetL1InfoRootLeafByIndexVx(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx, indexFieldName string) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 136 -
    -   -
    +
    +
    + - + const getL1InfoRootByIndexSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s
    - + + 137 -
    +
    +
      -
    + FROM state.exit_root
    - + + 138 -
    -   -
    +
    +
    + - + WHERE %s = $1`
    - + + 139 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getL1InfoRootByIndexSQL, indexFieldName, indexFieldName)
    - + + 140 -
    +
    +
      -
    + var entry state.L1InfoTreeExitRootStorageEntry
    - + + 141 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 142 -
    -   -
    +
    +
    + - + err := e.QueryRow(ctx, sql, l1InfoTreeIndex).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - + + 143 -
    +
    +
      -
    + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - + + 144 -
    +
    +
      -
    + if !errors.Is(err, pgx.ErrNoRows) {
    - + + 145 -
    +
    +
      -
    + return entry, err
    - - -
    -   -
    -
    +
    +
    @@ -148,18 +113,14 @@
    - + + 148 -
    +
    +
      -
    + }
    - + + 149 -
    +
    +
     
    - + + 150 -
    +
    +
      -
    + func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 151 -
    -   -
    +
    +
    + - + return p.GetLeavesByL1InfoRootVx(ctx, l1InfoRoot, dbTx, l1InfoTreeIndexFieldName)
    - + + 152 -
    -   -
    +
    +
    + - + }
    - + + 153 -
    -   +
    +
    + -
    - + + 154 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetLeavesByL1InfoRootVx(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx, indexFieldName string) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 155 -
    +
    +
      -
    + // TODO: Optimize this query
    - + + 156 -
    -   -
    +
    +
    + - + const getLeavesByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, %s
    - + + 157 -
    +
    +
      -
    + FROM state.exit_root
    - + + 158 -
    -   -
    +
    +
    + - + WHERE %s IS NOT NULL AND %s <= (SELECT %s FROM state.exit_root WHERE l1_info_root=$1)
    - + + 159 -
    -   -
    +
    +
    + - + ORDER BY %s ASC`
    - + + 160 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf(getLeavesByL1InfoRootSQL, indexFieldName, indexFieldName, indexFieldName, indexFieldName, indexFieldName)
    - + + 161 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 162 -
    -   -
    +
    +
    + - + rows, err := e.Query(ctx, sql, l1InfoRoot)
    - + + 163 -
    +
    +
      -
    + if err != nil {
    - + + 164 -
    +
    +
      -
    + return nil, err
    - + + 165 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -166463,61 +243961,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - @@ -166623,43 +244121,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -166673,93 +244171,93 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - @@ -166802,1538 +244300,1533 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    +
     
    - + + 3 -
    +
    +
      -
    + import (
    - + + 4 -
    +
    +
      -
    + "context"
    - + + 5 -
    +
    +
      -
    + "errors"
    - + + 6 -
    +
    +
     
    - + + 7 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 8 -
    +
    +
      -
    + "github.com/ethereum/go-ethereum/common"
    - + + 9 -
    +
    +
      -
    + "github.com/jackc/pgx/v4"
    - + + 10 -
    +
    +
      -
    + )
    - + + 11 -
    +
    +
     
    @@ -166563,23 +244061,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 12 -
    +
    +
      -
    + // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error
    - + + 13 -
    +
    +
      -
    + func (p *PostgresStorage) AddL1InfoRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeExitRootStorageEntry, dbTx pgx.Tx) error {
    - + + 14 -
    +
    +
      -
    + const addGlobalExitRootSQL = `
    - + + 15 -
    -   -
    +
    +
    + + + INSERT INTO state.exit_root(block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index)
    - + + 16 -
    +
    +
      -
    + VALUES ($1, $2, $3, $4, $5, $6, $7, $8);
    - + + 17 -
    +
    +
      -
    + `
    - + + 18 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 19 -
    -   -
    +
    +
    + + + _, err := e.Exec(ctx, addGlobalExitRootSQL,
    - + + 20 -
    +
    +
      -
    + exitRoot.BlockNumber, exitRoot.Timestamp, exitRoot.MainnetExitRoot, exitRoot.RollupExitRoot,
    - + + 21 -
    +
    +
      -
    + exitRoot.GlobalExitRoot.GlobalExitRoot, exitRoot.PreviousBlockHash, exitRoot.L1InfoTreeRoot, exitRoot.L1InfoTreeIndex)
    - + + 22 -
    +
    +
      -
    + return err
    - + + 23 -
    +
    +
      -
    + }
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + func (p *PostgresStorage) GetAllL1InfoRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 26 -
    -   -
    +
    +
    + + + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    -
    - 1 + + 27 +
    - + - package l1_check_block +   + FROM state.exit_root
    - 2 + + 28 +
    + -
    + WHERE l1_info_tree_index IS NOT NULL
    - 3 + + 29 +
    + - // This make a pre-check of blocks but don't mark them as checked + ORDER BY l1_info_tree_index`
    - 4 + + 30 +
    - + - // It checks blocks between a segment: example: +   +
    - 5 + + -
    - + - // real check point SAFE: +
    +
    +   +
    - 6 + + 31 +
    - + - // pre check: (SAFE+1) -> (LATEST-32) +   + e := p.getExecQuerier(dbTx)
    - 7 + + 32 +
    + - // It gets all pending blocks + rows, err := e.Query(ctx, getL1InfoRootSQL)
    - 8 + + 33 +
    - + - // - Start cheking +   + if err != nil {
    - 9 + + 34 +
    - + -
    +   + return nil, err
    - 10 + + 35 +
    - + - import ( +   + }
    - 11 + +
     
    +
    + 50 +
    - + - "context" +   +
    - 12 + + 51 +
    - + - "errors" +   + // GetLatestL1InfoRoot is used to get the latest L1InfoRoot
    - 13 + + 52 +
    - + - "fmt" +   + func (p *PostgresStorage) GetLatestL1InfoRoot(ctx context.Context, maxBlockNumber uint64) (state.L1InfoTreeExitRootStorageEntry, error) {
    - 14 + + 53 +
    + - "time" + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 15 + + -
    - + +
    +
    +  
    - 16 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/log" +
    +
    +   +
    - 17 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/state" +
    +
    +   +
    - 18 + + -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" +
    +
    +   +
    - 19 + + -
    - + - "github.com/jackc/pgx/v4" +
    +
    +   +
    - 20 + + 54 +
    - + - ) +   + FROM state.exit_root
    - 21 + + 55 +
    + -
    + WHERE l1_info_tree_index IS NOT NULL AND block_num <= $1
    - 22 + + 56 +
    + - var ( + ORDER BY l1_info_tree_index DESC LIMIT 1`
    - 23 + + -
    - + - // ErrDeSync is an error that indicates that from the starting of verification to end something have been changed on state +
    +
    +   +
    - 24 + + -
    - + - ErrDeSync = errors.New("DeSync: a block hash is different from the state block hash") +
    +
    +   +
    - 25 + + 57 +
    - + - ) +   +
    - 26 + + 58 +
    - + -
    +   + entry := state.L1InfoTreeExitRootStorageEntry{}
    - 27 + + 59 +
    - + - // StatePreCheckInterfacer is an interface for the state +   +
    - 28 + + 60 +
    + - type StatePreCheckInterfacer interface { + e := p.getExecQuerier(nil)
    - 29 + + 61 +
    + - GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error) + err := e.QueryRow(ctx, getL1InfoRootSQL, maxBlockNumber).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - 30 + + 62 +
    - + - } +   + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - 31 + + 63 +
    - + +  
    - 32 + + 64 +
    - + - // PreCheckL1BlockHash is a struct that implements a checker of L1Block hash +   + if !errors.Is(err, pgx.ErrNoRows) {
    - 33 - -
    - + - type PreCheckL1BlockHash struct { -
    +
    +
     
    - 34 + + 68 +
    - + - L1Client L1Requester +   + return entry, nil
    - 35 + + 69 +
    - + - State StatePreCheckInterfacer +   + }
    - 36 + + 70 +
    - + - InitialSegmentBlockNumber SafeL1BlockNumberFetcher +   + func (p *PostgresStorage) GetLatestIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) {
    - 37 + + 71 +
    + - EndSegmentBlockNumber SafeL1BlockNumberFetcher + const getLatestIndexSQL = `SELECT max(l1_info_tree_index) as l1_info_tree_index FROM state.exit_root
    - 38 + + 72 +
    + - } + WHERE l1_info_tree_index IS NOT NULL`
    - 39 + + -
    - + +
    +
    +  
    - 40 + + -
    - + - // NewPreCheckL1BlockHash creates a new CheckL1BlockHash +
    +
    +   +
    - 41 + + -
    - + - func NewPreCheckL1BlockHash(l1Client L1Requester, state StatePreCheckInterfacer, +
    +
    +   +
    - 42 + + -
    - + - initial, end SafeL1BlockNumberFetcher) *PreCheckL1BlockHash { +
    +
    +   +
    - 43 + + -
    - + - return &PreCheckL1BlockHash{ +
    +
    +   +
    - 44 + + 73 +
    - + - L1Client: l1Client, +   + var l1InfoTreeIndex *uint32
    - 45 + + 74 +
    - + - State: state, +   + e := p.getExecQuerier(dbTx)
    - 46 + + 75 +
    + - InitialSegmentBlockNumber: initial, + err := e.QueryRow(ctx, getLatestIndexSQL).Scan(&l1InfoTreeIndex)
    - 47 + + 76 +
    - + - EndSegmentBlockNumber: end, +   + if err != nil {
    - 48 + + 77 +
    - + - } +   + return 0, err
    - 49 + + 78 +
    - + - } +   + }
    - 50 - -
    - + -
    -
    +
    +
     
    - 51 + + 83 +
    - + - // Name is a method that returns the name of the checker +   + }
    - 52 + + 84 +
    - + - func (p *PreCheckL1BlockHash) Name() string { +   +
    - 53 + + 85 +
    - + - return logPrefix + ":memory_check: " +   + func (p *PostgresStorage) GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) {
    - 54 + + 86 +
    + - } + const getL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 55 + + -
    - + +
    +
    +  
    - 56 + + -
    - + - // Step is a method that checks the L1 block hash, run until all blocks are checked and returns +
    +
    +   +
    - 57 + + -
    - + - func (p *PreCheckL1BlockHash) Step(ctx context.Context) error { +
    +
    +   +
    - 58 + + -
    - + - from, err := p.InitialSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) +
    +
    +   +
    - 59 + + 87 +
    - + - if err != nil { +   + FROM state.exit_root
    - 60 + + 88 +
    + - return err + WHERE l1_info_tree_index IS NOT NULL AND l1_info_root=$1`
    - 61 + + 89 +
    + - } +
    - 62 + + 90 +
    - + - to, err := p.EndSegmentBlockNumber.GetSafeBlockNumber(ctx, p.L1Client) +   + var entry state.L1InfoTreeExitRootStorageEntry
    - 63 + + 91 +
    - + - if err != nil { +   + e := p.getExecQuerier(dbTx)
    - 64 + + 92 +
    + - return err + err := e.QueryRow(ctx, getL1InfoRootSQL, l1InfoRoot).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - 65 + + 93 +
    - + - } +   + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - 66 + + 94 +
    - + - if from > to { +   + if !errors.Is(err, pgx.ErrNoRows) {
    - 67 + + 95 +
    - + - log.Warnf("%s: fromBlockNumber(%s) %d is greater than toBlockNumber(%s) %d, Check configuration", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to) +   + return entry, err
    - 68 + +
     
    +
    + 98 +
    - + - return nil +   + }
    - 69 + + 99 +
    - + - } +   +
    - 70 + + 100 +
    - + -
    +   + func (p *PostgresStorage) GetL1InfoRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) {
    - 71 + + 101 +
    + - blocksToCheck, err := p.State.GetUncheckedBlocks(ctx, from, to, nil) + const getL1InfoRootByIndexSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 72 + + -
    - + - if err != nil { +
    +
    +   +
    - 73 + + -
    - + - log.Warnf("%s can't get unchecked blocks, so it discard the reorg error", p.Name()) +
    +
    +   +
    - 74 + + -
    - + - return err +
    +
    +   +
    - 75 + + -
    - + - } +
    +
    +   +
    - 76 + + 102 +
    - + - msg := fmt.Sprintf("%s: Checking blocks from (%s) %d to (%s) %d -> len(blocks)=%d", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck)) +   + FROM state.exit_root
    - 77 + + 103 +
    + - if len(blocksToCheck) == 0 { + WHERE l1_info_tree_index = $1`
    - 78 + + 104 +
    + - log.Debugf(msg) +
    - 79 + + 105 +
    - + - return nil +   + var entry state.L1InfoTreeExitRootStorageEntry
    - 80 + + 106 +
    - + - } +   + e := p.getExecQuerier(dbTx)
    - 81 + + 107 +
    + - log.Infof(msg) + err := e.QueryRow(ctx, getL1InfoRootByIndexSQL, l1InfoTreeIndex).Scan(&entry.BlockNumber, &entry.Timestamp, &entry.MainnetExitRoot, &entry.RollupExitRoot, &entry.GlobalExitRoot.GlobalExitRoot,
    - 82 + + 108 +
    - + - startTime := time.Now() +   + &entry.PreviousBlockHash, &entry.L1InfoTreeRoot, &entry.L1InfoTreeIndex)
    - 83 + + 109 +
    - + - for _, block := range blocksToCheck { +   + if !errors.Is(err, pgx.ErrNoRows) {
    - 84 + + 110 +
    - + - // check block +   + return entry, err
    - 85 + +
     
    +
    + 113 +
    - + - err = CheckBlockHash(ctx, block, p.L1Client, p.Name()) +   + }
    - 86 + + 114 +
    - + - if common.IsReorgError(err) { +   +
    - 87 + + 115 +
    - + - // Double-check the state block that still is the same +   + func (p *PostgresStorage) GetLeavesByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) ([]state.L1InfoTreeExitRootStorageEntry, error) {
    - 88 + + -
    - + - log.Debugf("%s: Reorg detected at blockNumber: %d, checking that the block on State doesn't have change", p.Name(), block.BlockNumber) +
    +
    +   +
    - 89 + + -
    - + - isTheSame, errBlockIsTheSame := p.checkThatStateBlockIsTheSame(ctx, block) +
    +
    +   +
    - 90 + + -
    - + - if errBlockIsTheSame != nil { +
    +
    +   +
    - 91 + + -
    - + - log.Warnf("%s can't double-check that blockNumber %d haven't changed, so it discard the reorg error", p.Name(), block.BlockNumber) +
    +
    +   +
    - 92 + + 116 +
    - + - return err +   + // TODO: Optimize this query
    - 93 + + 117 +
    + - } + const getLeafsByL1InfoRootSQL = `SELECT block_num, timestamp, mainnet_exit_root, rollup_exit_root, global_exit_root, prev_block_hash, l1_info_root, l1_info_tree_index
    - 94 + + 118 +
    - + - if !isTheSame { +   + FROM state.exit_root
    - 95 + + 119 +
    + - log.Infof("%s: DeSync detected, blockNumber: %d is different now that when we started the check", p.Name(), block.BlockNumber) + WHERE l1_info_tree_index IS NOT NULL AND l1_info_tree_index <= (SELECT l1_info_tree_index FROM state.exit_root WHERE l1_info_root=$1)
    - 96 + + 120 +
    + - return ErrDeSync + ORDER BY l1_info_tree_index ASC`
    - 97 + + 121 +
    + - } +
    - 98 + + 122 +
    - + - log.Infof("%s: Reorg detected and verified the state block, blockNumber: %d", p.Name(), block.BlockNumber) +   + e := p.getExecQuerier(dbTx)
    - 99 + + 123 +
    + - return err + rows, err := e.Query(ctx, getLeafsByL1InfoRootSQL, l1InfoRoot)
    - 100 + + 124 +
    - + - } +   + if err != nil {
    - 101 + + 125 +
    - + - if err != nil { +   + return nil, err
    - 102 + + 126 +
    - + - return err +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/l1infotree_recursive.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -1,46 +0,0 @@
    - 103 + + 1 +
    - + - } + - + package pgstatestorage
    - 104 + + 2 +
    - + - } + - +
    - 105 + + 3 +
    - + - elapsed := time.Since(startTime) + - + import (
    - 106 + + 4 +
    - + - log.Infof("%s: Checked blocks from (%s) %d to (%s) %d -> len(blocks):%d elapsed: %s", p.Name(), p.InitialSegmentBlockNumber.Description(), from, p.EndSegmentBlockNumber.Description(), to, len(blocksToCheck), elapsed.String()) + - + "context"
    - 107 + + 5 +
    - + + -
    - 108 + + 6 +
    - + - return nil + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 109 + + 7 +
    - + - } + - + "github.com/jackc/pgx/v4"
    - 110 + + 8 +
    - + -
    + - + )
    - 111 + + 9 +
    - + - // CheckBlockHash is a method that checks the L1 block hash + - +
    - 112 + + 10 +
    - + - // returns true if is the same + - + const (
    - 113 + + 11 +
    - + - func (p *PreCheckL1BlockHash) checkThatStateBlockIsTheSame(ctx context.Context, block *state.Block) (bool, error) { + - + l1InfoTreeRecursiveIndexFieldName = "l1_info_tree_recursive_index"
    - 114 + + 12 +
    - + - blocks, err := p.State.GetUncheckedBlocks(ctx, block.BlockNumber, block.BlockNumber, nil) + - + )
    - 115 + + 13 +
    - + - if err != nil { + - +
    - 116 + + 14 +
    - + - log.Warnf("%s: Fails to get blockNumber %d in state .Err:%s", p.Name(), block.BlockNumber, err.Error()) + - + // AddL1InfoRootToExitRoot adds a new entry in ExitRoot and returns index of L1InfoTree and error
    - 117 + + 15 +
    - + - return false, err + - + func (p *PostgresStorage) AddL1InfoTreeRecursiveRootToExitRoot(ctx context.Context, exitRoot *state.L1InfoTreeRecursiveExitRootStorageEntry, dbTx pgx.Tx) error {
    - 118 + + 16 +
    - + - } + - + exitRootOld := state.L1InfoTreeExitRootStorageEntry(*exitRoot)
    - 119 + + 17 +
    - + - if len(blocks) == 0 { + - + return p.addL1InfoRootToExitRootVx(ctx, &exitRootOld, dbTx, l1InfoTreeRecursiveIndexFieldName)
    - 120 + + 18 +
    - + - // The block is checked or deleted, so it is not the same + - + }
    - 121 + + 19 +
    - + - log.Debugf("%s: The blockNumber %d is no longer in the state (or checked or deleted)", p.Name(), block.BlockNumber) + - +
    - 122 + + 20 +
    - + - return false, nil + - + func (p *PostgresStorage) GetAllL1InfoTreeRecursiveRootEntries(ctx context.Context, dbTx pgx.Tx) ([]state.L1InfoTreeRecursiveExitRootStorageEntry, error) {
    - 123 + + 21 +
    - + - } + - + res, err := p.GetAllL1InfoRootEntriesVx(ctx, dbTx, l1InfoTreeRecursiveIndexFieldName)
    - 124 + + 22 +
    - + - stateBlock := blocks[0] + - + if err != nil {
    - 125 + + 23 +
    - + - if stateBlock.BlockNumber != block.BlockNumber { + - + return nil, err
    - 126 + + 24 +
    - + - msg := fmt.Sprintf("%s: The blockNumber returned by state %d is different from the state blockNumber %d", + - + }
    - 127 + + 25 +
    - + - p.Name(), block.BlockNumber, stateBlock.BlockNumber) + - + var entries []state.L1InfoTreeRecursiveExitRootStorageEntry
    - 128 + + 26 +
    - + - log.Warn(msg) + - + for _, entry := range res {
    - 129 + + 27 +
    - + - return false, fmt.Errorf(msg) + - + entries = append(entries, state.L1InfoTreeRecursiveExitRootStorageEntry(entry))
    - 130 + + 28 +
    - + + - }
    - 131 + + 29 +
    - + - if stateBlock.BlockHash != block.BlockHash { + - + return entries, nil
    - 132 + + 30 +
    - + - msg := fmt.Sprintf("%s: The blockNumber %d differs the hash checked %s from current in state %s", + - + }
    - 133 + + 31 +
    - + - p.Name(), block.BlockNumber, block.BlockHash.String(), stateBlock.BlockHash.String()) + - +
    - 134 + + 32 +
    - + - log.Warn(msg) + - + func (p *PostgresStorage) GetLatestL1InfoTreeRecursiveRoot(ctx context.Context, maxBlockNumber uint64, dbTx pgx.Tx) (state.L1InfoTreeRecursiveExitRootStorageEntry, error) {
    - 135 + + 33 +
    - + - return false, nil + - + res, err := p.GetLatestL1InfoRootVx(ctx, maxBlockNumber, dbTx, l1InfoTreeRecursiveIndexFieldName)
    - 136 + + 34 +
    - + - } + - + if err != nil {
    - 137 + + 35 +
    - + - // The block is the same + - + return state.L1InfoTreeRecursiveExitRootStorageEntry{}, err
    - 138 + + 36 +
    - + - return true, nil + - + }
    - 139 + + 37 +
    - + - } -
    -
    -
    + - + return state.L1InfoTreeRecursiveExitRootStorageEntry(res), nil
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/pre_check_l1block_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -0,0 +1,144 @@
    - + + 38 -
    -   -
    +
    +
    + - + }
    - + + 39 -
    -   +
    +
    + -
    - + + 40 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetLatestL1InfoTreeRecursiveIndex(ctx context.Context, dbTx pgx.Tx) (uint32, error) {
    - + + 41 -
    -   -
    +
    +
    + - + return p.GetLatestIndexVx(ctx, dbTx, l1InfoTreeRecursiveIndexFieldName)
    - + + 42 -
    -   -
    +
    +
    + - + }
    - + + 43 -
    -   +
    +
    + -
    - + + 44 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error) {
    - + + 45 -
    -   -
    +
    +
    + - + return p.GetL1InfoRootLeafByIndexVx(ctx, l1InfoTreeIndex, dbTx, l1InfoTreeIndexFieldName)
    - + + 46 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - + +
    +
     
    @@ -168795,44 +246288,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -169689,249 +247201,279 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + +
    +
    @@ -355,3 +355,87 @@
    - + + 355 -
    +
    +
      -
    + }
    - + + 356 -
    +
    +
      -
    + return nativeBlockHashes, nil
    - + + 357 -
    +
    +
      -
    + }
     
    + 355 + +
    +   + } +
    +
    + 356 + +
    +   + return nativeBlockHashes, nil +
    +
    + 357 + +
    +   + } +
    +
    - 1 + 358
    + - package l1_check_block_test +
    - 2 + 359
    + -
    + // GetBatchL2DataByNumber returns the batch L2 data of the given batch number.
    - 3 + 360
    + - import ( + func (p *PostgresStorage) GetBatchL2DataByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) ([]byte, error) {
    - 4 + 361
    + - "context" + batchData, err := p.GetBatchL2DataByNumbers(ctx, []uint64{batchNumber}, dbTx)
    - 5 + 362
    + - "math/big" + if err != nil {
    - 6 + 363
    + - "testing" + return nil, err
    - 7 + 364
    + -
    + }
    - 8 + 365
    + - "github.com/0xPolygonHermez/zkevm-node/state" + data, ok := batchData[batchNumber]
    - 9 + 366
    + - commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + if !ok {
    - 10 + 367
    + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + return nil, state.ErrNotFound
    - 11 + 368
    + - mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" + }
    - 12 + 369
    + - "github.com/ethereum/go-ethereum/common" + return data, nil
    - 13 + 370
    + - "github.com/ethereum/go-ethereum/core/types" + }
    - 14 + 371
    + - "github.com/stretchr/testify/require" +
    - 15 + 372
    + - ) + // GetBatchL2DataByNumbers returns the batch L2 data of the given batch numbers. The data is a union of state.batch and state.forced_batch tables.
    - 16 + 373
    + -
    + func (p *PostgresStorage) GetBatchL2DataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 17 + 374
    + - type testPreCheckData struct { + const sql = "SELECT batch_num, raw_txs_data FROM state.batch WHERE batch_num = ANY($1)"
    - 18 + 375
    + - sut *l1_check_block.PreCheckL1BlockHash + return p.getBatchData(ctx, sql, batchNumbers, dbTx)
    - 19 + 376
    + - mockL1Client *mock_l1_check_block.L1Requester + }
    - 20 + 377
    + - mockState *mock_l1_check_block.StatePreCheckInterfacer +
    - 21 + 378
    + - mockInitialFetch *mock_l1_check_block.SafeL1BlockNumberFetcher + // GetForcedBatchDataByNumbers returns the forced batch data of the given batch numbers
    - 22 + 379
    + - mockEndFetch *mock_l1_check_block.SafeL1BlockNumberFetcher + func (p *PostgresStorage) GetForcedBatchDataByNumbers(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 23 + 380
    + - ctx context.Context + const sql = "SELECT forced_batch_num, convert_from(decode(raw_txs_data, 'hex'), 'UTF8')::bytea FROM state.forced_batch WHERE forced_batch_num = ANY($1)"
    - 24 + 381
    + - stateBlocks []*state.Block + return p.getBatchData(ctx, sql, batchNumbers, dbTx)
    - 25 + 382
    @@ -169941,7 +247483,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 26 + 383
    @@ -169951,377 +247493,377 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 27 + 384
    + - func newPreCheckData(t *testing.T) *testPreCheckData { + func (p *PostgresStorage) getBatchData(ctx context.Context, sql string, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 28 + 385
    + - mockL1Client := mock_l1_check_block.NewL1Requester(t) + q := p.getExecQuerier(dbTx)
    - 29 + 386
    + - mockState := mock_l1_check_block.NewStatePreCheckInterfacer(t) + rows, err := q.Query(ctx, sql, batchNumbers)
    - 30 + 387
    + - mockInitialFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) + if errors.Is(err, pgx.ErrNoRows) {
    - 31 + 388
    + - mockEndFetch := mock_l1_check_block.NewSafeL1BlockNumberFetcher(t) + return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx)
    - 32 + 389
    + - sut := l1_check_block.NewPreCheckL1BlockHash(mockL1Client, mockState, mockInitialFetch, mockEndFetch) + } else if err != nil {
    - 33 + 390
    + - return &testPreCheckData{ + return nil, err
    - 34 + 391
    + - sut: sut, + }
    - 35 + 392
    + - mockL1Client: mockL1Client, + defer rows.Close()
    - 36 + 393
    + - mockState: mockState, +
    - 37 + 394
    + - mockInitialFetch: mockInitialFetch, + batchL2DataMap, err := readBatchDataResults(rows, batchNumbers)
    - 38 + 395
    + - mockEndFetch: mockEndFetch, + if err != nil {
    - 39 + 396
    + - ctx: context.Background(), + return nil, err
    - 40 + 397
    + - stateBlocks: []*state.Block{ + }
    - 41 + 398
    + - { +
    - 42 + 399
    + - BlockNumber: 1234, + if len(batchL2DataMap) == 0 {
    - 43 + 400
    + - BlockHash: common.HexToHash("0xd77dd3a9ee6f9202ca5a75024b7d9cbd3d7436b2910d450f88c261c0089c0cd9"), + return p.GetBatchL2DataByNumbersFromBackup(ctx, batchNumbers, dbTx)
    - 44 + 401
    + - }, + }
    - 45 + 402
    + - { +
    - 46 + 403
    + - BlockNumber: 1237, + return batchL2DataMap, nil
    - 47 + 404
    + - BlockHash: common.HexToHash("0x8faffac37f561c18917c33ff3540262ecfbe11a367b4e1c48181326cd8ba347f"), + }
    - 48 + 405
    + - }, +
    - 49 + 406
    + - }, + // GetBatchL2DataByNumbersFromBackup returns the batch L2 data of the given batch number from the backup table
    - 50 + 407
    + - } + func (p *PostgresStorage) GetBatchL2DataByNumbersFromBackup(ctx context.Context, batchNumbers []uint64, dbTx pgx.Tx) (map[uint64][]byte, error) {
    - 51 + 408
    + - } + getBatchL2DataByBatchNumber := `
    - 52 + 409
    + -
    + SELECT batch_num, data FROM state.batch_data_backup
    - 53 + 410
    + - // If from > to, it ignore because there are no blocks to check + WHERE batch_num = ANY($1)
    - 54 + 411
    + - func TestPreCheckL1BlockFromGreaterThanTo(t *testing.T) { + ORDER BY created_at DESC
    - 55 + 412
    + - data := newPreCheckData(t) + `
    - 56 + 413
    + - data.mockInitialFetch.EXPECT().Description().Return("initial") + q := p.getExecQuerier(dbTx)
    - 57 + 414
    + - data.mockEndFetch.EXPECT().Description().Return("end") + rows, err := q.Query(ctx, getBatchL2DataByBatchNumber, batchNumbers)
    - 58 + 415
    + - data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + if errors.Is(err, pgx.ErrNoRows) {
    - 59 + 416
    + - data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1230), nil) + return nil, state.ErrNotFound
    - 60 + 417
    + -
    + } else if err != nil {
    - 61 + 418
    + - res := data.sut.Step(data.ctx) + return nil, err
    - 62 + 419
    + - require.NoError(t, res) + }
    - 63 + 420
    + - } + defer rows.Close()
    - 64 + 421
    @@ -170331,832 +247873,972 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 65 + 422
    + - // No blocks on state -> nothing to do + return readBatchDataResults(rows, batchNumbers)
    - 66 + 423
    + - func TestPreCheckL1BlockNoBlocksOnState(t *testing.T) { + }
    - 67 + 424
    + - data := newPreCheckData(t) +
    - 68 + 425
    + - data.mockInitialFetch.EXPECT().Description().Return("initial") + // readBatchDataResults retrieves batch data from the provided result set
    - 69 + 426
    + - data.mockEndFetch.EXPECT().Description().Return("end") + func readBatchDataResults(results pgx.Rows, batchNumbers []uint64) (map[uint64][]byte, error) {
    - 70 + 427
    + - data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + batchL2DataMap := make(map[uint64][]byte, len(batchNumbers))
    - 71 + 428
    + - data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + for results.Next() {
    - 72 + 429
    + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(nil, nil) + var (
    - 73 + 430
    + -
    + batchNum uint64
    - 74 + 431
    + - res := data.sut.Step(data.ctx) + batchL2Data []byte
    - 75 + 432
    + - require.NoError(t, res) + )
    - 76 + 433
    + - } +
    - 77 + 434
    + -
    + if err := results.Scan(&batchNum, &batchL2Data); err != nil {
    - 78 + 435
    + - func TestPreCheckL1BlockBlocksMatch(t *testing.T) { + return nil, err
    - 79 + 436
    + - data := newPreCheckData(t) + }
    - 80 + 437
    + - data.mockInitialFetch.EXPECT().Description().Return("initial") + batchL2DataMap[batchNum] = batchL2Data
    - 81 + 438
    + - data.mockEndFetch.EXPECT().Description().Return("end") + }
    - 82 + 439
    + - data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +
    - 83 + 440
    + - data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + return batchL2DataMap, nil
    - 84 + 441
    + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/pgstatestorage_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - + + + - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - + - + + - - + + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - + + + - - - - - - - - - - - - - - - - - + - + + - - - - -
    +
    @@ -110,11 +110,7 @@
    - 85 + + 110 +
    - + - l1Block1 := &types.Header{ +   + if err != nil {
    - 86 + + 111 +
    - + - Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), +   + panic(err)
    - 87 + + 112 +
    - + +   }
    - 88 + + 113 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 89 + + 114 +
    - + - l1Block2 := &types.Header{ + - + if err != nil {
    - 90 + + 115 +
    - + - Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), + - + panic(err)
    - 91 + + 116 +
    - + + - }
    - 92 + + 117 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + - + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, eventLog, mt, mtr)
    - 93 + + 118 +
    - + - //data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[0:1], nil) +   +
    - 94 + + 119 +
    - + +   + result := m.Run() +
    +
    + 120 + +
    +  
    - 95 + +
    @@ -463,7 +459,7 @@
    +
    + 463 +
    - + - res := data.sut.Step(data.ctx) +   + batchNumber := uint64(42)
    - 96 + + 464 +
    - + - require.NoError(t, res) +   + _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num,wip) VALUES ($1, FALSE), ($2, FALSE), ($3, FALSE)", batchNumber, batchNumber+1, batchNumber+2)
    - 97 + + 465 +
    - + - } +   + require.NoError(err)
    - 98 + + 466 +
    - + -
    + - + const addGeneratedProofSQL = "INSERT INTO state.batch_proof (batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"
    - 99 + + 467 +
    - + - func TestPreCheckL1BlockBlocksMismatch(t *testing.T) { +   + // proof with `generating_since` older than interval
    - 100 + + 468 +
    - + - data := newPreCheckData(t) +   + now := time.Now().Round(time.Microsecond)
    - 101 + + 469 +
    - + - data.mockInitialFetch.EXPECT().Description().Return("initial") +   + oneHourAgo := now.Add(-time.Hour).Round(time.Microsecond)
    - 102 + +
    @@ -500,10 +496,10 @@
    +
    + 500 +
    - + - data.mockEndFetch.EXPECT().Description().Return("end") +   + _, err = testState.Exec(ctx, addGeneratedProofSQL, olderNotGenProof.BatchNumber, olderNotGenProof.BatchNumberFinal, olderNotGenProof.Proof, olderNotGenProof.ProofID, olderNotGenProof.InputProver, olderNotGenProof.Prover, olderNotGenProof.ProverID, olderNotGenProof.GeneratingSince, oneHourAgo, oneHourAgo)
    - 103 + + 501 +
    - + - data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) +   + require.NoError(err)
    - 104 + + 502 +
    - + - data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) +   +
    - 105 + + 503 +
    - + - data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") + - + _, err = testState.CleanupLockedBatchProofs(ctx, "1m", nil)
    - 106 + + 504 +
    - + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) +   +
    - 107 + + 505 +
    - + - l1Block1 := &types.Header{ +   + require.NoError(err)
    - 108 + + 506 +
    - + - Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), + - + rows, err := testState.Query(ctx, "SELECT batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at FROM state.batch_proof")
    - 109 + + 507 +
    - + - } +   + require.NoError(err)
    - 110 + + 508 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) +   + proofs := make([]state.Proof, 0, len(rows.RawValues()))
    - 111 + + 509 +
    - + - l1Block2 := &types.Header{ +   + for rows.Next() {
    - 112 + +
    @@ -885,11 +881,7 @@
    +
    + 885 +
    - + - Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), +   + if err != nil {
    - 113 + + 886 +
    - + +   + panic(err) +
    +
    + 887 + +
    +   }
    - 114 + + 888 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 115 + + 889 +
    - + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(data.stateBlocks[1:2], nil) + - + if err != nil {
    - 116 + + 890 +
    - + -
    + - + panic(err)
    - 117 + + 891 +
    - + - res := data.sut.Step(data.ctx) + - + }
    - 118 + + 892 +
    - + - require.Error(t, res) + - + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr)
    - 119 + + 893 +
    - + - resErr, ok := res.(*commonsync.ReorgError) +   +
    - 120 + + 894 +
    - + - require.True(t, ok, "The error must be ReorgError") +   + dbTx, err := testState.BeginStateTransaction(ctx)
    - 121 + + 895 +
    - + - require.Equal(t, uint64(1237), resErr.BlockNumber) +   + require.NoError(t, err)
    - 122 + +
    @@ -1086,11 +1078,7 @@
    +
    + 1086 +
    - + - } +   + if err != nil {
    - 123 + + 1087 +
    - + -
    +   + panic(err)
    - 124 + + 1088 +
    - + - func TestPreCheckL1BlockBlocksMismatchButIsNoLongerInState(t *testing.T) { +   + }
    - 125 + + 1089 +
    - + - data := newPreCheckData(t) + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 126 + + 1090 +
    - + - data.mockInitialFetch.EXPECT().Description().Return("initial") + - + if err != nil {
    - 127 + + 1091 +
    - + - data.mockEndFetch.EXPECT().Description().Return("end") + - + panic(err)
    - 128 + + 1092 +
    - + - data.mockInitialFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1234), nil) + - + }
    - 129 + + 1093 +
    - + - data.mockEndFetch.EXPECT().GetSafeBlockNumber(data.ctx, data.mockL1Client).Return(uint64(1250), nil) + - + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr)
    - 130 + + 1094 +
    - + - data.stateBlocks[1].BlockHash = common.HexToHash("0x12345678901234567890123456789012345678901234567890") +   +
    - 131 + + 1095 +
    - + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1234), uint64(1250), nil).Return(data.stateBlocks, nil) +   + dbTx, err := testState.BeginStateTransaction(ctx)
    - 132 + + 1096 +
    - + - l1Block1 := &types.Header{ +   + require.NoError(t, err)
    - 133 + +
    @@ -1268,11 +1256,7 @@
    +
    + 1268 +
    - + - Number: big.NewInt(int64(data.stateBlocks[0].BlockNumber)), +   + if err != nil {
    - 134 + + 1269 +
    - + +   + panic(err) +
    +
    + 1270 + +
    +   }
    - 135 + + 1271 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[0].BlockNumber))).Return(l1Block1, nil) + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 136 + + 1272 +
    - + - l1Block2 := &types.Header{ + - + if err != nil {
    - 137 + + 1273 +
    - + - Number: big.NewInt(int64(data.stateBlocks[1].BlockNumber)), + - + panic(err)
    - 138 + + 1274 +
    - + + - }
    - 139 + + 1275 +
    - + - data.mockL1Client.EXPECT().HeaderByNumber(data.ctx, big.NewInt(int64(data.stateBlocks[1].BlockNumber))).Return(l1Block2, nil) + - + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt, mtr)
    - 140 + + 1276 +
    - + - data.mockState.EXPECT().GetUncheckedBlocks(data.ctx, uint64(1237), uint64(1237), nil).Return(nil, nil) +   +
    - 141 + + 1277 +
    - + -
    +   + dbTx, err := testState.BeginStateTransaction(ctx)
    - 142 + + 1278 +
    - + - res := data.sut.Step(data.ctx) +   + require.NoError(t, err)
    - 143 + +
    @@ -1387,6 +1371,108 @@
    +
    + 1387 +
    - + - require.ErrorIs(t, res, l1_check_block.ErrDeSync) +   + require.NoError(t, dbTx.Commit(ctx))
    - 144 + + 1388 +
    - + +   }
    -
    + + + 1389 + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block.go - RENAMED - -
    -
    -
    -
    - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
    @@ -0,0 +1,120 @@
    @@ -172108,6 +249790,71 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 1390 + +
    +   + func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry { +
    +
    + 1391 + +
    +   + exitRoot := state.L1InfoTreeExitRootStorageEntry{ +
    +
    + 1392 + +
    +   + L1InfoTreeLeaf: state.L1InfoTreeLeaf{ +
    +
    +
    @@ -1588,6 +1674,13 @@
    +
    + 1588 + +
    +   + require.Equal(t, uint64(2002), fb.BlockNumber) +
    +
    + 1589 + +
    +   + require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String()) +
    +
    + 1590 + +
    +   + require.Equal(t, []byte{0xb}, fb.RawTxsData) +
    +
    @@ -172178,6 +249925,585 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 1591 + +
    +   + } +
    +
    + 1592 + +
    +   +
    +
    +
    + 1593 + +
    +   + func TestGetLastGER(t *testing.T) { +
    +
    +
    @@ -1664,49 +1757,6 @@
    +
    + 1664 + +
    +   + ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx) +
    +
    + 1665 + +
    +   + require.NoError(t, err) +
    +
    + 1666 + +
    +   + require.Equal(t, common.HexToHash("0x2").String(), ger.String()) +
    +
    + 1667 + +
    + - +
    +
    +
    + 1668 + +
    + - + } +
    +
    + 1669 + +
    + - +
    +
    +
    + 1670 + +
    + - + func TestAddBlobSequence(t *testing.T) { +
    +
    + 1671 + +
    + - + initOrResetDB() +
    +
    + 1672 + +
    + - + ctx := context.Background() +
    +
    + 1673 + +
    + - + dbTx, err := testState.BeginStateTransaction(ctx) +
    +
    + 1674 + +
    + - + require.NoError(t, err) +
    +
    + 1675 + +
    + - + defer func() { require.NoError(t, dbTx.Commit(ctx)) }() +
    +
    + 1676 + +
    + - +
    +
    +
    + 1677 + +
    + - + block := state.NewBlock(100) +
    +
    + 1678 + +
    + - + err = testState.AddBlock(ctx, block, dbTx) +
    +
    + 1679 + +
    + - + require.NoError(t, err) +
    +
    + 1680 + +
    + - +
    +
    +
    + 1681 + +
    + - + blobSeq := state.BlobSequence{ +
    +
    + 1682 + +
    + - + BlobSequenceIndex: 1, +
    +
    + 1683 + +
    + - + BlockNumber: 100, +
    +
    + 1684 + +
    + - + } +
    +
    + 1685 + +
    + - + err = testState.AddBlobSequence(ctx, &blobSeq, dbTx) +
    +
    + 1686 + +
    + - + require.NoError(t, err) +
    +
    + 1687 + +
    + - + } +
    +
    + 1688 + +
    + - +
    +
    +
    + 1689 + +
    + - + func TestStoreBlobInner(t *testing.T) { +
    +
    + 1690 + +
    + - + initOrResetDB() +
    +
    + 1691 + +
    + - + ctx := context.Background() +
    +
    + 1692 + +
    + - + dbTx, err := testState.BeginStateTransaction(ctx) +
    +
    + 1693 + +
    + - + require.NoError(t, err) +
    +
    + 1694 + +
    + - + defer func() { require.NoError(t, dbTx.Commit(ctx)) }() +
    +
    + 1695 + +
    + - + block := state.NewBlock(100) +
    +
    + 1696 + +
    + - + err = testState.AddBlock(ctx, block, dbTx) +
    +
    + 1697 + +
    + - + require.NoError(t, err) +
    +
    + 1698 + +
    + - +
    +
    +
    + 1699 + +
    + - + blobSeq := state.BlobSequence{ +
    +
    + 1700 + +
    + - + BlobSequenceIndex: 1, +
    +
    + 1701 + +
    + - + BlockNumber: 100, +
    +
    + 1702 + +
    + - + } +
    +
    + 1703 + +
    + - + err = testState.AddBlobSequence(ctx, &blobSeq, dbTx) +
    +
    + 1704 + +
    + - + require.NoError(t, err) +
    +
    + 1705 + +
    + - + blobInner := state.BlobInner{ +
    +
    + 1706 + +
    + - + BlobSequenceIndex: 1, +
    +
    + 1707 + +
    + - + } +
    +
    + 1708 + +
    + - + err = testState.AddBlobInner(ctx, &blobInner, dbTx) +
    +
    + 1709 + +
    + - + require.NoError(t, err) +
    +
    + 1710 + +
    +   + } +
    +
    + 1711 + +
    +   +
    +
    +
    + 1712 + +
    +   + func TestGetFirstUncheckedBlock(t *testing.T) { +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - -
    +
     
    +
    + 110 + +
    +   + if err != nil { +
    +
    + 111 + +
    +   + panic(err) +
    +
    + 112 + +
    +   + } +
    +
    + 113 + +
    + + + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), executorClient, stateTree, eventLog, mt) +
    +
    @@ -172218,6 +250544,261 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 114 + +
    +   +
    +
    +
    + 115 + +
    +   + result := m.Run() +
    +
    + 116 + +
    +   +
    +
    +
    +
     
    +
    + 459 + +
    +   + batchNumber := uint64(42) +
    +
    + 460 + +
    +   + _, err = testState.Exec(ctx, "INSERT INTO state.batch (batch_num,wip) VALUES ($1, FALSE), ($2, FALSE), ($3, FALSE)", batchNumber, batchNumber+1, batchNumber+2) +
    +
    + 461 + +
    +   + require.NoError(err) +
    +
    + 462 + +
    + + + const addGeneratedProofSQL = "INSERT INTO state.proof (batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)" +
    +
    + 463 + +
    +   + // proof with `generating_since` older than interval +
    +
    + 464 + +
    +   + now := time.Now().Round(time.Microsecond) +
    +
    + 465 + +
    +   + oneHourAgo := now.Add(-time.Hour).Round(time.Microsecond) +
    +
    +
     
    +
    + 496 + +
    +   + _, err = testState.Exec(ctx, addGeneratedProofSQL, olderNotGenProof.BatchNumber, olderNotGenProof.BatchNumberFinal, olderNotGenProof.Proof, olderNotGenProof.ProofID, olderNotGenProof.InputProver, olderNotGenProof.Prover, olderNotGenProof.ProverID, olderNotGenProof.GeneratingSince, oneHourAgo, oneHourAgo) +
    +
    + 497 + +
    +   + require.NoError(err) +
    +
    + 498 + +
    +   +
    +
    +
    + 499 + +
    + + + _, err = testState.CleanupLockedProofs(ctx, "1m", nil) +
    +
    + 500 + +
    +   +
    +
    +
    + 501 + +
    +   + require.NoError(err) +
    +
    + 502 + +
    + + + rows, err := testState.Query(ctx, "SELECT batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at FROM state.proof") +
    +
    + 503 + +
    +   + require.NoError(err) +
    +
    + 504 + +
    +   + proofs := make([]state.Proof, 0, len(rows.RawValues())) +
    +
    + 505 + +
    +   + for rows.Next() { +
    +
    +
     
    +
    + 881 + +
    +   + if err != nil { +
    +
    + 882 + +
    +   + panic(err) +
    +
    + 883 + +
    +   + } +
    +
    + 884 + +
    + + + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) +
    +
    @@ -172258,6 +250839,81 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 885 + +
    +   +
    +
    +
    + 886 + +
    +   + dbTx, err := testState.BeginStateTransaction(ctx) +
    +
    + 887 + +
    +   + require.NoError(t, err) +
    +
    +
     
    +
    + 1078 + +
    +   + if err != nil { +
    +
    + 1079 + +
    +   + panic(err) +
    +
    + 1080 + +
    +   + } +
    +
    + 1081 + +
    + + + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) +
    +
    @@ -172298,6 +250954,81 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 1082 + +
    +   +
    +
    +
    + 1083 + +
    +   + dbTx, err := testState.BeginStateTransaction(ctx) +
    +
    + 1084 + +
    +   + require.NoError(t, err) +
    +
    +
     
    +
    + 1256 + +
    +   + if err != nil { +
    +
    + 1257 + +
    +   + panic(err) +
    +
    + 1258 + +
    +   + } +
    +
    + 1259 + +
    + + + testState = state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(cfg, stateDb), executorClient, stateTree, nil, mt) +
    +
    @@ -172339,742 +251070,773 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 1260 -
    +
    +
     
    - + + 1261 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    -
    + + + 1262 + + +
    +   + require.NoError(t, err)
    -
    -
    - - - + + + + + + + + + + + + + + - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - -
     
    + 1371 + +
    +   + require.NoError(t, dbTx.Commit(ctx)) +
    +
    + 1372 + +
    +   + } +
    +
    + 1373 + +
    +   +
    +
    +
    - 1 + 1374
    + - package l1_check_block + func TestGetBatchL2DataByNumber(t *testing.T) {
    - 2 + 1375
    + -
    + // Init database instance
    - 3 + 1376
    + - import ( + initOrResetDB()
    - 4 + 1377
    + - "context" + ctx := context.Background()
    - 5 + 1378
    + - "fmt" + tx, err := testState.BeginStateTransaction(ctx)
    - 6 + 1379
    + - "math/big" + require.NoError(t, err)
    - 7 + 1380
    + -
    + defer func() { require.NoError(t, tx.Commit(ctx)) }()
    - 8 + 1381
    + - "github.com/0xPolygonHermez/zkevm-node/log" +
    - 9 + 1382
    + - "github.com/ethereum/go-ethereum/rpc" + // empty case
    - 10 + 1383
    + - ) + var batchNum uint64 = 4
    - 11 + 1384
    + -
    + const (
    - 12 + 1385
    + - // L1BlockPoint is an enum that represents the point of the L1 block + openBatchSQL = "INSERT INTO state.batch (batch_num, raw_txs_data, wip) VALUES ($1, $2, false)"
    - 13 + 1386
    + - type L1BlockPoint int + resetBatchesSQL = "DELETE FROM state.batch"
    - 14 + 1387
    + -
    + )
    - 15 + 1388
    + - const ( + _, err = tx.Exec(ctx, openBatchSQL, batchNum, nil)
    - 16 + 1389
    + - // FinalizedBlockNumber is the finalized block number + require.NoError(t, err)
    - 17 + 1390
    + - FinalizedBlockNumber L1BlockPoint = 3 + data, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - 18 + 1391
    + - // SafeBlockNumber is the safe block number + require.NoError(t, err)
    - 19 + 1392
    + - SafeBlockNumber L1BlockPoint = 2 + assert.Nil(t, data)
    - 20 + 1393
    + - // PendingBlockNumber is the pending block number +
    - 21 + 1394
    + - PendingBlockNumber L1BlockPoint = 1 + // not empty case
    - 22 + 1395
    + - // LastBlockNumber is the last block number + expectedData := []byte("foo bar")
    - 23 + 1396
    + - LastBlockNumber L1BlockPoint = 0 + batchNum = 5
    - 24 + 1397
    + - ) + _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData)
    - 25 + 1398
    + -
    + require.NoError(t, err)
    - 26 + 1399
    + - // ToString converts a L1BlockPoint to a string + actualData, err := testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - 27 + 1400
    + - func (v L1BlockPoint) ToString() string { + require.NoError(t, err)
    - 28 + 1401
    + - switch v { + assert.Equal(t, expectedData, actualData)
    - 29 + 1402
    + - case FinalizedBlockNumber: +
    - 30 + 1403
    + - return "finalized" + multiGet := []uint64{uint64(4), uint64(5), uint64(6)}
    - 31 + 1404
    + - case SafeBlockNumber: + allData, err := testState.GetBatchL2DataByNumbers(ctx, multiGet, tx)
    - 32 + 1405
    + - return "safe" + require.NoError(t, err)
    - 33 + 1406
    + - case PendingBlockNumber: + require.Equal(t, expectedData, allData[uint64(5)])
    - 34 + 1407
    + - return "pending" +
    - 35 + 1408
    + - case LastBlockNumber: + // Force backup
    - 36 + 1409
    + - return "latest" + _, err = tx.Exec(ctx, resetBatchesSQL)
    - 37 + 1410
    + - } + require.NoError(t, err)
    - 38 + 1411
    + - return "Unknown" +
    - 39 + 1412
    + - } + // Get batch 4 from backup
    - 40 + 1413
    + -
    + batchNum = 4
    - 41 + 1414
    + - // StringToL1BlockPoint converts a string to a L1BlockPoint + data, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - 42 + 1415
    + - func StringToL1BlockPoint(s string) L1BlockPoint { + require.NoError(t, err)
    - 43 + 1416
    + - switch s { + assert.Nil(t, data)
    - 44 + 1417
    + - case "finalized": +
    - 45 + 1418
    + - return FinalizedBlockNumber + // Get batch 5 from backup
    - 46 + 1419
    + - case "safe": + batchNum = 5
    - 47 + 1420
    + - return SafeBlockNumber + actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - 48 + 1421
    + - case "pending": + require.NoError(t, err)
    - 49 + 1422
    + - return PendingBlockNumber + assert.Equal(t, expectedData, actualData)
    - 50 + 1423
    + - case "latest": +
    - 51 + 1424
    + - return LastBlockNumber + // Update batch 5 and get it from backup
    - 52 + 1425
    + - default: + expectedData = []byte("new foo bar")
    - 53 + 1426
    + - return FinalizedBlockNumber + _, err = tx.Exec(ctx, openBatchSQL, batchNum, expectedData)
    - 54 + 1427
    + - } + require.NoError(t, err)
    - 55 + 1428
    + - } + _, err = tx.Exec(ctx, resetBatchesSQL)
    - 56 + 1429
    + -
    + require.NoError(t, err)
    - 57 + 1430
    + - // ToGethRequest converts a L1BlockPoint to a big.Int used for request to GETH + actualData, err = testState.GetBatchL2DataByNumber(ctx, batchNum, tx)
    - 58 + 1431
    + - func (v L1BlockPoint) ToGethRequest() *big.Int { + require.NoError(t, err)
    - 59 + 1432
    + - switch v { + assert.Equal(t, expectedData, actualData)
    - 60 + 1433
    + - case FinalizedBlockNumber: + }
    - 61 + 1434
    + - return big.NewInt(int64(rpc.FinalizedBlockNumber)) +
    - 62 + 1435
    + - case PendingBlockNumber: + func TestGetBatchL2DataByNumbers(t *testing.T) {
    - 63 + 1436
    + - return big.NewInt(int64(rpc.PendingBlockNumber)) + initOrResetDB()
    - 64 + 1437
    + - case SafeBlockNumber: + ctx := context.Background()
    - 65 + 1438
    + - return big.NewInt(int64(rpc.SafeBlockNumber)) + tx, err := testState.BeginStateTransaction(ctx)
    - 66 + 1439
    + - case LastBlockNumber: + require.NoError(t, err)
    - 67 + 1440
    + - return nil + defer func() { require.NoError(t, tx.Commit(ctx)) }()
    - 68 + 1441
    + - } +
    - 69 + 1442
    + - return big.NewInt(int64(v)) + var i1, i2, i3, i4, i5 = uint64(1), uint64(2), uint64(3), uint64(4), uint64(5)
    - 70 + 1443
    + - } + var d1, d2, d4 = []byte("foobar"), []byte("dingbat"), []byte{0xb}
    - 71 + 1444
    @@ -173084,77 +251846,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 72 + 1445
    + - // SafeL1BlockNumberFetch is a struct that implements a safe L1 block number fetch + const insertBatch = "INSERT INTO state.batch (batch_num, raw_txs_data) VALUES ($1, $2)"
    - 73 + 1446
    + - type SafeL1BlockNumberFetch struct { + _, err = tx.Exec(ctx, insertBatch, i1, d1)
    - 74 + 1447
    + - // SafeBlockPoint is the block number that is reference to l1 Block + require.NoError(t, err)
    - 75 + 1448
    + - SafeBlockPoint L1BlockPoint + _, err = tx.Exec(ctx, insertBatch, i2, d2)
    - 76 + 1449
    + - // Offset is a vaule add to the L1 block + require.NoError(t, err)
    - 77 + 1450
    + - Offset int + _, err = tx.Exec(ctx, insertBatch, i3, nil)
    - 78 + 1451
    + - } + require.NoError(t, err)
    - 79 + 1452
    @@ -173164,77 +251926,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 80 + 1453
    + - // NewSafeL1BlockNumberFetch creates a new SafeL1BlockNumberFetch + // Add a forced batch too, needs a block
    - 81 + 1454
    + - func NewSafeL1BlockNumberFetch(safeBlockPoint L1BlockPoint, offset int) *SafeL1BlockNumberFetch { + block1 := *block
    - 82 + 1455
    + - return &SafeL1BlockNumberFetch{ + block1.BlockNumber = 1000
    - 83 + 1456
    + - SafeBlockPoint: safeBlockPoint, + err = testState.AddBlock(ctx, &block1, tx)
    - 84 + 1457
    + - Offset: offset, + require.NoError(t, err)
    - 85 + 1458
    + - } + err = tx.Commit(ctx)
    - 86 + 1459
    + - } + require.NoError(t, err)
    - 87 + 1460
    @@ -173244,362 +252006,353 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 88 + 1461
    + - // Description returns a string representation of SafeL1BlockNumberFetch + tx, err = testState.BeginStateTransaction(ctx)
    - 89 + 1462
    + - func (p *SafeL1BlockNumberFetch) Description() string { + require.NoError(t, err)
    - 90 + 1463
    + - return fmt.Sprintf("%s/%d", p.SafeBlockPoint.ToString(), p.Offset) +
    - 91 + 1464
    + - } + const insertForcedBatch = "INSERT INTO state.forced_batch (forced_batch_num, timestamp, raw_txs_data, block_num) VALUES (4, now(),'0b', 1000)"
    - 92 + 1465
    + -
    + _, err = testState.Exec(ctx, insertForcedBatch)
    - 93 + 1466
    + - // GetSafeBlockNumber gets the safe block number from L1 + require.NoError(t, err)
    - 94 + 1467
    + - func (p *SafeL1BlockNumberFetch) GetSafeBlockNumber(ctx context.Context, requester L1Requester) (uint64, error) { +
    - 95 + 1468
    + - l1SafePointBlock, err := requester.HeaderByNumber(ctx, p.SafeBlockPoint.ToGethRequest()) + allData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{i4}, tx)
    - 96 + 1469
    + - if err != nil { + require.NoError(t, err)
    - 97 + 1470
    + - log.Errorf("%s: Error getting L1 block %d. err: %s", logPrefix, p.String(), err.Error()) + assert.Equal(t, d4, allData[i4])
    - 98 + 1471
    + - return uint64(0), err +
    - 99 + 1472
    + - } + _, ok := allData[i5]
    - 100 + 1473
    + - result := l1SafePointBlock.Number.Uint64() + assert.False(t, ok)
    - 101 + 1474
    + - if p.Offset < 0 { + }
    - 102 + 1475 + +
    + + +
    +
    +
    + 1476 +
    - + - if result < uint64(-p.Offset) { +   + func createL1InfoTreeExitRootStorageEntryForTest(blockNumber uint64, index uint32) *state.L1InfoTreeExitRootStorageEntry {
    - 103 + + 1477 +
    - + - result = 0 +   + exitRoot := state.L1InfoTreeExitRootStorageEntry{
    - 104 + + 1478 +
    - + - } else { +   + L1InfoTreeLeaf: state.L1InfoTreeLeaf{
    - 105 + +
     
    +
    + 1674 +
    - + - result += uint64(p.Offset) +   + require.Equal(t, uint64(2002), fb.BlockNumber)
    - 106 + + 1675 +
    - + - } +   + require.Equal(t, "0x717e05de47a87a7d1679e183f1c224150675f6302b7da4eaab526b2b91ae0761", fb.GlobalExitRoot.String())
    - 107 + + 1676 +
    - + - } else { +   + require.Equal(t, []byte{0xb}, fb.RawTxsData)
    - 108 + 1677
    + - result = l1SafePointBlock.Number.Uint64() + uint64(p.Offset) +
    - 109 + 1678
    + - } + // also check data retrieval
    - 110 + 1679
    + - if p.SafeBlockPoint == LastBlockNumber { + fbData, err := testState.GetForcedBatchDataByNumbers(ctx, []uint64{1}, dbTx)
    - 111 + 1680
    + - result = min(result, l1SafePointBlock.Number.Uint64()) + require.NoError(t, err)
    - 112 + 1681
    + - } + var expected = make(map[uint64][]byte)
    - 113 + 1682
    + -
    + expected[uint64(1)] = []byte{0xb}
    - 114 + 1683
    + - return result, nil + require.Equal(t, expected, fbData)
    - 115 + + 1684 +
    - + +   }
    - 116 + + 1685 +
    - + +  
    - 117 + + 1686 +
    - + - // String returns a string representation of SafeL1BlockNumberFetch +   + func TestGetLastGER(t *testing.T) {
    - 118 + +
     
    +
    + 1757 +
    - + - func (p *SafeL1BlockNumberFetch) String() string { +   + ger, err = testState.GetLatestBatchGlobalExitRoot(ctx, dbTx)
    - 119 + + 1758 +
    - + - return fmt.Sprintf("SafeBlockPoint: %s, Offset: %d", p.SafeBlockPoint.ToString(), p.Offset) +   + require.NoError(t, err)
    - 120 + + 1759 +
    - + - } -
    -
    -
    +   + require.Equal(t, common.HexToHash("0x2").String(), ger.String())
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_check_block/safe_l1_block_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - + + + - - + + +
    -
    @@ -0,0 +1,113 @@
    @@ -174032,65 +252785,534 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 1760 -
    +
    +
    +   + } +
    +
    + 1761 + +
     
    - + + 1762 -
    +
    +
    +   + func TestGetFirstUncheckedBlock(t *testing.T) { +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/proof.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - @@ -174382,153 +253979,148 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -174542,1337 +254134,1367 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -25,9 +25,9 @@
    +
    + 25 + +
    +   + return exists, nil +
    +
    + 26 + +
    +   + } +
    +
    + 27 + +
     
    - + + 28 -
    +
    +
    + - + // GetProofReadyForFinal return the proof that is ready to generate the final proof +
    +
    + 29 + +
    + - + func (p *PostgresStorage) GetProofReadyForFinal(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) { +
    +
    + 30 + +
    + - + const getProofReadyForFinalSQL = ` +
    +
    + 31 + +
    +   + SELECT +
    +
    + 32 + +
    +   + p.batch_num, +
    +
    + 33 + +
    +   + p.batch_num_final, +
    +
    +
    @@ -39,7 +39,7 @@
    +
    + 39 + +
    +   + p.generating_since, +
    +
    + 40 + +
    +   + p.created_at, +
    +
    + 41 + +
    +   + p.updated_at +
    +
    + 42 + +
    + - + FROM state.batch_proof p +
    +
    + 43 + +
    +   + WHERE batch_num = $1 AND generating_since IS NULL AND +
    +
    + 44 + +
    +   + EXISTS (SELECT 1 FROM state.sequences s1 WHERE s1.from_batch_num = p.batch_num) AND +
    +
    + 45 + +
    +   + EXISTS (SELECT 1 FROM state.sequences s2 WHERE s2.to_batch_num = p.batch_num_final) +
    +
    +
    @@ -48,7 +48,7 @@
    +
    + 48 + +
    +   + var proof *state.Proof = &state.Proof{} +
    +
    + 49 + +
     
    - + + 50 -
    +
    +
    +   + e := p.getExecQuerier(dbTx) +
    +
    + 51 + +
    + - + row := e.QueryRow(ctx, getProofReadyForFinalSQL, lastVerfiedBatchNumber+1) +
    +
    + 52 + +
    +   + err := row.Scan(&proof.BatchNumber, &proof.BatchNumberFinal, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover, &proof.ProverID, &proof.GeneratingSince, &proof.CreatedAt, &proof.UpdatedAt) +
    +
    + 53 + +
     
    - + + 54 -
    +
    +
    +   + if errors.Is(err, pgx.ErrNoRows) { +
    +
    +
    @@ -60,15 +60,15 @@
    +
    + 60 + +
    +   + return proof, err +
    +
    + 61 + +
    +   + } +
    +
    + 62 + +
     
    - + + 63 -
    +
    +
    + - + // GetBatchProofsToAggregate return the next 2 batch proofs that it are possible to aggregate +
    +
    + 64 + +
    + - + func (p *PostgresStorage) GetBatchProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) { +
    +
    + 65 + +
    +   + var ( +
    +
    + 66 + +
    +   + proof1 *state.Proof = &state.Proof{} +
    +
    + 67 + +
    +   + proof2 *state.Proof = &state.Proof{} +
    +
    + 68 + +
    +   + ) +
    +
    + 69 + +
     
    + 70 + +
    +   + // TODO: add comments to explain the query +
    +
    + 71 + +
    + - + const getBatchProofsToAggregateSQL = ` +
    +
    + 72 + +
    +   + SELECT +
    +
    + 73 + +
    +   + p1.batch_num as p1_batch_num, +
    +
    + 74 + +
    +   + p1.batch_num_final as p1_batch_num_final, +
    +
    +
    @@ -90,16 +90,31 @@
    +
    + 90 + +
    +   + p2.generating_since as p2_generating_since, +
    +
    + 91 + +
    +   + p2.created_at as p2_created_at, +
    +
    + 92 + +
    +   + p2.updated_at as p2_updated_at +
    +
    + 93 + +
    + - + FROM state.batch_proof p1 INNER JOIN state.batch_proof p2 ON p1.batch_num_final = p2.batch_num - 1 +
    +
    + 94 + +
    + - + WHERE p1.blob_inner_num = p2.blob_inner_num AND +
    +
    + 95 + +
    + - + p1.generating_since IS NULL AND p2.generating_since IS NULL AND +
    +
    + 96 + +
    + - + p1.proof IS NOT NULL AND p2.proof IS NOT NULL +
    +
    @@ -174242,45 +253464,340 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 97 -
    +
    +
    +   + ORDER BY p1.batch_num ASC +
    +
    + 98 + +
    +   + LIMIT 1 +
    +
    + 99 + +
    +   + ` +
    +
    + 100 + +
     
    - + + 101 -
    +
    +
    +   + e := p.getExecQuerier(dbTx) +
    +
    + 102 + +
    + - + row := e.QueryRow(ctx, getBatchProofsToAggregateSQL) +
    +
    + 103 + +
    +   + err := row.Scan( +
    +
    + 104 + +
    +   + &proof1.BatchNumber, &proof1.BatchNumberFinal, &proof1.Proof, &proof1.ProofID, &proof1.InputProver, &proof1.Prover, &proof1.ProverID, &proof1.GeneratingSince, &proof1.CreatedAt, &proof1.UpdatedAt, +
    +
    + 105 + +
    +   + &proof2.BatchNumber, &proof2.BatchNumberFinal, &proof2.Proof, &proof2.ProofID, &proof2.InputProver, &proof2.Prover, &proof2.ProverID, &proof2.GeneratingSince, &proof2.CreatedAt, &proof2.UpdatedAt) +
    +
    +
    @@ -113,47 +128,50 @@
    +
    + 113 + +
    +   + return proof1, proof2, err +
    +
    + 114 + +
    +   + } +
    +
    + 115 + +
     
    - + + 116 -
    +
    +
    + - + // AddBatchProof adds a batch proof to the storage +
    +
    + 117 + +
    + - + func (p *PostgresStorage) AddBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { +
    +
    + 118 + +
    + - + const addBatchProofSQL = "INSERT INTO state.batch_proof (batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)" +
    +
    + 119 + +
    +   + e := p.getExecQuerier(dbTx) +
    +
    + 120 + +
    +   + now := time.Now().UTC().Round(time.Microsecond) +
    +
    + 121 + +
    + - + _, err := e.Exec(ctx, addBatchProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now, now) +
    +
    + 122 + +
    +   + return err +
    +
    + 123 + +
    +   + } +
    +
    + 124 + +
     
    - + + 125 -
    +
    +
    + - + // UpdateBatchProof updates a batch proof in the storage +
    +
    + 126 + +
    + - + func (p *PostgresStorage) UpdateBatchProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error { +
    +
    + 127 + +
    + - + const addBatchProofSQL = "UPDATE state.batch_proof SET proof = $3, proof_id = $4, input_prover = $5, prover = $6, prover_id = $7, generating_since = $8, updated_at = $9 WHERE batch_num = $1 AND batch_num_final = $2" +
    +
    + 128 + +
    +   + e := p.getExecQuerier(dbTx) +
    +
    + 129 + +
    +   + now := time.Now().UTC().Round(time.Microsecond) +
    +
    + 130 + +
    + - + _, err := e.Exec(ctx, addBatchProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now) +
    +
    + 131 + +
    +   + return err +
    +
    + 132 + +
    +   + } +
    +
    + 133 + +
     
    + 134 + +
    + - + // DeleteBatchProofs deletes from the storage the batch proofs falling inside the batch numbers range. +
    +
    + 135 + +
    + - + func (p *PostgresStorage) DeleteBatchProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error { +
    +
    + 136 + +
    + - + const deleteBatchProofSQL = "DELETE FROM state.batch_proof WHERE batch_num >= $1 AND batch_num_final <= $2" +
    +
    @@ -174291,6 +253808,86 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + 137 + +
    +   + e := p.getExecQuerier(dbTx) +
    +
    + 138 + +
    + - + _, err := e.Exec(ctx, deleteBatchProofSQL, batchNumber, batchNumberFinal) +
    +
    + 139 + +
    +   + return err +
    +
    + 140 + +
    +   + } +
    +
    + 141 + +
    +   +
    +
    +
    + 142 + +
    + - + // CleanupBatchProofs deletes from the storage the batch proofs up to the specified batch number included. +
    +
    + 143 + +
    + - + func (p *PostgresStorage) CleanupBatchProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error { +
    +
    + 144 + +
    + - + const deleteBatchProofSQL = "DELETE FROM state.batch_proof WHERE batch_num_final <= $1" +
    +
    @@ -174302,73 +253899,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 145 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 146 -
    -   -
    +
    +
    + - + _, err := e.Exec(ctx, deleteBatchProofSQL, batchNumber)
    - + + 147 -
    +
    +
      -
    + return err
    - + + 148 -
    +
    +
      -
    + }
    - + + 149 -
    +
    +
     
    - + + 150 -
    -   -
    +
    +
    + - + // CleanupLockedBatchProofs deletes from the storage the proofs locked in generating state for more than the provided threshold.
    - + + 151 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) CleanupLockedBatchProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) {
    - + + 152 -
    +
    +
      -
    + interval, err := toPostgresInterval(duration)
    - + + 153 -
    +
    +
      -
    + if err != nil {
    - + + 154 -
    +
    +
      -
    + return 0, err
    - + + 155 -
    +
    +
      -
    + }
    - + + 156 -
    -   -
    +
    +
    + - + sql := fmt.Sprintf("DELETE FROM state.batch_proof WHERE generating_since < (NOW() - interval '%s')", interval)
    - + + 157 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 158 -
    +
    +
      -
    + ct, err := e.Exec(ctx, sql)
    - + + 159 -
    +
    +
      -
    + if err != nil {
    - - -
    -   -
    -
    +
    +
    @@ -162,9 +180,10 @@
    - + + 162 -
    +
    +
      -
    + return ct.RowsAffected(), nil
    - + + 163 -
    +
    +
      -
    + }
    - + + 164 -
    +
    +
     
    - + + 165 -
    -   -
    +
    +
    + - + // DeleteUngeneratedBatchProofs deletes ungenerated proofs. This method is meant to be use during aggregator boot-up sequence
    - + + 166 -
    -   -
    +
    +
    + - + func (p *PostgresStorage) DeleteUngeneratedBatchProofs(ctx context.Context, dbTx pgx.Tx) error {
    - + + 167 -
    -   -
    +
    +
    + - + const deleteUngeneratedProofsSQL = "DELETE FROM state.batch_proof WHERE generating_since IS NOT NULL"
    - + + 168 -
    +
    +
      -
    + e := p.getExecQuerier(dbTx)
    - + + 169 -
    +
    +
      -
    + _, err := e.Exec(ctx, deleteUngeneratedProofsSQL)
    - + + 170 -
    +
    +
      -
    + return err +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    +
     
    - + + 25 -
    +
    +
      -
    + return exists, nil
    - + + 26 -
    +
    +
      -
    + }
    - + + 27 -
    +
    +
     
    - + + 28 -
    -   -
    +
    +
    + + + // GetProofReadyToVerify return the proof that is ready to verify
    - + + 29 -
    -   -
    +
    +
    + + + func (p *PostgresStorage) GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error) {
    - + + 30 -
    -   -
    +
    +
    + + + const getProofReadyToVerifySQL = `
    - + + 31 -
    +
    +
      -
    + SELECT
    - + + 32 -
    +
    +
      -
    + p.batch_num,
    - + + 33 -
    +
    +
      -
    + p.batch_num_final,
    - + +
     
    -
    +
    + 39 + +
      -
    + p.generating_since,
    - + + 40 -
    +
    +
      -
    + p.created_at,
    - + + 41 -
    +
    +
      -
    + p.updated_at
    - + + 42 -
    -   -
    +
    +
    + + + FROM state.proof p
    - + + 43 -
    +
    +
      -
    + WHERE batch_num = $1 AND generating_since IS NULL AND
    - + + 44 -
    +
    +
      -
    + EXISTS (SELECT 1 FROM state.sequences s1 WHERE s1.from_batch_num = p.batch_num) AND
    - + + 45 -
    +
    +
      -
    + EXISTS (SELECT 1 FROM state.sequences s2 WHERE s2.to_batch_num = p.batch_num_final)
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - @@ -175882,12 +255504,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/pgstatestorage/transaction.go RENAMED
    - - + + + + + + - - + - - - - - - - - - - - - - - - - - - - - -
     
    - 1 + + 48 +
    - + - package l1_check_block_test +   + var proof *state.Proof = &state.Proof{}
    - 2 + + 49 +
    - + +  
    - 3 + + 50 +
    - + - import ( +   + e := p.getExecQuerier(dbTx)
    - 4 + + 51 +
    + - "context" + row := e.QueryRow(ctx, getProofReadyToVerifySQL, lastVerfiedBatchNumber+1)
    - 5 + + 52 +
    - + - "math/big" +   + err := row.Scan(&proof.BatchNumber, &proof.BatchNumberFinal, &proof.Proof, &proof.ProofID, &proof.InputProver, &proof.Prover, &proof.ProverID, &proof.GeneratingSince, &proof.CreatedAt, &proof.UpdatedAt)
    - 6 + + 53 +
    - + - "testing" +   +
    - 7 + + 54 +
    - + -
    +   + if errors.Is(err, pgx.ErrNoRows) {
    - 8 + +
     
    +
    + 60 +
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" +   + return proof, err
    - 9 + + 61 +
    - + - mock_l1_check_block "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block/mocks" +   + }
    - 10 + + 62 +
    - + - "github.com/ethereum/go-ethereum/core/types" +   +
    - 11 + + 63 +
    + - "github.com/ethereum/go-ethereum/rpc" + // GetProofsToAggregate return the next to proof that it is possible to aggregate
    - 12 + + 64 +
    + - "github.com/stretchr/testify/assert" + func (p *PostgresStorage) GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error) {
    - 13 + + 65 +
    - + - "github.com/stretchr/testify/mock" +   + var (
    - 14 + + 66 +
    - + - ) +   + proof1 *state.Proof = &state.Proof{}
    - 15 + + 67 +
    - + -
    +   + proof2 *state.Proof = &state.Proof{}
    - 16 + + 68 +
    - + - func TestGetSafeBlockNumber(t *testing.T) { +   + )
    - 17 + + 69 +
    - + - ctx := context.Background() +   +
    - 18 + + 70 +
    - + - mockRequester := mock_l1_check_block.NewL1Requester(t) +   + // TODO: add comments to explain the query
    - 19 + + 71 +
    + - //safeBlockPoint := big.NewInt(50) + const getProofsToAggregateSQL = `
    - 20 + + 72 +
    - + - offset := 10 +   + SELECT
    - 21 + + 73 +
    - + - safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint("safe"), offset) +   + p1.batch_num as p1_batch_num,
    - 22 + + 74 +
    - + -
    +   + p1.batch_num_final as p1_batch_num_final,
    - 23 + +
     
    +
    + 90 +
    - + - mockRequester.EXPECT().HeaderByNumber(ctx, mock.Anything).Return(&types.Header{ +   + p2.generating_since as p2_generating_since,
    - 24 + + 91 +
    - + - Number: big.NewInt(100), +   + p2.created_at as p2_created_at,
    - 25 + + 92 +
    - + - }, nil) +   + p2.updated_at as p2_updated_at
    - 26 + + 93 +
    + - blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) + FROM state.proof p1 INNER JOIN state.proof p2 ON p1.batch_num_final = p2.batch_num - 1
    - 27 + + 94 +
    + - assert.NoError(t, err) + WHERE p1.generating_since IS NULL AND p2.generating_since IS NULL AND
    - 28 + + 95 +
    + - expectedBlockNumber := uint64(100 + offset) + p1.proof IS NOT NULL AND p2.proof IS NOT NULL AND
    - 29 + + 96 +
    + - assert.Equal(t, expectedBlockNumber, blockNumber) + (
    - 30 + 97
    + - } + EXISTS (
    - 31 + 98
    + -
    + SELECT 1 FROM state.sequences s
    - 32 + 99
    + - func TestGetSafeBlockNumberMutliplesCases(t *testing.T) { + WHERE p1.batch_num >= s.from_batch_num AND p1.batch_num <= s.to_batch_num AND
    - 33 + 100
    + - tests := []struct { + p1.batch_num_final >= s.from_batch_num AND p1.batch_num_final <= s.to_batch_num AND
    - 34 + 101
    + - name string + p2.batch_num >= s.from_batch_num AND p2.batch_num <= s.to_batch_num AND
    - 35 + 102
    + - blockPoint string + p2.batch_num_final >= s.from_batch_num AND p2.batch_num_final <= s.to_batch_num
    - 36 + 103
    + - offset int + )
    - 37 + 104
    + - l1ReturnBlockNumber uint64 + OR
    - 38 + 105
    + - expectedCallToGeth *big.Int + (
    - 39 + 106
    + - expectedBlockNumber uint64 + EXISTS ( SELECT 1 FROM state.sequences s WHERE p1.batch_num = s.from_batch_num) AND
    - 40 + 107
    + - }{ + EXISTS ( SELECT 1 FROM state.sequences s WHERE p1.batch_num_final = s.to_batch_num) AND
    - 41 + 108
    + - { + EXISTS ( SELECT 1 FROM state.sequences s WHERE p2.batch_num = s.from_batch_num) AND
    - 42 + 109
    + - name: "SafeBlockNumber+10", + EXISTS ( SELECT 1 FROM state.sequences s WHERE p2.batch_num_final = s.to_batch_num)
    - 43 + 110
    + - blockPoint: "safe", + )
    - 44 + 111
    + - offset: 10, + )
    - 45 + + 112 +
    - + - l1ReturnBlockNumber: 100, +   + ORDER BY p1.batch_num ASC
    - 46 + + 113 +
    - + - expectedCallToGeth: big.NewInt(int64(rpc.SafeBlockNumber)), +   + LIMIT 1
    - 47 + + 114 +
    - + - expectedBlockNumber: 110, +   + `
    - 48 + + 115 +
    - + - }, +   +
    - 49 + + 116 +
    - + - { +   + e := p.getExecQuerier(dbTx)
    - 50 + + 117 +
    + - name: "FinalizedBlockNumber+10", + row := e.QueryRow(ctx, getProofsToAggregateSQL)
    - 51 + + 118 +
    - + - blockPoint: "finalized", +   + err := row.Scan(
    - 52 + + 119 +
    - + - offset: 10, +   + &proof1.BatchNumber, &proof1.BatchNumberFinal, &proof1.Proof, &proof1.ProofID, &proof1.InputProver, &proof1.Prover, &proof1.ProverID, &proof1.GeneratingSince, &proof1.CreatedAt, &proof1.UpdatedAt,
    - 53 + + 120 +
    - + - l1ReturnBlockNumber: 100, +   + &proof2.BatchNumber, &proof2.BatchNumberFinal, &proof2.Proof, &proof2.ProofID, &proof2.InputProver, &proof2.Prover, &proof2.ProverID, &proof2.GeneratingSince, &proof2.CreatedAt, &proof2.UpdatedAt)
    - 54 + +
     
    +
    + 128 +
    - + - expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), +   + return proof1, proof2, err
    - 55 + + 129 +
    - + - expectedBlockNumber: 110, +   + }
    - 56 + + 130 +
    - + - }, +   +
    - 57 + + 131 +
    + - { + // AddGeneratedProof adds a generated proof to the storage
    - 58 + + 132 +
    + - name: "PendingBlockNumber+10", + func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error {
    - 59 + + 133 +
    + - blockPoint: "pending", + const addGeneratedProofSQL = "INSERT INTO state.proof (batch_num, batch_num_final, proof, proof_id, input_prover, prover, prover_id, generating_since, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)"
    - 60 + + 134 +
    - + - offset: 10, +   + e := p.getExecQuerier(dbTx)
    - 61 + + 135 +
    - + - l1ReturnBlockNumber: 100, +   + now := time.Now().UTC().Round(time.Microsecond)
    - 62 + + 136 +
    + - expectedCallToGeth: big.NewInt(int64(rpc.PendingBlockNumber)), + _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now, now)
    - 63 + + 137 +
    - + - expectedBlockNumber: 110, +   + return err
    - 64 + + 138 +
    - + - }, +   + }
    - 65 + + 139 +
    - + - { +   +
    - 66 + + 140 +
    + - name: "LastBlockNumber+10, can't add 10 to latest block number. So must return latest block number and ignore positive offset", + // UpdateGeneratedProof updates a generated proof in the storage
    - 67 + + 141 +
    + - blockPoint: "latest", + func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error {
    - 68 + + 142 +
    + - offset: 10, + const addGeneratedProofSQL = "UPDATE state.proof SET proof = $3, proof_id = $4, input_prover = $5, prover = $6, prover_id = $7, generating_since = $8, updated_at = $9 WHERE batch_num = $1 AND batch_num_final = $2"
    - 69 + + 143 +
    - + - l1ReturnBlockNumber: 100, +   + e := p.getExecQuerier(dbTx)
    - 70 + + 144 +
    - + - expectedCallToGeth: nil, +   + now := time.Now().UTC().Round(time.Microsecond)
    - 71 + + 145 +
    + - expectedBlockNumber: 100, + _, err := e.Exec(ctx, addGeneratedProofSQL, proof.BatchNumber, proof.BatchNumberFinal, proof.Proof, proof.ProofID, proof.InputProver, proof.Prover, proof.ProverID, proof.GeneratingSince, now)
    - 72 + + 146 +
    - + - }, +   + return err
    - 73 + + 147 +
    - + - { +   + }
    - 74 + + 148 +
    - + - name: "FinalizedBlockNumber-1000. negative blockNumbers are not welcome. So must return 0", +   +
    - 75 + + 149 +
    + - blockPoint: "finalized", + // DeleteGeneratedProofs deletes from the storage the generated proofs falling
    - 76 + + 150 +
    + - offset: -1000, + // inside the batch numbers range.
    - 77 + + 151 +
    + - l1ReturnBlockNumber: 100, + func (p *PostgresStorage) DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error {
    - 78 + 152
    + - expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + const deleteGeneratedProofSQL = "DELETE FROM state.proof WHERE batch_num >= $1 AND batch_num_final <= $2"
    - 79 + + 153 +
    - + - expectedBlockNumber: 0, +   + e := p.getExecQuerier(dbTx)
    - 80 + + 154 +
    + - }, + _, err := e.Exec(ctx, deleteGeneratedProofSQL, batchNumber, batchNumberFinal)
    - 81 + + 155 +
    - + - { +   + return err
    - 82 + + 156 +
    - + - name: "FinalizedBlockNumber(1000)-1000. is 0 ", +   + }
    - 83 + + 157 +
    - + - blockPoint: "finalized", +   +
    - 84 + + 158 +
    + - offset: -1000, + // CleanupGeneratedProofs deletes from the storage the generated proofs up to
    - 85 + + 159 +
    + - l1ReturnBlockNumber: 1000, + // the specified batch number included.
    - 86 + + 160 +
    + - expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + func (p *PostgresStorage) CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error {
    - 87 + 161
    + - expectedBlockNumber: 0, + const deleteGeneratedProofSQL = "DELETE FROM state.proof WHERE batch_num_final <= $1"
    - 88 + + 162 +
    - + - }, +   + e := p.getExecQuerier(dbTx)
    - 89 + + 163 +
    + - { + _, err := e.Exec(ctx, deleteGeneratedProofSQL, batchNumber)
    - 90 + + 164 +
    - + - name: "FinalizedBlockNumber(1001)-1000. is 1 ", +   + return err
    - 91 + + 165 +
    - + - blockPoint: "finalized", +   + }
    - 92 + + 166 +
    - + - offset: -1000, +   +
    - 93 + + 167 +
    + - l1ReturnBlockNumber: 1001, + // CleanupLockedProofs deletes from the storage the proofs locked in generating
    - 94 + + 168 +
    + - expectedCallToGeth: big.NewInt(int64(rpc.FinalizedBlockNumber)), + // state for more than the provided threshold.
    - 95 + 169
    + - expectedBlockNumber: 1, + func (p *PostgresStorage) CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error) {
    - 96 + + 170 +
    - + - }, +   + interval, err := toPostgresInterval(duration)
    - 97 + + 171 +
    - + - } +   + if err != nil {
    - 98 + + 172 +
    - + -
    +   + return 0, err
    - 99 + + 173 +
    - + - for _, tt := range tests { +   + }
    - 100 + + 174 +
    + - t.Run(tt.name, func(t *testing.T) { + sql := fmt.Sprintf("DELETE FROM state.proof WHERE generating_since < (NOW() - interval '%s')", interval)
    - 101 + + 175 +
    - + - ctx := context.Background() +   + e := p.getExecQuerier(dbTx)
    - 102 + + 176 +
    - + - mockRequester := mock_l1_check_block.NewL1Requester(t) +   + ct, err := e.Exec(ctx, sql)
    - 103 + + 177 +
    - + - safeL1Block := l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(tt.blockPoint), tt.offset) +   + if err != nil {
    - 104 + +
     
    +
    + 180 +
    - + -
    +   + return ct.RowsAffected(), nil
    - 105 + + 181 +
    - + - mockRequester.EXPECT().HeaderByNumber(ctx, tt.expectedCallToGeth).Return(&types.Header{ +   + }
    - 106 + + 182 +
    - + - Number: big.NewInt(int64(tt.l1ReturnBlockNumber)), +   +
    - 107 + + 183 +
    + - }, nil) + // DeleteUngeneratedProofs deletes ungenerated proofs.
    - 108 + + 184 +
    + - blockNumber, err := safeL1Block.GetSafeBlockNumber(ctx, mockRequester) + // This method is meant to be use during aggregator boot-up sequence
    - 109 + + 185 +
    + - assert.NoError(t, err) + func (p *PostgresStorage) DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error {
    - 110 + 186
    + - assert.Equal(t, tt.expectedBlockNumber, blockNumber) + const deleteUngeneratedProofsSQL = "DELETE FROM state.proof WHERE generating_since IS NOT NULL"
    - 111 + + 187 +
    - + - }) +   + e := p.getExecQuerier(dbTx)
    - 112 + + 188 +
    - + - } +   + _, err := e.Exec(ctx, deleteUngeneratedProofsSQL)
    - 113 + + 189 +
    - + - } +   + return err
    -
    @@ -3,6 +3,7 @@
    +
    @@ -63,16 +63,13 @@
    - 3 + 63
      - import ( + } else if err != nil {
    - 4 + 64
      - "context" + return nil, err
    - 5 + 65
      - "errors" + }
    - + + 66 -
    -   +
    +
    + - +
    +
    +
    + 67 + +
    + - + defer rows.Close() +
    +
    + 68 + +
    + -
    - 6 + 69
      - "sync" + hashes := make([]common.Hash, 0, len(rows.RawValues()))
    - 7 + 70
      - "time" + for rows.Next() {
    - 8 + 71
      -
    + var hash string
    -
    @@ -22,7 +24,6 @@
    +
    + 72 + +
    + - + if err := rows.Scan(&hash); err != nil { +
    - 22 + + -
    +
    +
      - errContextCanceled = errors.New("consumer:context canceled") +
    - 23 + 73
      - errConsumerStopped = errors.New("consumer:stopped by request") + return nil, err
    - 24 + 74
      - errConsumerStoppedBecauseIsSynchronized = errors.New("consumer:stopped because is synchronized") + }
    - 25 + 75
    - - errL1Reorg = errors.New("consumer: L1 reorg detected") +
    - 26 + 76
      - errConsumerAndProducerDesynchronized = errors.New("consumer: consumer and producer are desynchronized") + hashes = append(hashes, common.HexToHash(hash))
    - 27 + 77
      - ) + }
    - 28 + 78
    @@ -176052,225 +255699,171 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -155,13 +156,12 @@
    +
    @@ -111,16 +108,13 @@
    - 155 + 111
      - } + } else if err != nil {
    - 156 + 112
      - if cachedBlock.BlockNumber == rollupInfo.previousBlockOfRange.NumberU64() { + return nil, err
    - 157 + 113
      - if cachedBlock.BlockHash != rollupInfo.previousBlockOfRange.Hash() { -
    -
    - 158 - -
    - - - log.Errorf("consumer: Previous block %d hash is not the same", cachedBlock.BlockNumber) -
    -
    - 159 - -
    - - - return errL1Reorg -
    -
    - 160 - -
    - - - } + }
    - 161 + + 114 +
    - - if cachedBlock.ParentHash != rollupInfo.previousBlockOfRange.ParentHash() { +
    - 162 + 115
    - - log.Errorf("consumer: Previous block %d parentHash is not the same", cachedBlock.BlockNumber) + defer rows.Close()
    - 163 + 116
    - - return errL1Reorg +
    - 164 + 117
      - } -
    -
    - - -
    -   -
    + hashes := make([]common.Hash, 0, len(rows.RawValues()))
    - 165 + 118
      - log.Infof("consumer: Verified previous block %d not the same: OK", cachedBlock.BlockNumber) + for rows.Next() {
    - 166 + 119
      - } + var hash string
    - 167 + + 120 +
    -   - return nil -
    -
    -
    + - + if err := rows.Scan(&hash); err != nil {
    -
    -
    - - - - - - - - - - + + +
    -
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + 121
      - "context" + return nil, err
    - 5 + 122
      - "errors" + }
    - 6 + + 123 +
    - + - "fmt" + - +
    - 7 + 124
      - "sync" + hashes = append(hashes, common.HexToHash(hash))
    - 8 + 125
      - "time" + }
    - 9 + 126
    @@ -176278,39 +255871,48 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    + + + @@ -176324,118 +255926,93 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - @@ -176450,235 +256027,207 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - -
     
    - 24 + 63
      - errContextCanceled = errors.New("consumer:context canceled") + } else if err != nil {
    - 25 + 64
      - errConsumerStopped = errors.New("consumer:stopped by request") + return nil, err
    - 26 + 65
      - errConsumerStoppedBecauseIsSynchronized = errors.New("consumer:stopped because is synchronized") + }
    - 27 - -
    -   - errConsumerAndProducerDesynchronized = errors.New("consumer: consumer and producer are desynchronized") -
    -
    - 28 + + -
    +
    +
      - ) +
    - 29 + + -
    +
    +
     
    -
     
    -
    - 156 + 66
      - } + hashes := make([]common.Hash, 0, len(rows.RawValues()))
    - 157 + 67
      - if cachedBlock.BlockNumber == rollupInfo.previousBlockOfRange.NumberU64() { + for rows.Next() {
    - 158 + 68
      - if cachedBlock.BlockHash != rollupInfo.previousBlockOfRange.Hash() { + var hash string
    - 159 + 69
    + - err := fmt.Errorf("consumer: Previous block %d hash is not the same. state.Hash:%s != l1.Hash:%s", + err := rows.Scan(&hash)
    - 160 + + 70 +
    + - cachedBlock.BlockNumber, cachedBlock.BlockHash, rollupInfo.previousBlockOfRange.Hash()) + if err != nil {
    - 161 + + 71 +
    - + - log.Errorf(err.Error()) +   + return nil, err
    - 162 + + 72 +
    - + - return syncCommon.NewReorgError(cachedBlock.BlockNumber, err) -
    -
    - - -
      -
    + }
    - 163 + 73
      - } + hashes = append(hashes, common.HexToHash(hash))
    - 164 + + 74 +
    - + -
    +   + }
    - 165 + 75
      - log.Infof("consumer: Verified previous block %d not the same: OK", cachedBlock.BlockNumber) +
    +
     
    +
    - 166 + 108
      - } + } else if err != nil {
    - 167 + 109
      - return nil -
    -
    -
    + return nil, err
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - -
    -
    @@ -31,7 +31,7 @@
    - 31 + 110
      - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + }
    - 32 + + -
    +
    +
      - } +
    - 33 + + -
    +
    +
     
    - 34 + + -
    - - - ethermanClient, err := etherman.NewClient(cfg, l1Config) +
    +
    +   +
    - 35 + 111
      - require.NoError(t, err) + hashes := make([]common.Hash, 0, len(rows.RawValues()))
    - 36 + 112
      - worker := newWorker(ethermanClient) + for rows.Next() {
    - 37 + 113
      - ch := make(chan responseRollupInfoByBlockRange) + var hash string
    -
    + + + 114 + + +
    + + + err := rows.Scan(&hash)
    -
    -
    - - - - - - - - - @@ -176688,12 +256237,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/processor_trusted_batch_sync.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/reset.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - @@ -176921,102 +256400,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - @@ -177026,92 +256475,52 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - @@ -177121,12 +256530,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/tests/trusted_batches_retrieve_test.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/client.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -177364,433 +256753,457 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    - 31 + + 115 +
    -   - GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"), + + + if err != nil {
    - 32 + 116
      - } + return nil, err
    - 33 + 117
      -
    + }
    - 34 + + -
    - + - ethermanClient, err := etherman.NewClient(cfg, l1Config, nil, nil) +
    +
    +   +
    - 35 + 118
      - require.NoError(t, err) + hashes = append(hashes, common.HexToHash(hash))
    - 36 + 119
      - worker := newWorker(ethermanClient) + }
    - 37 + 120
      - ch := make(chan responseRollupInfoByBlockRange) +
    -
    @@ -171,6 +171,10 @@
    +
    @@ -14,7 +14,6 @@
    - 171 + 14
      -
    + // - VerifiedBatches
    - 172 + 15
      - // ProcessTrustedBatch processes a trusted batch and return the new state + // - Entries in exit_root table
    - 173 + 16
      - func (s *ProcessorTrustedBatchSync) ProcessTrustedBatch(ctx context.Context, trustedBatch *types.Batch, status TrustedState, dbTx pgx.Tx, debugPrefix string) (*TrustedState, error) { -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx)
    - + + 17 -
    -   +
    +
    + -
    - 174 + 18
      - log.Debugf("%s Processing trusted batch: %v", debugPrefix, trustedBatch.Number) + if err != nil {
    - 175 + 19
      - stateCurrentBatch, statePreviousBatch := s.GetCurrentAndPreviousBatchFromCache(&status) + log.Error("error resetting L1BlockNumber. Error: ", err)
    - 176 + 20
      - if s.l1SyncChecker != nil { + return err
    -
    @@ -374,7 +378,9 @@
    +
    @@ -30,5 +29,4 @@
    - 374 + 30
      - result.OldAccInputHash = statePreviousBatch.AccInputHash + // is going to be a commit or a rollback. So is going to be rebuild on the next
    - 375 + 31
      - result.Now = s.timeProvider.Now() + // request that needs it.
    - 376 + 32
      - result.DebugPrefix = fmt.Sprintf("%s mode %s:", debugPrefix, result.Mode) + s.l1InfoTree = nil
    - 377 + + 33 +
    - -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - 378 - -
    -   - if isTrustedBatchEmptyAndClosed(trustedNodeBatch) { -
    -
    - 379 - -
    -   - if s.Cfg.AcceptEmptyClosedBatches { + s.l1InfoTreeRecursive = nil
    - 380 + 34
      - log.Infof("%s Batch %v: TrustedBatch Empty and closed, accepted due configuration", result.DebugPrefix, trustedNodeBatch.Number) + }
    - 171 + 14
      -
    + // - VerifiedBatches
    - 172 + 15
      - // ProcessTrustedBatch processes a trusted batch and return the new state + // - Entries in exit_root table
    - 173 + 16
      - func (s *ProcessorTrustedBatchSync) ProcessTrustedBatch(ctx context.Context, trustedBatch *types.Batch, status TrustedState, dbTx pgx.Tx, debugPrefix string) (*TrustedState, error) { -
    -
    - 174 - -
    - + - if trustedBatch == nil { -
    -
    - 175 - -
    - + - log.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix) -
    -
    - 176 - -
    - + - return nil, fmt.Errorf("%s trustedBatch is nil, it never should be nil", debugPrefix) + err := s.ResetToL1BlockNumber(ctx, blockNumber, dbTx)
    - 177 + + -
    - + - } +
    +
    +   +
    - 178 + 17
      - log.Debugf("%s Processing trusted batch: %v", debugPrefix, trustedBatch.Number) + if err != nil {
    - 179 + 18
      - stateCurrentBatch, statePreviousBatch := s.GetCurrentAndPreviousBatchFromCache(&status) + log.Error("error resetting L1BlockNumber. Error: ", err)
    - 180 + 19
      - if s.l1SyncChecker != nil { + return err
    - 378 - -
    -   - result.OldAccInputHash = statePreviousBatch.AccInputHash -
    -
    - 379 + 29
      - result.Now = s.timeProvider.Now() + // is going to be a commit or a rollback. So is going to be rebuild on the next
    - 380 + 30
      - result.DebugPrefix = fmt.Sprintf("%s mode %s:", debugPrefix, result.Mode) -
    -
    - 381 - -
    - + - if result.BatchMustBeClosed { -
    -
    - 382 - -
    - + - result.DebugPrefix += " (must_be_closed)" -
    -
    - 383 - -
    - + - } + // request that needs it.
    - 384 + 31
      - if isTrustedBatchEmptyAndClosed(trustedNodeBatch) { + s.l1InfoTree = nil
    - 385 + + -
    +
    +
      - if s.Cfg.AcceptEmptyClosedBatches { +
    - 386 + 32
      - log.Infof("%s Batch %v: TrustedBatch Empty and closed, accepted due configuration", result.DebugPrefix, trustedNodeBatch.Number) + }
    -
    @@ -0,0 +1,117 @@
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    +
    @@ -7,20 +7,26 @@
    - + + 7 -
    +
    +
     
    - + + 8 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 9 -
    +
    +
      -
    + "google.golang.org/grpc"
    - + + 10 -
    -   -
    +
    +
    + - + "google.golang.org/grpc/connectivity"
    - + + 11 -
    +
    +
      -
    + "google.golang.org/grpc/credentials/insecure"
    - + + 12 -
    +
    +
      -
    + )
    - + + 13 -
    +
    +
     
    @@ -177304,53 +256693,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 14 -
    +
    +
      -
    + // NewExecutorClient is the executor client constructor.
    - + + 15 -
    +
    +
      -
    + func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - + + 16 -
    +
    +
      -
    + opts := []grpc.DialOption{
    - + + 17 -
    +
    +
      -
    + grpc.WithTransportCredentials(insecure.NewCredentials()),
    - + + 18 -
    +
    +
      -
    + grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(c.MaxGRPCMessageSize)),
    - + + 19 -
    +
    +
      -
    + }
    - + + 20 -
    -   -
    +
    +
    + - + const maxWaitSeconds = 20
    - + + 21 -
    +
    +
      -
    + const maxRetries = 5
    - + + 22 -
    -   -
    +
    +
    + - + var innerCtx context.Context
    - + + 23 -
    -   -
    +
    +
    + - + var cancel context.CancelFunc
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + connectionRetries := 0
    - + + 26 -
    +
    +
     
    - + +
    @@ -28,15 +34,8 @@
    -
    +
    + 28 + +
      -
    + var err error
    - + + 29 -
    +
    +
      -
    + delay := 2
    - + + 30 -
    +
    +
      -
    + for connectionRetries < maxRetries {
    - + + 31 -
    -   -
    +
    +
    + - + innerCtx, cancel = context.WithTimeout(ctx, maxWaitSeconds*time.Second)
    - + + 32 -
    -   -
    +
    +
    + - + executorConn, err = grpc.NewClient(c.URI, opts...)
    - + + 33 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 34 -
    -   -
    +
    +
    + - + log.Fatalf("fail to create grpc connection to merkletree: %v", err)
    - + + 35 -
    -   -
    +
    +
    + - + }
    - + + 36 -
    -   +
    +
    + -
    - + + 37 -
    +
    +
      -
    + log.Infof("trying to connect to executor: %v", c.URI)
    - + + 38 -
    -   -
    +
    +
    + - + executorConn.Connect()
    - + + 39 -
    -   -
    +
    +
    + - + err = waitForConnection(innerCtx, executorConn)
    - + + 40 -
    +
    +
      -
    + if err != nil {
    - + + 41 -
    +
    +
      -
    + log.Infof("Retrying connection to executor #%d", connectionRetries)
    - + + 42 -
    +
    +
      -
    + time.Sleep(time.Duration(delay) * time.Second)
    - + +
    @@ -57,17 +56,3 @@
    -
    +
    + 57 + +
      -
    + executorClient := NewExecutorServiceClient(executorConn)
    - + + 58 -
    +
    +
      -
    + return executorClient, executorConn, cancel
    - + + 59 -
    +
    +
      -
    + }
    - + + 60 -
    -   +
    +
    + -
    - + + 61 -
    -   -
    +
    +
    + - + func waitForConnection(ctx context.Context, conn *grpc.ClientConn) error {
    - + + 62 -
    -   -
    +
    +
    + - + for {
    - + + 63 -
    -   -
    +
    +
    + - + select {
    - + + 64 -
    -   -
    +
    +
    + - + case <-ctx.Done():
    - + + 65 -
    -   -
    +
    +
    + - + return ctx.Err()
    - + + 66 -
    -   -
    +
    +
    + - + case <-time.After(time.Second):
    - + + 67 -
    -   -
    +
    +
    + - + s := conn.GetState()
    - + + 68 -
    -   -
    +
    +
    + - + if s == connectivity.Ready {
    - + + 69 -
    -   -
    +
    +
    + - + return nil
    - + + 70 -
    -   -
    +
    +
    + - + }
    - + + 71 -
    -   -
    +
    +
    + - + }
    - + + 72 -
    -   -
    +
    +
    + - + }
    - + + 73 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -177804,203 +257217,203 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -178014,63 +257427,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -178134,23 +257552,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -178164,63 +257582,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -178313,1991 +257736,1853 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    +
     
    - + + 7 -
    +
    +
     
    - + + 8 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 9 -
    +
    +
      -
    + "google.golang.org/grpc"
    - + + 10 -
    +
    +
      -
    + "google.golang.org/grpc/credentials/insecure"
    - + + 11 -
    +
    +
      -
    + )
    - + + 12 -
    +
    +
     
    - + + 13 -
    -   -
    +
    +
    + + + const (
    - + + 14 -
    -   -
    +
    +
    + + + // ExecutionMode0 is the execution mode for the sequencer and RPC, default one
    - + + 15 -
    -   -
    +
    +
    + + + ExecutionMode0 = uint64(0)
    - + + 16 -
    -   -
    +
    +
    + + + // ExecutionMode1 is the execution mode for the synchronizer
    - + + 17 -
    -   -
    +
    +
    + + + ExecutionMode1 = uint64(1)
    - + + 18 -
    -   -
    +
    +
    + + + )
    - + + 19 -
    -   +
    +
    + +
    - + + 20 -
    +
    +
      -
    + // NewExecutorClient is the executor client constructor.
    - + + 21 -
    +
    +
      -
    + func NewExecutorClient(ctx context.Context, c Config) (ExecutorServiceClient, *grpc.ClientConn, context.CancelFunc) {
    - + + 22 -
    +
    +
      -
    + opts := []grpc.DialOption{
    - + + 23 -
    +
    +
      -
    + grpc.WithTransportCredentials(insecure.NewCredentials()),
    - + + 24 -
    +
    +
      -
    + grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(c.MaxGRPCMessageSize)),
    - + + 25 -
    -   -
    +
    +
    + + + grpc.WithBlock(),
    - + + 26 -
    +
    +
      -
    + }
    - + + 27 -
    -   -
    +
    +
    + + + const maxWaitSeconds = 120
    - + + 28 -
    +
    +
      -
    + const maxRetries = 5
    - + + 29 -
    -   -
    +
    +
    + + + ctx, cancel := context.WithTimeout(ctx, maxWaitSeconds*time.Second)
    - + + 30 -
    +
    +
     
    - + + 31 -
    +
    +
      -
    + connectionRetries := 0
    - + + 32 -
    +
    +
     
    - + +
     
    -
    +
    + 34 + +
      -
    + var err error
    - + + 35 -
    +
    +
      -
    + delay := 2
    - + + 36 -
    +
    +
      -
    + for connectionRetries < maxRetries {
    - + + 37 -
    +
    +
      -
    + log.Infof("trying to connect to executor: %v", c.URI)
    - + + 38 -
    -   -
    +
    +
    + + + executorConn, err = grpc.DialContext(ctx, c.URI, opts...)
    - + + 39 -
    +
    +
      -
    + if err != nil {
    - + + 40 -
    +
    +
      -
    + log.Infof("Retrying connection to executor #%d", connectionRetries)
    - + + 41 -
    +
    +
      -
    + time.Sleep(time.Duration(delay) * time.Second)
    - + +
     
    -
    +
    + 56 + +
      -
    + executorClient := NewExecutorServiceClient(executorConn)
    - + + 57 -
    +
    +
      -
    + return executorClient, executorConn, cancel
    - + + 58 -
    +
    +
      -
    + }
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    -
    - 1 - -
    - + - package test_l2_shared -
    -
    - 2 - -
    - + -
    -
    -
    - 3 - -
    - + - import ( -
    -
    - 4 - -
    - + - "context" -
    -
    - 5 - -
    - + - "math/big" -
    -
    - 6 - -
    - + - "testing" -
    -
    - 7 - -
    - + -
    -
    -
    - 8 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types" -
    -
    - 9 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/state" -
    -
    - 10 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" -
    -
    - 11 - -
    - + - mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks" -
    -
    - 12 - -
    - + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" -
    -
    - 13 - -
    - + - l2sharedmocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared/mocks" -
    -
    - 14 - -
    - + - syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" -
    -
    - 15 + + -
    - + - "github.com/stretchr/testify/mock" +
    +
    +   +
    - 16 + + -
    - + - "github.com/stretchr/testify/require" +
    +
    +   +
    - 17 + + -
    - + - ) +
    +
    +   +
    - 18 + + -
    - + +
    +
    +  
    - 19 + + -
    - + - type testDataTrustedBatchRetrieve struct { +
    +
    +   +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/executor/errors.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -20,13 +20,6 @@
    + 20 +
    - + - mockBatchProcessor *l2sharedmocks.BatchProcessor +   + ErrROMUnknown = fmt.Errorf("unknown ROM error")
    + 21 +
    - + - mockZkEVMClient *mock_syncinterfaces.ZKEVMClientTrustedBatchesGetter +   + // ErrCodeROMUnknown indicates an unknown ROM error
    + 22 +
    - + - mockState *l2sharedmocks.StateInterface +   + ErrCodeROMUnknown = RomError(math.MaxInt32)
    + 23 +
    - + - mockSync *mock_syncinterfaces.SynchronizerFlushIDManager + - +
    + 24 +
    - + - mockTimer *common.MockTimerProvider + - + // ErrROMBlobUnspecified indicates an unspecified ROM blob error
    + 25 +
    - + - mockDbTx *syncMocks.DbTxMock + - + ErrROMBlobUnspecified = fmt.Errorf("unspecified ROM blob error")
    + 26 +
    - + - TrustedStateMngr *l2_shared.TrustedStateManager + - + // ErrROMBlobUnknown indicates an unknown ROM blob error
    + 27 +
    - + - sut *l2_shared.TrustedBatchesRetrieve + - + ErrROMBlobUnknown = fmt.Errorf("unknown ROM blob error")
    + 28 +
    - + - ctx context.Context + - + // ErrCodeROMBlobUnknown indicates an unknown ROM blob error
    + 29 +
    - + - } + - + ErrCodeROMBlobUnknown = RomBlobError(math.MaxInt32)
    + 30 +
    - + -
    +   + )
    + 31 +
    - + - func newTestDataTrustedBatchRetrieve(t *testing.T) *testDataTrustedBatchRetrieve { +   +
    + 32 +
    - + - mockBatchProcessor := l2sharedmocks.NewBatchProcessor(t) +   + // RomErr returns an instance of error related to the ExecutorError
    - 33 + +
    @@ -103,9 +96,6 @@
    +
    + 103 +
    - + - mockZkEVMClient := mock_syncinterfaces.NewZKEVMClientTrustedBatchesGetter(t) +   + return runtime.ErrInvalidTxChangeL2BlockLimitTimestamp
    - 34 + + 104 +
    - + - mockState := l2sharedmocks.NewStateInterface(t) +   + case RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP:
    - 35 + + 105 +
    - + - mockSync := mock_syncinterfaces.NewSynchronizerFlushIDManager(t) +   + return runtime.ErrInvalidTxChangeL2BlockMinTimestamp
    - 36 + + 106 +
    - + - mockTimer := &common.MockTimerProvider{} + - + // Start of V3 errors
    - 37 + + 107 +
    - + - mockDbTx := syncMocks.NewDbTxMock(t) + - + case RomError_ROM_ERROR_INVALID_L1_INFO_TREE_INDEX:
    - 38 + + 108 +
    - + - TrustedStateMngr := l2_shared.NewTrustedStateManager(mockTimer, 0) + - + return runtime.ErrInvalidL1InfoTreeIndex
    - 39 + + 109 +
    - + - sut := l2_shared.NewTrustedBatchesRetrieve(mockBatchProcessor, mockZkEVMClient, mockState, mockSync, *TrustedStateMngr) +   + }
    - 40 + + 110 +
    - + - ctx := context.TODO() +   + return ErrROMUnknown
    - 41 + + 111 +
    - + - return &testDataTrustedBatchRetrieve{ +   + }
    - 42 + +
    @@ -182,8 +172,6 @@
    +
    + 182 +
    - + - mockBatchProcessor: mockBatchProcessor, +   + return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP
    - 43 + + 183 +
    - + - mockZkEVMClient: mockZkEVMClient, +   + case runtime.ErrInvalidTxChangeL2BlockMinTimestamp:
    - 44 + + 184 +
    - + - mockState: mockState, +   + return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP
    - 45 + + 185 +
    - + - mockSync: mockSync, + - + case runtime.ErrInvalidL1InfoTreeIndex:
    - 46 + + 186 +
    - + - mockTimer: mockTimer, + - + return RomError_ROM_ERROR_INVALID_L1_INFO_TREE_INDEX
    - 47 + + 187 +
    - + - mockDbTx: mockDbTx, +   + }
    - 48 + + 188 +
    - + - TrustedStateMngr: TrustedStateMngr, +   + return ErrCodeROMUnknown
    - 49 + + 189 +
    - + - sut: sut, +   + }
    - 50 + +
    @@ -468,49 +456,7 @@
    +
    + 468 +
    - + - ctx: ctx, +   + return runtime.ErrExecutorErrorInvalidUpdateMerkleTree
    - 51 + + 469 +
    - + - } +   + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR:
    - 52 + + 470 +
    - + - } +   + return runtime.ErrExecutorErrorSMMainInvalidTxStatusError
    - 53 + + 471 +
    - + -
    + - + // Start of V3 errors
    - 54 + + 472 +
    - + - const ( + - + case ExecutorError_EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT:
    - 55 + + 473 +
    - + - closedBatch = true + - + return runtime.ErrExecutorErrorInvalidPreviousL1InfoTreeRoot
    - 56 + + 474 +
    - + - notClosedBatch = false + - + case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA:
    - 57 + + 475 +
    - + - ) + - + return runtime.ErrExecutorErrorInvalidForcedHashData
    - 58 + + 476 +
    - + -
    + - + case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT:
    - 59 + + 477 +
    - + - // This test must do from 100 to 104. + - + return runtime.ErrExecutorErrorInvalidForcedDataGlobalExitRoot
    - 60 + + 478 +
    - + - // But the batch 100 is open on TrustedNode so it stop processing + - + case ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1:
    - 61 + + 479 +
    - + - func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatch(t *testing.T) { + - + return runtime.ErrExecutorErrorInvalidForcedDataBlockHashL1
    - 62 + + 480 +
    - + - data := newTestDataTrustedBatchRetrieve(t) + - + case ExecutorError_EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT:
    - 63 + + 481 +
    - + - data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) + - + return runtime.ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot
    - 64 + + 482 +
    - + -
    + - + case ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT:
    - 65 + + 483 +
    - + - expectationsForSyncTrustedStateIteration(t, 100, notClosedBatch, data) + - + return runtime.ErrExecutorErrorInvalidOldBlobStateRoot
    - 66 + + 484 +
    - + -
    + - + case ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH:
    - 67 + + 485 +
    - + - err := data.sut.SyncTrustedState(data.ctx, 100, 104) + - + return runtime.ErrExecutorErrorInvalidOldBlobAccInputHash
    - 68 + + 486 +
    - + - require.NoError(t, err) + - + case ExecutorError_EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT:
    - 69 + + 487 +
    - + - } + - + return runtime.ErrExecutorErrorInvalidLastL1InfoTreeRoot
    - 70 + + 488 +
    - + -
    + - + case ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT:
    - 71 + + 489 +
    - + - // This must process 100 (that is closed) + - + return runtime.ErrExecutorErrorInvalidNewBlobStateRoot
    - 72 + + 490 +
    - + - // and stop processing at 101 because is not yet close this batch + - + case ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH:
    - 73 + + 491 +
    - + - func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase2(t *testing.T) { + - + return runtime.ErrExecutorErrorInvalidNewBlobAccInputHash
    - 74 + + 492 +
    - + - data := newTestDataTrustedBatchRetrieve(t) + - + case ExecutorError_EXECUTOR_ERROR_INVALID_BLOB_DATA:
    - 75 + + 493 +
    - + - data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) + - + return runtime.ErrExecutorErrorInvalidBlobData
    - 76 + + 494 +
    - + -
    + - + case ExecutorError_EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT:
    - 77 + + 495 +
    - + - expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data) + - + return runtime.ErrExecutorErrorInvalidZKGasLimit
    - 78 + + 496 +
    - + - expectationsForSyncTrustedStateIteration(t, 101, notClosedBatch, data) + - + case ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Z:
    - 79 + + 497 +
    - + -
    + - + return runtime.ErrExecutorErrorInvalidPointZ
    - 80 + + 498 +
    - + - err := data.sut.SyncTrustedState(data.ctx, 100, 104) + - + case ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Y:
    - 81 + + 499 +
    - + - require.NoError(t, err) + - + return runtime.ErrExecutorErrorInvalidPointY
    - 82 + + 500 +
    - + - } + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH:
    - 83 + + 501 +
    - + -
    + - + return runtime.ErrExecutorErrorSMMainPointZMismatch
    - 84 + + 502 +
    - + - // This test must do from 100 to 102. Is for check manually that the logs + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH:
    - 85 + + 503 +
    - + - // That is not tested but must not emit the log: + - + return runtime.ErrExecutorErrorSMMainBlobL2HashDataMismatch
    - 86 + + 504 +
    - + - // - Batch 101 is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_BATCH_HASH_DATA_MISMATCH:
    - 87 + + 505 +
    - + - func TestSyncTrustedBatchesToFromStopAfterFirstWIPBatchCase3(t *testing.T) { + - + return runtime.ErrExecutorErrorSMMainBatchHashDataMismatch
    - 88 + + 506 +
    - + - data := newTestDataTrustedBatchRetrieve(t) + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_BLOB_TYPE:
    - 89 + + 507 +
    - + - data.mockZkEVMClient.EXPECT().BatchNumber(data.ctx).Return(uint64(102), nil) + - + return runtime.ErrExecutorErrorSMMainInvalidBlobType
    - 90 + + 508 +
    - + - expectationsForSyncTrustedStateIteration(t, 100, closedBatch, data) + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_UNRESTORED_SAVED_CONTEXT:
    - 91 + + 509 +
    - + - expectationsForSyncTrustedStateIteration(t, 101, closedBatch, data) + - + return runtime.ErrExecutorErrorSMMainUnrestoredSavedContext
    - 92 + + 510 +
    - + - expectationsForSyncTrustedStateIteration(t, 102, notClosedBatch, data) + - + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX:
    - 93 + + 511 +
    - + -
    + - + return runtime.ErrExecutorErrorSMMainInvalidMemoryCtx
    - 94 + + 512 +
    - + - err := data.sut.SyncTrustedState(data.ctx, 100, 102) +   + }
    - 95 + + 513 +
    - + - require.NoError(t, err) + - +
    - 96 + + 514 +
    - + - } +   + return ErrExecutorUnknown
    - 97 + + 515 +
    - + -
    +   + }
    - 98 + + 516 +
    - + - func expectationsForSyncTrustedStateIteration(t *testing.T, batchNumber uint64, closed bool, data *testDataTrustedBatchRetrieve) { +   +
    - 99 + +
    @@ -752,96 +698,7 @@
    +
    + 752 +
    - + - batch100 := &types.Batch{ +   + return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE
    - 100 + + 753 +
    - + - Number: types.ArgUint64(batchNumber), +   + case runtime.ErrExecutorErrorSMMainInvalidTxStatusError:
    - 101 + + 754 +
    - + - Closed: closed, +   + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR
    - 102 + + 755 +
    - + - } + - + // Start of V3 errors
    - 103 + + 756 +
    - + - data.mockZkEVMClient.EXPECT().BatchByNumber(data.ctx, big.NewInt(0).SetUint64(batchNumber)).Return(batch100, nil) + - + case runtime.ErrExecutorErrorInvalidPreviousL1InfoTreeRoot:
    - 104 + + 757 +
    - + - data.mockState.EXPECT().BeginStateTransaction(data.ctx).Return(data.mockDbTx, nil) + - + return ExecutorError_EXECUTOR_ERROR_INVALID_PREVIOUS_L1_INFO_TREE_ROOT
    - 105 + + 758 +
    - + - // Get Previous Batch 99 from State + - + case runtime.ErrExecutorErrorInvalidForcedHashData:
    - 106 + + 759 +
    - + - stateBatch99 := &state.Batch{ + - + return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_HASH_DATA
    - 107 + + 760 +
    - + - BatchNumber: batchNumber - 1, + - + case runtime.ErrExecutorErrorInvalidForcedDataGlobalExitRoot:
    - 108 + + 761 +
    - + - } + - + return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_GLOBAL_EXIT_ROOT
    - 109 + + 762 +
    - + - data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber-1), data.mockDbTx).Return(stateBatch99, nil) + - + case runtime.ErrExecutorErrorInvalidForcedDataBlockHashL1:
    - 110 + + 763 +
    - + - stateBatch100 := &state.Batch{ + - + return ExecutorError_EXECUTOR_ERROR_INVALID_FORCED_DATA_BLOCK_HASH_L1
    - 111 + + 764 +
    - + - BatchNumber: batchNumber, + - + case runtime.ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot:
    - 112 + + 765 +
    - + - } + - + return ExecutorError_EXECUTOR_ERROR_INVALID_L1_DATA_V3_INITIAL_HISTORIC_ROOT
    - 113 + + 766 +
    - + - data.mockState.EXPECT().GetBatchByNumber(data.ctx, uint64(batchNumber), data.mockDbTx).Return(stateBatch100, nil) + - + case runtime.ErrExecutorErrorInvalidOldBlobStateRoot:
    - 114 + + 767 +
    - + - data.mockBatchProcessor.EXPECT().ProcessTrustedBatch(data.ctx, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil, nil) + - + return ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_STATE_ROOT
    - 115 + + 768 +
    - + - data.mockSync.EXPECT().CheckFlushID(mock.Anything).Return(nil) + - + case runtime.ErrExecutorErrorInvalidOldBlobAccInputHash:
    - 116 + + 769 +
    - + - data.mockDbTx.EXPECT().Commit(data.ctx).Return(nil) + - + return ExecutorError_EXECUTOR_ERROR_INVALID_OLD_BLOB_ACC_INPUT_HASH
    - 117 + + 770 +
    - + - } -
    -
    -
    + - + case runtime.ErrExecutorErrorInvalidLastL1InfoTreeRoot:
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_shared/trusted_batches_retrieve.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -109,6 +109,16 @@
    - 109 + + 771 +
    -   - return lastTrustedStateBatchNumber < latestSyncedBatch + - + return ExecutorError_EXECUTOR_ERROR_INVALID_LAST_L1_INFO_TREE_ROOT
    - 110 + + 772 +
    -   - } + - + case runtime.ErrExecutorErrorInvalidNewBlobStateRoot:
    - 111 + + 773 +
    -   -
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_STATE_ROOT
    - + + 774 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorInvalidNewBlobAccInputHash:
    - + + 775 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_NEW_BLOB_ACC_INPUT_HASH
    - + + 776 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorInvalidBlobData:
    - + + 777 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_BLOB_DATA
    - + + 778 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorInvalidZKGasLimit:
    - + + 779 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_ZK_GAS_LIMIT
    - + + 780 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorInvalidPointZ:
    - - -
    -   -
    +
    + 781 + +
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Z
    - + + 782 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorInvalidPointY:
    - + + 783 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_INVALID_POINT_Y
    - 112 + + 784 +
    -   - func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, latestSyncedBatch uint64, lastTrustedStateBatchNumber uint64) error { + - + case runtime.ErrExecutorErrorSMMainPointZMismatch:
    - 113 + + 785 +
    -   - batchNumberToSync := max(latestSyncedBatch, s.firstBatchNumberToSync) + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_POINT_Z_MISMATCH
    - 114 + + 786 +
    -   - for batchNumberToSync <= lastTrustedStateBatchNumber { + - + case runtime.ErrExecutorErrorSMMainBlobL2HashDataMismatch:
    -
    @@ -120,6 +130,11 @@
    -
    - 120 + + 787 +
    -   - log.Warnf("%s failed to get batch %d from trusted state. Error: %v", debugPrefix, batchNumberToSync, err) + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_BLOB_L2_HASH_DATA_MISMATCH
    - 121 + + 788 +
    -   - return err + - + case runtime.ErrExecutorErrorSMMainBatchHashDataMismatch:
    - 122 + + 789 +
    -   - } + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_BATCH_HASH_DATA_MISMATCH
    - + + 790 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorSMMainInvalidBlobType:
    - + + 791 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_BLOB_TYPE
    - + + 792 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorSMMainUnrestoredSavedContext:
    - + + 793 -
    -   -
    +
    +
    + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_UNRESTORED_SAVED_CONTEXT
    - + + 794 -
    -   -
    +
    +
    + - + case runtime.ErrExecutorErrorSMMainInvalidMemoryCtx:
    - 123 + + 795 +
    -   -
    + - + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_MEMORY_CTX
    - 124 + 796
      - dbTx, err := s.state.BeginStateTransaction(ctx) + }
    - 125 + 797
      - if err != nil { +
    -
    @@ -161,6 +176,10 @@
    -
    - 161 + 798
      - s.TrustedStateMngr.Clear() + return ErrCodeExecutorUnknown
    - 162 + 799
      - } + }
    - 163 + + 800 +
    -   - batchNumberToSync++ + - +
    - + + 801 -
    -   -
    +
    +
    + - + // RomBlobErr returns an instance of error related to the ExecutorError
    - + + 802 -
    -   -
    +
    +
    + - + func RomBlobErr(errorCode RomBlobError) error {
    - + + 803 -
    -   -
    +
    +
    + - + switch errorCode {
    - + + 804 -
    -   -
    +
    +
    + - + case RomBlobError_ROM_BLOB_ERROR_UNSPECIFIED:
    - 164 + + 805 +
    -   - } + - + return ErrROMBlobUnspecified
    - 165 + + 806 +
    -   -
    + - + case RomBlobError_ROM_BLOB_ERROR_NO_ERROR:
    - 166 + + 807 +
    -   - log.Infof("syncTrustedState: Trusted state fully synchronized from %d to %d", latestSyncedBatch, lastTrustedStateBatchNumber) + - + return nil
    -
    + + + 808 + + +
    + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_PARSING:
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - @@ -180305,21 +259590,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
     
    - 109 + + 809 +
    -   - return lastTrustedStateBatchNumber < latestSyncedBatch + - + return runtime.ErrROMBlobInvalidParsing
    - 110 + + 810 +
    -   - } + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_MSB_BYTE:
    - 111 + + 811 +
    -   -
    + - + return runtime.ErrROMBlobInvalidMSBByte
    - 112 + + 812 +
    - + - func sanityCheckBatchReturnedByTrusted(batch *types.Batch, expectedBatchNumber uint64) error { + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT:
    - 113 + + 813 +
    - + - if batch == nil { + - + return runtime.ErrROMBlobInvalidZKGasLimit
    - 114 + + 814 +
    - + - return fmt.Errorf("batch %d is nil", expectedBatchNumber) + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_BLOB_TYPE:
    - 115 + + 815 +
    - + - } + - + return runtime.ErrROMBlobInvalidBlobType
    - 116 + + 816 +
    - + - if uint64(batch.Number) != expectedBatchNumber { + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE:
    - 117 + + 817 +
    - + - return fmt.Errorf("batch %d is not the expected batch %d", batch.Number, expectedBatchNumber) + - + return runtime.ErrROMBlobInvalidCompressionType
    - 118 + + 818 +
    - + - } + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_FORCED_BATCHES:
    - 119 + + 819 +
    - + - return nil + - + return runtime.ErrROMBlobInvalidForcedBatches
    - 120 + + 820 +
    - + - } + - + case RomBlobError_ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN:
    - 121 + + 821 +
    - + -
    + - + return runtime.ErrROMBlobInvalidTotalBodyLen
    - 122 + + 822 +
    -   - func (s *TrustedBatchesRetrieve) syncTrustedBatchesToFrom(ctx context.Context, latestSyncedBatch uint64, lastTrustedStateBatchNumber uint64) error { + - + }
    - 123 + + 823 +
    -   - batchNumberToSync := max(latestSyncedBatch, s.firstBatchNumberToSync) + - + return ErrROMBlobUnknown
    - 124 + + 824 +
    -   - for batchNumberToSync <= lastTrustedStateBatchNumber { + - + }
    -
     
    +
    + 825 + +
    + - +
    +
    - 130 + + 826 +
    -   - log.Warnf("%s failed to get batch %d from trusted state. Error: %v", debugPrefix, batchNumberToSync, err) + - + // RomBlobErrorCode returns the error code for a given error
    - 131 + + 827 +
    -   - return err + - + func RomBlobErrorCode(err error) RomBlobError {
    - 132 + + 828 +
    -   - } + - + switch err {
    - 133 + + 829 +
    - + - err = sanityCheckBatchReturnedByTrusted(batchToSync, batchNumberToSync) + - + case nil:
    - 134 + + 830 +
    - + - if err != nil { + - + return RomBlobError_ROM_BLOB_ERROR_NO_ERROR
    - 135 + + 831 +
    - + - log.Warnf("%s sanity check over Batch returned by Trusted-RPC failed: %v", debugPrefix, err) + - + case runtime.ErrROMBlobInvalidParsing:
    - 136 + + 832 +
    - + - return err + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_PARSING
    - 137 + + 833 +
    - + - } + - + case runtime.ErrROMBlobInvalidMSBByte:
    - 138 + + 834 +
    -   -
    + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_MSB_BYTE
    - 139 + + 835 +
    -   - dbTx, err := s.state.BeginStateTransaction(ctx) + - + case runtime.ErrROMBlobInvalidZKGasLimit:
    - 140 + + 836 +
    -   - if err != nil { + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_ZK_GAS_LIMIT
    -
     
    +
    + 837 + +
    + - + case runtime.ErrROMBlobInvalidBlobType: +
    - 176 + + 838 +
    -   - s.TrustedStateMngr.Clear() + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_BLOB_TYPE
    - 177 + + 839 +
    -   - } + - + case runtime.ErrROMBlobInvalidCompressionType:
    - 178 + + 840 +
    -   - batchNumberToSync++ + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_COMPRESSION_TYPE
    - 179 + + 841 +
    - + - if !batchToSync.Closed && batchNumberToSync <= lastTrustedStateBatchNumber { + - + case runtime.ErrROMBlobInvalidForcedBatches:
    - 180 + + 842 +
    - + - log.Infof("%s Batch %d is not closed. so we break synchronization from Trusted Node because can only have 1 WIP batch on state", debugPrefix, batchToSync.Number) + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_FORCED_BATCHES
    - 181 + + 843 +
    - + - return nil + - + case runtime.ErrROMBlobInvalidTotalBodyLen:
    - 182 + + 844 +
    - + - } + - + return RomBlobError_ROM_BLOB_ERROR_INVALID_TOTALBODY_LEN
    - 183 + + 845 +
    -   + - }
    - 184 + + 846 +
    -   -
    + - + return ErrCodeROMBlobUnknown
    - 185 + + 847 +
    -   - log.Infof("syncTrustedState: Trusted state fully synchronized from %d to %d", latestSyncedBatch, lastTrustedStateBatchNumber) + - + }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go - RENAMED - -
    -
    @@ -180327,231 +259597,206 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - @@ -180656,7 +259881,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -136,13 +137,13 @@
    +
     
    - 136 + 20
      - return nil, err + ErrROMUnknown = fmt.Errorf("unknown ROM error")
    - 137 + 21
      - } + // ErrCodeROMUnknown indicates an unknown ROM error
    - 138 + 22
      -
    + ErrCodeROMUnknown = RomError(math.MaxInt32)
    - 139 + + -
    - - - leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) +
    +
    +   +
    - 140 + + -
    +
    +
      - if err != nil { +
    - 141 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 142 + + -
    +
    +
      - return nil, err +
    - 143 + + -
    +
    +
      - } +
    - 144 + + -
    +
    +
      - debugStr := data.DebugPrefix +
    - 145 + + -
    - - - processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leafs, l1InfoRoot), dbTx, debugStr) +
    +
    +   +
    - 146 + 23
      - if err != nil { + )
    - 147 + 24
      - log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) +
    - 148 + 25
      - return nil, err + // RomErr returns an instance of error related to the ExecutorError
    -
    @@ -197,7 +198,7 @@
    -
    - 197 - -
    -   - return nil, err -
    +
     
    - 198 + 96
      - } + return runtime.ErrInvalidTxChangeL2BlockLimitTimestamp
    - 199 + 97
      -
    -
    -
    - 200 - -
    - - - leafs, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) + case RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP:
    - 201 + 98
      - if err != nil { + return runtime.ErrInvalidTxChangeL2BlockMinTimestamp
    - 202 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 203 + + -
    +
    +
      - // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data +
    -
    @@ -205,7 +206,7 @@
    -
    - 205 + + -
    +
    +
      - return nil, syncinterfaces.ErrMissingSyncFromL1 +
    - 206 + 99
    @@ -180561,87 +259806,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 207 + 100
      - debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) -
    -
    - 208 - -
    - - - processReq := b.getProcessRequest(data, leafs, l1InfoRoot) + return ErrROMUnknown
    - 209 + 101
      - processReq.Transactions = PartialBatchL2Data + }
    - 210 - -
    -   - processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) -
    +
    +
     
    - 211 + 172
      - if err != nil { + return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP
    -
    @@ -429,6 +430,7 @@
    -
    - 429 + 173
      - Transactions: data.TrustedBatch.BatchL2Data, + case runtime.ErrInvalidTxChangeL2BlockMinTimestamp:
    - 430 + 174
      - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), + return RomError_ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP
    - 431 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 432 + 175
    @@ -180666,17 +259891,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 433 + 176
      - return request + return ErrCodeROMUnknown
    - 434 + 177
    @@ -180684,432 +259909,379 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
    - 137 + 456
      - return nil, err + return runtime.ErrExecutorErrorInvalidUpdateMerkleTree
    - 138 + 457
      - } + case ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR:
    - 139 + 458
      -
    + return runtime.ErrExecutorErrorSMMainInvalidTxStatusError
    - 140 + + -
    - + - leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, data.TrustedBatch.BatchL2Data, dbTx) +
    +
    +   +
    - 141 + + -
    +
    +
      - if err != nil { +
    - 142 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 143 + + -
    +
    +
      - return nil, err +
    - 144 + + -
    +
    +
      - } +
    - 145 + + -
    +
    +
      - debugStr := data.DebugPrefix +
    - 146 + + -
    - + - processBatchResp, err := b.processAndStoreTxs(ctx, b.getProcessRequest(data, leaves, l1InfoRoot), dbTx, debugStr) +
    +
    +   +
    - 147 + + -
    +
    +
      - if err != nil { +
    - 148 + + -
    +
    +
      - log.Error("%s error procesingAndStoringTxs. Error: ", debugStr, err) +
    - 149 + + -
    +
    +
      - return nil, err +
    -
     
    -
    - 198 + + -
    +
    +
      - return nil, err +
    - 199 + + -
    +
    +
      - } +
    - 200 + + -
    +
    +
     
    - 201 + + -
    - + - leaves, l1InfoRoot, _, err := b.state.GetL1InfoTreeDataFromBatchL2Data(ctx, PartialBatchL2Data, dbTx) +
    +
    +   +
    - 202 + + -
    +
    +
      - if err != nil { +
    - 203 + + -
    +
    +
      - log.Errorf("%s error getting GetL1InfoTreeDataFromBatchL2Data: %v. Error:%w", data.DebugPrefix, l1InfoRoot, err) +
    - 204 + + -
    +
    +
      - // TODO: Need to refine, depending of the response of GetL1InfoTreeDataFromBatchL2Data +
    -
     
    -
    - 206 + + -
    +
    +
      - return nil, syncinterfaces.ErrMissingSyncFromL1 +
    - 207 + + -
    +
    +
      - } +
    - 208 + + -
    +
    +
      - debugStr := fmt.Sprintf("%s: Batch %d:", data.Mode, uint64(data.TrustedBatch.Number)) +
    - 209 + + -
    - + - processReq := b.getProcessRequest(data, leaves, l1InfoRoot) +
    +
    +   +
    - 210 + + -
    +
    +
      - processReq.Transactions = PartialBatchL2Data +
    - 211 + + -
    +
    +
      - processBatchResp, err := b.processAndStoreTxs(ctx, processReq, dbTx, debugStr) +
    - 212 + + -
    +
    +
      - if err != nil { +
    -
     
    -
    - 430 + + -
    +
    +
      - Transactions: data.TrustedBatch.BatchL2Data, +
    - 431 + + -
    +
    +
      - ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)), +
    - 432 + + -
    +
    +
      - SkipVerifyL1InfoRoot_V2: true, +
    - 433 + + -
    - + - ExecutionMode: executor.ExecutionMode1, +
    +
    +   +
    - 434 + + -
    +
    +
      - } +
    - 435 + + -
    +
    +
      - return request +
    - 436 + + -
    +
    +
      - } -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -181123,176 +260295,148 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - -
    -
    @@ -196,6 +196,7 @@
    - 196 + + -
    +
    +
      - OldAccInputHash: batches[1].AccInputHash, +
    - 197 + + -
    +
    +
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    - 198 + + -
    +
    +
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), +
    - 199 + + -
    +
    +
      - } +
    - 200 + + -
    +
    +
      - // check if batch needs to be synchronized +
    - 201 + + -
    +
    +
      - if batches[0] != nil { +
    -
    + + + + + +
    +   +
    -
    -
    - - - - - - - - - - - - - -
    -
     
    - 196 + + -
    +
    +
      - OldAccInputHash: batches[1].AccInputHash, +
    - 197 + + -
    +
    +
      - Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()), +
    - 198 + 459
      - Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0), + }
    - 199 + + -
    - + - ExecutionMode: executor.ExecutionMode1, +
    +
    +   +
    - 200 + 460
      - } + return ErrExecutorUnknown
    - 201 + 461
      - // check if batch needs to be synchronized + }
    - 202 + 462
      - if batches[0] != nil { +
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go - RENAMED - -
    -
    -
    -
    - - - + @@ -181306,63 +260450,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - @@ -181376,178 +260520,153 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -181571,68 +260690,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -181646,68 +260760,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -181721,63 +260830,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -181851,183 +260960,143 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -182297,182 +261366,394 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + +
    -
    @@ -16,12 +16,14 @@
    +
     
    - 16 + 698
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/processor_manager" + return ExecutorError_EXECUTOR_ERROR_INVALID_UPDATE_MERKLE_TREE
    - 17 + 699
      - syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + case runtime.ErrExecutorErrorSMMainInvalidTxStatusError:
    - 18 + 700
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + return ExecutorError_EXECUTOR_ERROR_SM_MAIN_INVALID_TX_STATUS_ERROR
    - 19 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_parallel_sync" +
    - 20 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" +
    - 21 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" +
    - 22 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    - 23 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" +
    - 24 + + -
    +
    +
      - "github.com/ethereum/go-ethereum/common" +
    - 25 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 26 + + -
    +
    +
      - ) +
    - 27 + + -
    +
    +
     
    -
    @@ -52,17 +54,19 @@
    -
    - 52 + + -
    +
    +
      - etherMan syncinterfaces.EthermanFullInterface +
    - 53 + + -
    +
    +
      - latestFlushID uint64 +
    - 54 + + -
    +
    +
      - // If true the lastFlushID is stored in DB and we don't need to check again -
    -
    - 55 - -
    - - - latestFlushIDIsFulfilled bool -
    -
    - 56 - -
    - - - etherManForL1 []syncinterfaces.EthermanFullInterface +
    - 57 + + -
    - - - state syncinterfaces.StateFullInterface +
    +
    +   +
    - 58 + + -
    - - - pool syncinterfaces.PoolInterface +
    +
    +   +
    - 59 + + -
    - - - ethTxManager syncinterfaces.EthTxManager +
    +
    +   +
    - 60 + + -
    - - - zkEVMClient syncinterfaces.ZKEVMClientInterface +
    +
    +   +
    - 61 + + -
    - - - eventLog syncinterfaces.EventLogInterface +
    +
    +   +
    - 62 + + -
    - - - ctx context.Context +
    +
    +   +
    - 63 + + -
    - - - cancelCtx context.CancelFunc +
    +
    +   +
    - 64 + + -
    - - - genesis state.Genesis +
    +
    +   +
    - 65 + + -
    - - - cfg Config +
    +
    +   +
    - 66 + + -
    +
    +
      - // Id of the 'process' of the executor. Each time that it starts this value changes +
    - 67 + + -
    +
    +
      - // This value is obtained from the call state.GetStoredFlushID +
    - 68 + + -
    +
    +
      - // It starts as an empty string and it is filled in the first call +
    -
    @@ -74,6 +78,7 @@
    -
    - 74 + + -
    +
    +
      - l1EventProcessors *processor_manager.L1EventProcessors +
    - 75 + + -
    +
    +
      - syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor +
    - 76 + + -
    +
    +
      - halter syncinterfaces.CriticalErrorHandler +
    - 77 + + -
    +
    +
      - } +
    - 78 + + -
    +
    +
     
    - 79 + + -
    +
    +
      - // NewSynchronizer creates and initializes an instance of Synchronizer +
    -
    @@ -85,30 +90,65 @@
    -
    - 85 + + -
    +
    +
      - pool syncinterfaces.PoolInterface, +
    - 86 + + -
    +
    +
      - ethTxManager syncinterfaces.EthTxManager, +
    - 87 + + -
    +
    +
      - zkEVMClient syncinterfaces.ZKEVMClientInterface, +
    - 88 + + -
    +
    +
      - eventLog syncinterfaces.EventLogInterface, +
    - 89 + + -
    +
    +
      - genesis state.Genesis, +
    - 90 + 701
      - cfg Config, + }
    - 91 + 702
      - runInDevelopmentMode bool) (Synchronizer, error) { +
    - 92 + 703
      - ctx, cancel := context.WithCancel(context.Background()) + return ErrCodeExecutorUnknown
    - 93 + 704
      - metrics.Register() + }
    - 94 + + -
    +
    +
      - res := &ClientSynchronizer{ -
    -
    - 95 - -
    - - - isTrustedSequencer: isTrustedSequencer, -
    -
    - 96 - -
    - - - state: st, -
    -
    - 97 - -
    - - - etherMan: ethMan, -
    -
    - 98 - -
    - - - etherManForL1: etherManForL1, +
    - 99 + + -
    - - - pool: pool, +
    +
    +   +
    - 100 + + -
    - - - ctx: ctx, +
    +
    +   +
    - 101 + + -
    - - - cancelCtx: cancel, +
    +
    +   +
    - 102 + + -
    - - - ethTxManager: ethTxManager, +
    +
    +   +
    - 103 + + -
    - - - zkEVMClient: zkEVMClient, +
    +
    +   +
    - 104 + + -
    - - - eventLog: eventLog, +
    +
    +   +
    - 105 + + -
    - - - genesis: genesis, +
    +
    +   +
    - 106 + + -
    - - - cfg: cfg, +
    +
    +   +
    - 107 + + -
    - - - proverID: "", +
    +
    +   +
    - 108 + + -
    - - - previousExecutorFlushID: 0, +
    +
    +   +
    - 109 + + -
    - - - l1SyncOrchestration: nil, +
    +
    +   +
    - 110 + + -
    - - - l1EventProcessors: nil, +
    +
    +   +
    - 111 + + -
    - - - halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd +
    +
    +   +
      -
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/instrumentation/tracers/native/gen_callframe_json.go + RENAMED + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    @@ -16,7 +16,7 @@
    +
    + 16 + +
    +   + // MarshalJSON marshals as JSON. +
    +
    + 17 + +
    +   + func (c callFrame) MarshalJSON() ([]byte, error) { +
    +
    + 18 + +
    +   + type callFrame0 struct { +
    +
    + 19 + +
    + - + Type fakevm.OpCode `json:"-"` +
    +
    + 20 + +
    +   + From common.Address `json:"from"` +
    +
    + 21 + +
    +   + Gas hexutil.Uint64 `json:"gas"` +
    +
    + 22 + +
    +   + GasUsed hexutil.Uint64 `json:"gasUsed"` +
    +
    +
    @@ -50,7 +50,7 @@
    +
    + 50 + +
    +   + // UnmarshalJSON unmarshals from JSON. +
    +
    + 51 + +
    +   + func (c *callFrame) UnmarshalJSON(input []byte) error { +
    +
    + 52 + +
    +   + type callFrame0 struct { +
    +
    + 53 + +
    + - + Type *fakevm.OpCode `json:"-"` +
    +
    + 54 + +
    +   + From *common.Address `json:"from"` +
    +
    + 55 + +
    +   + Gas *hexutil.Uint64 `json:"gas"` +
    +
    + 56 + +
    +   + GasUsed *hexutil.Uint64 `json:"gasUsed"` +
    +
    +
    +
    +
    + + + + + - - + - - + - - - - - - - - - + + +
    +
     
    - 112 + 16
      - } + // MarshalJSON marshals as JSON.
    - 113 + 17
      -
    + func (c callFrame) MarshalJSON() ([]byte, error) {
    - 114 + 18
      - if !isTrustedSequencer { + type callFrame0 struct {
    -
    @@ -143,7 +183,11 @@
    +
    + 19 + +
    + + + Type fakevm.OpCode `json:"-"` +
    - 143 + 20
      - log.Errorf("error getting last L2Block number from state. Error: %v", err) + From common.Address `json:"from"`
    - 144 + 21
      - return nil, err + Gas hexutil.Uint64 `json:"gas"`
    - 145 + 22
      - } + GasUsed hexutil.Uint64 `json:"gasUsed"`
    - 146 - -
    - - - l1checkerL2Blocks = actions.NewCheckL2BlockHash(res.state, res.zkEVMClient, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) -
    +
    +
     
    - + + 50 -
    +
    +
      -
    + // UnmarshalJSON unmarshals from JSON.
    - + + 51 -
    +
    +
      -
    + func (c *callFrame) UnmarshalJSON(input []byte) error {
    - + + 52 -
    +
    +
      -
    + type callFrame0 struct {
    - + + 53 -
    -   -
    +
    +
    + + + Type *fakevm.OpCode `json:"-"`
    - 147 + 54
      - } else { + From *common.Address `json:"from"`
    - 148 + 55
      - log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") + Gas *hexutil.Uint64 `json:"gas"`
    - 149 + 56
      - } + GasUsed *hexutil.Uint64 `json:"gasUsed"`
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/runtime/runtime.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -163,6 +207,19 @@
    +
    @@ -83,11 +83,6 @@
    - 163 + 83
      - return res, nil + // ErrInvalidTxChangeL2BlockMinTimestamp indicates that the change l2 block transaction has trigger an error while executing
    - 164 + 84
      - } + ErrInvalidTxChangeL2BlockMinTimestamp = errors.New("indicates that the change l2 block transaction has trigger an error while executing (min timestamp)")
    - 165 + 85
    @@ -182481,803 +261762,842 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 86 -
    -   -
    +
    +
    + - + // Start of V3 errors
    - + + 87 -
    -   +
    +
    + -
    - + + 88 -
    -   -
    +
    +
    + - + // ErrInvalidL1InfoTreeIndex indicates that the l1 info tree index added is not valid since its value is 0
    - + + 89 -
    -   -
    +
    +
    + - + ErrInvalidL1InfoTreeIndex = errors.New("l1 info tree index is invalid")
    - + + 90 -
    -   +
    +
    + -
    - + + 91 -
    +
    +
      -
    + // EXECUTOR ERRORS
    - + + 92 -
    +
    +
      -
    + // ===============
    - + + 93 -
    +
    +
     
    - + +
    @@ -327,67 +322,6 @@
    -
    +
    + 327 + +
      -
    + // ErrExecutorErrorSMMainInvalidTxStatusError indicates that the TX has an invalid status-error combination
    - + + 328 -
    +
    +
      -
    + ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("tx has an invalid status-error combination")
    - + + 329 -
    +
    +
     
    - + + 330 -
    -   -
    +
    +
    + - + // Start of V3 errors
    - + + 331 -
    -   +
    +
    + -
    - 166 + + 332 +
    -   - var waitDuration = time.Duration(0) + - + // ErrExecutorErrorInvalidPreviousL1InfoTreeRoot indicates that the input parameter previous_l1_info_tree_root is invalid
    - 167 + + 333 +
    -   -
    + - + ErrExecutorErrorInvalidPreviousL1InfoTreeRoot = errors.New("previous_l1_info_tree_root is invalid")
    - 168 + + 334 +
    -   - func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { + - + // ErrExecutorErrorInvalidForcedHashData indicates that the input parameter forced_hash_data is invalid
    -
    @@ -225,6 +282,10 @@
    +
    + 335 + +
    + - + ErrExecutorErrorInvalidForcedHashData = errors.New("forced_hash_data is invalid") +
    - 225 + + 336 +
    -   - // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block + - + // ErrExecutorErrorInvalidForcedDataGlobalExitRoot indicates that the input parameter forced_data.global_exit_root is invalid
    - 226 + + 337 +
    -   - // Get the latest synced block. If there is no block on db, use genesis block + - + ErrExecutorErrorInvalidForcedDataGlobalExitRoot = errors.New("forced_data.global_exit_root is invalid")
    - 227 + + 338 +
    -   - log.Info("Sync started") + - + // ErrExecutorErrorInvalidForcedDataBlockHashL1 indicates that the input parameter forced_data.block_hash_l1 is invalid
    - + + 339 -
    -   -
    +
    +
    + - + ErrExecutorErrorInvalidForcedDataBlockHashL1 = errors.New("forced_data.block_hash_l1 is invalid")
    - + + 340 -
    -   -
    +
    +
    + - + // ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot indicates that the input parameter L1 Data initiali_historic_root is invalid
    - + + 341 -
    -   -
    +
    +
    + - + ErrExecutorErrorInvalidL1DataV3InitialHistoricRoot = errors.New("L1 Data initiali_historic_root is invalid")
    - + + 342 -
    -   -
    +
    +
    + - + // ErrExecutorErrorInvalidOldBlobStateRoot indicates that the input parameter old_blob_state_root is invalid
    - 228 + + 343 +
    -   - dbTx, err := s.state.BeginStateTransaction(s.ctx) + - + ErrExecutorErrorInvalidOldBlobStateRoot = errors.New("old_blob_state_root is invalid")
    - 229 + + 344 +
    -   - if err != nil { + - + // ErrExecutorErrorInvalidOldBlobAccInputHash indicates that the input parameter old_blob_acc_input_hash is invalid
    - 230 + + 345 +
    -   - log.Errorf("error creating db transaction to get latest block. Error: %v", err) + - + ErrExecutorErrorInvalidOldBlobAccInputHash = errors.New("old_blob_acc_input_hash is invalid")
    -
    @@ -234,7 +295,7 @@
    +
    + 346 + +
    + - + // ErrExecutorErrorInvalidLastL1InfoTreeRoot indicates that the input parameter last_l1_info_tree_root is invalid +
    - 234 + + 347 +
    -   - if err != nil { + - + ErrExecutorErrorInvalidLastL1InfoTreeRoot = errors.New("last_l1_info_tree_root is invalid")
    - 235 + + 348 +
    -   - if errors.Is(err, state.ErrStateNotSynchronized) { + - + // ErrExecutorErrorInvalidNewBlobStateRoot indicates that the input parameter new_blob_state_root is invalid
    - 236 + + 349 +
    -   - log.Info("State is empty, verifying genesis block") + - + ErrExecutorErrorInvalidNewBlobStateRoot = errors.New("new_blob_state_root is invalid")
    - 237 + + 350 +
    - - valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber) + // ErrExecutorErrorInvalidNewBlobAccInputHash indicates that the input parameter new_blob_acc_input_hash is invalid
    - 238 + + 351 +
    -   - if err != nil { + - + ErrExecutorErrorInvalidNewBlobAccInputHash = errors.New("new_blob_acc_input_hash is invalid")
    - 239 + + 352 +
    -   - log.Error("error checking genesis block number. Error: ", err) + - + // ErrExecutorErrorInvalidBlobData indicates that the input parameter blob_data is invalid
    - 240 + + 353 +
    -   - return rollback(s.ctx, dbTx, err) + - + ErrExecutorErrorInvalidBlobData = errors.New("blob_data is invalid")
    -
    @@ -242,12 +303,42 @@
    +
    + 354 + +
    + - + // ErrExecutorErrorInvalidZKGasLimit indicates that the input parameter zk_gas_limit is invalid +
    - 242 + + 355 +
    -   - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") + - + ErrExecutorErrorInvalidZKGasLimit = errors.New("zk_gas_limit is invalid")
    - 243 + + 356 +
    -   - return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) + - + // ErrExecutorErrorInvalidPointZ indicates that the input parameter point_z is invalid
    - 244 + + 357 +
    -   - } + - + ErrExecutorErrorInvalidPointZ = errors.New("point_z is invalid")
    - 245 + + 358 +
    - - log.Info("Setting genesis block") + // ErrExecutorErrorInvalidPointY indicates that the input parameter point_y is invalid
    - 246 + + 359 +
    - - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.BlockNumber)) + ErrExecutorErrorInvalidPointY = errors.New("point_y is invalid")
    - + + 360 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainPointZMismatch indicates that the input parameter point_z is different from the one calculated by the executor
    - + + 361 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainPointZMismatch = errors.New("point_z mismatch")
    - + + 362 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainBlobL2HashDataMismatch indicates that the input parameter blob L2 data hash is different from the one calculated by the executor
    - + + 363 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainBlobL2HashDataMismatch = errors.New("blob L2 hash data mismatch")
    - + + 364 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainBatchHashDataMismatch indicates that the input parameter batch data hash is different from the one calculated by the executor
    - + + 365 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainBatchHashDataMismatch = errors.New("batch hash data mismatch")
    - + + 366 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainInvalidBlobType indicates that the input parameter blob type is invalid
    - + + 367 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainInvalidBlobType = errors.New("invalid blob type")
    - + + 368 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainUnrestoredSavedContext indicates that at least one saved context was not restored before finishing the execution
    - + + 369 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainUnrestoredSavedContext = errors.New("unrestored saved context")
    - + + 370 -
    -   -
    +
    +
    + - + // ErrExecutorErrorSMMainInvalidMemoryCtx indicates that the memory context polynomial was assigned an invalid value
    - + + 371 -
    -   -
    +
    +
    + - + ErrExecutorErrorSMMainInvalidMemoryCtx = errors.New("invalid memory ctx")
    - + + 372 -
    -   +
    +
    + -
    - + + 373 -
    -   -
    +
    +
    + - + // ROM BLOB ERRORS
    - + + 374 -
    -   -
    +
    +
    + - + // ===============
    - + + 375 -
    -   +
    +
    + -
    - + + 376 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidParsing indicates that has been an error while parsing the blob data
    - + + 377 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidParsing = errors.New("error while parsing the blob data")
    - + + 378 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidMSBByte indicates that the MSB on one field element is different than zero (only for blob_type = 1)
    - + + 379 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidMSBByte = errors.New("MSB on one field element is different than zero")
    - + + 380 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidZKGasLimit not enough zk_gas_limit supplied to pay for batches proofs
    - + + 381 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidZKGasLimit = errors.New("not enough zk_gas_limit supplied to pay for batches proofs")
    - + + 382 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidBlobType blob_type not supported
    - + + 383 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidBlobType = errors.New("blob_type not supported")
    - + + 384 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidCompressionType compression type not supported
    - + + 385 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidCompressionType = errors.New("compression type not supported")
    - + + 386 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidForcedBatches fblobtype = 2 and numBatches > 1
    - + + 387 -
    -   -
    +
    +
    + - + ErrROMBlobInvalidForcedBatches = errors.New("fblobtype = 2 and numBatches > 1")
    - + + 388 -
    -   -
    +
    +
    + - + // ErrROMBlobInvalidTotalBodyLen totalBodyLen != blobDataLen - 1 (byte compression) - 4 (bytes totalBodyLen)
    - 247 + + 389 +
    -   - if err != nil { + - + ErrROMBlobInvalidTotalBodyLen = errors.New("totalBodyLen != blobDataLen - 1 (byte compression) - 4 (bytes totalBodyLen)")
    - 248 + + 390 +
    - - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err) +
    - 249 + 391
      - return rollback(s.ctx, dbTx, err) + // GRPC ERRORS
    - 250 + 392
      - } + // ===========
    - + + 393 -
    +
    +
     
    +
    +
    +
    +
    + + + + + - - + - - - - - - @@ -183292,67 +262612,67 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -183426,108 +262746,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -183571,68 +262836,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -183686,68 +262946,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -183881,553 +263136,442 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - 251 + 83
      - lastEthBlockSynced = &state.Block{ + // ErrInvalidTxChangeL2BlockMinTimestamp indicates that the change l2 block transaction has trigger an error while executing
    - 252 + 84
      - BlockNumber: header.Number.Uint64(), + ErrInvalidTxChangeL2BlockMinTimestamp = errors.New("indicates that the change l2 block transaction has trigger an error while executing (min timestamp)")
    - 253 + 85
      - BlockHash: header.Hash(), +
    -
    @@ -346,6 +437,7 @@
    +
    + + +
    +   +
    +
    - 346 + + -
    +
    +
      - continue +
    - 347 + + -
    +
    +
      - } +
    - 348 + + -
    +
    +
      - log.Infof("latestSequencedBatchNumber: %d, latestSyncedBatch: %d, lastVerifiedBatchNumber: %d", latestSequencedBatchNumber, latestSyncedBatch, lastVerifiedBatchNumber) +
    - 349 + 86
      - // Sync trusted state + // EXECUTOR ERRORS
    - 350 + 87
      - // latestSyncedBatch -> Last batch on DB + // ===============
    - 351 + 88
      - // latestSequencedBatchNumber -> last batch on SMC +
    -
    @@ -353,6 +445,13 @@
    +
     
    - 353 + 322
      - startTrusted := time.Now() + // ErrExecutorErrorSMMainInvalidTxStatusError indicates that the TX has an invalid status-error combination
    - 354 + 323
      - if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { + ErrExecutorErrorSMMainInvalidTxStatusError = errors.New("tx has an invalid status-error combination")
    - 355 + 324
      - log.Info("Syncing trusted state (permissionless)") +
    - 356 - -
    -   - err = s.syncTrustedState(latestSyncedBatch) -
    -
    - 357 + + -
    +
    +
      - metrics.FullTrustedSyncTime(time.Since(startTrusted)) +
    - 358 + + -
    +
    +
      - if err != nil { +
    -
    @@ -361,10 +460,14 @@
    -
    - 361 + + -
    +
    +
      - if errors.Is(err, syncinterfaces.ErrFatalDesyncFromL1) { +
    - 362 + + -
    +
    +
      - l1BlockNumber := err.(*l2_shared.DeSyncPermissionlessAndTrustedNodeError).L1BlockNumber +
    - 363 + + -
    +
    +
      - log.Error("Trusted and permissionless desync! reseting to last common point: L1Block (%d-1)", l1BlockNumber) -
    -
    - 364 - -
    - - - err = s.resetState(l1BlockNumber - 1) -
    -
    - 365 - -
    - - - if err != nil { -
    -
    - 366 - -
    - - - log.Errorf("error resetting the state to a discrepancy block. Retrying... Err: %v", err) -
    -
    - 367 - -
    - - - continue +
    - 368 + + -
    +
    +
      - } +
    - 369 + + -
    +
    +
      - } else if errors.Is(err, syncinterfaces.ErrMissingSyncFromL1) { +
    - 370 + + -
    +
    +
      - log.Info("Syncing from trusted node need data from L1") +
    -
    @@ -381,6 +484,11 @@
    -
    - 381 + + -
    +
    +
      - waitDuration = s.cfg.SyncInterval.Duration +
    - 382 + + -
    +
    +
      - } +
    - 383 + + -
    +
    +
      - //Sync L1Blocks +
    - 384 + + -
    +
    +
      - startL1 := time.Now() +
    - 385 + + -
    +
    +
      - if s.l1SyncOrchestration != nil && (latestSyncedBatch < latestSequencedBatchNumber || !s.cfg.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized) { +
    - 386 + + -
    +
    +
      - log.Infof("Syncing L1 blocks in parallel lastEthBlockSynced=%d", lastEthBlockSynced.BlockNumber) +
    -
    @@ -395,6 +503,19 @@
    -
    - 395 + + -
    +
    +
      - lastEthBlockSynced, err = s.syncBlocksSequential(lastEthBlockSynced) +
    - 396 + + -
    +
    +
      - } +
    - 397 + + -
    +
    +
      - metrics.FullL1SyncTime(time.Since(startL1)) +
    - 398 + + -
    +
    +
      - if err != nil { +
    - 399 + + -
    +
    +
      - log.Warn("error syncing blocks: ", err) +
    - 400 + + -
    +
    +
      - s.CleanTrustedState() +
    -
    @@ -465,57 +586,35 @@
    -
    - 465 + + -
    +
    +
      - // This function syncs the node from a specific block to the latest +
    - 466 + + -
    +
    +
      - // lastEthBlockSynced -> last block synced in the db +
    - 467 + + -
    +
    +
      - func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { -
    -
    - 468 - -
    - - - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. -
    -
    - 469 - -
    - - - block, err := s.checkReorg(lastEthBlockSynced) -
    -
    - 470 - -
    - - - if err != nil { -
    -
    - 471 - -
    - - - log.Errorf("error checking reorgs. Retrying... Err: %v", err) -
    -
    - 472 - -
    - - - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") -
    -
    - 473 - -
    - - - } -
    -
    - 474 - -
    - - - if block != nil { +
    - 475 + + -
    - - - log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, block.BlockNumber) +
    +
    +   +
    - 476 + + -
    - - - err = s.resetState(block.BlockNumber) +
    +
    +   +
    - 477 + + -
    - - - if err != nil { +
    +
    +   +
    - 478 + + -
    - - - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    +   +
    - 479 + + -
    - - - s.l1SyncOrchestration.Reset(lastEthBlockSynced.BlockNumber) +
    +
    +   +
    - 480 + + -
    - - - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    +   +
    - 481 + + -
    - - - } +
    +
    +   +
    - 482 + + -
    - - - return block, nil +
    +
    +   +
    - 483 + + -
    - - - } +
    +
    +   +
    - 484 + 325
      - log.Infof("Starting L1 sync orchestrator in parallel block: %d", lastEthBlockSynced.BlockNumber) + // GRPC ERRORS
    - 485 + 326
      - return s.l1SyncOrchestration.Start(lastEthBlockSynced) + // ===========
    - 486 + 327
      - } +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/state.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + +
    +
    @@ -32,18 +32,17 @@
    - 487 + 32
      -
    + type State struct {
    - 488 + 33
      - // This function syncs the node from a specific block to the latest + cfg Config
    - 489 + 34
      - func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { -
    -
    - 490 - -
    - - - // This function will read events fromBlockNum to latestEthBlock. Check reorg to be sure that everything is ok. -
    -
    - 491 - -
    - - - block, err := s.checkReorg(lastEthBlockSynced) -
    -
    - 492 - -
    - - - if err != nil { + storage
    - 493 - -
    - - - log.Errorf("error checking reorgs. Retrying... Err: %v", err) -
    -
    - 494 - -
    - - - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") -
    -
    - 495 + + 35 +
    - - } + executorClient executor.ExecutorServiceClient
    - 496 + + 36 +
    - - if block != nil { + tree *merkletree.StateTree
    - 497 + + 37 +
    - - err = s.resetState(block.BlockNumber) + eventLog *event.EventLog
    - 498 + + 38 +
    - - if err != nil { + l1InfoTree *l1infotree.L1InfoTree
    - 499 + 39
    - - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) + l1InfoTreeRecursive *l1infotree.L1InfoTreeRecursive
    - 500 + + 40 +
    - - - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +   +
    - 501 + + 41 +
    - - - } +   + newL2BlockEvents chan NewL2BlockEvent
    - 502 + + 42 +
    - - - return block, nil +   + newL2BlockEventHandlers []NewL2BlockEventHandler
    - 503 + + 43 +
    - - - } +   + }
    - 504 + + 44 +
    - - +  
    - 505 + 45
      - // Call the blockchain to retrieve data + // NewState creates a new State
    - 506 + 46
    - - header, err := s.etherMan.HeaderByNumber(s.ctx, nil) + func NewState(cfg Config, storage storage, executorClient executor.ExecutorServiceClient, stateTree *merkletree.StateTree, eventLog *event.EventLog, mt *l1infotree.L1InfoTree, mtr *l1infotree.L1InfoTreeRecursive) *State {
    - 507 + 47
      - if err != nil { -
    -
    - - -
    -   -
    + var once sync.Once
    - 508 + 48
      - return lastEthBlockSynced, err + once.Do(func() {
    - 509 + 49
      - } + metrics.Register()
    - 510 - -
    -   - lastKnownBlock := header.Number -
    +
    +
    @@ -58,7 +57,6 @@
    - 511 + 58
      -
    + newL2BlockEvents: make(chan NewL2BlockEvent, newL2BlockEventBufferSize),
    - 512 + 59
      - var fromBlock uint64 + newL2BlockEventHandlers: []NewL2BlockEventHandler{},
    - 513 + 60
      - if lastEthBlockSynced.BlockNumber > 0 { + l1InfoTree: mt,
    - 514 + + 61 +
    - - fromBlock = lastEthBlockSynced.BlockNumber + 1 + l1InfoTreeRecursive: mtr,
    - 515 + 62
    @@ -184436,103 +263580,107 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 63 -
    +
    +
     
    - 516 + 64
      -
    + return state +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - @@ -184547,147 +263695,137 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - + - - - - - - @@ -184701,838 +263839,992 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - + +
    +
     
    - 517 + 32
      - for { + type State struct {
    - 518 + + 33 +
    - - - toBlock := fromBlock + s.cfg.SyncChunkSize -
    -
    - - -
      -
    + cfg Config
    - + + 34 -
    +
    +
      -
    + storage
    - + + 35 -
    -   -
    +
    +
    + + + executorClient executor.ExecutorServiceClient
    - + + 36 -
    -   -
    +
    +
    + + + tree *merkletree.StateTree
    - + + 37 -
    -   -
    +
    +
    + + + eventLog *event.EventLog
    - + + 38 -
    -   -
    +
    +
    + + + l1InfoTree *l1infotree.L1InfoTree
    - 519 + 39
      - log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) +
    - 520 + 40
      - log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) + newL2BlockEvents chan NewL2BlockEvent
    - 521 + 41
      - // This function returns the rollup information contained in the ethereum blocks and an extra param called order. + newL2BlockEventHandlers []NewL2BlockEventHandler
    -
    @@ -529,6 +628,53 @@
    -
    - 529 + 42
      - if err != nil { + }
    - 530 + 43
      - return lastEthBlockSynced, err +
    - 531 + 44
      - } + // NewState creates a new State
    - + + 45 -
    -   -
    +
    +
    + + + func NewState(cfg Config, storage storage, executorClient executor.ExecutorServiceClient, stateTree *merkletree.StateTree, eventLog *event.EventLog, mt *l1infotree.L1InfoTree) *State {
    - + + 46 -
    +
    +
      -
    + var once sync.Once
    - + + 47 -
    +
    +
      -
    + once.Do(func() {
    - + + 48 -
    +
    +
      -
    + metrics.Register()
    - - -
    -   -
    -
    +
    +
     
    - + + 57 -
    +
    +
      -
    + newL2BlockEvents: make(chan NewL2BlockEvent, newL2BlockEventBufferSize),
    - + + 58 -
    +
    +
      -
    + newL2BlockEventHandlers: []NewL2BlockEventHandler{},
    - + + 59 -
    +
    +
      -
    + l1InfoTree: mt,
    - + + 60 -
    +
    +
      -
    + }
    - + + 61 -
    +
    +
     
    - + + 62 -
    +
    +
      -
    + return state
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/syncinginfo_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
    @@ -28,7 +28,7 @@
    - + + 28 -
    +
    +
      -
    + ctx := context.Background()
    - + + 29 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 30 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 31 -
    -   -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil, nil)
    - + + 32 -
    +
    +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 33 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 34 -
    +
    +
      -
    + require.NoError(t, err)
    - - -
    -   -
    -
    +
    +
    @@ -74,7 +74,7 @@
    - + + 74 -
    +
    +
      -
    + ctx := context.Background()
    - + + 75 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 76 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 77 -
    -   -
    +
    +
    + - + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil, nil)
    - + + 78 -
    +
    +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 79 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 80 -
    +
    +
      -
    + require.NoError(t, err) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
     
    - + + 28 -
    +
    +
      -
    + ctx := context.Background()
    - + + 29 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 30 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 31 -
    -   -
    +
    +
    + + + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil)
    - + + 32 -
    +
    +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 33 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 34 -
    +
    +
      -
    + require.NoError(t, err)
    - - -
    -   -
    -
    +
    +
     
    - + + 74 -
    +
    +
      -
    + ctx := context.Background()
    - + + 75 -
    +
    +
      -
    + mockStorage := mocks.NewStorageMock(t)
    - + + 76 -
    +
    +
      -
    + mockExecutor := mocks.NewExecutorServiceClientMock(t)
    - + + 77 -
    -   -
    +
    +
    + + + testState := state.NewState(stateCfg, mockStorage, mockExecutor, nil, nil, nil)
    - + + 78 -
    +
    +
      -
    + mockStorage.EXPECT().Begin(ctx).Return(mocks.NewDbTxMock(t), nil)
    - + + 79 -
    +
    +
      -
    + dbTx, err := testState.BeginStateTransaction(ctx)
    - + + 80 -
    +
    +
      -
    + require.NoError(t, err) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_common/common.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + + + + +
    +
    @@ -53,7 +53,7 @@
    - + + 53 -
    +
    +
      -
    + panic(err)
    - + + 54 -
    +
    +
      -
    + }
    - + + 55 -
    +
    +
     
    - + + 56 -
    -   -
    +
    +
    + - + zkProverURI := testutils.GetEnv("ZKPROVER_URI", "localhost")
    - 532 + 57
      - start = time.Now() +
    - 533 + 58
      - err = s.ProcessBlockRange(blocks, order) + executorServerConfig := executor.Config{URI: fmt.Sprintf("%s:50071", zkProverURI), MaxGRPCMessageSize: 100000000}
    - 534 + 59
      - metrics.ProcessL1DataTime(time.Since(start)) + ExecutorClient, executorClientConn, executorCancel = executor.NewExecutorClient(ctx, executorServerConfig)
    -
    @@ -543,47 +689,36 @@
    +
    @@ -76,11 +76,7 @@
    - 543 + 76
      - ReceivedAt: blocks[len(blocks)-1].ReceivedAt, + if err != nil {
    - 544 + 77
      - } + panic(err)
    - 545 + 78
      - for i := range blocks { + }
    - 546 + 79
    - - log.Debug("Position: ", i, ". BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 547 + + 80 +
    -   - } + - + if err != nil {
    - 548 + + 81 +
    -   - } + - + panic(err)
    - 549 + 82 + +
    + - + } +
    +
    + 83
    - - fromBlock = toBlock + 1 + return state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), ExecutorClient, stateTree, eventLog, mt, mtr)
    - 550 + 84
      -
    + }
    - 551 + 85
      - if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 { +
    - 552 + 86
      - waitDuration = s.cfg.SyncInterval.Duration + func InitOrResetDB(cfg db.Config) { +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 553 + 53
      - break + panic(err)
    - 554 + 54
      - } + }
    - 555 + + 55 +
    - - - if len(blocks) == 0 { // If there is no events in the checked blocks range and lastKnownBlock > fromBlock. +   +
    - 556 + + 56 +
    - - - // Store the latest block of the block range. Get block info and process the block + + + zkProverURI := testutils.GetEnv("ZKPROVER_URI", "zkevm-prover")
    - 557 + + 57 +
    - - - fb, err := s.etherMan.EthBlockByNumber(s.ctx, toBlock) +   +
    - 558 + + 58 +
    - - - if err != nil { +   + executorServerConfig := executor.Config{URI: fmt.Sprintf("%s:50071", zkProverURI), MaxGRPCMessageSize: 100000000}
    - 559 + + 59 +
    - - - return lastEthBlockSynced, err +   + ExecutorClient, executorClientConn, executorCancel = executor.NewExecutorClient(ctx, executorServerConfig)
    - 560 + +
     
    +
    + 76 +
    - - - } +   + if err != nil {
    - 561 + + 77 +
    - - - b := etherman.Block{ +   + panic(err)
    - 562 + + 78 +
    - - - BlockNumber: fb.NumberU64(), +   + }
    - 563 + + 79 +
    - - - BlockHash: fb.Hash(), + + + return state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), ExecutorClient, stateTree, eventLog, mt)
    - 564 + + -
    - - - ParentHash: fb.ParentHash(), +
    +
    +   +
    - 565 + + -
    - - - ReceivedAt: time.Unix(int64(fb.Time()), 0), +
    +
    +   +
    - 566 + + -
    - - - } +
    +
    +   +
    - 567 + + -
    - - - err = s.ProcessBlockRange([]etherman.Block{b}, order) +
    +
    +   +
    - 568 + + 80 +
    - - - if err != nil { +   + }
    - 569 + + 81 +
    - - - return lastEthBlockSynced, err +   +
    - 570 + + 82 +
    - - - } +   + func InitOrResetDB(cfg db.Config) { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/test/forkid_etrog/etrog_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -98,11 +98,9 @@
    - 571 + + 98 +
    - - - block := state.Block{ +   + if len(txs) > 0 {
    - 572 + + 99 +
    - - - BlockNumber: fb.NumberU64(), +   + // Generate batchdata from the txs in the test and compared with the vector
    - 573 + + 100 +
    - - - BlockHash: fb.Hash(), +   + l2block := state.L2BlockRaw{
    - 574 + + 101 +
    - - ParentHash: fb.ParentHash(), + ChangeL2BlockHeader: state.ChangeL2BlockHeader{
    - 575 + + 102 +
    - - ReceivedAt: time.Unix(int64(fb.Time()), 0), + DeltaTimestamp: uint32(timestampLimit.Uint64()),
    - 576 + + 103 +
    - - } + IndexL1InfoTree: testCase.Txs[0].IndexL1InfoTree,
    - 577 + 104
    - - lastEthBlockSynced = &block + },
    - 578 + 105
    - - log.Debug("Storing empty block. BlockNumber: ", b.BlockNumber, ". BlockHash: ", b.BlockHash) + Transactions: txs,
    - 579 + + 106 +
    - - - } +   + }
    - 580 + 107
      - } +
    - 581 + 108
      -
    + batch := state.BatchRawV2{ +
    +
    +
    +
    +
    + + + + + + + + + + + + + + @@ -185556,63 +264848,122 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
     
    - 582 + 98
      - return lastEthBlockSynced, nil + if len(txs) > 0 {
    - 583 + 99
      - } + // Generate batchdata from the txs in the test and compared with the vector
    - 584 + 100
      -
    + l2block := state.L2BlockRaw{ +
    +
    + 101 + +
    + + + DeltaTimestamp: uint32(timestampLimit.Uint64()), +
    +
    + 102 + +
    + + + IndexL1InfoTree: testCase.Txs[0].IndexL1InfoTree, +
    +
    + 103 + +
    + + + Transactions: txs,
    - + + 104 -
    +
    +
      -
    + }
    - + + 105 -
    +
    +
     
    - + + 106 -
    +
    +
      -
    + batch := state.BatchRawV2{ +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/trace.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + + + + + + + + @@ -185677,352 +265028,405 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - + + +
    +
    @@ -78,7 +78,15 @@
    - + + 78 -
    +
    +
      -
    + var effectivePercentage []uint8
    - 585 + 79
      - // ProcessBlockRange process the L1 events and stores the information in the db + for i := 0; i <= count; i++ {
    - 586 + 80
      - func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { + txsToEncode = append(txsToEncode, *l2Block.Transactions()[i]) +
    +
    + 81 + +
    + - + effectivePercentage = append(effectivePercentage, MaxEffectivePercentage) +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 587 + 82
      - // New info has to be included into the db using the state + log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
    - 588 + 83
      - for i := range blocks { + }
    - 589 + 84
      - // Begin db transaction +
    -
    @@ -598,9 +733,13 @@
    +
    @@ -307,7 +315,7 @@
    - 598 + 307
      - ParentHash: blocks[i].ParentHash, + return nil, err
    - 599 + 308
      - ReceivedAt: blocks[i].ReceivedAt, + } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 600 + 309
      - } + err = executor.ExecutorErr(processBatchResponseV2.Error)
    - + + 310 -
    +
    +
    + - + s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2) +
    +
    + 311 + +
      -
    + return nil, err
    - + + 312 -
    +
    +
      -
    + }
    - + + 313 -
    +
    +
     
    +
    +
    +
    +
    + + + + + - - - - - - - - - - + - - - - - - - - - - - + + +
    +
     
    +
    - 601 + 78
      - // Add block information + var effectivePercentage []uint8
    - 602 + 79
      - err = s.state.AddBlock(s.ctx, &b, dbTx) + for i := 0; i <= count; i++ {
    - 603 + 80
      - if err != nil { + txsToEncode = append(txsToEncode, *l2Block.Transactions()[i])
    - + + 81 -
    -   -
    +
    +
    + + + txGasPrice := tx.GasPrice()
    - 604 + + 82 +
    -   - log.Errorf("error storing block. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err) + + + effectiveGasPrice := receipt.EffectiveGasPrice
    - 605 + + 83 +
    -   - rollbackErr := dbTx.Rollback(s.ctx) + + + egpPercentage, err := CalculateEffectiveGasPricePercentage(txGasPrice, effectiveGasPrice)
    - 606 + + 84 +
    -   - if rollbackErr != nil { + + + if errors.Is(err, ErrEffectiveGasPriceEmpty) {
    -
    @@ -618,7 +757,7 @@
    +
    + 85 + +
    + + + egpPercentage = MaxEffectivePercentage +
    - 618 + + 86 +
    -   - log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) + + + } else if err != nil {
    - 619 + + 87 +
    -   - } else { + + + return nil, err
    - 620 + + 88 +
    -   - forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) + + + }
    - 621 + + 89 +
    - - - log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, "forkId: ", forkId) + + + effectivePercentage = append(effectivePercentage, egpPercentage)
    - 622 + 90
      - } + log.Debugf("trace will reprocess tx: %v", l2Block.Transactions()[i].Hash().String())
    - 623 + 91
      - forkIdTyped := actions.ForkIdType(forkId) + }
    - 624 + 92
      - // Process event received from l1 +
    -
    @@ -637,6 +776,7 @@
    +
     
    - 637 + 315
      - log.Debug("Checking FlushID to commit L1 data to db") + return nil, err
    - 638 + 316
      - err = s.checkFlushID(dbTx) + } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 639 + 317
      - if err != nil { + err = executor.ExecutorErr(processBatchResponseV2.Error)
    - + + 318 -
    -   -
    +
    +
    + + + s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2)
    - 640 + 319
      - log.Errorf("error checking flushID. Error: %v", err) + return nil, err
    - 641 + 320
      - rollbackErr := dbTx.Rollback(s.ctx) + }
    - 642 + 321
      - if rollbackErr != nil { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/transaction.go + RENAMED + +
    +
    +
    +
    + + + @@ -186037,77 +265441,97 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + @@ -186121,53 +265545,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - + - + + - - - - @@ -186181,113 +265620,143 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + + + + + + - + + + - - - + - + + - - - - @@ -186301,1568 +265770,1615 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - + + +
    -
    @@ -647,6 +787,7 @@
    +
    @@ -244,6 +244,7 @@
    - 647 + 244
      - } + imStateRoots := make([]common.Hash, 0, numTxs)
    - 648 + 245
      - err = dbTx.Commit(s.ctx) + var receipt *types.Receipt
    - 649 + 246
      - if err != nil { +
    - 650 + 247
      - log.Errorf("error committing state to store block. BlockNumber: %d, err: %v", blocks[i].BlockNumber, err) + for i, txResponse := range l2Block.TransactionResponses {
    - 651 + 248
      - rollbackErr := dbTx.Rollback(s.ctx) + // if the transaction has an intrinsic invalid tx error it means
    - 652 + 249
      - if rollbackErr != nil { + // the transaction has not changed the state, so we don't store it
    -
    @@ -705,12 +846,118 @@
    +
    @@ -263,9 +264,10 @@
    - 705 + 263
      - log.Error("error committing the resetted state. Error: ", err) +
    - 706 + 264
      - return err + storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData)
    - 707 + 265
      - } +
    - + + 266 -
    +
    +
    + - + receipt = GenerateReceipt(header.Number, txResponse, uint(i), forkID) +
    +
    + 267 + +
      -
    + receipts = append(receipts, receipt) +
    +
    + 268 + +
    +   + imStateRoots = append(imStateRoots, txResp.StateRoot)
    - + + 269 -
    +
    +
    +   + } +
    +
    + 270 + +
     
    - 708 + 271
      - if s.l1SyncOrchestration != nil { + // Create block to be able to calculate its hash
    - 709 + +
    @@ -536,6 +538,7 @@
    +
    + 536 +
    - - - s.l1SyncOrchestration.Reset(blockNumber) +   + TimestampLimit: l2Block.Time(),
    - + + 537 -
    +
    +
      -
    + SkipFirstChangeL2Block: cFalse,
    - + + 538 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 539 -
    +
    +
      -
    + }
    - + + 540 -
    +
    +
      -
    + if noZKEVMCounters {
    - + + 541 + +
    +   + processBatchRequestV2.NoCounters = cTrue +
    +
    +
    @@ -600,7 +603,7 @@
    +
    + 600 -
    +
    +
     
    - 710 + 601
      - } + if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - 711 + 602
      - return nil + err = executor.ExecutorErr(processBatchResponseV2.Error) +
    +
    + 603 + +
    + - + s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2)
    - 712 + 604
      - } + return nil, err
    - 713 + 605
      -
    + }
    - + + 606 -
    +
    +
     
    - + +
    @@ -1014,6 +1017,7 @@
    -
    +
    + 1014 + +
      -
    + TimestampLimit: uint64(time.Now().Unix()),
    - + + 1015 -
    +
    +
      -
    + SkipFirstChangeL2Block: cTrue,
    - + + 1016 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 1017 -
    +
    +
      -
    + }
    - + + 1018 -
    +
    +
     
    - + + 1019 -
    +
    +
      -
    + log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
    - + +
    @@ -1040,7 +1044,7 @@
    -
    +
    + 1040 + +
      -
    + }
    - + + 1041 -
    +
    +
      -
    + if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - + + 1042 -
    +
    +
      -
    + err = executor.ExecutorErr(processBatchResponseV2.Error)
    - + + 1043 -
    -   -
    +
    +
    + - + s.eventLog.LogExecutorError(ctx, processBatchResponseV2.Error, processBatchRequestV2)
    - + + 1044 -
    +
    +
      -
    + return false, false, gasUsed, nil, err
    - + + 1045 -
    +
    +
      -
    + }
    - + + 1046 -
    +
    +
      -
    + if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - + + 244 -
    +
    +
      -
    + imStateRoots := make([]common.Hash, 0, numTxs)
    - + + 245 -
    +
    +
      -
    + var receipt *types.Receipt
    - + + 246 -
    +
    +
     
    - + + 247 -
    -   -
    +
    +
    + + + txIndex := 0
    - + + 248 -
    +
    +
      -
    + for i, txResponse := range l2Block.TransactionResponses {
    - + + 249 -
    +
    +
      -
    + // if the transaction has an intrinsic invalid tx error it means
    - + + 250 -
    +
    +
      -
    + // the transaction has not changed the state, so we don't store it
    - + +
     
    -
    +
    + 264 + +
     
    - + + 265 -
    +
    +
      -
    + storeTxsEGPData = append(storeTxsEGPData, storeTxEGPData)
    - + + 266 -
    +
    +
     
    - + + 267 -
    -   -
    +
    +
    + + + receipt = GenerateReceipt(header.Number, txResponse, uint(txIndex), forkID)
    - + + 268 -
    +
    +
      -
    + receipts = append(receipts, receipt)
    - + + 269 -
    +
    +
      -
    + imStateRoots = append(imStateRoots, txResp.StateRoot)
    - + + 270 -
    -   -
    +
    +
    + + + txIndex++
    - + + 271 -
    +
    +
      -
    + }
    - + + 272 -
    +
    +
     
    - + + 273 -
    +
    +
      -
    + // Create block to be able to calculate its hash
    - + +
     
    -
    +
    + 538 + +
      -
    + TimestampLimit: l2Block.Time(),
    - + + 539 -
    +
    +
      -
    + SkipFirstChangeL2Block: cFalse,
    - + + 540 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 541 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 542 -
    +
    +
      -
    + }
    - + + 543 -
    +
    +
      -
    + if noZKEVMCounters {
    - + + 544 -
    +
    +
      -
    + processBatchRequestV2.NoCounters = cTrue
    - + +
     
    -
    +
    + 603 + +
     
    - + + 604 -
    +
    +
      -
    + if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - + + 605 -
    +
    +
      -
    + err = executor.ExecutorErr(processBatchResponseV2.Error)
    - + + 606 -
    -   -
    +
    +
    + + + s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2)
    - + + 607 -
    +
    +
      -
    + return nil, err
    - + + 608 -
    +
    +
      -
    + }
    - + + 609 -
    +
    +
     
    - + +
     
    -
    +
    + 1017 + +
      -
    + TimestampLimit: uint64(time.Now().Unix()),
    - + + 1018 -
    +
    +
      -
    + SkipFirstChangeL2Block: cTrue,
    - + + 1019 -
    +
    +
      -
    + SkipWriteBlockInfoRoot: cTrue,
    - + + 1020 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode0,
    - + + 1021 -
    +
    +
      -
    + }
    - + + 1022 -
    +
    +
     
    - + + 1023 -
    +
    +
      -
    + log.Debugf("EstimateGas[processBatchRequestV2.From]: %v", processBatchRequestV2.From)
    - + +
     
    -
    +
    + 1044 + +
      -
    + }
    - + + 1045 -
    +
    +
      -
    + if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR {
    - + + 1046 -
    +
    +
      -
    + err = executor.ExecutorErr(processBatchResponseV2.Error)
    - + + 1047 -
    -   -
    +
    +
    + + + s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2)
    - + + 1048 -
    +
    +
      -
    + return false, false, gasUsed, nil, err
    - + + 1049 -
    +
    +
      -
    + }
    - + + 1050 -
    +
    +
      -
    + if processBatchResponseV2.ErrorRom != executor.RomError_ROM_ERROR_NO_ERROR { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/state/types.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -15,25 +15,23 @@
    - + + 15 -
    +
    +
     
    - + + 16 -
    +
    +
      -
    + // ProcessRequest represents the request of a batch process.
    - + + 17 -
    +
    +
      -
    + type ProcessRequest struct {
    - + + 18 -
    -   -
    +
    +
    + - + BatchNumber uint64
    - + + 19 -
    -   -
    +
    +
    + - + GlobalExitRoot_V1 common.Hash
    - + + 20 -
    -   -
    +
    +
    + - + L1InfoRoot_V2 common.Hash
    - + + 21 -
    -   -
    +
    +
    + - + L1InfoTreeData_V2 map[uint32]L1DataV2
    - + + 22 -
    -   -
    +
    +
    + - + L1InfoTreeData_V3 map[uint32]L1DataV3
    - + + 23 -
    -   -
    +
    +
    + - + OldStateRoot common.Hash
    - + + 24 -
    -   -
    +
    +
    + - + OldAccInputHash common.Hash
    - + + 25 -
    -   -
    +
    +
    + - + Transactions []byte
    - + + 26 -
    -   -
    +
    +
    + - + Coinbase common.Address
    - + + 27 -
    -   -
    +
    +
    + - + ForcedBlockHashL1 common.Hash
    - + + 28 -
    -   -
    +
    +
    + - + Timestamp_V1 time.Time
    - + + 29 -
    -   -
    +
    +
    + - + TimestampLimit_V2 uint64
    - + + 30 -
    -   -
    +
    +
    + - + Caller metrics.CallerLabel
    - + + 31 -
    -   -
    +
    +
    + - + SkipFirstChangeL2Block_V2 bool
    - + + 32 -
    -   -
    +
    +
    + - + SkipWriteBlockInfoRoot_V2 bool
    - + + 33 -
    -   -
    +
    +
    + - + SkipVerifyL1InfoRoot_V2 bool
    - + + 34 -
    -   -
    +
    +
    + - + ForkID uint64
    - + + 35 -
    -   -
    +
    +
    + - + PreviousL1InfoTreeRoot_V3 common.Hash
    - + + 36 -
    -   -
    +
    +
    + - + PreviousL1InfoTreeIndex_V3 uint32
    - + + 37 -
    +
    +
      -
    + }
    - + + 38 -
    +
    +
     
    - + + 39 -
    +
    +
      -
    + // L1DataV2 represents the L1InfoTree data used in ProcessRequest.L1InfoTreeData_V2 parameter
    - + +
    @@ -44,15 +42,6 @@
    -
    +
    + 44 + +
      -
    + SmtProof [][]byte
    - + + 45 -
    +
    +
      -
    + }
    - + + 46 -
    +
    +
     
    - + + 47 -
    -   -
    +
    +
    + - + // L1DataV3 represents the L1InfoTree data used in ProcessRequest.L1InfoTreeData_V3 parameter
    - + + 48 -
    -   -
    +
    +
    + - + type L1DataV3 struct {
    - + + 49 -
    -   -
    +
    +
    + - + GlobalExitRoot common.Hash
    - + + 50 -
    -   -
    +
    +
    + - + BlockHashL1 common.Hash
    - + + 51 -
    -   -
    +
    +
    + - + MinTimestamp uint64
    - + + 52 -
    -   -
    +
    +
    + - + SmtProofPreviousIndex [][]byte
    - + + 53 -
    -   -
    +
    +
    + - + InitialHistoricRoot common.Hash
    - + + 54 -
    -   -
    +
    +
    + - + }
    - + + 55 -
    -   +
    +
    + -
    - 714 + 56
      - /* + // ProcessBatchResponse represents the response of a batch process.
    - 715 + 57
      - This function will check if there is a reorg. + type ProcessBatchResponse struct {
    - 716 + 58
      - As input param needs the last ethereum block synced. Retrieve the block info from the blockchain + NewStateRoot common.Hash
    -
    @@ -719,31 +966,47 @@
    +
    @@ -62,25 +51,21 @@
    - 719 + 62
      - must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check + UsedZkCounters ZKCounters
    - 720 + 63
      - hash and has parent. This operation has to be done until a match is found. + ReservedZkCounters ZKCounters
    - 721 + 64
      - */ + // TransactionResponses_V1 []*ProcessTransactionResponse
    - 722 + 65
    - - func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block) (*state.Block, error) { -
    -
    - - -
    -   -
    + BlockResponses []*ProcessBlockResponse
    - 723 + + 66 +
    -   - // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. + - + ExecutorError error
    - 724 + 67
    - - latestEthBlockSynced := *latestBlock -
    -
    - - -
    -   -
    + ReadWriteAddresses map[common.Address]*InfoReadWrite
    - 725 + + 68 +
    -   - var depth uint64 -
    -
    - - -
    -   -
    + - + IsRomLevelError bool
    - 726 + + 69 +
    -   - for { + - + IsExecutorLevelError bool
    - 727 + 70
    - - block, err := s.etherMan.EthBlockByNumber(s.ctx, latestBlock.BlockNumber) + IsRomOOCError bool
    - 728 + 71
    - - if err != nil { + FlushID uint64
    - 729 + 72
    - - log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", latestBlock.BlockNumber, err) + StoredFlushID uint64
    - 730 + 73
    - - return nil, err + ProverID string
    - 731 + 74
    - - } + GasUsed_V2 uint64
    - 732 + 75
    - - if block.NumberU64() != latestBlock.BlockNumber { + SMTKeys_V2 []merkletree.Key
    - 733 + 76
    - - err = fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", + ProgramKeys_V2 []merkletree.Key
    - 734 + 77
    - - latestBlock.BlockNumber, block.NumberU64()) + ForkID uint64
    - 735 + 78
    - - log.Error("error: ", err) + InvalidBatch_V2 bool
    - 736 + 79
    - - return nil, err + RomError_V2 error
    - + + 80 -
    -   -
    +
    +
    + - + OldStateRoot_V2 common.Hash
    - + + 81 -
    -   -
    +
    +
    + - + NewLastTimestamp_V3 uint64
    - + + 82 -
    -   -
    +
    +
    + - + CurrentL1InfoTreeRoot_V3 common.Hash
    - + + 83 -
    -   -
    +
    +
    + - + CurrentL1InfoTreeIndex_V3 uint32
    - + + 84 -
    +
    +
      -
    + }
    - + + 85 -
    +
    +
     
    - + + 86 -
    +
    +
      -
    + // ProcessBlockResponse represents the response of a block
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -187876,23 +267392,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -187906,13 +267422,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -187927,1531 +267443,1671 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - + - + + - - - - - - - - - - - - - - - - - - - - -
    +
     
    - + + 15 -
    +
    +
     
    - + + 16 -
    +
    +
      -
    + // ProcessRequest represents the request of a batch process.
    - 737 + 17
      - } + type ProcessRequest struct {
    - + + 18 -
    -   -
    +
    +
    + + + BatchNumber uint64
    - + + 19 -
    -   -
    +
    +
    + + + GlobalExitRoot_V1 common.Hash
    - + + 20 -
    -   -
    +
    +
    + + + L1InfoRoot_V2 common.Hash
    - 738 + + 21 +
    -   - // Compare hashes + + + L1InfoTreeData_V2 map[uint32]L1DataV2
    - 739 + + 22 +
    - - - if (block.Hash() != latestBlock.BlockHash || block.ParentHash() != latestBlock.ParentHash) && latestBlock.BlockNumber > s.genesis.BlockNumber { + + + OldStateRoot common.Hash
    - 740 + + 23 +
    - - - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", latestBlock.BlockNumber, block.Hash() == latestBlock.BlockHash, block.ParentHash() == latestBlock.ParentHash) + + + OldAccInputHash common.Hash
    - 741 + + 24 +
    - - - log.Debug("[checkReorg function] => latestBlockNumber: ", latestBlock.BlockNumber) + + + Transactions []byte
    - 742 + + 25 +
    - - - log.Debug("[checkReorg function] => latestBlockHash: ", latestBlock.BlockHash) + + + Coinbase common.Address
    - 743 + + 26 +
    - - - log.Debug("[checkReorg function] => latestBlockHashParent: ", latestBlock.ParentHash) + + + ForcedBlockHashL1 common.Hash
    - 744 + + 27 +
    - - - log.Debug("[checkReorg function] => BlockNumber: ", latestBlock.BlockNumber, block.NumberU64()) + + + Timestamp_V1 time.Time
    - 745 + + 28 +
    - - - log.Debug("[checkReorg function] => BlockHash: ", block.Hash()) + + + TimestampLimit_V2 uint64
    - 746 + + 29 +
    - - - log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash()) + + + Caller metrics.CallerLabel
    - 747 + + 30 +
    -   - depth++ + + + SkipFirstChangeL2Block_V2 bool
    - 748 + + 31 +
    -   - log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) + + + SkipWriteBlockInfoRoot_V2 bool
    - 749 + + 32 +
    -   - // Reorg detected. Getting previous block + + + SkipVerifyL1InfoRoot_V2 bool
    -
    @@ -752,7 +1015,7 @@
    -
    - 752 + + 33 +
    -   - log.Errorf("error creating db transaction to get prevoius blocks") + + + ForkID uint64
    - 753 + + 34 +
    -   - return nil, err + + + ExecutionMode uint64
    - 754 + + -
    +
    +
      - } +
    - 755 + + -
    - - - latestBlock, err = s.state.GetPreviousBlock(s.ctx, depth, dbTx) +
    +
    +   +
    - 756 + 35
      - errC := dbTx.Commit(s.ctx) + }
    - 757 + 36
      - if errC != nil { +
    - 758 + 37
      - log.Errorf("error committing dbTx, err: %v", errC) + // L1DataV2 represents the L1InfoTree data used in ProcessRequest.L1InfoTreeData_V2 parameter
    -
    @@ -765,19 +1028,26 @@
    +
     
    - 765 + 42
      - return nil, errC + SmtProof [][]byte
    - 766 + 43
      - } + }
    - 767 + 44
      - if errors.Is(err, state.ErrNotFound) { +
    - 768 + + -
    - - - log.Warn("error checking reorg: previous block not found in db: ", err) +
    +
    +   +
    - 769 + + -
    - - - return &state.Block{}, nil +
    +
    +   +
    - 770 + + -
    +
    +
      - } else if err != nil { +
    - 771 + + -
    +
    +
      - return nil, err +
    - 772 + + -
    +
    +
      - } +
    - 773 + + -
    +
    +
      - } else { +
    - 774 + 45
      - break + // ProcessBatchResponse represents the response of a batch process.
    - 775 + 46
      - } + type ProcessBatchResponse struct {
    - + + 47 -
    +
    +
      -
    + NewStateRoot common.Hash
    - + +
     
    -
    +
    + 51 + +
      -
    + UsedZkCounters ZKCounters
    - 776 + 52
      - } + ReservedZkCounters ZKCounters
    - 777 + + 53 +
    - - - if latestEthBlockSynced.BlockHash != latestBlock.BlockHash { +   + // TransactionResponses_V1 []*ProcessTransactionResponse
    - 778 + + 54 +
    - - - log.Info("Reorg detected in block: ", latestEthBlockSynced.BlockNumber, " last block OK: ", latestBlock.BlockNumber) + + + BlockResponses []*ProcessBlockResponse
    - 779 + + 55 +
    - - - return latestBlock, nil + + + ExecutorError error
    - + + 56 -
    -   -
    +
    +
    + + + ReadWriteAddresses map[common.Address]*InfoReadWrite
    - 780 + + 57 +
    -   - } + + + IsRomLevelError bool
    - + + 58 -
    -   -
    +
    +
    + + + IsExecutorLevelError bool
    - 781 + + 59 +
    -   - return nil, nil + + + IsRomOOCError bool
    - 782 + + 60 +
    -   - } + + + FlushID uint64
    - 783 + + 61 +
    -   -
    + + + StoredFlushID uint64
    -
    + + + 62 + + +
    + + + ProverID string
    -
    -
    - - - - - - - - - - - - - - - - - + + + - - - - + + + - - + + +
    -
     
    - 16 + + 63 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/processor_manager" + + + GasUsed_V2 uint64
    - 17 + + 64 +
    -   - syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common" + + + SMTKeys_V2 []merkletree.Key
    - 18 + + 65 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" + + + ProgramKeys_V2 []merkletree.Key
    - 19 + + 66 +
    + - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_check_block" + ForkID uint64
    - 20 + + 67 +
    -   - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1_parallel_sync" + + + InvalidBatch_V2 bool
    - 21 + + 68 +
    + + + RomError_V2 error +
    +
    + + +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders" +
    - 22 + + -
    +
    +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared" +
    - 23 + + -
    +
    +
    +   +
    +
    +
    + + +
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_sync_etrog" +
    - 24 + 69
      - "github.com/0xPolygonHermez/zkevm-node/synchronizer/metrics" + }
    - 25 + 70
      - "github.com/ethereum/go-ethereum/common" +
    - 26 + + 71 +
    - + - "github.com/ethereum/go-ethereum/rpc" +   + // ProcessBlockResponse represents the response of a block +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go + RENAMED + +
    +
    +
    +
    + + + + + - - + + + +
    +
    @@ -101,7 +101,7 @@
    - 27 + 101
      - "github.com/jackc/pgx/v4" + trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber)))
    - 28 + 102
      - ) + if err != nil {
    - 29 + 103
      -
    + log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error())
    -
     
    +
    + 104 + +
    + - + return nil, nil, nil +
    - 54 + 105
      - etherMan syncinterfaces.EthermanFullInterface + }
    - 55 + 106
      - latestFlushID uint64 + return localL2Block, trustedL2Block, nil
    - 56 + 107
      - // If true the lastFlushID is stored in DB and we don't need to check again + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + +
    +
     
    - 57 + + 101 +
    - + - latestFlushIDIsFulfilled bool +   + trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber)))
    - 58 + + 102 +
    - + - syncBlockProtection rpc.BlockNumber +   + if err != nil {
    - 59 + + 103 +
    - + - etherManForL1 []syncinterfaces.EthermanFullInterface +   + log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error())
    - 60 + 104
    + - state syncinterfaces.StateFullInterface + return nil, nil, err
    - 61 + + 105 +
    - + - pool syncinterfaces.PoolInterface +   + }
    - 62 + + 106 +
    - + - ethTxManager syncinterfaces.EthTxManager +   + return localL2Block, trustedL2Block, nil
    - 63 + + 107 +
    - + - zkEVMClient syncinterfaces.ZKEVMClientInterface +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_initial_sequence_batches.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + + +
    +
    @@ -19,9 +19,9 @@
    - 64 + + 19 +
    - + - zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface +   + // NewProcessorL1InitialSequenceBatchesElderberry returns instance of a processor for InitialSequenceBatchesOrder
    - 65 + + 20 +
    - + - eventLog syncinterfaces.EventLogInterface +   + func NewProcessorL1InitialSequenceBatchesElderberry(previousProcessor actions.L1EventProcessor) *ProcessorL1InitialSequenceBatchesElderberry {
    - 66 + + 21 +
    - + - ctx context.Context +   + return &ProcessorL1InitialSequenceBatchesElderberry{
    - 67 + + 22 +
    - + - cancelCtx context.CancelFunc + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1InitialSequenceBatchesElderberry](
    - 68 + + 23 +
    - + - genesis state.Genesis + - + []etherman.EventOrder{etherman.InitialSequenceBatchesOrder},
    - 69 + + 24 +
    - + - cfg Config + - + actions.ForksIdOnlyElderberry),
    - 70 + 25
      - // Id of the 'process' of the executor. Each time that it starts this value changes + previousProcessor: previousProcessor,
    - 71 + 26
      - // This value is obtained from the call state.GetStoredFlushID + }
    - 72 + 27
      - // It starts as an empty string and it is filled in the first call + }
    +
    +
    +
    +
    + + + - - + + + + + + - + + +
     
    - 78 + 19
      - l1EventProcessors *processor_manager.L1EventProcessors + // NewProcessorL1InitialSequenceBatchesElderberry returns instance of a processor for InitialSequenceBatchesOrder
    - 79 + 20
      - syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor + func NewProcessorL1InitialSequenceBatchesElderberry(previousProcessor actions.L1EventProcessor) *ProcessorL1InitialSequenceBatchesElderberry {
    - 80 + 21
      - halter syncinterfaces.CriticalErrorHandler + return &ProcessorL1InitialSequenceBatchesElderberry{
    - 81 + + 22 +
    + - asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator + ProcessorBase: actions.ProcessorBase[ProcessorL1InitialSequenceBatchesElderberry]{ +
    +
    + 23 + +
    + + + SupportedEvent: []etherman.EventOrder{etherman.InitialSequenceBatchesOrder}, +
    +
    + 24 + +
    + + + SupportedForkdIds: &actions.ForksIdOnlyElderberry},
    - 82 + 25
      - } + previousProcessor: previousProcessor,
    - 83 + 26
      -
    + }
    - 84 + 27
      - // NewSynchronizer creates and initializes an instance of Synchronizer + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/elderberry/processor_l1_sequence_batches.go + RENAMED + +
    +
    +
    +
    + + + - - + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    +
    @@ -3,7 +3,6 @@
    - 90 + 3
      - pool syncinterfaces.PoolInterface, + import (
    - 91 + 4
      - ethTxManager syncinterfaces.EthTxManager, + "context"
    - 92 + 5
      - zkEVMClient syncinterfaces.ZKEVMClientInterface, + "errors"
    - 93 + + 6 +
    - + - zkEVMClientEthereumCompatible syncinterfaces.ZKEVMClientEthereumCompatibleInterface, + - + "fmt"
    - 94 + 7
      - eventLog syncinterfaces.EventLogInterface, + "time"
    - 95 + 8
      - genesis state.Genesis, +
    - 96 + 9
      - cfg Config, + "github.com/0xPolygonHermez/zkevm-node/etherman"
    +
    @@ -40,9 +39,9 @@
    +
    - 97 + 40
      - runInDevelopmentMode bool) (Synchronizer, error) { + // NewProcessorL1SequenceBatchesElderberry returns instance of a processor for SequenceBatchesOrder
    - 98 + 41
      - ctx, cancel := context.WithCancel(context.Background()) + func NewProcessorL1SequenceBatchesElderberry(previousProcessor PreviousProcessor, state StateL1SequenceBatchesElderberry) *ProcessorL1SequenceBatchesElderberry {
    - 99 + 42
      - metrics.Register() + return &ProcessorL1SequenceBatchesElderberry{
    - 100 + + 43 +
    - + - syncBlockProtection, err := decodeSyncBlockProtection(cfg.SyncBlockProtection) + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1SequenceBatchesElderberry](
    - 101 + + 44 +
    - + - if err != nil { + - + []etherman.EventOrder{etherman.SequenceBatchesOrder},
    - 102 + + 45 +
    - + - log.Errorf("error decoding syncBlockProtection. Error: %v", err) + - + actions.ForksIdOnlyElderberry),
    - 103 + + 46 +
    - + - cancel() +   + previousProcessor: previousProcessor,
    - 104 + + 47 +
    - + - return nil, err +   + state: state,
    - 105 + + 48 +
    - + +   }
    - 106 + +
    @@ -60,58 +59,12 @@
    +
    + 60 +
    - + - log.Info("syncBlockProtection: ", syncBlockProtection) +   +
    - 107 + 61
      - res := &ClientSynchronizer{ + sbatch := l1Block.SequencedBatches[order.Pos][0]
    - 108 + + 62 +
    - + - isTrustedSequencer: isTrustedSequencer, +   +
    - 109 + + -
    - + - state: st, +
    +
    +   +
    - 110 + + 63 +
    - + - etherMan: ethMan, +   + if sbatch.SequencedBatchElderberryData == nil {
    - 111 + + 64 +
    - + - etherManForL1: etherManForL1, + - + log.Errorf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 112 + + 65 +
    - + - pool: pool, + - + return fmt.Errorf("no elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 113 + + -
    - + - ctx: ctx, +
    +
    +   +
    - 114 + + 66 +
    - + - cancelCtx: cancel, +   + }
    - 115 + + 67 +
    - + - ethTxManager: ethTxManager, + - + // We need to check that the sequence match
    - 116 + + 68 +
    - + - zkEVMClient: zkEVMClient, + - + err := g.sanityCheckExpectedSequence(sbatch.SequencedBatchElderberryData.InitSequencedBatchNumber, dbTx)
    - 117 + + 69 +
    - + - zkEVMClientEthereumCompatible: zkEVMClientEthereumCompatible, + - + if err != nil {
    - 118 + + 70 +
    - + - eventLog: eventLog, + - + return err
    - 119 + + 71 +
    - + - genesis: genesis, + - + }
    - 120 + + 72 +
    - + - cfg: cfg, + - + // We known that the MaxSequenceTimestamp is the same for all the batches so we can use the first one
    - 121 + + 73 +
    - + - proverID: "", + - + err = g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0), dbTx)
    - 122 + + 74 +
    - + - previousExecutorFlushID: 0, + - + // The last L2block timestamp must match MaxSequenceTimestamp
    - 123 + + 75 +
    - + - l1SyncOrchestration: nil, + - + if err != nil {
    - 124 + + 76 +
    - + - l1EventProcessors: nil, + - + return err
    - 125 + + 77 +
    - + - syncBlockProtection: syncBlockProtection, + - + }
    - 126 + + 78 +
    - + - halter: syncCommon.NewCriticalErrorHalt(eventLog, 5*time.Second), //nolint:gomnd + - + // It checks the timestamp of the last L2 block, but it's just log an error instead of refusing the event
    - 127 + + 79 +
    - + - } + - + _ = g.sanityCheckTstampLastL2Block(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp, dbTx)
    - 128 + + 80 +
    - + - if cfg.L1BlockCheck.Enable { + - + return nil
    - 129 + + 81 +
    - + - log.Infof("L1BlockChecker enabled: %s", cfg.L1BlockCheck.String()) + - + }
    - 130 + + 82 +
    - + - l1BlockChecker := l1_check_block.NewCheckL1BlockHash(ethMan, res.state, + - +
    - 131 + + 83 +
    - + - l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset)) + - + func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckExpectedSequence(initialBatchNumber uint64, dbTx pgx.Tx) error {
    - 132 + + 84 +
    - + -
    + - + // We need to check that the sequence match
    - 133 + + 85 +
    - + - var preCheckAsync syncinterfaces.AsyncL1BlockChecker + - + lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx)
    - 134 + + 86 +
    - + - if cfg.L1BlockCheck.PreCheckEnable { + - + if err != nil {
    - 135 + + 87 +
    - + - log.Infof("L1BlockChecker enabled precheck from: %s/%d to: %s/%d", + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 136 + + 88 +
    - + - cfg.L1BlockCheck.L1SafeBlockPoint, cfg.L1BlockCheck.L1SafeBlockOffset, + - + return err
    - 137 + + 89 +
    - + - cfg.L1BlockCheck.L1PreSafeBlockPoint, cfg.L1BlockCheck.L1PreSafeBlockOffset) + - + }
    - 138 + + 90 +
    - + - l1BlockPreChecker := l1_check_block.NewPreCheckL1BlockHash(ethMan, res.state, + - + if lastVirtualBatchNum != initialBatchNumber {
    - 139 + + 91 +
    - + - l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1SafeBlockPoint), cfg.L1BlockCheck.L1SafeBlockOffset), + - + log.Errorf("The last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event)", lastVirtualBatchNum+1, initialBatchNumber)
    - 140 + + 92 +
    - + - l1_check_block.NewSafeL1BlockNumberFetch(l1_check_block.StringToL1BlockPoint(cfg.L1BlockCheck.L1PreSafeBlockPoint), cfg.L1BlockCheck.L1PreSafeBlockOffset), + - + return fmt.Errorf("the last virtual batch number is not the expected one. Expected: %d (last on DB), got: %d (L1 event) err:%w", lastVirtualBatchNum+1, initialBatchNumber, ErrInvalidInitialBatchNumber)
    - 141 + + 93 +
    - + - ) + - + }
    - 142 + + 94 +
    - + - preCheckAsync = l1_check_block.NewAsyncCheck(l1BlockPreChecker) + - + return nil
    - 143 + + 95 +
    - + - } + - + }
    - 144 + + 96 +
    - + +  
    - 145 + + 97 +
    - + - res.asyncL1BlockChecker = l1_check_block.NewL1BlockCheckerIntegration( + - + func (g *ProcessorL1SequenceBatchesElderberry) sanityCheckTstampLastL2Block(timeLimit uint64, dbTx pgx.Tx) error {
    - 146 + + 98 +
    - + - l1_check_block.NewAsyncCheck(l1BlockChecker), + - + lastVirtualBatchNum, err := g.state.GetLastVirtualBatchNum(context.Background(), dbTx)
    - 147 + + 99 +
    - + - preCheckAsync, + - + if err != nil {
    - 148 + + 100 +
    - + - res.state, + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 149 + + 101 +
    - + - res, + - + return err
    - 150 + + 102 +
    - + - cfg.L1BlockCheck.ForceCheckBeforeStart, + - + }
    - 151 + + 103 +
    - + - time.Second) + - + lastL2Block, err := g.state.GetLastL2BlockByBatchNumber(context.Background(), lastVirtualBatchNum, dbTx)
    - 152 + + 104 +
    -   - } + - + if err != nil {
    - 153 + + 105 +
    -   -
    + - + log.Errorf("Error getting last virtual batch number: %s", err)
    - 154 + + 106 +
    -   - if !isTrustedSequencer { + - + return err
    -
     
    -
    - 183 + + 107 +
    -   - log.Errorf("error getting last L2Block number from state. Error: %v", err) + - + }
    - 184 + + 108 +
    -   - return nil, err + - + if lastL2Block == nil {
    - 185 + + 109 +
    -   - } + - + //TODO: find the previous batch until we find a L2 block to check the timestamp
    - 186 + + 110 +
    - + - l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) + - + return nil
    - 187 + + 111 +
    - + - if err != nil { + - + }
    - 188 + + 112 +
    - + - log.Error("error creating new instance of checkL2BlockHash. Error: ", err) + - + if uint64(lastL2Block.ReceivedAt.Unix()) > timeLimit {
    - 189 + + 113 +
    - + - return nil, err + - + log.Errorf("The last L2 block timestamp can't be greater than timeLimit. Expected: %d (L1 event), got: %d (last L2Block)", timeLimit, lastL2Block.ReceivedAt.Unix())
    - 190 + + 114 +
    - + - } + - + return fmt.Errorf("wrong timestamp of last L2 block timestamp with L1 event timestamp")
    - 191 + + 115 +
    -   - } else { + - + }
    - 192 + + 116 +
    -   - log.Infof("Trusted Node can't check L2Block hash, ignoring parameter") + - + return nil
    - 193 + 117
      - } + }
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -189461,1267 +269117,1316 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
     
    - 207 + 3
      - return res, nil + import (
    - 208 + 4
      - } + "context"
    - 209 + 5
      -
    -
    -
    - 210 - -
    - + - func decodeSyncBlockProtection(sBP string) (rpc.BlockNumber, error) { -
    -
    - 211 - -
    - + - switch sBP { + "errors"
    - 212 + + -
    - + - case "latest": +
    +
    +   +
    - 213 + + 6 +
    - + - return rpc.LatestBlockNumber, nil +   + "time"
    - 214 + + 7 +
    - + - case "finalized": +   +
    - 215 + + 8 +
    - + - return rpc.FinalizedBlockNumber, nil +   + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 216 - -
    - + - case "safe": -
    +
    +
     
    - 217 + + 39 +
    - + - return rpc.SafeBlockNumber, nil +   + // NewProcessorL1SequenceBatchesElderberry returns instance of a processor for SequenceBatchesOrder
    - 218 + + 40 +
    - + - default: +   + func NewProcessorL1SequenceBatchesElderberry(previousProcessor PreviousProcessor, state StateL1SequenceBatchesElderberry) *ProcessorL1SequenceBatchesElderberry {
    - 219 + + 41 +
    - + - return 0, fmt.Errorf("error decoding SyncBlockProtection. Unknown value") +   + return &ProcessorL1SequenceBatchesElderberry{
    - 220 + + 42 +
    + - } + ProcessorBase: actions.ProcessorBase[ProcessorL1SequenceBatchesElderberry]{
    - 221 + + 43 +
    + - } + SupportedEvent: []etherman.EventOrder{etherman.SequenceBatchesOrder},
    - 222 + + 44 +
    + -
    + SupportedForkdIds: &actions.ForksIdOnlyElderberry},
    - 223 + 45
      - var waitDuration = time.Duration(0) + previousProcessor: previousProcessor,
    - 224 + 46
      -
    + state: state,
    - 225 + 47
      - func newL1SyncParallel(ctx context.Context, cfg Config, etherManForL1 []syncinterfaces.EthermanFullInterface, sync *ClientSynchronizer, runExternalControl bool) *l1_parallel_sync.L1SyncOrchestration { + }
    - 282 + 59
      - // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block +
    - 283 + 60
      - // Get the latest synced block. If there is no block on db, use genesis block + sbatch := l1Block.SequencedBatches[order.Pos][0]
    - 284 + 61
      - log.Info("Sync started") +
    - 285 + 62
    + - if s.asyncL1BlockChecker != nil { + executionTime := l1Block.ReceivedAt
    - 286 + + 63 + +
    +   + if sbatch.SequencedBatchElderberryData == nil { +
    +
    + 64 +
    + - _ = s.asyncL1BlockChecker.OnStart(s.ctx) + log.Warnf("No elderberry sequenced batch data for batch %d", sbatch.BatchNumber)
    - 287 + + 65 +
    + - } + } else {
    - 288 + 66
    + -
    + executionTime = time.Unix(int64(sbatch.SequencedBatchElderberryData.MaxSequenceTimestamp), 0)
    - 289 + 67
      - dbTx, err := s.state.BeginStateTransaction(s.ctx) + }
    - 290 + + -
    +
    +
      - if err != nil { +
    - 291 + + -
    +
    +
      - log.Errorf("error creating db transaction to get latest block. Error: %v", err) +
    -
     
    +
    + + +
    +   +
    +
    - 295 + + -
    +
    +
      - if err != nil { +
    - 296 + + -
    +
    +
      - if errors.Is(err, state.ErrStateNotSynchronized) { +
    - 297 + + -
    +
    +
      - log.Info("State is empty, verifying genesis block") +
    - 298 + + -
    - + - valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.RollupBlockNumber) +
    +
    +   +
    - 299 + + -
    +
    +
      - if err != nil { +
    - 300 + + -
    +
    +
      - log.Error("error checking genesis block number. Error: ", err) +
    - 301 + + -
    +
    +
      - return rollback(s.ctx, dbTx, err) +
    -
     
    +
    + + +
    +   +
    +
    - 303 + + -
    +
    +
      - log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +
    - 304 + + -
    +
    +
      - return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) +
    - 305 + + -
    +
    +
      - } +
    - 306 + + -
    - + +
    +
    +  
    - 307 + + -
    - + - // Sync events from RollupManager that happen before rollup creation +
    +
    +   +
    - 308 + + -
    - + - log.Info("synchronizing events from RollupManager that happen before rollup creation") +
    +
    +   +
    - 309 + + -
    - + - for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize { +
    +
    +   +
    - 310 + + -
    - + - toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1) +
    +
    +   +
    - 311 + + -
    - + - blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock) +
    +
    +   +
    - 312 + + -
    - + - if err != nil { +
    +
    +   +
    - 313 + + -
    - + - log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err) +
    +
    +   +
    - 314 + + -
    - + - rollbackErr := dbTx.Rollback(s.ctx) +
    +
    +   +
    - 315 + + -
    - + - if rollbackErr != nil { +
    +
    +   +
    - 316 + + -
    - + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    +   +
    - 317 + + -
    - + - return rollbackErr +
    +
    +   +
    - 318 + + -
    - + - } +
    +
    +   +
    - 319 + + -
    - + - return err +
    +
    +   +
    - 320 + + -
    - + - } +
    +
    +   +
    - 321 + + 68 +
    - + - err = s.ProcessBlockRange(blocks, order) +   +
    - 322 + + 69 +
    + - if err != nil { + return g.previousProcessor.ProcessSequenceBatches(ctx, l1Block.SequencedBatches[order.Pos], l1Block.BlockNumber, executionTime, dbTx)
    - 323 + + -
    - + - log.Error("error processing blocks before the genesis: ", err) +
    +
    +   +
    - 324 + + -
    - + - rollbackErr := dbTx.Rollback(s.ctx) +
    +
    +   +
    - 325 + + -
    - + - if rollbackErr != nil { +
    +
    +   +
    - 326 + + -
    - + - log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    +   +
    - 327 + + -
    - + - return rollbackErr +
    +
    +   +
    - 328 + + -
    - + - } +
    +
    +   +
    - 329 + + -
    - + - return err +
    +
    +   +
    - 330 + + -
    - + - } +
    +
    +   +
    - 331 + + -
    - + - if toBlock == s.genesis.RollupBlockNumber-1 { +
    +
    +   +
    - 332 + + -
    - + - break +
    +
    +   +
    - 333 + + -
    - + - } +
    +
    +   +
    - 334 + + -
    - + - } +
    +
    +   +
    - 335 + + -
    - + +
    +
    +  
    - 336 + + -
    - + - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber)) +
    +
    +   +
    - 337 + + -
    +
    +
      - if err != nil { +
    - 338 + + -
    - + - log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err) +
    +
    +   +
    - 339 + + -
    +
    +
      - return rollback(s.ctx, dbTx, err) +
    - 340 + + -
    +
    +
      - } +
    - 341 + + -
    - + - log.Info("synchronizing rollup creation block") +
    +
    +   +
    - 342 + 70
      - lastEthBlockSynced = &state.Block{ + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + + +
    +
    @@ -24,9 +24,9 @@
    - 343 + 24
      - BlockNumber: header.Number.Uint64(), + // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder
    - 344 + 25
      - BlockHash: header.Hash(), + func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeInterface) *ProcessorL1InfoTreeUpdate {
    -
     
    -
    - 437 + 26
      - continue + return &ProcessorL1InfoTreeUpdate{
    - 438 + + 27 +
    -   - } + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate](
    - 439 + + 28 +
    -   - log.Infof("latestSequencedBatchNumber: %d, latestSyncedBatch: %d, lastVerifiedBatchNumber: %d", latestSequencedBatchNumber, latestSyncedBatch, lastVerifiedBatchNumber) + - + []etherman.EventOrder{etherman.L1InfoTreeOrder},
    - 440 + + 29 +
    - + - resetDone := false + - + actions.ForksIdToElderberry),
    - 441 + 30
      - // Sync trusted state + state: state}
    - 442 + 31
      - // latestSyncedBatch -> Last batch on DB + }
    - 443 + 32
      - // latestSequencedBatchNumber -> last batch on SMC +
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - + + +
     
    - 445 + 24
      - startTrusted := time.Now() + // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder
    - 446 + 25
      - if s.syncTrustedStateExecutor != nil && !s.isTrustedSequencer { + func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeInterface) *ProcessorL1InfoTreeUpdate {
    - 447 + 26
      - log.Info("Syncing trusted state (permissionless)") -
    -
    - 448 - -
    - + - //Sync Trusted State -
    -
    - 449 - -
    - + - log.Debug("Doing reorg check before L2 sync") -
    -
    - 450 - -
    - + - resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) -
    -
    - 451 - -
    - + - if resetDone || err != nil { + return &ProcessorL1InfoTreeUpdate{
    - 452 + + 27 +
    + - log.Infof("Reset done before L2 sync") + ProcessorBase: actions.ProcessorBase[ProcessorL1InfoTreeUpdate]{
    - 453 + + 28 +
    + - continue + SupportedEvent: []etherman.EventOrder{etherman.L1InfoTreeOrder},
    - 454 + + 29 +
    + - } + SupportedForkdIds: &actions.ForksIdAll},
    - 455 + 30
      - err = s.syncTrustedState(latestSyncedBatch) + state: state}
    - 456 + 31
      - metrics.FullTrustedSyncTime(time.Since(startTrusted)) + }
    - 457 + 32
      - if err != nil { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_info_tree_update_test.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - + + +
    -
     
    +
    @@ -45,7 +45,7 @@
    - 460 + 45
      - if errors.Is(err, syncinterfaces.ErrFatalDesyncFromL1) { + if err != nil {
    - 461 + 46
      - l1BlockNumber := err.(*l2_shared.DeSyncPermissionlessAndTrustedNodeError).L1BlockNumber + panic(err)
    - 462 + 47
      - log.Error("Trusted and permissionless desync! reseting to last common point: L1Block (%d-1)", l1BlockNumber) + }
    - 463 + + 48 +
    - + - for { + - + testState := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), nil, nil, nil, mt, nil)
    - 464 + + 49 +
    - + - resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) +   +
    - 465 + + 50 +
    - + - if resetDone { +   + sut := NewProcessorL1InfoTreeUpdate(testState)
    - 466 + + 51 +
    - + - break +   + l1infotree := etherman.GlobalExitRoot{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - + + +
    +
     
    - 467 + + 45 +
    - + - } else { +   + if err != nil {
    - 468 + + 46 +
    - + - log.Error("reorg isn't done, retrying...") +   + panic(err)
    - 469 + + 47 +
    - + - time.Sleep(time.Second) +   + }
    - 470 + + 48 +
    + - } + testState := state.NewState(stateCfg, pgstatestorage.NewPostgresStorage(stateCfg, stateDb), nil, nil, nil, mt)
    - 471 + 49
      - } +
    - 472 + 50
      - } else if errors.Is(err, syncinterfaces.ErrMissingSyncFromL1) { + sut := NewProcessorL1InfoTreeUpdate(testState)
    - 473 + 51
      - log.Info("Syncing from trusted node need data from L1") + l1infotree := etherman.GlobalExitRoot{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    +
    @@ -55,9 +55,9 @@
    - 484 + 55
      - waitDuration = s.cfg.SyncInterval.Duration + timeProvider syncCommon.TimeProvider,
    - 485 + 56
      - } + halter syncinterfaces.CriticalErrorHandler) *ProcessorL1SequenceBatchesEtrog {
    - 486 + 57
      - //Sync L1Blocks -
    -
    - 487 - -
    - + - resetDone, lastEthBlockSynced, err = s.checkReorgAndExecuteReset(lastEthBlockSynced) -
    -
    - 488 - -
    - + - if resetDone || err != nil { + return &ProcessorL1SequenceBatchesEtrog{
    - 489 + + 58 +
    - + - continue + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1SequenceBatchesEtrog](
    - 490 + + 59 +
    - + - } + - + []etherman.EventOrder{etherman.SequenceBatchesOrder, etherman.InitialSequenceBatchesOrder},
    - 491 + + 60 +
    - + -
    + - + actions.ForksIdOnlyEtrog),
    - 492 + 61
      - startL1 := time.Now() + state: state,
    - 493 + 62
      - if s.l1SyncOrchestration != nil && (latestSyncedBatch < latestSequencedBatchNumber || !s.cfg.L1ParallelSynchronization.FallbackToSequentialModeOnSynchronized) { + sync: sync,
    - 494 + 63
      - log.Infof("Syncing L1 blocks in parallel lastEthBlockSynced=%d", lastEthBlockSynced.BlockNumber) + timeProvider: timeProvider,
    -
     
    +
    @@ -287,8 +287,8 @@
    - 503 + 287
      - lastEthBlockSynced, err = s.syncBlocksSequential(lastEthBlockSynced) +
    - 504 + 288
      - } + // Reset trusted state
    - 505 + 289
      - metrics.FullL1SyncTime(time.Since(startL1)) -
    -
    - 506 - -
    - + - if syncCommon.IsReorgError(err) { + previousBatchNumber := batch.BatchNumber - 1
    - 507 + + 290 +
    - + - log.Warnf("error syncing blocks: %s", err.Error()) + - + if tBatch.WIP {
    - 508 + + 291 +
    - + - for { + - + log.Infof("cleaning state before inserting batch from L1. Clean until batch: %d", previousBatchNumber)
    - 509 + + 292 +
    - + - resetDone, lastEthBlockSynced, err = s.detectedReorgBadBlockExecuteReset(lastEthBlockSynced, syncCommon.GetReorgErrorBlockNumber(err)) +   + } else {
    - 510 + + 293 +
    - + - if resetDone { +   + log.Warnf("missmatch in trusted state detected, discarding batches until batchNum %d", previousBatchNumber)
    - 511 + + 294 +
    - + - break +   + }
    - 512 - -
    - + - } else { +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -190731,1262 +270436,1451 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - + +
    +
     
    - 513 + + 55 +
    - + - log.Error("reorg isn't done, retrying...") +   + timeProvider syncCommon.TimeProvider,
    - 514 + + 56 +
    - + - time.Sleep(time.Second) +   + halter syncinterfaces.CriticalErrorHandler) *ProcessorL1SequenceBatchesEtrog {
    - 515 + + 57 +
    - + - } +   + return &ProcessorL1SequenceBatchesEtrog{
    - 516 + + 58 +
    + - } + ProcessorBase: actions.ProcessorBase[ProcessorL1SequenceBatchesEtrog]{
    - 517 + + 59 +
    + - continue + SupportedEvent: []etherman.EventOrder{etherman.SequenceBatchesOrder, etherman.InitialSequenceBatchesOrder},
    - 518 + + 60 +
    + - } + SupportedForkdIds: &actions.ForksIdOnlyEtrog},
    - 519 + 61
      - if err != nil { + state: state,
    - 520 + 62
      - log.Warn("error syncing blocks: ", err) + sync: sync,
    - 521 + 63
      - s.CleanTrustedState() + timeProvider: timeProvider,
    - 586 + 287
      - // This function syncs the node from a specific block to the latest +
    - 587 + 288
      - // lastEthBlockSynced -> last block synced in the db + // Reset trusted state
    - 588 + 289
      - func (s *ClientSynchronizer) syncBlocksParallel(lastEthBlockSynced *state.Block) (*state.Block, error) { -
    -
    - - -
    -   -
    + previousBatchNumber := batch.BatchNumber - 1
    - + + 290 -
    -   -
    +
    +
    + + + if tBatch.StateRoot == (common.Hash{}) {
    - + + 291 -
    -   -
    +
    +
    + + + log.Warnf("cleaning state before inserting batch from L1. Clean until batch: %d", previousBatchNumber)
    - + + 292 -
    +
    +
      -
    + } else {
    - + + 293 -
    +
    +
      -
    + log.Warnf("missmatch in trusted state detected, discarding batches until batchNum %d", previousBatchNumber)
    - + + 294 -
    +
    +
      -
    + }
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_sequence_batches_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - + + + + + +
    +
    @@ -268,7 +268,7 @@
    - + + 268 -
    +
    +
      -
    + TxHash: state.HashByteArray(batch.BatchL2Data),
    - + + 269 -
    +
    +
      -
    + Coinbase: batch.Coinbase,
    - + + 270 -
    +
    +
      -
    + SequencerAddr: common.HexToAddress(addrExampleValues[0]),
    - + + 271 -
    -   -
    +
    +
    + - + PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 272 -
    +
    +
      -
    + Transactions: []byte{},
    - + + 273 -
    +
    +
      -
    + ForcedTimestamp: uint64(forcedTimestamp.Unix()),
    - + + 274 -
    +
    +
      -
    + ForcedGlobalExitRoot: forcedGlobalExitRoot,
    - - -
    -   -
    -
    +
    +
    @@ -284,7 +284,7 @@
    - + + 284 -
    +
    +
      -
    + TxHash: state.HashByteArray(batch.BatchL2Data),
    - 589 + 285
      - log.Infof("Starting L1 sync orchestrator in parallel block: %d", lastEthBlockSynced.BlockNumber) + Coinbase: batch.Coinbase,
    - 590 + 286
      - return s.l1SyncOrchestration.Start(lastEthBlockSynced) + SequencerAddr: common.HexToAddress(addrExampleValues[0]), +
    +
    + 287 + +
    + - + PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 591 + 288
      - } + Transactions: []byte{},
    - 592 + 289
      -
    + },
    - 593 + 290
      - // This function syncs the node from a specific block to the latest + }
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    +
    - 594 + 268
      - func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Block) (*state.Block, error) { + TxHash: state.HashByteArray(batch.BatchL2Data),
    - + + 269 -
    +
    +
      -
    + Coinbase: batch.Coinbase,
    - + + 270 -
    +
    +
      -
    + SequencerAddr: common.HexToAddress(addrExampleValues[0]),
    - + + 271 -
    -   -
    +
    +
    + + + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 272 -
    +
    +
      -
    + Transactions: []byte{},
    - + + 273 -
    +
    +
      -
    + ForcedTimestamp: uint64(forcedTimestamp.Unix()),
    - + + 274 -
    +
    +
      -
    + ForcedGlobalExitRoot: forcedGlobalExitRoot,
    - + +
     
    -
    +
    + 284 + +
      -
    + TxHash: state.HashByteArray(batch.BatchL2Data),
    - + + 285 -
    +
    +
      -
    + Coinbase: batch.Coinbase,
    - + + 286 -
    +
    +
      -
    + SequencerAddr: common.HexToAddress(addrExampleValues[0]),
    - + + 287 -
    -   -
    +
    +
    + + + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - + + 288 -
    +
    +
      -
    + Transactions: []byte{},
    - + + 289 -
    +
    +
      -
    + },
    - + + 290 -
    +
    +
      -
    + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/etrog/processor_l1_update_etrog_sequence.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + + +
    +
    @@ -38,9 +38,9 @@
    +
    - + + 38 -
    +
    +
      -
    + sync syncProcessUpdateEtrogSequenceInterface,
    - + + 39 -
    +
    +
      -
    + timeProvider syncCommon.TimeProvider) *ProcessorL1UpdateEtrogSequence {
    - 595 + 40
      - // Call the blockchain to retrieve data + return &ProcessorL1UpdateEtrogSequence{
    - 596 + + 41 +
    - + - header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(s.syncBlockProtection.Int64())) + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1UpdateEtrogSequence](
    - 597 + + 42 +
    -   - if err != nil { + - + []etherman.EventOrder{etherman.UpdateEtrogSequenceOrder},
    - 598 + + 43 +
    - + - log.Error("error getting header of the latest block in L1. Error: ", err) + - + actions.ForksIdOnlyEtrog),
    - 599 + 44
      - return lastEthBlockSynced, err + state: state,
    - 600 + 45
      - } + sync: sync,
    - 601 + 46
      - lastKnownBlock := header.Number + timeProvider: timeProvider, +
    +
    +
    +
    +
    + + + + + - - - - - - + + +
    +
     
    - 602 + 38
      -
    + sync syncProcessUpdateEtrogSequenceInterface,
    - 603 + 39
      - var fromBlock uint64 + timeProvider syncCommon.TimeProvider) *ProcessorL1UpdateEtrogSequence {
    - 604 + 40
      - if lastEthBlockSynced.BlockNumber > 0 { + return &ProcessorL1UpdateEtrogSequence{
    - 605 + 41
    + - fromBlock = lastEthBlockSynced.BlockNumber + ProcessorBase: actions.ProcessorBase[ProcessorL1UpdateEtrogSequence]{
    - 606 + + 42 +
    -   - } + + + SupportedEvent: []etherman.EventOrder{etherman.UpdateEtrogSequenceOrder},
    - 607 + + 43 +
    + - toBlock := fromBlock + s.cfg.SyncChunkSize + SupportedForkdIds: &actions.ForksIdOnlyEtrog},
    - 608 + 44
      -
    + state: state,
    - 609 + 45
      - for { + sync: sync,
    - 610 + + 46 +
    - + - if toBlock > lastKnownBlock.Uint64() { +   + timeProvider: timeProvider, +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_info_tree_update.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,54 +0,0 @@
    - 611 + + 1 +
    - + - log.Debug("Setting toBlock to the lastKnownBlock") + - + package feijoa
    - 612 + + 2 +
    - + - toBlock = lastKnownBlock.Uint64() + - +
    - 613 + + 3 +
    - + - } + - + import (
    - 614 + + 4 +
    - + - if fromBlock > toBlock { + - + "context"
    - 615 + + 5 +
    - + - log.Debug("FromBlock is higher than toBlock. Skipping...") + - +
    - 616 + + 6 +
    - + - return lastEthBlockSynced, nil + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 617 + + 7 +
    - + - } + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 618 + + 8 +
    -   - log.Infof("Syncing block %d of %d", fromBlock, lastKnownBlock.Uint64()) + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 619 + + 9 +
    -   - log.Infof("Getting rollup info from block %d to block %d", fromBlock, toBlock) + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions"
    - 620 + + 10 +
    -   - // This function returns the rollup information contained in the ethereum blocks and an extra param called order. + - + "github.com/jackc/pgx/v4"
    -
     
    +
    + 11 + +
    + - + ) +
    - 628 + + 12 +
    -   - if err != nil { + - +
    - 629 + + 13 +
    -   - return lastEthBlockSynced, err + - + // stateProcessorL1InfoTreeInterface interface required from state
    - 630 + + 14 +
    -   - } + - + type stateProcessorL1InfoTreeRecursiveInterface interface {
    - 631 + + 15 +
    - + -
    + - + AddL1InfoTreeRecursiveLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error)
    - 632 + + 16 +
    - + - var initBlockReceived *etherman.Block + - + }
    - 633 + + 17 +
    - + - if len(blocks) != 0 { + - +
    - 634 + + 18 +
    - + - initBlockReceived = &blocks[0] + - + // ProcessorL1InfoTreeUpdate implements L1EventProcessor for GlobalExitRootsOrder
    - 635 + + 19 +
    - + - // First position of the array must be deleted + - + type ProcessorL1InfoTreeUpdate struct {
    - 636 + + 20 +
    - + - blocks = removeBlockElement(blocks, 0) + - + actions.ProcessorBase[ProcessorL1InfoTreeUpdate]
    - 637 + + 21 +
    - + - } else { + - + state stateProcessorL1InfoTreeRecursiveInterface
    - 638 + + 22 +
    - + - // Reorg detected + - + }
    - 639 + + 23 +
    - + - log.Infof("Reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", fromBlock) + - +
    - 640 + + 24 +
    - + - prevBlock, err := s.state.GetPreviousBlock(s.ctx, 1, nil) + - + // NewProcessorL1InfoTreeUpdate new processor for GlobalExitRootsOrder
    - 641 + + 25 +
    - + - if errors.Is(err, state.ErrNotFound) { + - + func NewProcessorL1InfoTreeUpdate(state stateProcessorL1InfoTreeRecursiveInterface) *ProcessorL1InfoTreeUpdate {
    - 642 + + 26 +
    - + - log.Warn("error checking reorg: previous block not found in db: ", err) + - + return &ProcessorL1InfoTreeUpdate{
    - 643 + + 27 +
    - + - prevBlock = &state.Block{} + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate](
    - 644 + + 28 +
    - + - } else if err != nil { + - + []etherman.EventOrder{etherman.L1InfoTreeOrder},
    - 645 + + 29 +
    - + - log.Error("error getting previousBlock from db. Error: ", err) + - + actions.ForksIdOnlyFeijoa),
    - 646 + + 30 +
    - + - return lastEthBlockSynced, err + - + state: state}
    - 647 + + 31 +
    - + - } + - + }
    - 648 + + 32 +
    - + - blockReorged, err := s.checkReorg(prevBlock, nil) + - +
    - 649 + + 33 +
    - + - if err != nil { + - + // Process process event
    - 650 + + 34 +
    - + - log.Error("error checking reorgs in previous blocks. Error: ", err) + - + func (p *ProcessorL1InfoTreeUpdate) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error {
    - 651 + + 35 +
    - + - return lastEthBlockSynced, err + - + l1InfoTree := l1Block.L1InfoTree[order.Pos]
    - 652 + + 36 +
    - + - } + - + ger := state.GlobalExitRoot{
    - 653 + + 37 +
    - + - if blockReorged == nil { + - + BlockNumber: l1InfoTree.BlockNumber,
    - 654 + + 38 +
    - + - blockReorged = prevBlock + - + MainnetExitRoot: l1InfoTree.MainnetExitRoot,
    - 655 + + 39 +
    - + - } + - + RollupExitRoot: l1InfoTree.RollupExitRoot,
    - 656 + + 40 +
    - + - err = s.resetState(blockReorged.BlockNumber) + - + GlobalExitRoot: l1InfoTree.GlobalExitRoot,
    - 657 + + 41 +
    - + - if err != nil { + - + Timestamp: l1InfoTree.Timestamp,
    - 658 + + 42 +
    - + - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) + - + }
    - 659 + + 43 +
    - + - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") + - + l1IntoTreeLeaf := state.L1InfoTreeLeaf{
    - 660 + + 44 +
    - + - } + - + GlobalExitRoot: ger,
    - 661 + + 45 +
    - + - return blockReorged, nil + - + PreviousBlockHash: l1InfoTree.PreviousBlockHash,
    - 662 + + 46 +
    - + - } + - + }
    - 663 + + 47 +
    - + - // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange + - + entry, err := p.state.AddL1InfoTreeRecursiveLeaf(ctx, &l1IntoTreeLeaf, dbTx)
    - 664 + + 48 +
    - + - block, err := s.checkReorg(lastEthBlockSynced, initBlockReceived) + - + if err != nil {
    - 665 + + 49 +
    - + - if err != nil { + - + log.Errorf("error storing the l1InfoTree(feijoa). BlockNumber: %d, error: %v", l1Block.BlockNumber, err)
    - 666 + + 50 +
    - + - log.Errorf("error checking reorgs. Retrying... Err: %v", err) + - + return err
    - 667 + + 51 +
    - + - return lastEthBlockSynced, fmt.Errorf("error checking reorgs") + - + }
    - 668 + + 52 +
    - + - } + - + log.Infof("L1InfoTree(feijoa) stored. BlockNumber: %d,GER:%s L1InfoTreeIndex: %d L1InfoRoot:%s", l1Block.BlockNumber, entry.GlobalExitRoot.GlobalExitRoot, entry.L1InfoTreeIndex, entry.L1InfoTreeRoot)
    - 669 + + 53 +
    - + - if block != nil { + - + return nil
    - 670 + + 54 +
    - + - err = s.resetState(block.BlockNumber) + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - @@ -192000,83 +271894,83 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - @@ -192299,2643 +272193,2887 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
     
    - 671 + + -
    - + - if err != nil { +
    +
    +   +
    - 672 + + -
    - + - log.Errorf("error resetting the state to a previous block. Retrying... Err: %v", err) +
    +
    +   +
    - 673 + + -
    - + - return lastEthBlockSynced, fmt.Errorf("error resetting the state to a previous block") +
    +
    +   +
    - 674 + + -
    - + - } +
    +
    +   +
    - 675 + + -
    - + - return block, nil +
    +
    +   +
    - 676 + + -
    - + - } +
    +
    +   +
    - 677 + + -
    - + +
    +
    +  
    - 678 + + -
    +
    +
      - start = time.Now() +
    - 679 + + -
    +
    +
      - err = s.ProcessBlockRange(blocks, order) +
    - 680 + + -
    +
    +
      - metrics.ProcessL1DataTime(time.Since(start)) +
    -
     
    +
    + + +
    +   +
    +
    - 689 + + -
    +
    +
      - ReceivedAt: blocks[len(blocks)-1].ReceivedAt, +
    - 690 + + -
    +
    +
      - } +
    - 691 + + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + -
    +
    +
      - for i := range blocks { +
    - 692 + + -
    - + - log.Info("Position: ", i, ". New block. BlockNumber: ", blocks[i].BlockNumber, ". BlockHash: ", blocks[i].BlockHash) +
    +
    +   +
    - 693 + + -
    +
    +
      - } +
    - 694 + + -
    +
    +
      - } +
    - 695 + + -
    +
    +
     
    - 696 + + -
    +
    +
      - if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 { +
    - 697 + + -
    +
    +
      - waitDuration = s.cfg.SyncInterval.Duration +
    - 698 + + -
    +
    +
      - break +
    - 699 + + -
    +
    +
      - } +
    - 700 + + -
    - + +
    +
    +  
    - 701 + + -
    - + - fromBlock = lastEthBlockSynced.BlockNumber +
    +
    +   +
    - 702 + + -
    - + - toBlock = toBlock + s.cfg.SyncChunkSize +
    +
    +   +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + + + + + + - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - - - - + + + + + + + + + - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,189 +0,0 @@
    +
    - 703 + + 1 +
    -   - } + - + package feijoa
    - 704 + + 2 +
    -   + -
    - 705 + + 3 +
    -   - return lastEthBlockSynced, nil + - + import (
    - 706 + + 4 +
    -   - } + - + "context"
    - 707 + + 5 +
    -   + - + "errors" +
    +
    + 6 + +
    + - + "time" +
    +
    + 7 + +
    + -
    - 708 + + 8 +
    - + - func removeBlockElement(slice []etherman.Block, s int) []etherman.Block { + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 709 + + 9 +
    - + - ret := make([]etherman.Block, 0) + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 710 + + 10 +
    - + - ret = append(ret, slice[:s]...) + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 711 + + 11 +
    - + - return append(ret, slice[s+1:]...) + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions"
    - 712 + + 12 +
    - + - } + - + commonsync "github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
    - 713 + + 13 +
    - + + - + "github.com/ethereum/go-ethereum/common" +
    +
    + 14 + +
    + - + "github.com/jackc/pgx/v4" +
    +
    + 15 + +
    + - + ) +
    +
    + 16 + +
    + -
    - 714 + + 17 +
    -   - // ProcessBlockRange process the L1 events and stores the information in the db + - + // stateProcessorSequenceBlobsInterface interface required from state
    - 715 + + 18 +
    -   - func (s *ClientSynchronizer) ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error { + - + type stateProcessorSequenceBlobsInterface interface {
    - 716 + + 19 +
    - + - // Check the latest finalized block in L1 + - + AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error
    - 717 + + 20 +
    - + - finalizedBlockNumber, err := s.etherMan.GetFinalizedBlockNumber(s.ctx) + - + GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error)
    - 718 + + 21 +
    - + - if err != nil { + - + AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error
    - 719 + + 22 +
    - + - log.Errorf("error getting finalized block number in L1. Error: %v", err) + - + GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)
    - 720 + + 23 +
    - + - return err + - + }
    - 721 + + 24 +
    - + - } + - +
    - 722 + + 25 +
    -   - // New info has to be included into the db using the state + - + type stateBlobInnerProcessor interface {
    - 723 + + 26 +
    -   - for i := range blocks { + - + ProcessBlobInner(ctx context.Context, request state.ProcessBlobInnerProcessRequest, data []byte) (*state.ProcessBlobInnerResponse, error)
    - 724 + + 27 +
    -   - // Begin db transaction + - + }
    -
     
    +
    + 28 + +
    + - +
    +
    - 733 + + 29 +
    -   - ParentHash: blocks[i].ParentHash, + - + // ProcessorSequenceBlobs processor for SequenceBlobs
    - 734 + + 30 +
    -   - ReceivedAt: blocks[i].ReceivedAt, + - + type ProcessorSequenceBlobs struct {
    - 735 + + 31 +
    -   - } + - + actions.ProcessorBase[ProcessorL1InfoTreeUpdate]
    - 736 + + 32 +
    - + - if blocks[i].BlockNumber <= finalizedBlockNumber { + - + state stateProcessorSequenceBlobsInterface
    - 737 + + 33 +
    - + - b.Checked = true + - + stateBlobInnerProcessor stateBlobInnerProcessor
    - 738 + + 34 +
    - + - } + - + timeProvider commonsync.TimeProvider
    - 739 + + 35 +
    -   - // Add block information + - + }
    - 740 + + 36 +
    -   - err = s.state.AddBlock(s.ctx, &b, dbTx) + - +
    - 741 + + 37 +
    -   - if err != nil { + - + // NewProcessorSequenceBlobs new processor for SequenceBlobs
    - 742 + + 38 +
    - + - // If any goes wrong we ensure that the state is rollbacked + - + func NewProcessorSequenceBlobs(state stateProcessorSequenceBlobsInterface, stateBlobInnerProcessor stateBlobInnerProcessor, timeProvider commonsync.TimeProvider) *ProcessorSequenceBlobs {
    - 743 + + 39 +
    -   - log.Errorf("error storing block. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err) + - + if timeProvider == nil {
    - 744 + + 40 +
    -   - rollbackErr := dbTx.Rollback(s.ctx) + - + timeProvider = &commonsync.DefaultTimeProvider{}
    - 745 + + 41 +
    -   - if rollbackErr != nil { + - + }
    -
     
    +
    + 42 + +
    + - + return &ProcessorSequenceBlobs{ +
    - 757 + + 43 +
    -   - log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId) + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1InfoTreeUpdate](
    - 758 + + 44 +
    -   - } else { + - + []etherman.EventOrder{etherman.SequenceBlobsOrder},
    - 759 + + 45 +
    -   - forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber) + - + actions.ForksIdOnlyFeijoa),
    - 760 + + 46 +
    - + - log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, ". forkId: ", forkId) + - + state: state,
    - 761 + + 47 +
    -   - } + - + stateBlobInnerProcessor: stateBlobInnerProcessor,
    - 762 + + 48 +
    -   - forkIdTyped := actions.ForkIdType(forkId) + - + timeProvider: timeProvider,
    - 763 + + 49 +
    -   - // Process event received from l1 + - + }
    -
     
    +
    + 50 + +
    + - + } +
    - 776 + + 51 +
    -   - log.Debug("Checking FlushID to commit L1 data to db") + - +
    - 777 + + 52 +
    -   - err = s.checkFlushID(dbTx) + - + // Process process event
    - 778 + + 53 +
    -   - if err != nil { + - + // - Store BlobSequence
    - 779 + + 54 +
    - + - // If any goes wrong we ensure that the state is rollbacked + - + // - Split BlobInner into Batches (executor)
    - 780 + + 55 +
    -   - log.Errorf("error checking flushID. Error: %v", err) + - + // - Store BlobInner
    - 781 + + 56 +
    -   - rollbackErr := dbTx.Rollback(s.ctx) + - + func (p *ProcessorSequenceBlobs) Process(ctx context.Context, order etherman.Order, l1Block *etherman.Block, dbTx pgx.Tx) error {
    - 782 + + 57 +
    -   - if rollbackErr != nil { + - + seqBlobs := &l1Block.SequenceBlobs[order.Pos]
    -
     
    +
    + 58 + +
    + - + previousBlobSequence, newBlobSequence, err := p.doBlobSequence(ctx, seqBlobs, l1Block, dbTx) +
    - 787 + + 59 +
    -   - } + - + if err != nil {
    - 788 + + 60 +
    -   - err = dbTx.Commit(s.ctx) + - + return err
    - 789 + + 61 +
    -   + - + } +
    +
    + 62 + +
    + - +
    +
    +
    + 63 + +
    + - + for idx := range seqBlobs.Blobs { +
    +
    + 64 + +
    + - + blobNum := newBlobSequence.FirstBlobSequenced + uint64(idx) +
    +
    + 65 + +
    + - + log.Infof("Blob %d: blobNum:%d", idx, blobNum) +
    +
    + 66 + +
    + - + err := p.doBlobInner(ctx, blobNum, &seqBlobs.Blobs[idx], newBlobSequence, previousBlobSequence, dbTx) +
    +
    + 67 + +
    + - if err != nil {
    - 790 + + 68 +
    - + - // If any goes wrong we ensure that the state is rollbacked + - + return err
    - 791 + + 69 +
    -   - log.Errorf("error committing state to store block. BlockNumber: %d, err: %v", blocks[i].BlockNumber, err) + - + }
    - 792 + + 70 +
    -   - rollbackErr := dbTx.Rollback(s.ctx) + - + }
    - 793 + + 71 +
    -   - if rollbackErr != nil { + - + return nil
    -
     
    +
    + 72 + +
    + - + } +
    - 846 + + 73 +
    -   - log.Error("error committing the resetted state. Error: ", err) + - + func (p *ProcessorSequenceBlobs) doBlobInner(ctx context.Context, blobNum uint64, blob *etherman.SequenceBlob, newBlobSequence, previousBlobSequence *state.BlobSequence, dbTx pgx.Tx) error {
    - 847 + + 74 +
    -   + - + // TODO: We have to choose which tree depending on ForkID? +
    +
    + 75 + +
    + - + leaf, err := p.state.GetL1InfoRecursiveRootLeafByIndex(ctx, blob.Params.L1InfoLeafIndex, dbTx) +
    +
    + 76 + +
    + - + if err != nil { +
    +
    + 77 + +
    + - return err
    - 848 + + 78 +
    -   + - }
    - 849 + + 79 +
    - + - if s.asyncL1BlockChecker != nil { + - +
    - 850 + + 80 +
    - + - s.asyncL1BlockChecker.OnResetState(s.ctx) + - + stateBlob, err := p.convertToStateBlobInner(blob, blobNum, newBlobSequence.BlobSequenceIndex, leaf.L1InfoTreeRoot)
    - 851 + + 81 +
    - + + - + if err != nil { +
    +
    + 82 + +
    + - + log.Errorf("Error converting blob to state: %v", err) +
    +
    + 83 + +
    + - + return err +
    +
    + 84 + +
    + - }
    - 852 + + 85 +
    -   - if s.l1SyncOrchestration != nil { + - +
    - 853 + + 86 +
    - + - lastBlock, err := s.state.GetLastBlock(s.ctx, nil) + - + processRequest, err := state.NewProcessBlobInnerProcessRequest(uint64(actions.ForkIDFeijoa), stateBlob, previousBlobSequence, *newBlobSequence)
    - 854 + + 87 +
    - + - if err != nil { + - + if err != nil {
    - 855 + + 88 +
    - + - log.Errorf("error getting last block synced from db. Error: %v", err) + - + return err
    - 856 + + 89 +
    - + - s.l1SyncOrchestration.Reset(blockNumber) + - + }
    - 857 + + 90 +
    - + - } else { + - + log.Infof("storing Blob %d: BlobInner: %v", blobNum, stateBlob)
    - 858 + + 91 +
    - + - s.l1SyncOrchestration.Reset(lastBlock.BlockNumber) + - + err = p.state.AddBlobInner(ctx, stateBlob, dbTx)
    - 859 + + 92 +
    - + - } + - + if err != nil {
    - 860 + + 93 +
    -   + - + log.Errorf("Error storing blobInner to state: %v", err) +
    +
    + 94 + +
    + - + return err +
    +
    + 95 + +
    + - }
    - 861 + + 96 + +
    + - + response, err := p.stateBlobInnerProcessor.ProcessBlobInner(ctx, *processRequest, blob.Data) +
    +
    + 97 + +
    + - + if err != nil { +
    +
    + 98 +
    -   - return nil + - + return err
    - 862 + + 99 +
    -   - } + - + }
    - 863 + + 100 +
    -   -
    + - + if response == nil {
    - 864 + + 101 +
    - + - // OnDetectedMismatchL1BlockReorg function will be called when a reorg is detected (asynchronous call) + - + return errors.New("response is nil")
    - 865 + + 102 +
    - + - func (s *ClientSynchronizer) OnDetectedMismatchL1BlockReorg() { + - + }
    - 866 + + 103 +
    - + - log.Infof("Detected Reorg in background at block (mismatch)") + - + log.Infof("Blob %d: response: %v", blobNum, response)
    - 867 + + 104 +
    - + - if s.l1SyncOrchestration != nil && s.l1SyncOrchestration.IsProducerRunning() { + - + if response.IsSuccessfulExecution() {
    - 868 + + 105 +
    - + - log.Errorf("Stop synchronizer: because L1 sync parallel aborting background process") + - + // We need to store the batches
    - 869 + + 106 +
    - + - s.l1SyncOrchestration.Abort() + - + outcomeData := response.GetSuccesfulData()
    - 870 + + 107 +
    - + - } + - + for idx := 0; idx < outcomeData.HowManyBatches(); idx++ {
    - 871 + + 108 +
    - + - } + - + log.Infof("storing Blob %d: Batch %d: Hash:%s", blobNum, idx, outcomeData.GetBatchHash(idx).String())
    - 872 + + 109 +
    - + -
    + - + // TODO: Store batch
    - 873 + + 110 +
    - + - // ExecuteReorgFromMismatchBlock function will reset the state to the block before the bad block + - + }
    - 874 + + 111 +
    - + - func (s *ClientSynchronizer) ExecuteReorgFromMismatchBlock(blockNumber uint64, reason string) error { + - + } else {
    - 875 + + 112 +
    - + - log.Info("Detected reorg at block (mismatch): ", blockNumber, " reason: ", reason, " resetting the state to block:", blockNumber-1) + - + err := response.GetUnifiedError()
    - 876 + + 113 +
    - + - s.CleanTrustedState() + - + log.Errorf("Blob %d: response is not successful: Err: %s", blobNum, err.Error())
    - 877 + + 114 +
    - + - return s.resetState(blockNumber - 1) + - + return err
    - 878 + + 115 +
    - + - } + - + }
    - 879 + + 116 +
    - + - func (s *ClientSynchronizer) detectedReorgBadBlockExecuteReset(lastEthBlockSynced *state.Block, badBlockNumber uint64) (bool, *state.Block, error) { + - +
    - 880 + + 117 +
    - + - firstBlockOK, err := s.checkReorg(lastEthBlockSynced, nil) + - + return nil
    - 881 + + 118 +
    - + - if err != nil { + - + }
    - 882 + + 119 +
    - + - log.Warnf("error checking reorgs. using badBlock detected: %d Err: %v", badBlockNumber, err) + - +
    - 883 + + 120 +
    - + - firstBlockOK = nil + - + // returns previousBlobSequence and new one
    - 884 + + 121 +
    - + - } + - + func (p *ProcessorSequenceBlobs) doBlobSequence(ctx context.Context,
    - 885 + + 122 +
    - + - if firstBlockOK != nil && firstBlockOK.BlockNumber >= badBlockNumber { + - + incommingSequenceBlobs *etherman.SequenceBlobs, l1Block *etherman.Block, dbTx pgx.Tx) (*state.BlobSequence, *state.BlobSequence, error) {
    - 886 + + 123 +
    - + - log.Warnf("Reorg detected firstBlockOk: %d. But oldest bad block detected: %d", firstBlockOK.BlockNumber, badBlockNumber) + - + previousBlobSequence, err := p.state.GetLastBlobSequence(ctx, dbTx)
    - 887 + + 124 +
    - + - firstBlockOK = nil + - + if err != nil {
    - 888 + + 125 +
    - + - } + - + return nil, nil, err
    - 889 + + 126 +
    - + - // We already known a bad block, reset from there + - + }
    - 890 + + 127 +
    - + - if firstBlockOK == nil { + - + blobSequenceIndex := p.calculateBlobSequenceIndex(previousBlobSequence)
    - 891 + + 128 +
    - + - firstBlockOK, err = s.state.GetPreviousBlockToBlockNumber(s.ctx, badBlockNumber, nil) + - + newBlobSequence := p.convertToStateBlobSequence(incommingSequenceBlobs, blobSequenceIndex, l1Block.ReceivedAt, p.timeProvider.Now(), l1Block.BlockNumber)
    - 892 + + 129 +
    - + - if err != nil { + - + log.Infof("storing BlobSequence: %v", newBlobSequence)
    - 893 + + 130 +
    - + - log.Errorf("error getting previous block %d from db. Can't execute REORG. Error: %v", badBlockNumber, err) + - + err = p.state.AddBlobSequence(ctx, newBlobSequence, dbTx)
    - 894 + + 131 +
    - + - return false, lastEthBlockSynced, err + - + if err != nil {
    - 895 + + 132 +
    - + - } + - + return nil, nil, err
    - 896 + + 133 +
    - + + - }
    - 897 + + 134 +
    - + - newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, firstBlockOK) + - + return previousBlobSequence, newBlobSequence, nil
    - 898 + + 135 +
    - + - if err != nil { + - + }
    - 899 + + 136 +
    - + - log.Errorf("error executing reorg. Retrying... Err: %v", err) + - +
    - 900 + + 137 +
    - + - return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) + - + func (p *ProcessorSequenceBlobs) calculateBlobSequenceIndex(previousBlobSequence *state.BlobSequence) uint64 {
    - 901 + + 138 +
    - + - } + - + nextIndex := uint64(1)
    - 902 + + 139 +
    - + - return true, newFirstBlock, nil + - + if previousBlobSequence != nil {
    - 903 + + 140 +
    - + - } + - + nextIndex = previousBlobSequence.BlobSequenceIndex + 1
    - 904 + + 141 +
    - + -
    + - + }
    - 905 + + 142 +
    - + - // checkReorgAndExecuteReset function will check if there is a reorg and execute the reset + - + return nextIndex
    - 906 + + 143 +
    - + - // returns true is reset have been done + - + }
    - 907 + + 144 +
    - + - func (s *ClientSynchronizer) checkReorgAndExecuteReset(lastEthBlockSynced *state.Block) (bool, *state.Block, error) { + - +
    - 908 + + 145 +
    - + - var err error + - + func (p *ProcessorSequenceBlobs) convertToStateBlobInner(blobInner *etherman.SequenceBlob, blobInnerNum uint64, blobSequenceIndex uint64, l1InfoTreeRoot common.Hash) (*state.BlobInner, error) {
    - 909 + + 146 +
    - + -
    + - + res := &state.BlobInner{
    - 910 + + 147 +
    - + - block, err := s.checkReorg(lastEthBlockSynced, nil) + - + BlobSequenceIndex: blobSequenceIndex,
    - 911 + + 148 +
    - + - if err != nil { + - + BlobInnerNum: blobInnerNum, // ho trect del previousBlobSequence
    - 912 + + 149 +
    - + - log.Errorf("error checking reorgs. Retrying... Err: %v", err) + - + Type: p.convertBlobType(blobInner.Type),
    - 913 + + 150 +
    - + - return false, lastEthBlockSynced, fmt.Errorf("error checking reorgs") + - + MaxSequenceTimestamp: time.Unix(int64(blobInner.Params.MaxSequenceTimestamp), 0),
    - 914 + + 151 +
    - + - } + - + ZkGasLimit: blobInner.Params.ZkGasLimit,
    - 915 + + 152 +
    - + - if block != nil { + - + L1InfoLeafIndex: blobInner.Params.L1InfoLeafIndex,
    - 916 + + 153 +
    - + - newFirstBlock, err := s.executeReorgFromFirstValidBlock(lastEthBlockSynced, block) + - + L1InfoTreeRoot: l1InfoTreeRoot,
    - 917 + + 154 +
    - + - if err != nil { + - + }
    - 918 + + 155 +
    - + - log.Errorf("error executing reorg. Retrying... Err: %v", err) + - + if res.Type == state.TypeBlobTransaction {
    - 919 + + 156 +
    - + - return false, lastEthBlockSynced, fmt.Errorf("error executing reorg. Err: %w", err) + - + if blobInner.BlobBlobTypeParams == nil {
    - 920 + + 157 +
    - + - } + - + return nil, errors.New("BlobBlobTypeParams from etherman is required for BlobTransaction")
    - 921 + + 158 +
    - + - return true, newFirstBlock, nil + - + }
    - 922 + + 159 +
    - + - } + - + res.BlobBlobTypeParams = &state.BlobBlobTypeParams{
    - 923 + + 160 +
    - + -
    + - + BlobIndex: blobInner.BlobBlobTypeParams.BlobIndex.Uint64(),
    - 924 + + 161 +
    - + - return false, lastEthBlockSynced, nil + - + Z: blobInner.BlobBlobTypeParams.Z,
    - 925 + + 162 +
    - + - } + - + Y: blobInner.BlobBlobTypeParams.Y,
    - 926 + + 163 +
    - + -
    + - + Commitment: blobInner.BlobBlobTypeParams.Commitment,
    - 927 + + 164 +
    - + - func (s *ClientSynchronizer) executeReorgFromFirstValidBlock(lastEthBlockSynced *state.Block, firstValidBlock *state.Block) (*state.Block, error) { + - + Proof: blobInner.BlobBlobTypeParams.Proof,
    - 928 + + 165 +
    - + - log.Infof("reorg detected. Resetting the state from block %v to block %v", lastEthBlockSynced.BlockNumber, firstValidBlock.BlockNumber) + - + }
    - 929 + + 166 +
    - + - s.CleanTrustedState() + - + }
    - 930 + + 167 +
    - + - err := s.resetState(firstValidBlock.BlockNumber) + - + return res, nil
    - 931 + + 168 +
    - + - if err != nil { + - + }
    - 932 + + 169 +
    - + - log.Errorf("error resetting the state to a previous block. Retrying... Err: %s", err.Error()) + - +
    - 933 + + 170 +
    - + - return nil, fmt.Errorf("error resetting the state to a previous block. Err: %w", err) + - + func (p *ProcessorSequenceBlobs) convertBlobType(value etherman.BlobType) state.BlobType {
    - 934 + + 171 +
    - + - } + - + return state.BlobType(value)
    - 935 + + 172 +
    - + - newLastBlock, err := s.state.GetLastBlock(s.ctx, nil) + - + }
    - 936 + + 173 +
    - + - if err != nil { + - +
    - 937 + + 174 +
    - + - log.Warnf("error getting last block synced from db, returning expected block %d. Error: %v", firstValidBlock.BlockNumber, err) + - + func (p *ProcessorSequenceBlobs) convertToStateBlobSequence(etherSeqBlobs *etherman.SequenceBlobs,
    - 938 + + 175 +
    - + - return firstValidBlock, nil + - + nextIndex uint64,
    - 939 + + 176 +
    - + - } + - + createAt time.Time,
    - 940 + + 177 +
    - + - if newLastBlock.BlockNumber != firstValidBlock.BlockNumber { + - + receviedAt time.Time,
    - 941 + + 178 +
    - + - log.Warnf("Doesnt match LastBlock on State and expecting one after a resetState. The block in state is %d and the expected block is %d", newLastBlock.BlockNumber, + - + l1BlockNumber uint64) *state.BlobSequence {
    - 942 + + 179 +
    - + - firstValidBlock.BlockNumber) + - + return &state.BlobSequence{
    - 943 + + 180 +
    - + - return firstValidBlock, nil + - + BlobSequenceIndex: nextIndex,
    - 944 + + 181 +
    - + - } + - + L2Coinbase: etherSeqBlobs.L2Coinbase,
    - 945 + + 182 +
    - + - return newLastBlock, nil + - + FirstBlobSequenced: etherSeqBlobs.EventData.LastBlobSequenced - uint64(len(etherSeqBlobs.Blobs)),
    - 946 + + 183 +
    - + - } + - + LastBlobSequenced: etherSeqBlobs.EventData.LastBlobSequenced,
    - 947 + + 184 +
    - + -
    + - + FinalAccInputHash: etherSeqBlobs.FinalAccInputHash,
    - 948 + + 185 +
    - + - func (s *ClientSynchronizer) checkReorg(latestBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { + - + CreateAt: createAt,
    - 949 + + 186 +
    - + - if latestBlock == nil { + - + ReceivedAt: receviedAt,
    - 950 + + 187 +
    - + - err := fmt.Errorf("lastEthBlockSynced is nil calling checkReorgAndExecuteReset") + - + BlockNumber: l1BlockNumber,
    - 951 + + 188 +
    - + - log.Errorf("%s, it never have to happens", err.Error()) + - + }
    - 952 + + 189 +
    - + - return nil, err + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    - 953 + + -
    - + - } +
    +
    +   +
    - 954 + + -
    - + - block, errReturnedReorgFunction := s.newCheckReorg(latestBlock, syncedBlock) +
    +
    +   +
    - 955 + + -
    - + - if s.asyncL1BlockChecker != nil { +
    +
    +   +
    - 956 + + -
    - + - return s.asyncL1BlockChecker.CheckReorgWrapper(s.ctx, block, errReturnedReorgFunction) +
    +
    +   +
    - 957 + + -
    - + - } +
    +
    +   +
    - 958 + + -
    - + - return block, errReturnedReorgFunction +
    +
    +   +
    - 959 + + -
    - + - } +
    +
    +   +
    - 960 + + -
    - + +
    +
    +  
    - 961 + + -
    +
    +
      - /* +
    - 962 + + -
    +
    +
      - This function will check if there is a reorg. +
    - 963 + + -
    +
    +
      - As input param needs the last ethereum block synced. Retrieve the block info from the blockchain +
    -
     
    +
    + + +
    +   +
    +
    - 966 + + -
    +
    +
      - must be reverted. Then, check the previous ethereum block synced, get block info from the blockchain and check +
    - 967 + + -
    +
    +
      - hash and has parent. This operation has to be done until a match is found. +
    - 968 + + -
    +
    +
      - */ +
    - 969 + + -
    - + +
    +
    +  
    - 970 + + -
    - + - func (s *ClientSynchronizer) newCheckReorg(latestStoredBlock *state.Block, syncedBlock *etherman.Block) (*state.Block, error) { +
    +
    +   +
    - 971 + + -
    +
    +
      - // This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info. +
    - 972 + + -
    - + - latestStoredEthBlock := *latestStoredBlock +
    +
    +   +
    - 973 + + -
    - + - reorgedBlock := *latestStoredBlock +
    +
    +   +
    - 974 + + -
    +
    +
      - var depth uint64 +
    - 975 + + -
    - + - block := syncedBlock +
    +
    +   +
    - 976 + + -
    +
    +
      - for { +
    - 977 + + -
    - + - if block == nil { +
    +
    +   +
    - 978 + + -
    - + - log.Infof("[checkReorg function] Checking Block %d in L1", reorgedBlock.BlockNumber) +
    +
    +   +
    - 979 + + -
    - + - b, err := s.etherMan.EthBlockByNumber(s.ctx, reorgedBlock.BlockNumber) +
    +
    +   +
    - 980 + + -
    - + - if err != nil { +
    +
    +   +
    - 981 + + -
    - + - log.Errorf("error getting latest block synced from blockchain. Block: %d, error: %v", reorgedBlock.BlockNumber, err) +
    +
    +   +
    - 982 + + -
    - + - return nil, err +
    +
    +   +
    - 983 + + -
    - + - } +
    +
    +   +
    - 984 + + -
    - + - block = &etherman.Block{ +
    +
    +   +
    - 985 + + -
    - + - BlockNumber: b.Number().Uint64(), +
    +
    +   +
    - 986 + + -
    - + - BlockHash: b.Hash(), +
    +
    +   +
    - 987 + + -
    - + - ParentHash: b.ParentHash(), +
    +
    +   +
    - 988 + + -
    - + - } +
    +
    +   +
    - 989 + + -
    - + - if block.BlockNumber != reorgedBlock.BlockNumber { +
    +
    +   +
    - 990 + + -
    - + - err := fmt.Errorf("wrong ethereum block retrieved from blockchain. Block numbers don't match. BlockNumber stored: %d. BlockNumber retrieved: %d", +
    +
    +   +
    - 991 + + -
    - + - reorgedBlock.BlockNumber, block.BlockNumber) +
    +
    +   +
    - 992 + + -
    - + - log.Error("error: ", err) +
    +
    +   +
    - 993 + + -
    - + - return nil, err +
    +
    +   +
    - 994 + + -
    - + - } +
    +
    +   +
    - 995 + + -
    - + - } else { +
    +
    +   +
    - 996 + + -
    - + - log.Infof("[checkReorg function] Using block %d from GetRollupInfoByBlockRange", block.BlockNumber) +
    +
    +   +
    - 997 + + -
    +
    +
      - } +
    - 998 + + -
    - + - log.Infof("[checkReorg function] BlockNumber: %d BlockHash got from L1 provider: %s", block.BlockNumber, block.BlockHash.String()) +
    +
    +   +
    - 999 + + -
    - + - log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String()) +
    +
    +   +
    - 1000 + + -
    - + +
    +
    +  
    - 1001 + + -
    +
    +
      - // Compare hashes +
    - 1002 + + -
    - + - if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupBlockNumber { +
    +
    +   +
    - 1003 + + -
    - + - log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) +
    +
    +   +
    - 1004 + + -
    - + - log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber) +
    +
    +   +
    - 1005 + + -
    - + - log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash) +
    +
    +   +
    - 1006 + + -
    - + - log.Debug("[checkReorg function] => latestBlockHashParent: ", reorgedBlock.ParentHash) +
    +
    +   +
    - 1007 + + -
    - + - log.Debug("[checkReorg function] => BlockNumber: ", reorgedBlock.BlockNumber, block.BlockNumber) +
    +
    +   +
    - 1008 + + -
    - + - log.Debug("[checkReorg function] => BlockHash: ", block.BlockHash) +
    +
    +   +
    - 1009 + + -
    - + - log.Debug("[checkReorg function] => BlockHashParent: ", block.ParentHash) +
    +
    +   +
    - 1010 + + -
    +
    +
      - depth++ +
    - 1011 + + -
    +
    +
      - log.Debug("REORG: Looking for the latest correct ethereum block. Depth: ", depth) +
    - 1012 + + -
    +
    +
      - // Reorg detected. Getting previous block +
    -
     
    -
    - 1015 + + -
    +
    +
      - log.Errorf("error creating db transaction to get prevoius blocks") +
    - 1016 + + -
    +
    +
      - return nil, err +
    - 1017 + + -
    +
    +
      - } +
    - 1018 + + -
    - + - lb, err := s.state.GetPreviousBlock(s.ctx, depth, dbTx) +
    +
    +   +
    - 1019 + + -
    +
    +
      - errC := dbTx.Commit(s.ctx) +
    - 1020 + + -
    +
    +
      - if errC != nil { +
    - 1021 + + -
    +
    +
      - log.Errorf("error committing dbTx, err: %v", errC) +
    -
     
    -
    - 1028 + + -
    +
    +
      - return nil, errC +
    - 1029 + + -
    +
    +
      - } +
    - 1030 + + -
    +
    +
      - if errors.Is(err, state.ErrNotFound) { +
    - 1031 + + -
    - + - log.Warn("error checking reorg: previous block not found in db. Reorg reached the genesis block: %v.Genesis block can't be reorged, using genesis block as starting point. Error: %v", reorgedBlock, err) +
    +
    +   +
    - 1032 + + -
    - + - return &reorgedBlock, nil +
    +
    +   +
    - 1033 + + -
    +
    +
      - } else if err != nil { +
    - 1034 + + -
    - + - log.Error("error getting previousBlock from db. Error: ", err) +
    +
    +   +
    - 1035 + + -
    +
    +
      - return nil, err +
    - 1036 + + -
    +
    +
      - } +
    - 1037 + + -
    - + - reorgedBlock = *lb +
    +
    +   +
    - 1038 + + -
    +
    +
      - } else { +
    - 1039 + + -
    - + - log.Debugf("checkReorg: Block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash) +
    +
    +   +
    - 1040 + + -
    +
    +
      - break +
    - 1041 + + -
    +
    +
      - } +
    - 1042 + + -
    - + - // This forces to get the block from L1 in the next iteration of the loop +
    +
    +   +
    - 1043 + + -
    - + - block = nil +
    +
    +   +
    - 1044 + + -
    +
    +
      - } +
    - 1045 + + -
    - + - if latestStoredEthBlock.BlockHash != reorgedBlock.BlockHash { +
    +
    +   +
    - 1046 + + -
    - + - latestStoredBlock = &reorgedBlock +
    +
    +   +
    - 1047 + + -
    - + - log.Info("Reorg detected in block: ", latestStoredEthBlock.BlockNumber, " last block OK: ", latestStoredBlock.BlockNumber) +
    +
    +   +
    - 1048 + + -
    - + - return latestStoredBlock, nil +
    +
    +   +
    - 1049 + + -
    +
    +
      - } +
    - 1050 + + -
    - + - log.Debugf("No reorg detected in block: %d. BlockHash: %s", latestStoredEthBlock.BlockNumber, latestStoredEthBlock.BlockHash.String()) +
    +
    +   +
    - 1051 + + -
    +
    +
      - return nil, nil +
    - 1052 + + -
    +
    +
      - } +
    - 1053 + + -
    +
    +
     
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - @@ -194949,68 +275087,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -195024,128 +275167,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - @@ -195159,278 +275307,263 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -195474,173 +275607,163 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -195674,53 +275797,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - @@ -195734,1263 +275857,1286 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -2,6 +2,7 @@
    -
    - 2 + + -
    +
    +
     
    - 3 + + -
    +
    +
      - import ( +
    - 4 + + -
    +
    +
      - context "context" +
    - 5 + + -
    +
    +
      - "math/big" +
    - 6 + + -
    +
    +
      - "testing" +
    - 7 + + -
    +
    +
      - "time" +
    -
    @@ -18,6 +19,7 @@
    +
    + + +
    +   +
    +
    - 18 + + -
    +
    +
      - syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" +
    - 19 + + -
    +
    +
      - "github.com/ethereum/go-ethereum/common" +
    - 20 + + -
    +
    +
      - ethTypes "github.com/ethereum/go-ethereum/core/types" +
    - 21 + + -
    +
    +
      - "github.com/jackc/pgx/v4" +
    - 22 + + -
    +
    +
      - "github.com/stretchr/testify/assert" +
    - 23 + + -
    +
    +
      - "github.com/stretchr/testify/mock" +
    -
    @@ -32,12 +34,13 @@
    +
    + + +
    +   +
    +
    - 32 + + -
    +
    +
      - ) +
    - 33 + + -
    +
    +
     
    - 34 + + -
    +
    +
      - type mocks struct { +
    - 35 + + -
    - - - Etherman *mock_syncinterfaces.EthermanFullInterface +
    +
    +   +
    - 36 + + -
    - - - State *mock_syncinterfaces.StateFullInterface +
    +
    +   +
    - 37 + + -
    - - - Pool *mock_syncinterfaces.PoolInterface +
    +
    +   +
    - 38 + + -
    - - - EthTxManager *mock_syncinterfaces.EthTxManager +
    +
    +   +
    - 39 + + -
    - - - DbTx *syncMocks.DbTxMock +
    +
    +   +
    - 40 + + -
    - - - ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface +
    +
    +   +
    - 41 + + -
    +
    +
      - //EventLog *eventLogMock +
    - 42 + + -
    +
    +
      - } +
    - 43 + + -
    +
    +
     
    -
    @@ -47,7 +50,7 @@
    -
    - 47 + + -
    +
    +
      - func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { +
    - 48 + + -
    +
    +
      - genesis, cfg, m := setupGenericTest(t) +
    - 49 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 50 + + -
    - - - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    +   +
    - 51 + + -
    +
    +
      - require.NoError(t, err) +
    - 52 + + -
    +
    +
      - sync, ok := syncInterface.(*ClientSynchronizer) +
    - 53 + + -
    +
    +
      - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    -
    @@ -87,7 +90,7 @@
    -
    - 87 + + -
    +
    +
      - func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { +
    - 88 + + -
    +
    +
      - genesis, cfg, m := setupGenericTest(t) +
    - 89 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 90 + + -
    - - - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, *genesis, *cfg, false) +
    +
    +   +
    - 91 + + -
    +
    +
      - require.NoError(t, err) +
    - 92 + + -
    +
    +
      - sync, ok := syncInterface.(*ClientSynchronizer) +
    - 93 + + -
    +
    +
      - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") +
    -
    @@ -119,12 +122,16 @@
    -
    - 119 + + -
    +
    +
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    - 120 + + -
    +
    +
      - func TestForcedBatchEtrog(t *testing.T) { +
    - 121 + + -
    +
    +
      - genesis := state.Genesis{ +
    - 122 + + -
    - - - BlockNumber: uint64(123456), +
    +
    +   +
    - 123 + + -
    +
    +
      - } +
    - 124 + + -
    +
    +
      - cfg := Config{ +
    - 125 + + -
    +
    +
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    - 126 + + -
    +
    +
      - SyncChunkSize: 10, +
    - 127 + + -
    +
    +
      - L1SynchronizationMode: SequentialMode, +
    - 128 + + -
    +
    +
      - } +
    - 129 + + -
    +
    +
     
    - 130 + + -
    +
    +
      - m := mocks{ +
    -
    @@ -135,7 +142,7 @@
    -
    - 135 + + -
    +
    +
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    - 136 + + -
    +
    +
      - } +
    - 137 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 138 + + -
    - - - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) +
    +
    +   +
    - 139 + + -
    +
    +
      - require.NoError(t, err) +
    - 140 + + -
    +
    +
     
    - 141 + + -
    +
    +
      - // state preparation +
    -
    @@ -151,17 +158,21 @@
    -
    - 151 + + -
    +
    +
      - Run(func(args mock.Arguments) { +
    - 152 + + -
    +
    +
      - ctx := args[0].(context.Context) +
    - 153 + + -
    +
    +
      - parentHash := common.HexToHash("0x111") +
    - 154 + + -
    - - - ethHeader := &ethTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} +
    +
    +   +
    - 155 + + -
    - - - ethBlock := ethTypes.NewBlockWithHeader(ethHeader) +
    +
    +   +
    - 156 + + -
    - - - lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} +
    +
    +   +
    - 157 + + -
    +
    +
     
    - 158 + + -
    +
    +
      - m.State. +
    - 159 + + -
    +
    +
      - On("GetForkIDByBatchNumber", mock.Anything). +
    - 160 + + -
    +
    +
      - Return(uint64(7), nil). +
    - 161 + + -
    +
    +
      - Maybe() +
    - 162 + + -
    +
    +
      - m.State. +
    - 163 + + -
    +
    +
      - On("GetLastBlock", ctx, m.DbTx). +
    - 164 + + -
    - - - Return(lastBlock, nil). +
    +
    +   +
    - 165 + + -
    +
    +
      - Once() +
    - 166 + + -
    +
    +
     
    - 167 + + -
    +
    +
      - m.State. +
    -
    @@ -197,14 +208,14 @@
    -
    - 197 + + -
    +
    +
      - Return(nil) +
    - 198 + + -
    +
    +
     
    - 199 + + -
    +
    +
      - m.Etherman. +
    - 200 + + -
    - - - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). +
    +
    +   +
    - 201 + + -
    - - - Return(ethBlock, nil). +
    +
    +   +
    - 202 + + -
    - - - Once() +
    +
    +   +
    - 203 + + -
    +
    +
     
    - 204 + + -
    - - - var n *big.Int +
    +
    +   +
    - 205 + + -
    +
    +
      - m.Etherman. +
    - 206 + + -
    +
    +
      - On("HeaderByNumber", mock.Anything, n). +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/feijoa/processor_l1_sequence_blobs_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + + + +
    +
    @@ -1,102 +0,0 @@
    - 207 + + 1 +
    - - Return(ethHeader, nil). + package feijoa_test
    - 208 + + 2 +
    -   - Once() + - +
    - 209 + + 3 +
    -   -
    + - + import (
    - 210 + + 4 +
    -   - t := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + - + "context"
    -
    @@ -223,7 +234,7 @@
    +
    + 5 + +
    + - + "os" +
    - 223 + + 6 +
    -   - } + - + "testing"
    - 224 + + 7 +
    -   + -
    - 225 + + 8 +
    -   - forceb := []etherman.ForcedBatch{{ + - + "github.com/0xPolygonHermez/zkevm-node/db"
    - 226 + + 9 +
    - - BlockNumber: lastBlock.BlockNumber, + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 227 + + 10 +
    -   - ForcedBatchNumber: 1, + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 228 + + 11 +
    -   - Sequencer: sequencedBatch.Coinbase, + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 229 + + 12 +
    -   - GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + "github.com/0xPolygonHermez/zkevm-node/state/pgstatestorage"
    -
    @@ -231,16 +242,21 @@
    -
    - 231 + + 13 +
    -   - ForcedAt: time.Unix(int64(sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), + - + "github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
    - 232 + + 14 +
    -   - }} + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions/feijoa"
    - 233 + + 15 +
    -   -
    + - + "github.com/0xPolygonHermez/zkevm-node/test/dbutils"
    - 234 + + 16 +
    - - ethermanBlock := etherman.Block{ + "github.com/ethereum/go-ethereum/common"
    - + + 17 -
    -   -
    +
    +
    + - + "github.com/jackc/pgconn"
    - + + 18 -
    -   -
    +
    +
    + - + "github.com/jackc/pgx/v4"
    - + + 19 -
    -   -
    +
    +
    + - + "github.com/stretchr/testify/require"
    - + + 20 -
    -   -
    +
    +
    + - + )
    - + + 21 -
    -   +
    +
    + -
    - 235 + + 22 +
    -   - BlockNumber: 1, + - + // This test is a exploratory test used to develop. It use a sequencedBlob on Sepolia
    - 236 + + 23 +
    -   - ReceivedAt: t, + - + // It need Database, a prover >7.x and L1 client
    - 237 + + 24 +
    - - BlockHash: ethBlock.Hash(), + // TODO: Remove this test or convert to a test than can be executed
    - 238 + + 25 +
    -   - SequencedBatches: [][]etherman.SequencedBatch{{sequencedBatch}}, + - + func TestProcessASequenceBlobUsingCallDataFromSepolia(t *testing.T) {
    - 239 + + 26 +
    -   - ForcedBatches: forceb, + - + l1url := os.Getenv("ZKEVM_NODE_ETHERMAN_URL")
    - 240 + + 27 +
    -   - } + - + consensusl1url := os.Getenv("ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL")
    - 241 + + 28 +
    - - blocks := []etherman.Block{ethermanBlock} + if l1url == "" || consensusl1url == "" {
    - 242 + + 29 +
    -   - order := map[common.Hash][]etherman.Order{ + - + // You can set un vscode editing setings.json
    - 243 + + 30 +
    - - ethBlock.Hash(): { + // "go.testEnvVars": {
    - 244 + + 31 +
    -   - { + - + // "ZKEVM_NODE_ETHERMAN_URL": "url1",
    - 245 + + 32 +
    -   - Name: etherman.ForcedBatchesOrder, + - + // "ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL": "url2",
    - 246 + + 33 +
    -   - Pos: 0, + - + //}
    -
    @@ -252,9 +268,11 @@
    -
    - 252 + + 34 +
    -   - }, + - + t.Skip("ZKEVM_NODE_ETHERMAN_URL or ZKEVM_NODE_ETHERMAN_CONSENSUSL1URL not set")
    - 253 + + 35 +
    -   - } + - + }
    - 254 + + 36 +
    -   -
    + - + cfg := etherman.Config{
    - 255 + + 37 +
    - - fromBlock := ethBlock.NumberU64() + 1 + URL: l1url,
    - 256 + + 38 +
    -   - toBlock := fromBlock + cfg.SyncChunkSize + - + ConsensusL1URL: consensusl1url,
    - 257 + + 39 +
    - -
    + }
    - + + 40 -
    -   -
    +
    +
    + - + l1Config := etherman.L1Config{
    - + + 41 -
    -   -
    +
    +
    + - + L1ChainID: 11155111,
    - 258 + + 42 +
    -   - m.Etherman. + - + //ZkEVMAddr: common.HexToAddress("0x31A6ae85297DD0EeBD66D7556941c33Bd41d565C"),
    - 259 + + 43 +
    -   - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + - + //ZkEVMAddr: common.HexToAddress("0xD23C761025306cF5038D74FEEb077Cf66DE134DA"),
    - 260 + + 44 +
    -   - Return(blocks, order, nil). + - + ZkEVMAddr: common.HexToAddress("0x5e5880098741d1fbd38eaaac51c4215f80f92d27"),
    -
    @@ -270,10 +288,11 @@
    -
    - 270 + + 45 +
    -   - Once() + - + RollupManagerAddr: common.HexToAddress("0x9fB0B4A5d4d60aaCfa8DC20B8DF5528Ab26848d3"),
    - 271 + + 46 +
    -   -
    + - + GlobalExitRootManagerAddr: common.HexToAddress("0x76216E45Bdd20022eEcC07999e50228d7829534B"),
    - 272 + + 47 +
    -   - stateBlock := &state.Block{ + - + }
    - 273 + + 48 +
    - - BlockNumber: ethermanBlock.BlockNumber, + eth, err := etherman.NewClient(cfg, l1Config)
    - 274 + + 49 +
    - - BlockHash: ethermanBlock.BlockHash, + require.NoError(t, err)
    - 275 + + 50 +
    - - ParentHash: ethermanBlock.ParentHash, + ctx := context.Background()
    - 276 + + 51 +
    - - ReceivedAt: ethermanBlock.ReceivedAt, + //toBlock := uint64(5611933)
    - + + 52 -
    -   -
    +
    +
    + - + //toBlock := uint64(5704000)
    - 277 + + 53 +
    -   - } + - + toBlock := uint64(5760696)
    - 278 + + 54 +
    -   -
    + - + blocks, orders, err := eth.GetRollupInfoByBlockRange(ctx, toBlock, &toBlock)
    - 279 + + 55 +
    -   - executionResponse := executor.ProcessBatchResponseV2{ + - + require.NoError(t, err)
    -
    @@ -285,13 +304,18 @@
    -
    - 285 + + 56 +
    -   - Return(&executionResponse, nil). + - + require.Equal(t, 1, len(blocks))
    - 286 + + 57 +
    -   - Times(1) + - + require.Equal(t, 1, len(orders))
    - 287 + + 58 +
    -   + -
    - + + 59 -
    -   -
    +
    +
    + - + realState := createRealState(t)
    - + + 60 -
    -   -
    +
    +
    + - + err = addBlock(ctx, &blocks[0], realState, nil)
    - + + 61 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 62 -
    -   -
    +
    +
    + - + log.Error(err)
    - + + 63 -
    -   -
    +
    +
    + - + }
    - 288 + + 64 +
    -   - m.State. + - + sut := feijoa.NewProcessorSequenceBlobs(realState, realState, nil)
    - 289 + + 65 +
    -   - On("AddBlock", ctx, stateBlock, m.DbTx). + - + err = sut.Process(ctx, orders[blocks[0].BlockHash][0], &blocks[0], nil)
    - 290 + + 66 +
    -   - Return(nil). + - + require.NoError(t, err)
    - 291 + + 67 +
    -   - Once() + - + }
    - 292 + + 68 +
    -   + -
    - 293 + + 69 +
    -   - fb := []state.ForcedBatch{{ + - + const UniqueViolationErr = "23505"
    - 294 + + 70 +
    - - BlockNumber: lastBlock.BlockNumber, +
    - 295 + + 71 +
    -   - ForcedBatchNumber: 1, + - + func addBlock(ctx context.Context, block *etherman.Block, storage *state.State, dbTx pgx.Tx) error {
    - 296 + + 72 +
    -   - Sequencer: sequencedBatch.Coinbase, + - + b := state.Block{
    - 297 + + 73 +
    -   - GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + BlockNumber: block.BlockNumber,
    -
    @@ -326,7 +350,7 @@
    -
    - 326 + + 74 +
    -   - BatchNumber: sequencedBatch.BatchNumber, + - + BlockHash: block.BlockHash,
    - 327 + + 75 +
    -   - TxHash: sequencedBatch.TxHash, + - + ParentHash: block.ParentHash,
    - 328 + + 76 +
    -   - Coinbase: sequencedBatch.Coinbase, + - + ReceivedAt: block.ReceivedAt,
    - 329 + + 77 +
    - - BlockNumber: ethermanBlock.BlockNumber, + }
    - 330 + + 78 +
    -   - TimestampBatchEtrog: &t, + - + // Add block information
    - 331 + + 79 +
    -   - L1InfoRoot: &forcedGER, + - + err := storage.AddBlock(ctx, &b, dbTx)
    - 332 + + 80 +
    -   - } + - +
    -
    @@ -372,12 +396,13 @@
    -
    - 372 + + 81 +
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + - + if pgerr, ok := err.(*pgconn.PgError); ok && pgerr.Code == UniqueViolationErr {
    - 373 + + 82 +
    -   - func TestSequenceForcedBatchIncaberry(t *testing.T) { + - + return nil
    - 374 + + 83 +
    -   - genesis := state.Genesis{ + - + }
    - 375 + + 84 +
    - - BlockNumber: uint64(123456), + return err
    - 376 + + 85 +
    -   - } + - + }
    - 377 + + 86 +
    -   - cfg := Config{ + - +
    - 378 + + 87 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + - + func createRealState(t *testing.T) *state.State {
    - 379 + + 88 +
    -   - SyncChunkSize: 10, + - + stateDBCfg := dbutils.NewStateConfigFromEnv()
    - 380 + + 89 +
    -   - L1SynchronizationMode: SequentialMode, + - + stateCfg := state.Config{}
    - + + 90 -
    -   -
    +
    +
    + - + err := db.RunMigrationsUp(stateDBCfg, db.StateMigrationName)
    - 381 + + 91 +
    -   - } + - + require.NoError(t, err)
    - 382 + + 92 +
    -   -
    + - + stateSqlDB, err := db.NewSQLDB(stateDBCfg)
    - 383 + + 93 +
    -   - m := mocks{ + - + stateDb := pgstatestorage.NewPostgresStorage(stateCfg, stateSqlDB)
    -
    @@ -388,7 +413,7 @@
    +
    + 94 + +
    + - + executorConfig := executor.Config{ +
    - 388 + + 95 +
    -   - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + - + URI: "localhost:50071",
    - 389 + + 96 +
    -   - } + - + MaxGRPCMessageSize: 1024 * 1024 * 1024,
    - 390 + + 97 +
    -   - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + - + }
    - 391 + + 98 +
    - - sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, nil, genesis, cfg, false) + executorClient, _, _ := executor.NewExecutorClient(context.TODO(), executorConfig)
    - 392 + + 99 +
    -   + - require.NoError(t, err)
    - 393 + + 100 +
    -   + -
    - 394 + + 101 +
    -   - // state preparation + - + return state.NewState(stateCfg, stateDb, executorClient, nil, nil, nil, nil)
    + 102 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + - - - - - - - - - - - - @@ -197024,186 +277170,181 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -197539,157 +277670,112 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -197714,51 +277800,51 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -197924,66 +277970,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -398,21 +423,20 @@
    +
     
    - 398 + + -
    +
    +
      - Run(func(args mock.Arguments) { +
    - 399 + + -
    +
    +
      - ctx := args[0].(context.Context) +
    - 400 + + -
    +
    +
      - parentHash := common.HexToHash("0x111") +
    - 401 + + -
    - - - ethHeader := &ethTypes.Header{Number: big.NewInt(1), ParentHash: parentHash} +
    +
    +   +
    - 402 + + -
    - - - ethBlock := ethTypes.NewBlockWithHeader(ethHeader) +
    +
    +   +
    - 403 + + -
    - - - lastBlock := &state.Block{BlockHash: ethBlock.Hash(), BlockNumber: ethBlock.Number().Uint64()} +
    +
    +   +
    - 404 + + -
    +
    +
      - m.State. +
    - 405 + + -
    +
    +
      - On("GetForkIDByBatchNumber", mock.Anything). +
    - 406 + + -
    +
    +
      - Return(uint64(1), nil). +
    - 407 + + -
    +
    +
      - Maybe() +
    - 408 + + -
    - - - m.State. +
    +
    +   +
    - 409 + + -
    - - - On("GetForkIDByBlockNumber", mock.Anything). +
    +
    +   +
    - 410 + + -
    - - - Return(uint64(1), nil). +
    +
    +   +
    - 411 + + -
    - - - Maybe() +
    +
    +   +
    - 412 + + -
    +
    +
     
    - 413 + + -
    +
    +
      - m.State. +
    - 414 + + -
    +
    +
      - On("GetLastBlock", ctx, m.DbTx). +
    - 415 + + -
    - - - Return(lastBlock, nil). +
    +
    +   +
    - 416 + + -
    +
    +
      - Once() +
    - 417 + + -
    +
    +
     
    - 418 + + -
    +
    +
      - m.State. +
    -
    @@ -450,15 +474,15 @@
    -
    - 450 + + -
    +
    +
      - Return(nil). +
    - 451 + + -
    +
    +
      - Once() +
    - 452 + + -
    +
    +
     
    @@ -197219,253 +277360,243 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 453 + + -
    +
    +
      - m.Etherman. +
    - 454 + + -
    - - - On("EthBlockByNumber", ctx, lastBlock.BlockNumber). +
    +
    +   +
    - 455 + + -
    - - - Return(ethBlock, nil). +
    +
    +   +
    - 456 + + -
    +
    +
      - Once() +
    - 457 + + -
    +
    +
     
    - 458 + + -
    - - - var n *big.Int +
    +
    +   +
    - 459 + + -
    +
    +
      - m.Etherman. +
    - 460 + + -
    - - - On("HeaderByNumber", ctx, n). +
    +
    +   +
    - 461 + + -
    - - - Return(ethHeader, nil). +
    +
    +   +
    - 462 + + -
    +
    +
      - Once() +
    - 463 + + -
    +
    +
     
    - 464 + + -
    +
    +
      - sequencedForceBatch := etherman.SequencedForceBatch{ +
    -
    @@ -474,7 +498,7 @@
    -
    - 474 + + -
    +
    +
      - } +
    - 475 + + -
    +
    +
     
    - 476 + + -
    +
    +
      - forceb := []etherman.ForcedBatch{{ +
    - 477 + + -
    - - - BlockNumber: lastBlock.BlockNumber, +
    +
    +   +
    - 478 + + -
    +
    +
      - ForcedBatchNumber: 1, +
    - 479 + + -
    +
    +
      - Sequencer: sequencedForceBatch.Coinbase, +
    - 480 + + -
    +
    +
      - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    -
    @@ -482,14 +506,21 @@
    -
    - 482 + + -
    +
    +
      - ForcedAt: time.Unix(int64(sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    - 483 + + -
    +
    +
      - }} +
    - 484 + + -
    +
    +
     
    - 485 + + -
    - - - ethermanBlock := etherman.Block{ +
    +
    +   +
    - 486 + + -
    - - - BlockHash: ethBlock.Hash(), +
    +
    +   +
    - 487 + + -
    +
    +
      - SequencedForceBatches: [][]etherman.SequencedForceBatch{{sequencedForceBatch}}, +
    - 488 + + -
    +
    +
      - ForcedBatches: forceb, +
    - 489 + + -
    +
    +
      - } -
    -
    - 490 - -
    - - - blocks := []etherman.Block{ethermanBlock} +
    - 491 + + -
    +
    +
      - order := map[common.Hash][]etherman.Order{ -
    -
    - 492 - -
    - - - ethBlock.Hash(): { +
    - 493 + + -
    +
    +
      - { +
    - 494 + + -
    +
    +
      - Name: etherman.ForcedBatchesOrder, +
    - 495 + + -
    +
    +
      - Pos: 0, +
    -
    @@ -501,24 +532,32 @@
    -
    - 501 + + -
    +
    +
      - }, +
    - 502 + + -
    +
    +
      - } +
    - 503 + + -
    +
    +
     
    - 504 - -
    - - - fromBlock := ethBlock.NumberU64() + 1 -
    -
    - 505 + + -
    +
    +
      - toBlock := fromBlock + cfg.SyncChunkSize -
    -
    - 506 - -
    - -
    - 507 + + -
    +
    +
      - m.Etherman. +
    - 508 + + -
    +
    +
      - On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). +
    - 509 + + -
    +
    +
      - Return(blocks, order, nil). +
    - 510 + + -
    +
    +
      - Once() +
    - 511 + + -
    +
    +
     
    @@ -197814,103 +277900,63 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 512 + + -
    +
    +
      - m.State. +
    - 513 + + -
    +
    +
      - On("BeginStateTransaction", ctx). +
    - 514 + + -
    +
    +
      - Return(m.DbTx, nil). +
    - 515 + + -
    +
    +
      - Once() +
    - 516 + + -
    +
    +
     
    - 517 + + -
    +
    +
      - stateBlock := &state.Block{ -
    -
    - 518 - -
    - - - BlockNumber: ethermanBlock.BlockNumber, -
    -
    - 519 - -
    - - - BlockHash: ethermanBlock.BlockHash, -
    -
    - 520 - -
    - - - ParentHash: ethermanBlock.ParentHash, -
    -
    - 521 - -
    - - - ReceivedAt: ethermanBlock.ReceivedAt, +
    - 522 + + -
    +
    +
      - } +
    - 523 + + -
    +
    +
     
    - 524 + + -
    +
    +
      - m.State. +
    -
    @@ -526,8 +565,13 @@
    -
    - 526 + + -
    +
    +
      - Return(nil). +
    - 527 + + -
    +
    +
      - Once() +
    - 528 + + -
    +
    +
     
    @@ -198039,653 +278080,526 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 529 + + -
    +
    +
      - fb := []state.ForcedBatch{{ -
    -
    - 530 - -
    - - - BlockNumber: lastBlock.BlockNumber, +
    - 531 + + -
    +
    +
      - ForcedBatchNumber: 1, +
    - 532 - -
    -   - Sequencer: sequencedForceBatch.Coinbase, +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/forksids.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -12,41 +12,21 @@
    - 533 + 12
      - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + ForkIDEtrog = ForkIdType(7) //nolint:gomnd
    -
    @@ -559,7 +603,7 @@
    -
    - 559 + 13
      - processingContext := state.ProcessingContext{ + // ForkIDElderberry is the forkId for Elderberry
    - 560 + 14
      - BatchNumber: sequencedForceBatch.BatchNumber, + ForkIDElderberry = ForkIdType(8) //nolint:gomnd
    - 561 + + 15 +
    -   - Coinbase: sequencedForceBatch.Coinbase, + - + // ForkIDElderberry2 is the forkId for Elderberry2
    - 562 + 16
    - - Timestamp: ethBlock.ReceivedAt, + ForkIDElderberry2 = ForkIdType(9) //nolint:gomnd
    - 563 + + 17 +
    -   - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + // ForkIDFeijoa is the forkId for Feijoa
    - 564 + + 18 +
    -   - ForcedBatchNum: &f, + - + ForkIDFeijoa = ForkIdType(10) //nolint:gomnd
    - 565 + 19
      - BatchL2Data: &sequencedForceBatch.PolygonRollupBaseEtrogBatchData.Transactions, + )
    -
    @@ -574,7 +618,7 @@
    -
    - 574 + 20
      - TxHash: sequencedForceBatch.TxHash, +
    - 575 + 21
      - Coinbase: sequencedForceBatch.Coinbase, + var (
    - 576 + 22
      - SequencerAddr: sequencedForceBatch.Coinbase, +
    - 577 + + 23 +
    - - BlockNumber: ethermanBlock.BlockNumber, -
    -
    - 578 - -
    -   - } + /// ************** ALL ***************///
    - 579 + + 24 +
    -   + -
    - 580 + 25
      - m.State. + // ForksIdAll support all forkIds
    -
    @@ -598,7 +642,10 @@
    -
    - 598 + 26
      -
    + ForksIdAll = []ForkIdType{WildcardForkId}
    - 599 + 27
      - m.DbTx. +
    - 600 + + 28 +
    -   - On("Commit", ctx). + - + /// ************** SINGLE ***************///
    - 601 + + 29 +
    - - Run(func(args mock.Arguments) { sync.Stop() }). -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -  
    - 602 - -
    -   - Return(nil). -
    -
    - 603 + + 30 +
    -   - Once() + - + // ForksIdOnlyFeijoa support only etrog forkId
    - 604 + + 31 +
    -   - }). + - + ForksIdOnlyFeijoa = []ForkIdType{ForkIDFeijoa}
    -
    @@ -611,12 +658,13 @@
    -
    - 611 + + 32 +
    -   + -
    - 612 - -
    -   - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { -
    -
    - 613 + 33
      - genesis := state.Genesis{ + // ForksIdOnlyElderberry support only elderberry forkId
    - 614 + 34
    - - BlockNumber: uint64(123456), -
    -
    - 615 - -
    -   - } + ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry, ForkIDElderberry2}
    - 616 + 35
      - cfg := Config{ +
    - 617 + 36
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + // ForksIdOnlyEtrog support only etrog forkId
    - 618 + 37
      - SyncChunkSize: 10, + ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog}
    - 619 + 38
    -   - L1SynchronizationMode: SequentialMode, -
    -
    - - -
     
    - 620 + + 39 +
    -   - L1ParallelSynchronization: L1ParallelSynchronizationConfig{ + - + /// ************** MULTIPLE ***************///
    - 621 + + 40 +
    -   - MaxClients: 2, + - +
    - 622 + 41
      - MaxPendingNoProcessedBlocks: 2, + // ForksIdToIncaberry support all forkIds till incaberry
    -
    @@ -631,12 +679,13 @@
    -
    - 631 + 42
      - } + ForksIdToIncaberry = []ForkIdType{1, 2, 3, 4, 5, ForkIDIncaberry}
    - 632 + + 43 +
    -   + -
    - 633 - -
    -   - m := mocks{ -
    -
    - 634 + + 44 +
    - - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + // ForksIdToEtrog support all forkIds till etrog
    - 635 + + 45 +
    - - State: mock_syncinterfaces.NewStateFullInterface(t), + ForksIdToEtrog = append(ForksIdToIncaberry, ForksIdOnlyEtrog...)
    - 636 + + 46 +
    - - Pool: mock_syncinterfaces.NewPoolInterface(t), +
    - 637 + + 47 +
    - - DbTx: syncMocks.NewDbTxMock(t), + // ForksIdToElderberry support all forkIds till elderberry
    - 638 + + 48 +
    - - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + ForksIdToElderberry = append(ForksIdToEtrog, ForksIdOnlyElderberry...)
    - 639 + + 49 +
    - - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), -
    -
    - - -
    -  
    - 640 + + 50 +
    -   - //EventLog: newEventLogMock(t), + - + // ForksIdToFeijoa support all forkIds till feijoa
    - 641 + + 51 +
    -   - } + - + ForksIdToFeijoa = append(ForksIdToElderberry, ForksIdOnlyFeijoa...)
    - 642 + 52
      - return &genesis, &cfg, &m + )
    +
    +
    +
    +
    + + + - - - - - - - - - - @@ -198709,41 +278623,41 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -199039,263 +278953,325 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - + +
    -
    @@ -870,3 +919,1365 @@
    +
     
    - 870 + 12
      - Return(nil). + ForkIDEtrog = ForkIdType(7) //nolint:gomnd
    - 871 + 13
      - Once() + // ForkIDElderberry is the forkId for Elderberry
    - 872 + 14
      - } -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + ForkIDElderberry = ForkIdType(8) //nolint:gomnd
    - + + 15 -
    -   -
    +
    +
    + + + // ForkID9 is the forkId for 9
    - + + 16 -
    -   -
    +
    +
    + + + ForkID9 = ForkIdType(9) //nolint:gomnd
    - + + 17 -
    +
    +
      -
    + )
    - + + 18 -
    +
    +
     
    - + + 19 -
    +
    +
      -
    + var (
    - + + 20 -
    +
    +
     
    @@ -198769,31 +278683,31 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 21 -
    +
    +
      -
    + // ForksIdAll support all forkIds
    - + + 22 -
    +
    +
      -
    + ForksIdAll = []ForkIdType{WildcardForkId}
    - + + 23 -
    +
    +
     
    @@ -198849,61 +278763,61 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 24 -
    +
    +
      -
    + // ForksIdOnlyElderberry support only elderberry forkId
    - + + 25 -
    -   -
    +
    +
    + + + ForksIdOnlyElderberry = []ForkIdType{ForkIDElderberry, ForkID9}
    - + + 26 -
    +
    +
     
    - + + 27 -
    +
    +
      -
    + // ForksIdOnlyEtrog support only etrog forkId
    - + + 28 -
    +
    +
      -
    + ForksIdOnlyEtrog = []ForkIdType{ForkIDEtrog}
    - + + 29 -
    +
    +
     
    @@ -198929,23 +278843,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 30 -
    +
    +
      -
    + // ForksIdToIncaberry support all forkIds till incaberry
    - + + 31 -
    +
    +
      -
    + ForksIdToIncaberry = []ForkIdType{1, 2, 3, 4, 5, ForkIDIncaberry}
    - + + 32 -
    +
    +
      -
    + )
    - - -
    -   -
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forced_batches.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + - - - - + + +
    +
    @@ -23,9 +23,9 @@
    - + + 23 -
    +
    +
      -
    + // NewProcessL1ForcedBatches returns instance of a processor for ForcedBatchesOrder
    - + + 24 -
    +
    +
      -
    + func NewProcessL1ForcedBatches(state stateProcessL1ForcedBatchesInterface) *ProcessL1ForcedBatches {
    - + + 25 -
    +
    +
      -
    + return &ProcessL1ForcedBatches{
    - + + 26 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessL1ForcedBatches](
    - + + 27 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.ForcedBatchesOrder},
    - + + 28 -
    -   -
    +
    +
    + - + actions.ForksIdAll),
    - - -
    +
    + 29 + +
      -
    + state: state}
    - + + 30 -
    +
    +
      -
    + }
    - + + 31 -
    +
    +
     
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - + + 23 -
    +
    +
      -
    + // NewProcessL1ForcedBatches returns instance of a processor for ForcedBatchesOrder
    - + + 24 -
    +
    +
      -
    + func NewProcessL1ForcedBatches(state stateProcessL1ForcedBatchesInterface) *ProcessL1ForcedBatches {
    - + + 25 -
    +
    +
      -
    + return &ProcessL1ForcedBatches{
    - + + 26 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessL1ForcedBatches]{
    - + + 27 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.ForcedBatchesOrder},
    - + + 28 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdAll},
    - + + 29 -
    +
    +
      -
    + state: state}
    - + + 30 -
    +
    +
      -
    + }
    - + + 31 -
    +
    +
     
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_forkid.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - @@ -199309,593 +279285,736 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -36,9 +36,10 @@
    +
    - + + 36 -
    +
    +
      -
    + // NewProcessorForkId returns instance of a processor for ForkIDsOrder
    - + + 37 -
    +
    +
      -
    + func NewProcessorForkId(state stateProcessorForkIdInterface, sync syncProcessorForkIdInterface) *ProcessorForkId {
    - + + 38 -
    +
    +
      -
    + return &ProcessorForkId{
    - + + 39 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessorForkId](
    - + + 40 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.ForkIDsOrder},
    - + + 41 -
    -   -
    +
    +
    + - + actions.ForksIdAll),
    - + + 42 -
    +
    +
      -
    + state: state,
    - + + 43 -
    +
    +
      -
    + sync: sync}
    - + + 44 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 36 -
    +
    +
      -
    + // NewProcessorForkId returns instance of a processor for ForkIDsOrder
    - + + 37 -
    +
    +
      -
    + func NewProcessorForkId(state stateProcessorForkIdInterface, sync syncProcessorForkIdInterface) *ProcessorForkId {
    - + + 38 -
    +
    +
      -
    + return &ProcessorForkId{
    - + + 39 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessorForkId]{
    - + + 40 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.ForkIDsOrder},
    - + + 41 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdAll,
    - + + 42 -
    -   -
    +
    +
    + + + },
    - + + 43 -
    +
    +
      -
    + state: state,
    - + + 44 -
    +
    +
      -
    + sync: sync}
    - + + 45 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_global_exit_root.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -24,9 +24,9 @@
    - + + 24 -
    +
    +
      -
    + // NewProcessorL1GlobalExitRoot new processor for GlobalExitRootsOrder
    - + + 25 -
    +
    +
      -
    + func NewProcessorL1GlobalExitRoot(state stateProcessorL1GlobalExitRootInterface) *ProcessorL1GlobalExitRoot {
    - + + 26 -
    +
    +
      -
    + return &ProcessorL1GlobalExitRoot{
    - + + 27 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1GlobalExitRoot](
    - + + 28 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.GlobalExitRootsOrder},
    - + + 29 -
    -   -
    +
    +
    + - + actions.ForksIdToIncaberry),
    - + + 30 -
    +
    +
      -
    + state: state}
    - + + 31 -
    +
    +
      -
    + }
    - + + 32 -
    +
    +
     
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    +
    - + + 24 -
    +
    +
      -
    + // NewProcessorL1GlobalExitRoot new processor for GlobalExitRootsOrder
    - + + 25 -
    +
    +
      -
    + func NewProcessorL1GlobalExitRoot(state stateProcessorL1GlobalExitRootInterface) *ProcessorL1GlobalExitRoot {
    - + + 26 -
    +
    +
      -
    + return &ProcessorL1GlobalExitRoot{
    - + + 27 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessorL1GlobalExitRoot]{
    - + + 28 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.GlobalExitRootsOrder},
    - + + 29 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdToIncaberry},
    - + + 30 -
    +
    +
      -
    + state: state}
    - + + 31 -
    +
    +
      -
    + }
    - + + 32 -
    +
    +
     
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -64,9 +64,9 @@
    +
    - + + 64 -
    +
    +
      -
    + func NewProcessorL1SequenceBatches(state stateProcessSequenceBatches,
    - + + 65 -
    +
    +
      -
    + etherMan ethermanProcessSequenceBatches, pool poolProcessSequenceBatchesInterface, eventLog syncinterfaces.EventLogInterface, sync syncProcessSequenceBatchesInterface) *ProcessorL1SequenceBatches {
    - + + 66 -
    +
    +
      -
    + return &ProcessorL1SequenceBatches{
    - + + 67 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1SequenceBatches](
    - + + 68 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.SequenceBatchesOrder},
    - + + 69 -
    -   -
    +
    +
    + - + actions.ForksIdToIncaberry),
    - + + 70 -
    +
    +
      -
    + state: state,
    - + + 71 -
    +
    +
      -
    + etherMan: etherMan,
    - + + 72 -
    +
    +
      -
    + pool: pool, +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 64 -
    +
    +
      -
    + func NewProcessorL1SequenceBatches(state stateProcessSequenceBatches,
    - + + 65 -
    +
    +
      -
    + etherMan ethermanProcessSequenceBatches, pool poolProcessSequenceBatchesInterface, eventLog syncinterfaces.EventLogInterface, sync syncProcessSequenceBatchesInterface) *ProcessorL1SequenceBatches {
    - + + 66 -
    +
    +
      -
    + return &ProcessorL1SequenceBatches{
    - + + 67 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessorL1SequenceBatches]{
    - + + 68 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.SequenceBatchesOrder},
    - + + 69 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdToIncaberry},
    - + + 70 -
    +
    +
      -
    + state: state,
    - + + 71 -
    +
    +
      -
    + etherMan: etherMan,
    - + + 72 -
    +
    +
      -
    + pool: pool, +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_batches_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -23,7 +23,6 @@
    - + + 23 -
    +
    +
      -
    + // Create an instance of ProcessorL1SequenceBatches
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + // Test invalid call, no sequenced batches
    - + + 26 -
    -   -
    +
    +
    + - + sut.ProcessorBase.SupportedEvents()
    - + + 27 -
    +
    +
      -
    + err := sut.Process(ctx, etherman.Order{Name: sut.SupportedEvents()[0], Pos: 0}, l1Block, dbTx)
    - + + 28 -
    +
    +
      -
    + require.Error(t, err)
    - + + 29 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -199909,763 +280028,887 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
     
    - + + 23 -
    +
    +
      -
    + // Create an instance of ProcessorL1SequenceBatches
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + // Test invalid call, no sequenced batches
    - + + 26 -
    +
    +
      -
    + err := sut.Process(ctx, etherman.Order{Name: sut.SupportedEvents()[0], Pos: 0}, l1Block, dbTx)
    - + + 27 -
    +
    +
      -
    + require.Error(t, err)
    - + + 28 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_sequence_force_batches.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -39,9 +39,9 @@
    - + + 39 -
    +
    +
      -
    + func NewProcessL1SequenceForcedBatches(state stateProcessL1SequenceForcedBatchesInterface,
    - + + 40 -
    +
    +
      -
    + sync syncProcessL1SequenceForcedBatchesInterface) *ProcessL1SequenceForcedBatches {
    - + + 41 -
    +
    +
      -
    + return &ProcessL1SequenceForcedBatches{
    - + + 42 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessL1SequenceForcedBatches](
    - + + 43 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.SequenceForceBatchesOrder},
    - + + 44 -
    -   -
    +
    +
    + - + actions.ForksIdAll),
    - + + 45 -
    +
    +
      -
    + state: state,
    - + + 46 -
    +
    +
      -
    + sync: sync}
    - + + 47 -
    +
    +
      -
    + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 39 -
    +
    +
      -
    + func NewProcessL1SequenceForcedBatches(state stateProcessL1SequenceForcedBatchesInterface,
    - + + 40 -
    +
    +
      -
    + sync syncProcessL1SequenceForcedBatchesInterface) *ProcessL1SequenceForcedBatches {
    - + + 41 -
    +
    +
      -
    + return &ProcessL1SequenceForcedBatches{
    - + + 42 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessL1SequenceForcedBatches]{
    - + + 43 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.SequenceForceBatchesOrder},
    - + + 44 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdAll},
    - + + 45 -
    +
    +
      -
    + state: state,
    - + + 46 -
    +
    +
      -
    + sync: sync}
    - + + 47 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/incaberry/processor_l1_verify_batch.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -26,9 +26,9 @@
    - + + 26 -
    +
    +
      -
    + // NewProcessorL1VerifyBatch returns instance of a processor for VerifyBatchOrder
    - + + 27 -
    +
    +
      -
    + func NewProcessorL1VerifyBatch(state stateL1VerifyBatchInterface) *ProcessorL1VerifyBatch {
    - + + 28 -
    +
    +
      -
    + return &ProcessorL1VerifyBatch{
    - + + 29 -
    -   -
    +
    +
    + - + ProcessorBase: *actions.NewProcessorBase[ProcessorL1VerifyBatch](
    - + + 30 -
    -   -
    +
    +
    + - + []etherman.EventOrder{etherman.VerifyBatchOrder, etherman.TrustedVerifyBatchOrder},
    - + + 31 -
    -   -
    +
    +
    + - + actions.ForksIdAll),
    - + + 32 -
    +
    +
      -
    + state: state,
    - + + 33 -
    +
    +
      -
    + }
    - + + 34 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 26 -
    +
    +
      -
    + // NewProcessorL1VerifyBatch returns instance of a processor for VerifyBatchOrder
    - + + 27 -
    +
    +
      -
    + func NewProcessorL1VerifyBatch(state stateL1VerifyBatchInterface) *ProcessorL1VerifyBatch {
    - + + 28 -
    +
    +
      -
    + return &ProcessorL1VerifyBatch{
    - + + 29 -
    -   -
    +
    +
    + + + ProcessorBase: actions.ProcessorBase[ProcessorL1VerifyBatch]{
    - + + 30 -
    -   -
    +
    +
    + + + SupportedEvent: []etherman.EventOrder{etherman.VerifyBatchOrder, etherman.TrustedVerifyBatchOrder},
    - + + 31 -
    -   -
    +
    +
    + + + SupportedForkdIds: &actions.ForksIdAll},
    - + + 32 -
    +
    +
      -
    + state: state,
    - + + 33 -
    +
    +
      -
    + }
    - + + 34 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/processor_base.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -9,18 +9,8 @@
    - + + 9 -
    +
    +
      -
    + // ProcessorBase is the base struct for all the processors, if reduces the boilerplate
    - + + 10 -
    +
    +
      -
    + // implementing the Name, SupportedEvents and SupportedForkIds functions
    - + + 11 -
    +
    +
      -
    + type ProcessorBase[T any] struct {
    - + + 12 -
    -   -
    +
    +
    + - + supportedEvent []etherman.EventOrder
    - + + 13 -
    -   -
    +
    +
    + - + supportedForkIds []ForkIdType
    - + + 14 -
    -   -
    +
    +
    + - + }
    - + + 15 -
    -   +
    +
    + -
    - + + 16 -
    -   -
    +
    +
    + - + // NewProcessorBase creates and initializes internal fields of an new instance of ProcessorBase
    - + + 17 -
    -   -
    +
    +
    + - + func NewProcessorBase[T any](supportedEvent []etherman.EventOrder, supportedForkIds []ForkIdType) *ProcessorBase[T] {
    - + + 18 -
    -   -
    +
    +
    + - + p := &ProcessorBase[T]{
    - + + 19 -
    -   -
    +
    +
    + - + supportedEvent: supportedEvent,
    - + + 20 -
    -   -
    +
    +
    + - + supportedForkIds: supportedForkIds,
    - + + 21 -
    -   -
    +
    +
    + - + }
    - + + 22 -
    -   +
    +
    + -
    - + + 23 -
    -   -
    +
    +
    + - + return p
    - + + 24 -
    +
    +
      -
    + }
    - + + 25 -
    +
    +
     
    - + + 26 -
    +
    +
      -
    + // Name returns the name of the struct T
    - + +
    @@ -33,13 +23,13 @@
    -
    +
    + 33 + +
     
    - + + 34 -
    +
    +
      -
    + // SupportedEvents returns the supported events in the struct
    - + + 35 -
    +
    +
      -
    + func (p *ProcessorBase[T]) SupportedEvents() []etherman.EventOrder {
    - + + 36 -
    -   -
    +
    +
    + - + return p.supportedEvent
    - + + 37 -
    +
    +
      -
    + }
    - + + 38 -
    +
    +
     
    - + + 39 -
    -   -
    +
    +
    + - + // SupportedForkIds returns the supported forkIds in the struct or the default till incaberry forkId
    - + + 40 -
    +
    +
      -
    + func (p *ProcessorBase[T]) SupportedForkIds() []ForkIdType {
    - + + 41 -
    -   -
    +
    +
    + - + if len(p.supportedForkIds) != 0 {
    - + + 42 -
    -   -
    +
    +
    + - + return p.supportedForkIds
    - + + 43 -
    +
    +
      -
    + }
    - + + 44 -
    +
    +
      -
    + // returns none
    - + + 45 -
    +
    +
      -
    + return []ForkIdType{} +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - @@ -200769,384 +281012,422 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - + + 9 -
    +
    +
      -
    + // ProcessorBase is the base struct for all the processors, if reduces the boilerplate
    - + + 10 -
    +
    +
      -
    + // implementing the Name, SupportedEvents and SupportedForkIds functions
    - + + 11 -
    +
    +
      -
    + type ProcessorBase[T any] struct {
    - + + 12 -
    -   -
    +
    +
    + + + SupportedEvent []etherman.EventOrder
    - + + 13 -
    -   -
    +
    +
    + + + SupportedForkdIds *[]ForkIdType
    - + + 14 -
    +
    +
      -
    + }
    - + + 15 -
    +
    +
     
    - + + 16 -
    +
    +
      -
    + // Name returns the name of the struct T
    - + +
     
    -
    +
    + 23 + +
     
    - + + 24 -
    +
    +
      -
    + // SupportedEvents returns the supported events in the struct
    - + + 25 -
    +
    +
      -
    + func (p *ProcessorBase[T]) SupportedEvents() []etherman.EventOrder {
    - + + 26 -
    -   -
    +
    +
    + + + return p.SupportedEvent
    - + + 27 -
    +
    +
      -
    + }
    - + + 28 -
    +
    +
     
    - + + 29 -
    -   -
    +
    +
    + + + // SupportedForkIds returns the supported forkIds in the struct or the dafault till incaberry forkId
    - + + 30 -
    +
    +
      -
    + func (p *ProcessorBase[T]) SupportedForkIds() []ForkIdType {
    - + + 31 -
    -   -
    +
    +
    + + + if p.SupportedForkdIds != nil {
    - + + 32 -
    -   -
    +
    +
    + + + return *p.SupportedForkdIds
    - + + 33 -
    +
    +
      -
    + }
    - + + 34 -
    +
    +
      -
    + // returns none
    - + + 35 -
    +
    +
      -
    + return []ForkIdType{} +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/block_range_processor.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -1,21 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package syncinterfaces
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   +
    +
    + -
    - + + 6 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - + + 7 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/common"
    - + + 8 -
    -   -
    +
    +
    + - + "github.com/jackc/pgx/v4"
    - + + 9 -
    -   -
    +
    +
    + - + )
    - + + 10 -
    -   +
    +
    + -
    - + + 11 -
    -   -
    +
    +
    + - + type ProcessBlockRangeL1BlocksMode bool
    - + + 12 -
    -   +
    +
    + -
    - + + 13 -
    -   -
    +
    +
    + - + const (
    - + + 14 -
    -   -
    +
    +
    + - + StoreL1Blocks ProcessBlockRangeL1BlocksMode = true
    - + + 15 -
    -   -
    +
    +
    + - + NoStoreL1Blocks ProcessBlockRangeL1BlocksMode = false
    - + + 16 -
    -   -
    +
    +
    + - + )
    - + + 17 -
    -   +
    +
    + -
    - + + 18 -
    -   -
    +
    +
    + - + type BlockRangeProcessor interface {
    - + + 19 -
    -   -
    +
    +
    + - + ProcessBlockRange(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order) error
    - + + 20 -
    -   -
    +
    +
    + - + ProcessBlockRangeSingleDbTx(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order, storeBlocks ProcessBlockRangeL1BlocksMode, dbTx pgx.Tx) error
    - + + 21 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -201358,174 +281639,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/etherman.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -20,14 +20,8 @@
    +
    - + + 20 -
    +
    +
     
    - + + 21 -
    +
    +
      -
    + EthermanGetLatestBatchNumber
    - + + 22 -
    +
    +
      -
    + GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
    - + + 23 -
    -   -
    +
    +
    + - + EthermanPreRollup
    - + + 24 -
    +
    +
      -
    + }
    - + + 25 -
    +
    +
     
    - + + 26 -
    +
    +
      -
    + type EthermanGetLatestBatchNumber interface {
    - + + 27 -
    +
    +
      -
    + GetLatestBatchNumber() (uint64, error)
    - + + 28 -
    +
    +
      -
    + }
    - + + 29 -
    -   +
    +
    + -
    - + + 30 -
    -   -
    +
    +
    + - + type EthermanPreRollup interface {
    - + + 31 -
    -   -
    +
    +
    + - + GetL1BlockUpgradeLxLy(ctx context.Context, genesisBlock uint64) (uint64, error)
    - + + 32 -
    -   -
    +
    +
    + - + GetRollupInfoByBlockRangePreviousRollupGenesis(ctx context.Context, fromBlock uint64, toBlock *uint64) ([]etherman.Block, map[common.Hash][]etherman.Order, error)
    - + + 33 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + - - - - - - @@ -201539,53 +281863,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - @@ -201638,145 +281962,188 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + +
    +
     
    - + + 20 -
    +
    +
     
    - + + 21 -
    +
    +
      -
    + EthermanGetLatestBatchNumber
    - + + 22 -
    +
    +
      -
    + GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
    - + + 23 -
    +
    +
      -
    + }
    - + + 24 -
    +
    +
     
    - + + 25 -
    +
    +
      -
    + type EthermanGetLatestBatchNumber interface {
    - + + 26 -
    +
    +
      -
    + GetLatestBatchNumber() (uint64, error)
    - + + 27 -
    +
    +
      -
    + }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/l1_event_processor_manager.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -1,14 +0,0 @@
    +
    - + + 1 -
    -   -
    +
    +
    + - + package syncinterfaces
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   +
    +
    + -
    - + + 6 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - + + 7 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions"
    - + + 8 -
    -   -
    +
    +
    + - + "github.com/jackc/pgx/v4"
    - + + 9 -
    -   -
    +
    +
    + - + )
    - + + 10 -
    -   +
    +
    + -
    - + + 11 -
    -   -
    +
    +
    + - + type L1EventProcessorManager interface {
    - + + 12 -
    -   -
    +
    +
    + - + Process(ctx context.Context, forkId actions.ForkIdType, order etherman.Order, block *etherman.Block, dbTx pgx.Tx) error
    - + + 13 -
    -   -
    +
    +
    + - + Get(forkId actions.ForkIdType, event etherman.EventOrder) actions.L1EventProcessor
    - + + 14 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -201918,342 +282285,395 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/state.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -21,13 +21,6 @@
    +
    - + + 21 -
    +
    +
      -
    + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - + + 22 -
    +
    +
      -
    + }
    - + + 23 -
    +
    +
     
    - + + 24 -
    -   -
    +
    +
    + - + type StateLastBlockGetter interface {
    - + + 25 -
    -   -
    +
    +
    + - + GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
    - + + 26 -
    -   -
    +
    +
    + - + }
    - + + 27 -
    -   +
    +
    + -
    - + + 28 -
    -   -
    +
    +
    + - + type StateBlobSequencer interface {
    - + + 29 -
    -   -
    +
    +
    + - + }
    - + + 30 -
    -   +
    +
    + -
    - + + 31 -
    +
    +
      -
    + // StateFullInterface gathers the methods required to interact with the state.
    - + + 32 -
    +
    +
      -
    + type StateFullInterface interface {
    - + + 33 -
    +
    +
      -
    + GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
    - + +
    @@ -73,7 +66,6 @@
    -
    +
    + 73 + +
      -
    + GetForkIDByBlockNumber(blockNumber uint64) uint64
    - + + 74 -
    +
    +
      -
    + GetStoredFlushID(ctx context.Context) (uint64, string, error)
    - + + 75 -
    +
    +
      -
    + AddL1InfoTreeLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error)
    - + + 76 -
    -   -
    +
    +
    + - + AddL1InfoTreeRecursiveLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error)
    - + + 77 -
    +
    +
      -
    + StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error
    - + + 78 -
    +
    +
      -
    + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)
    - + + 79 -
    +
    +
      -
    + UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
    - + +
    @@ -84,11 +76,6 @@
    -
    +
    + 84 + +
      -
    + UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
    - + + 85 -
    +
    +
      -
    + GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 86 -
    +
    +
      -
    + GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
    - + + 87 -
    -   -
    +
    +
    + - + GetLastBlobSequence(ctx context.Context, dbTx pgx.Tx) (*state.BlobSequence, error)
    - + + 88 -
    -   -
    +
    +
    + - + AddBlobSequence(ctx context.Context, blobSequence *state.BlobSequence, dbTx pgx.Tx) error
    - + + 89 -
    -   -
    +
    +
    + - + GetL1InfoRecursiveRootLeafByIndex(ctx context.Context, l1InfoTreeIndex uint32, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)
    - + + 90 -
    -   -
    +
    +
    + - + ProcessBlobInner(ctx context.Context, request state.ProcessBlobInnerProcessRequest, data []byte) (*state.ProcessBlobInnerResponse, error)
    - + + 91 -
    -   -
    +
    +
    + - + AddBlobInner(ctx context.Context, blobInner *state.BlobInner, dbTx pgx.Tx) error
    - + + 92 -
    +
    +
      -
    + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error)
    - + + 93 -
    +
    +
      -
    + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 94 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - - - @@ -202399,63 +282824,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -202509,105 +282939,178 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
     
    - + + 21 -
    +
    +
      -
    + GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error)
    - + + 22 -
    +
    +
      -
    + }
    - + + 23 -
    +
    +
     
    @@ -202329,63 +282749,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 24 -
    +
    +
      -
    + // StateFullInterface gathers the methods required to interact with the state.
    - + + 25 -
    +
    +
      -
    + type StateFullInterface interface {
    - + + 26 -
    +
    +
      -
    + GetLastBlock(ctx context.Context, dbTx pgx.Tx) (*state.Block, error)
    - + +
     
    -
    +
    + 66 + +
      -
    + GetForkIDByBlockNumber(blockNumber uint64) uint64
    - + + 67 -
    +
    +
      -
    + GetStoredFlushID(ctx context.Context) (uint64, string, error)
    - + + 68 -
    +
    +
      -
    + AddL1InfoTreeLeaf(ctx context.Context, L1InfoTreeLeaf *state.L1InfoTreeLeaf, dbTx pgx.Tx) (*state.L1InfoTreeExitRootStorageEntry, error)
    - + + 69 -
    +
    +
      -
    + StoreL2Block(ctx context.Context, batchNumber uint64, l2Block *state.ProcessBlockResponse, txsEGPLog []*state.EffectiveGasPriceLog, dbTx pgx.Tx) error
    - + + 70 -
    +
    +
      -
    + GetL1InfoRootLeafByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash, dbTx pgx.Tx) (state.L1InfoTreeExitRootStorageEntry, error)
    - + + 71 -
    +
    +
      -
    + UpdateWIPBatch(ctx context.Context, receipt state.ProcessingReceipt, dbTx pgx.Tx) error
    - + +
     
    -
    +
    + 76 + +
      -
    + UpdateForkIDBlockNumber(ctx context.Context, forkdID uint64, newBlockNumber uint64, updateMemCache bool, dbTx pgx.Tx) error
    - + + 77 -
    +
    +
      -
    + GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error)
    - + + 78 -
    +
    +
      -
    + GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.L2Block, error)
    - + + 79 -
    +
    +
      -
    + GetUncheckedBlocks(ctx context.Context, fromBlockNumber uint64, toBlockNumber uint64, dbTx pgx.Tx) ([]*state.Block, error)
    - + + 80 -
    +
    +
      -
    + GetPreviousBlockToBlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*state.Block, error)
    - + + 81 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/common/syncinterfaces/sync_pre_rollup_syncer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + +
    +
    @@ -1,10 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package syncinterfaces
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   -
    +
    +
    + - + )
    - + + 6 -
    -   +
    +
    + -
    - + + 7 -
    -   -
    +
    +
    + - + // SyncPreRollupSyncer is the interface for synchronizing pre genesis rollup events
    + 8 + +
    + - + type SyncPreRollupSyncer interface { +
    +
    + 9 + +
    + - + SynchronizePreGenesisRollupEvents(ctx context.Context) error +
    +
    + 10 + +
    + - + } +
    +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    +
    @@ -202708,284 +283211,435 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/config.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - + + + - - - - + + +
    +
    @@ -20,9 +20,9 @@
    +
    - + + 20 -
    +
    +
     
    - + + 21 -
    +
    +
      -
    + // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)
    - + + 22 -
    +
    +
      -
    + L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"`
    - + + 23 -
    +
    +
    + - + // L1SyncCheckL2BlockNumberModulus is the modulus used to choose the l2block to check +
    +
    + 24 + +
      -
    + // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
    - + + 25 -
    +
    +
    + - + L1SyncCheckL2BlockNumberModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberModulus"` +
    +
    + 26 + +
     
    - + + 27 -
    +
    +
      -
    + L1BlockCheck L1BlockCheckConfig `mapstructure:"L1BlockCheck"`
    - + + 28 -
    +
    +
      -
    + // L1SynchronizationMode define how to synchronize with L1: +
    +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - + + + - - - - + + +
    +
     
    - + + 20 -
    +
    +
     
    - + + 21 -
    +
    +
      -
    + // L1SyncCheckL2BlockHash if is true when a batch is closed is force to check L2Block hash against trustedNode (only apply for permissionless)
    - + + 22 -
    +
    +
      -
    + L1SyncCheckL2BlockHash bool `mapstructure:"L1SyncCheckL2BlockHash"`
    - + + 23 -
    +
    +
    + + + // L1SyncCheckL2BlockNumberhModulus is the modulus used to choose the l2block to check +
    +
    + 24 + +
      -
    + // a modules 5, for instance, means check all l2block multiples of 5 (10,15,20,...)
    - + + 25 -
    +
    +
    + + + L1SyncCheckL2BlockNumberhModulus uint64 `mapstructure:"L1SyncCheckL2BlockNumberhModulus"` +
    +
    + 26 + +
     
    - + + 27 -
    +
    +
      -
    + L1BlockCheck L1BlockCheckConfig `mapstructure:"L1BlockCheck"`
    - + + 28 -
    +
    +
      -
    + // L1SynchronizationMode define how to synchronize with L1: +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/default_l1processors.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - - - - + - + + - - - - - - + + + - - + + +
    +
    @@ -18,7 +17,6 @@
    - + + 18 -
    +
    +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(incaberry.NewProcessL1SequenceForcedBatches(sync.state, sync), l2Blockchecker))
    - + + 19 -
    +
    +
      -
    + p.Register(incaberry.NewProcessorForkId(sync.state, sync))
    - + + 20 -
    +
    +
      -
    + p.Register(etrog.NewProcessorL1InfoTreeUpdate(sync.state))
    - + + 21 -
    +
    +
    + - + p.Register(feijoa.NewProcessorL1InfoTreeUpdate(sync.state)) +
    +
    + 22 + +
      -
    + sequenceBatchesProcessor := etrog.NewProcessorL1SequenceBatches(sync.state, sync, common.DefaultTimeProvider{}, sync.halter)
    - + + 23 -
    +
    +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(sequenceBatchesProcessor, l2Blockchecker))
    - + + 24 -
    +
    +
      -
    + p.Register(incaberry.NewProcessorL1VerifyBatch(sync.state))
    - + +
    @@ -26,6 +24,5 @@
    -
    +
    + 26 + +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(elderberry.NewProcessorL1SequenceBatchesElderberry(sequenceBatchesProcessor, sync.state), l2Blockchecker))
    - + + 27 -
    +
    +
      -
    + // intialSequence is process in ETROG by the same class, this is just a wrapper to pass directly to ETROG
    - + + 28 -
    +
    +
      -
    + p.Register(elderberry.NewProcessorL1InitialSequenceBatchesElderberry(sequenceBatchesProcessor))
    - + + 29 -
    +
    +
    + - + p.Register(feijoa.NewProcessorSequenceBlobs(sync.state, sync.state, nil)) +
    +
    + 30 + +
      -
    + return p.Build()
    - + + 31 -
    +
    +
      -
    + }
    +
    +
    +
    +
    + + + + + - - - - - - @@ -202999,63 +283653,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -203069,111 +283728,155 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - + + +
    +
     
    +
    - + + 17 -
    +
    +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(incaberry.NewProcessL1SequenceForcedBatches(sync.state, sync), l2Blockchecker))
    - + + 18 -
    +
    +
      -
    + p.Register(incaberry.NewProcessorForkId(sync.state, sync))
    - + + 19 -
    +
    +
      -
    + p.Register(etrog.NewProcessorL1InfoTreeUpdate(sync.state))
    - + + 20 -
    +
    +
      -
    + sequenceBatchesProcessor := etrog.NewProcessorL1SequenceBatches(sync.state, sync, common.DefaultTimeProvider{}, sync.halter)
    - + + 21 -
    +
    +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(sequenceBatchesProcessor, l2Blockchecker))
    - + + 22 -
    +
    +
      -
    + p.Register(incaberry.NewProcessorL1VerifyBatch(sync.state))
    - + +
     
    -
    +
    + 24 + +
      -
    + p.Register(actions.NewCheckL2BlockDecorator(elderberry.NewProcessorL1SequenceBatchesElderberry(sequenceBatchesProcessor, sync.state), l2Blockchecker))
    - + + 25 -
    +
    +
      -
    + // intialSequence is process in ETROG by the same class, this is just a wrapper to pass directly to ETROG
    - + + 26 -
    +
    +
      -
    + p.Register(elderberry.NewProcessorL1InitialSequenceBatchesElderberry(sequenceBatchesProcessor))
    - + + 27 -
    +
    +
      -
    + return p.Build()
    - + + 28 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -11,7 +11,7 @@
    - + + 11 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 12 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 13 -
    +
    +
      -
    + syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
    - + + 14 -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces" +
    +
    + 15 + +
      -
    + types "github.com/ethereum/go-ethereum/core/types"
    - + + 16 -
    +
    +
      -
    + )
    - + + 17 -
    +
    +
     
    - + +
    @@ -33,10 +33,16 @@
    -
    +
    + 33 + +
      -
    + AceptableInacctivityTime time.Duration
    - + + 34 -
    +
    +
      -
    + }
    - + + 35 -
    +
    +
     
    @@ -203239,1853 +283942,2097 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 36 -
    +
    +
      -
    + // l1RollupInfoConsumer is the object that process the rollup info data incomming from channel chIncommingRollupInfo
    - + + 37 -
    +
    +
      -
    + type l1RollupInfoConsumer struct {
    - + + 38 -
    +
    +
      -
    + mutex sync.Mutex
    - + + 39 -
    +
    +
    + - + synchronizer syncinterfaces.BlockRangeProcessor +
    +
    + 40 + +
      -
    + chIncommingRollupInfo chan L1SyncMessage
    - + + 41 -
    +
    +
      -
    + ctx context.Context
    - + + 42 -
    +
    +
      -
    + statistics l1RollupInfoConsumerStatistics
    - + +
    @@ -47,7 +53,7 @@
    -
    +
    + 47 + +
     
    - + + 48 -
    +
    +
      -
    + // NewL1RollupInfoConsumer creates a new l1RollupInfoConsumer
    - + + 49 -
    +
    +
      -
    + func NewL1RollupInfoConsumer(cfg ConfigConsumer,
    - + + 50 -
    +
    +
    + - + synchronizer syncinterfaces.BlockRangeProcessor, ch chan L1SyncMessage) *l1RollupInfoConsumer { +
    +
    + 51 + +
      -
    + if cfg.AceptableInacctivityTime < minAcceptableTimeWaitingForNewRollupInfoData {
    - + + 52 -
    +
    +
      -
    + log.Warnf("consumer: the AceptableInacctivityTime is too low (%s) minimum recommended %s", cfg.AceptableInacctivityTime, minAcceptableTimeWaitingForNewRollupInfoData)
    - + + 53 -
    +
    +
      -
    + }
    - + +
    @@ -231,7 +237,7 @@
    -
    +
    + 231 + +
      -
    + return nil, nil
    - + + 232 -
    +
    +
      -
    + }
    - + + 233 -
    +
    +
      -
    + b := convertL1BlockToEthBlock(lb)
    - + + 234 -
    -   -
    +
    +
    + - + err := l.synchronizer.ProcessBlockRange(l.ctx, []etherman.Block{b}, order)
    - + + 235 -
    +
    +
      -
    + if err != nil {
    - + + 236 -
    +
    +
      -
    + log.Error("consumer: Error processing last block of range: ", rollupInfo.blockRange, " err:", err)
    - + + 237 -
    +
    +
      -
    + return nil, err
    - + +
    @@ -243,7 +249,7 @@
    -
    +
    + 243 + +
      -
    + tmpStateBlock := convertEthmanBlockToStateBlock(&blocks[len(blocks)-1])
    - + + 244 -
    +
    +
      -
    + lastEthBlockSynced = &tmpStateBlock
    - + + 245 -
    +
    +
      -
    + logBlocks(blocks)
    - + + 246 -
    -   -
    +
    +
    + - + err := l.synchronizer.ProcessBlockRange(l.ctx, blocks, order)
    - + + 247 -
    +
    +
      -
    + if err != nil {
    - + + 248 -
    +
    +
      -
    + log.Info("consumer: Error processing block range: ", rollupInfo.blockRange, " err:", err)
    - + + 249 -
    +
    +
      -
    + return nil, err +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - + + 11 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 12 -
    +
    +
      -
    + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 13 -
    +
    +
      -
    + syncCommon "github.com/0xPolygonHermez/zkevm-node/synchronizer/common"
    - + + 14 -
    -   -
    +
    +
    + + + "github.com/ethereum/go-ethereum/common"
    - + + 15 -
    +
    +
      -
    + types "github.com/ethereum/go-ethereum/core/types"
    - + + 16 -
    +
    +
      -
    + )
    - + + 17 -
    +
    +
     
    - + +
     
    -
    +
    + 33 + +
      -
    + AceptableInacctivityTime time.Duration
    - + + 34 -
    +
    +
      -
    + }
    - + + 35 -
    +
    +
     
    - + + 36 -
    -   -
    +
    +
    + + + // synchronizerProcessBlockRangeInterface is the interface with synchronizer
    - + + 37 -
    -   -
    +
    +
    + + + // to execute blocks. This interface is used to mock the synchronizer in the tests
    - + + 38 -
    -   -
    +
    +
    + + + type synchronizerProcessBlockRangeInterface interface {
    - + + 39 -
    -   -
    +
    +
    + + + ProcessBlockRange(blocks []etherman.Block, order map[common.Hash][]etherman.Order) error
    - + + 40 -
    -   -
    +
    +
    + + + }
    - + + 41 -
    -   +
    +
    + +
    - + + 42 -
    +
    +
      -
    + // l1RollupInfoConsumer is the object that process the rollup info data incomming from channel chIncommingRollupInfo
    - + + 43 -
    +
    +
      -
    + type l1RollupInfoConsumer struct {
    - + + 44 -
    +
    +
      -
    + mutex sync.Mutex
    - + + 45 -
    -   -
    +
    +
    + + + synchronizer synchronizerProcessBlockRangeInterface
    - + + 46 -
    +
    +
      -
    + chIncommingRollupInfo chan L1SyncMessage
    - + + 47 -
    +
    +
      -
    + ctx context.Context
    - + + 48 -
    +
    +
      -
    + statistics l1RollupInfoConsumerStatistics
    - + +
     
    -
    +
    + 53 + +
     
    - + + 54 -
    +
    +
      -
    + // NewL1RollupInfoConsumer creates a new l1RollupInfoConsumer
    - + + 55 -
    +
    +
      -
    + func NewL1RollupInfoConsumer(cfg ConfigConsumer,
    - + + 56 -
    -   -
    +
    +
    + + + synchronizer synchronizerProcessBlockRangeInterface, ch chan L1SyncMessage) *l1RollupInfoConsumer {
    - + + 57 -
    +
    +
      -
    + if cfg.AceptableInacctivityTime < minAcceptableTimeWaitingForNewRollupInfoData {
    - + + 58 -
    +
    +
      -
    + log.Warnf("consumer: the AceptableInacctivityTime is too low (%s) minimum recommended %s", cfg.AceptableInacctivityTime, minAcceptableTimeWaitingForNewRollupInfoData)
    - + + 59 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 237 + +
      -
    + return nil, nil
    - + + 238 -
    +
    +
      -
    + }
    - + + 239 -
    +
    +
      -
    + b := convertL1BlockToEthBlock(lb)
    - + + 240 -
    -   -
    +
    +
    + + + err := l.synchronizer.ProcessBlockRange([]etherman.Block{b}, order)
    - + + 241 -
    +
    +
      -
    + if err != nil {
    - + + 242 -
    +
    +
      -
    + log.Error("consumer: Error processing last block of range: ", rollupInfo.blockRange, " err:", err)
    - + + 243 -
    +
    +
      -
    + return nil, err
    - + +
     
    -
    +
    + 249 + +
      -
    + tmpStateBlock := convertEthmanBlockToStateBlock(&blocks[len(blocks)-1])
    - + + 250 -
    +
    +
      -
    + lastEthBlockSynced = &tmpStateBlock
    - + + 251 -
    +
    +
      -
    + logBlocks(blocks)
    - + + 252 -
    -   -
    +
    +
    + + + err := l.synchronizer.ProcessBlockRange(blocks, order)
    - + + 253 -
    +
    +
      -
    + if err != nil {
    - + + 254 -
    +
    +
      -
    + log.Info("consumer: Error processing block range: ", rollupInfo.blockRange, " err:", err)
    - + + 255 -
    +
    +
      -
    + return nil, err +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_rollup_info_consumer_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -17,7 +16,7 @@
    - + + 17 -
    +
    +
     
    - + + 18 -
    +
    +
      -
    + type consumerTestData struct {
    - + + 19 -
    +
    +
      -
    + sut *l1RollupInfoConsumer
    - + + 20 -
    -   -
    +
    +
    + - + syncMock *mock_syncinterfaces.BlockRangeProcessor
    - + + 21 -
    +
    +
      -
    + ch chan L1SyncMessage
    - + + 22 -
    +
    +
      -
    + }
    - + + 23 -
    +
    +
     
    - + +
    @@ -55,7 +54,7 @@
    -
    +
    + 55 + +
      -
    + lastBlockOfRange: types.NewBlock(&types.Header{Number: big.NewInt(123)}, nil, nil, nil, nil),
    - + + 56 -
    +
    +
      -
    + }
    - + + 57 -
    +
    +
      -
    + data.syncMock.
    - + + 58 -
    -   -
    +
    +
    + - + On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything).
    - + + 59 -
    +
    +
      -
    + Return(errors.New("error")).
    - + + 60 -
    +
    +
      -
    + Once()
    - + + 61 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + +
    @@ -107,7 +106,7 @@
    -
    +
    + 107 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 108 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 109 -
    +
    +
      -
    + data.syncMock.
    - + + 110 -
    -   -
    +
    +
    + - + On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything).
    - + + 111 -
    +
    +
      -
    + Return(nil).
    - + + 112 -
    +
    +
      -
    + Once()
    - + + 113 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
    @@ -134,7 +133,7 @@
    -
    +
    + 134 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 135 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(300)
    - + + 136 -
    +
    +
      -
    + data.syncMock.
    - + + 137 -
    -   -
    +
    +
    + - + On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything).
    - + + 138 -
    +
    +
      -
    + Return(nil).
    - + + 139 -
    +
    +
      -
    + Once()
    - + + 140 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
    @@ -163,7 +162,7 @@
    -
    +
    + 163 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 164 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 165 -
    +
    +
      -
    + data.syncMock.
    - + + 166 -
    -   -
    +
    +
    + - + On("ProcessBlockRange", mock.Anything, mock.Anything, mock.Anything).
    - + + 167 -
    +
    +
      -
    + Return(nil).
    - + + 168 -
    +
    +
      -
    + Once()
    - + + 169 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
    @@ -192,7 +191,7 @@
    -
    +
    + 192 + +
      -
    + responseRollupInfoByBlockRange.blockRange.toBlock = 400
    - + + 193 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 194 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 195 -
    -   -
    +
    +
    + - + data.syncMock.EXPECT().ProcessBlockRange(mock.Anything, mock.Anything, mock.Anything).Return(nil).Times(1)
    - + + 196 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + + 197 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 198 -
    +
    +
      -
    + }
    - + +
    @@ -207,7 +206,7 @@
    -
    +
    + 207 + +
      -
    + }
    - + + 208 -
    +
    +
     
    - + + 209 -
    +
    +
      -
    + func setupConsumerTest(t *testing.T) consumerTestData {
    - + + 210 -
    -   -
    +
    +
    + - + syncMock := mock_syncinterfaces.NewBlockRangeProcessor(t)
    - + + 211 -
    +
    +
      -
    + ch := make(chan L1SyncMessage, 10)
    - + + 212 -
    +
    +
     
    - + + 213 -
    +
    +
      -
    + cfg := ConfigConsumer{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - + + 16 -
    +
    +
     
    - + + 17 -
    +
    +
      -
    + type consumerTestData struct {
    - + + 18 -
    +
    +
      -
    + sut *l1RollupInfoConsumer
    - + + 19 -
    -   -
    +
    +
    + + + syncMock *synchronizerProcessBlockRangeInterfaceMock
    - + + 20 -
    +
    +
      -
    + ch chan L1SyncMessage
    - + + 21 -
    +
    +
      -
    + }
    - + + 22 -
    +
    +
     
    - + +
     
    -
    +
    + 54 + +
      -
    + lastBlockOfRange: types.NewBlock(&types.Header{Number: big.NewInt(123)}, nil, nil, nil, nil),
    - + + 55 -
    +
    +
      -
    + }
    - + + 56 -
    +
    +
      -
    + data.syncMock.
    - + + 57 -
    -   -
    +
    +
    + + + On("ProcessBlockRange", mock.Anything, mock.Anything).
    - + + 58 -
    +
    +
      -
    + Return(errors.New("error")).
    - + + 59 -
    +
    +
      -
    + Once()
    - + + 60 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + +
     
    -
    +
    + 106 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 107 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 108 -
    +
    +
      -
    + data.syncMock.
    - + + 109 -
    -   -
    +
    +
    + + + On("ProcessBlockRange", mock.Anything, mock.Anything).
    - + + 110 -
    +
    +
      -
    + Return(nil).
    - + + 111 -
    +
    +
      -
    + Once()
    - + + 112 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
     
    -
    +
    + 133 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 134 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(300)
    - + + 135 -
    +
    +
      -
    + data.syncMock.
    - + + 136 -
    -   -
    +
    +
    + + + On("ProcessBlockRange", mock.Anything, mock.Anything).
    - + + 137 -
    +
    +
      -
    + Return(nil).
    - + + 138 -
    +
    +
      -
    + Once()
    - + + 139 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
     
    -
    +
    + 162 + +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 163 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 164 -
    +
    +
      -
    + data.syncMock.
    - + + 165 -
    -   -
    +
    +
    + + + On("ProcessBlockRange", mock.Anything, mock.Anything).
    - + + 166 -
    +
    +
      -
    + Return(nil).
    - + + 167 -
    +
    +
      -
    + Once()
    - + + 168 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + +
     
    -
    +
    + 191 + +
      -
    + responseRollupInfoByBlockRange.blockRange.toBlock = 400
    - + + 192 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageData(&responseRollupInfoByBlockRange)
    - + + 193 -
    +
    +
      -
    + data.ch <- *newL1SyncMessageControlWProducerIsFullySynced(200)
    - + + 194 -
    -   -
    +
    +
    + + + data.syncMock.EXPECT().ProcessBlockRange(mock.Anything, mock.Anything).Return(nil).Times(1)
    - + + 195 -
    +
    +
      -
    + err := data.sut.Start(ctxTimeout, nil)
    - + + 196 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 197 -
    +
    +
      -
    + }
    - + +
     
    -
    +
    + 206 + +
      -
    + }
    - + + 207 -
    +
    +
     
    - + + 208 -
    +
    +
      -
    + func setupConsumerTest(t *testing.T) consumerTestData {
    - + + 209 -
    -   -
    +
    +
    + + + syncMock := newSynchronizerProcessBlockRangeInterfaceMock(t)
    - + + 210 -
    +
    +
      -
    + ch := make(chan L1SyncMessage, 10)
    - + + 211 -
    +
    +
     
    - + + 212 -
    +
    +
      -
    + cfg := ConfigConsumer{ +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l1_parallel_sync/l1_worker_etherman_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
    @@ -31,7 +31,7 @@
    - + + 31 -
    +
    +
      -
    + GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
    - + + 32 -
    +
    +
      -
    + }
    - + + 33 -
    +
    +
     
    - + + 34 -
    -   -
    +
    +
    + - + ethermanClient, err := etherman.NewClient(cfg, l1Config)
    - + + 35 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 36 -
    +
    +
      -
    + worker := newWorker(ethermanClient)
    - + + 37 -
    +
    +
      -
    + ch := make(chan responseRollupInfoByBlockRange) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - + + 31 -
    +
    +
      -
    + GlobalExitRootManagerAddr: common.HexToAddress("0x8A791620dd6260079BF849Dc5567aDC3F2FdC318"),
    - + + 32 -
    +
    +
      -
    + }
    - + + 33 -
    +
    +
     
    - + + 34 -
    -   -
    +
    +
    + + + ethermanClient, err := etherman.NewClient(cfg, l1Config, nil, nil)
    - + + 35 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 36 -
    +
    +
      -
    + worker := newWorker(ethermanClient)
    - + + 37 -
    +
    +
      -
    + ch := make(chan responseRollupInfoByBlockRange) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_etrog/executor_trusted_batch_sync.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -205099,133 +286046,176 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -429,6 +430,7 @@
    - + + 429 -
    +
    +
      -
    + Transactions: data.TrustedBatch.BatchL2Data,
    - + + 430 -
    +
    +
      -
    + ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)),
    - + + 431 -
    +
    +
      -
    + SkipVerifyL1InfoRoot_V2: true,
    - + + 432 -
    +
    +
      -
    + }
    - + + 433 -
    +
    +
      -
    + return request
    - + + 434 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - + + 430 -
    +
    +
      -
    + Transactions: data.TrustedBatch.BatchL2Data,
    - + + 431 -
    +
    +
      -
    + ForkID: b.state.GetForkIDByBatchNumber(uint64(data.TrustedBatch.Number)),
    - + + 432 -
    +
    +
      -
    + SkipVerifyL1InfoRoot_V2: true,
    - + + 433 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode1,
    - + + 434 -
    +
    +
      -
    + }
    - + + 435 -
    +
    +
      -
    + return request
    - + + 436 -
    +
    +
      -
    + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/l2_sync/l2_sync_incaberry/sync_trusted_state.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - @@ -205239,1734 +286229,1821 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + +
    +
    @@ -196,6 +196,7 @@
    - + + 196 -
    +
    +
      -
    + OldAccInputHash: batches[1].AccInputHash,
    - + + 197 -
    +
    +
      -
    + Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()),
    - + + 198 -
    +
    +
      -
    + Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0),
    - + + 199 -
    +
    +
      -
    + }
    - + + 200 -
    +
    +
      -
    + // check if batch needs to be synchronized
    - + + 201 -
    +
    +
      -
    + if batches[0] != nil { +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - + + +
    +
     
    - + + 196 -
    +
    +
      -
    + OldAccInputHash: batches[1].AccInputHash,
    - + + 197 -
    +
    +
      -
    + Coinbase: common.HexToAddress(trustedBatch.Coinbase.String()),
    - + + 198 -
    +
    +
      -
    + Timestamp_V1: time.Unix(int64(trustedBatch.Timestamp), 0),
    - + + 199 -
    -   -
    +
    +
    + + + ExecutionMode: executor.ExecutionMode1,
    - + + 200 -
    +
    +
      -
    + }
    - + + 201 -
    +
    +
      -
    + // check if batch needs to be synchronized
    - + + 202 -
    +
    +
      -
    + if batches[0] != nil { +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_block_range_process.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -1,166 +0,0 @@
    - + + 1 -
    -   -
    +
    +
    + - + package synchronizer
    - + + 2 -
    -   +
    +
    + -
    - + + 3 -
    -   -
    +
    +
    + - + import (
    - + + 4 -
    -   -
    +
    +
    + - + "context"
    - + + 5 -
    -   -
    +
    +
    + - + "errors"
    - + + 6 -
    -   +
    +
    + -
    - + + 7 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - + + 8 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - + + 9 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - + + 10 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/actions"
    - + + 11 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces"
    - + + 12 -
    -   -
    +
    +
    + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/l1event_orders"
    - + + 13 -
    -   -
    +
    +
    + - + "github.com/ethereum/go-ethereum/common"
    - + + 14 -
    -   -
    +
    +
    + - + "github.com/jackc/pgx/v4"
    - + + 15 -
    -   -
    +
    +
    + - + )
    - + + 16 -
    -   +
    +
    + -
    - + + 17 -
    -   -
    +
    +
    + - + type stateBlockRangeProcessor interface {
    - + + 18 -
    -   -
    +
    +
    + - + BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
    - + + 19 -
    -   -
    +
    +
    + - + AddBlock(ctx context.Context, block *state.Block, dbTx pgx.Tx) error
    - + + 20 -
    -   -
    +
    +
    + - + GetForkIDByBatchNumber(batchNumber uint64) uint64
    - + + 21 -
    -   -
    +
    +
    + - + GetForkIDByBlockNumber(blockNumber uint64) uint64
    - + + 22 -
    -   -
    +
    +
    + - + }
    - + + 23 -
    -   +
    +
    + -
    - + + 24 -
    -   -
    +
    +
    + - + type ethermanI interface {
    - + + 25 -
    -   -
    +
    +
    + - + GetFinalizedBlockNumber(ctx context.Context) (uint64, error)
    - + + 26 -
    -   -
    +
    +
    + - + }
    - + + 27 -
    -   +
    +
    + -
    - + + 28 -
    -   -
    +
    +
    + - + // BlockRangeProcess is the struct that process the block range that implements syncinterfaces.BlockRangeProcessor
    - + + 29 -
    -   -
    +
    +
    + - + type BlockRangeProcess struct {
    - + + 30 -
    -   -
    +
    +
    + - + state stateBlockRangeProcessor
    - + + 31 -
    -   -
    +
    +
    + - + etherMan ethermanI
    - + + 32 -
    -   -
    +
    +
    + - + l1EventProcessors syncinterfaces.L1EventProcessorManager
    - + + 33 -
    -   -
    +
    +
    + - + flushIdManager syncinterfaces.SynchronizerFlushIDManager
    - + + 34 -
    -   -
    +
    +
    + - + }
    - + + 35 -
    -   +
    +
    + -
    - + + 36 -
    -   -
    +
    +
    + - + // NewBlockRangeProcessLegacy creates a new BlockRangeProcess
    - + + 37 -
    -   -
    +
    +
    + - + func NewBlockRangeProcessLegacy(
    - + + 38 -
    -   -
    +
    +
    + - + state stateBlockRangeProcessor,
    - + + 39 -
    -   -
    +
    +
    + - + etherMan ethermanI,
    - + + 40 -
    -   -
    +
    +
    + - + l1EventProcessors syncinterfaces.L1EventProcessorManager,
    - + + 41 -
    -   -
    +
    +
    + - + flushIdManager syncinterfaces.SynchronizerFlushIDManager,
    - + + 42 -
    -   -
    +
    +
    + - + ) *BlockRangeProcess {
    - + + 43 -
    -   -
    +
    +
    + - + return &BlockRangeProcess{
    - + + 44 -
    -   -
    +
    +
    + - + state: state,
    - + + 45 -
    -   -
    +
    +
    + - + etherMan: etherMan,
    - + + 46 -
    -   -
    +
    +
    + - + l1EventProcessors: l1EventProcessors,
    - + + 47 -
    -   -
    +
    +
    + - + flushIdManager: flushIdManager,
    - + + 48 -
    -   -
    +
    +
    + - + }
    - + + 49 -
    -   -
    +
    +
    + - + }
    - + + 50 -
    -   +
    +
    + -
    - + + 51 -
    -   -
    +
    +
    + - + // ProcessBlockRangeSingleDbTx process the L1 events and stores the information in the db reusing same DbTx
    - + + 52 -
    -   -
    +
    +
    + - + func (s *BlockRangeProcess) ProcessBlockRangeSingleDbTx(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order, storeBlocks syncinterfaces.ProcessBlockRangeL1BlocksMode, dbTx pgx.Tx) error {
    - + + 53 -
    -   -
    +
    +
    + - + return s.internalProcessBlockRange(ctx, blocks, order, storeBlocks, &dbTx)
    - + + 54 -
    -   -
    +
    +
    + - + }
    - + + 55 -
    -   +
    +
    + -
    - + + 56 -
    -   -
    +
    +
    + - + // ProcessBlockRange process the L1 events and stores the information in the db
    - + + 57 -
    -   -
    +
    +
    + - + func (s *BlockRangeProcess) ProcessBlockRange(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order) error {
    - + + 58 -
    -   -
    +
    +
    + - + return s.internalProcessBlockRange(ctx, blocks, order, syncinterfaces.StoreL1Blocks, nil)
    - + + 59 -
    -   -
    +
    +
    + - + }
    - + + 60 -
    -   +
    +
    + -
    - + + 61 -
    -   -
    +
    +
    + - + // ProcessBlockRange process the L1 events and stores the information in the db
    - + + 62 -
    -   -
    +
    +
    + - + func (s *BlockRangeProcess) internalProcessBlockRange(ctx context.Context, blocks []etherman.Block, order map[common.Hash][]etherman.Order, storeBlocks syncinterfaces.ProcessBlockRangeL1BlocksMode, dbTxExt *pgx.Tx) error {
    - + + 63 -
    -   -
    +
    +
    + - + // Check the latest finalized block in L1
    - + + 64 -
    -   -
    +
    +
    + - + finalizedBlockNumber, err := s.etherMan.GetFinalizedBlockNumber(ctx)
    - + + 65 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 66 -
    -   -
    +
    +
    + - + log.Errorf("error getting finalized block number in L1. Error: %v", err)
    - + + 67 -
    -   -
    +
    +
    + - + return err
    - + + 68 -
    -   -
    +
    +
    + - + }
    - + + 69 -
    -   -
    +
    +
    + - + // New info has to be included into the db using the state
    - + + 70 -
    -   -
    +
    +
    + - + for i := range blocks {
    - + + 71 -
    -   -
    +
    +
    + - + // Begin db transaction
    - + + 72 -
    -   -
    +
    +
    + - + var dbTx pgx.Tx
    - + + 73 -
    -   -
    +
    +
    + - + var err error
    - + + 74 -
    -   -
    +
    +
    + - + if dbTxExt == nil {
    - + + 75 -
    -   -
    +
    +
    + - + log.Debugf("Starting dbTx for BlockNumber:%d", blocks[i].BlockNumber) +
    +
    + 76 + +
    + - + dbTx, err = s.state.BeginStateTransaction(ctx) +
    +
    + 77 + +
    + - + if err != nil { +
    +
    + 78 + +
    + - + return err +
    +
    + 79 + +
    + - + }
    - + + 80 -
    -   -
    +
    +
    + - + } else {
    - + + 81 -
    -   -
    +
    +
    + - + dbTx = *dbTxExt
    - + + 82 -
    -   -
    +
    +
    + - + }
    - + + 83 -
    -   -
    +
    +
    + - + // Process event received from l1
    - + + 84 -
    -   -
    +
    +
    + - + err = s.processBlock(ctx, blocks, i, dbTx, order, storeBlocks, finalizedBlockNumber)
    - + + 85 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 86 -
    -   -
    +
    +
    + - + if dbTxExt == nil {
    - + + 87 -
    -   -
    +
    +
    + - + // Rollback db transaction
    - + + 88 -
    -   -
    +
    +
    + - + rollbackErr := dbTx.Rollback(ctx)
    - + + 89 -
    -   -
    +
    +
    + - + if rollbackErr != nil {
    - + + 90 -
    -   -
    +
    +
    + - + if !errors.Is(rollbackErr, pgx.ErrTxClosed) {
    - + + 91 -
    -   -
    +
    +
    + - + log.Errorf("error rolling back state. RollbackErr: %s, Error : %v", rollbackErr.Error(), err)
    - + + 92 -
    -   -
    +
    +
    + - + return rollbackErr
    - + + 93 -
    -   -
    +
    +
    + - + } else {
    - + + 94 -
    -   -
    +
    +
    + - + log.Warnf("error rolling back state because is already closed. RollbackErr: %s, Error : %v", rollbackErr.Error(), err)
    - + + 95 -
    -   -
    +
    +
    + - + return err
    - + + 96 -
    -   -
    +
    +
    + - + }
    - + + 97 -
    -   -
    +
    +
    + - + }
    - + + 98 -
    -   -
    +
    +
    + - + return err
    - + + 99 -
    -   -
    +
    +
    + - + }
    - + + 100 -
    -   -
    +
    +
    + - + return err
    - + + 101 -
    -   -
    +
    +
    + - + }
    - + + 102 -
    -   -
    +
    +
    + - + if dbTxExt == nil {
    - + + 103 -
    -   -
    +
    +
    + - + // Commit db transaction
    - + + 104 -
    -   -
    +
    +
    + - + err = dbTx.Commit(ctx)
    - + + 105 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 106 -
    -   -
    +
    +
    + - + log.Errorf("error committing state. BlockNumber: %d, Error: %v", blocks[i].BlockNumber, err)
    - + + 107 -
    -   -
    +
    +
    + - + }
    - + + 108 -
    -   -
    +
    +
    + - + }
    - + + 109 -
    -   -
    +
    +
    + - + }
    - + + 110 -
    -   -
    +
    +
    + - + return nil
    - + + 111 -
    -   -
    +
    +
    + - + }
    - + + 112 -
    -   +
    +
    + -
    - + + 113 -
    -   -
    +
    +
    + - + func (s *BlockRangeProcess) processBlock(ctx context.Context, blocks []etherman.Block, i int, dbTx pgx.Tx, order map[common.Hash][]etherman.Order, storeBlock syncinterfaces.ProcessBlockRangeL1BlocksMode, finalizedBlockNumber uint64) error {
    - + + 114 -
    -   -
    +
    +
    + - + var err error
    - + + 115 -
    -   -
    +
    +
    + - + if storeBlock == syncinterfaces.StoreL1Blocks {
    - + + 116 -
    -   -
    +
    +
    + - + b := state.Block{
    - + + 117 -
    -   -
    +
    +
    + - + BlockNumber: blocks[i].BlockNumber,
    - + + 118 -
    -   -
    +
    +
    + - + BlockHash: blocks[i].BlockHash,
    - + + 119 -
    -   -
    +
    +
    + - + ParentHash: blocks[i].ParentHash,
    - + + 120 -
    -   -
    +
    +
    + - + ReceivedAt: blocks[i].ReceivedAt,
    - + + 121 -
    -   -
    +
    +
    + - + }
    - + + 122 -
    -   -
    +
    +
    + - + if blocks[i].BlockNumber <= finalizedBlockNumber {
    - + + 123 -
    -   -
    +
    +
    + - + b.Checked = true
    - + + 124 -
    -   -
    +
    +
    + - + }
    - + + 125 -
    -   -
    +
    +
    + - + err = s.state.AddBlock(ctx, &b, dbTx)
    - + + 126 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 127 -
    -   -
    +
    +
    + - + log.Errorf("error adding block to db. BlockNumber: %d, error: %v", blocks[i].BlockNumber, err)
    - + + 128 -
    -   -
    +
    +
    + - + return err
    - + + 129 -
    -   -
    +
    +
    + - + }
    - + + 130 -
    -   -
    +
    +
    + - + } else {
    - + + 131 -
    -   -
    +
    +
    + - + log.Debugf("Skip storing block BlockNumber:%d", blocks[i].BlockNumber)
    - + + 132 -
    -   -
    +
    +
    + - + }
    - + + 133 -
    -   -
    +
    +
    + - + for _, element := range order[blocks[i].BlockHash] {
    - + + 134 -
    -   -
    +
    +
    + - + err := s.processElement(ctx, element, blocks, i, dbTx)
    - + + 135 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 136 -
    -   -
    +
    +
    + - + return err
    - + + 137 -
    -   -
    +
    +
    + - + }
    - + + 138 -
    -   -
    +
    +
    + - + }
    - + + 139 -
    -   -
    +
    +
    + - + log.Debug("Checking FlushID to commit L1 data to db")
    - + + 140 -
    -   -
    +
    +
    + - + err = s.flushIdManager.CheckFlushID(dbTx)
    - + + 141 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 142 -
    -   -
    +
    +
    + - + log.Errorf("error checking flushID. BlockNumber: %d, Error: %v", blocks[i].BlockNumber, err)
    - + + 143 -
    -   -
    +
    +
    + - + return err
    - + + 144 -
    -   -
    +
    +
    + - + }
    - + + 145 -
    -   -
    +
    +
    + - + return nil
    - + + 146 -
    -   -
    +
    +
    + - + }
    - + + 147 -
    -   +
    +
    + -
    - + + 148 -
    -   -
    +
    +
    + - + func (s *BlockRangeProcess) processElement(ctx context.Context, element etherman.Order, blocks []etherman.Block, i int, dbTx pgx.Tx) error {
    - + + 149 -
    -   -
    +
    +
    + - + batchSequence := l1event_orders.GetSequenceFromL1EventOrder(element.Name, &blocks[i], element.Pos)
    - + + 150 -
    -   -
    +
    +
    + - + var forkId uint64
    - + + 151 -
    -   -
    +
    +
    + - + if batchSequence != nil {
    - + + 152 -
    -   -
    +
    +
    + - + forkId = s.state.GetForkIDByBatchNumber(batchSequence.FromBatchNumber)
    - + + 153 -
    -   -
    +
    +
    + - + log.Debug("EventOrder: ", element.Name, ". Batch Sequence: ", batchSequence, "forkId: ", forkId)
    - + + 154 -
    -   -
    +
    +
    + - + } else {
    - + + 155 -
    -   -
    +
    +
    + - + forkId = s.state.GetForkIDByBlockNumber(blocks[i].BlockNumber)
    - + + 156 -
    -   -
    +
    +
    + - + log.Debug("EventOrder: ", element.Name, ". BlockNumber: ", blocks[i].BlockNumber, "forkId: ", forkId)
    - + + 157 -
    -   -
    +
    +
    + - + }
    - + + 158 -
    -   -
    +
    +
    + - + forkIdTyped := actions.ForkIdType(forkId)
    - + + 159 -
    -   +
    +
    + -
    - + + 160 -
    -   -
    +
    +
    + - + err := s.l1EventProcessors.Process(ctx, forkIdTyped, element, &blocks[i], dbTx)
    - + + 161 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 162 -
    -   -
    +
    +
    + - + log.Error("error l1EventProcessors.Process: ", err)
    - + + 163 -
    -   -
    +
    +
    + - + return err
    - + + 164 -
    -   -
    +
    +
    + - + }
    - + + 165 -
    -   -
    +
    +
    + - + return nil
    - + + 166 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -208628,1264 +289705,1483 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - + + + + + + - - - - - + - + + - - - - - - + + + + + + + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + + + + + + + + + + + + + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - @@ -210629,273 +291925,342 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - + + + - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - + + + - - - - + + +
    +
    @@ -79,8 +79,6 @@
    +
    - + + 79 -
    +
    +
      -
    + syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor
    - + + 80 -
    +
    +
      -
    + halter syncinterfaces.CriticalErrorHandler
    - + + 81 -
    +
    +
      -
    + asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator
    - + + 82 -
    +
    +
    + - + blockRangeProcessor syncinterfaces.BlockRangeProcessor +
    +
    + 83 + +
    + - + syncPreRollup syncinterfaces.SyncPreRollupSyncer +
    +
    + 84 + +
      -
    + }
    - + + 85 -
    +
    +
     
    - + + 86 -
    +
    +
      -
    + // NewSynchronizer creates and initializes an instance of Synchronizer
    - + +
    @@ -168,9 +166,9 @@
    -
    +
    + 168 + +
     
    - + + 169 -
    +
    +
      -
    + syncTrustedStateEtrog := l2_shared.NewTrustedBatchesRetrieve(executor, zkEVMClient, res.state, *sync, *l2_shared.NewTrustedStateManager(syncCommon.DefaultTimeProvider{}, timeOfLiveBatchOnCache))
    - + + 170 -
    +
    +
      -
    + res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{
    - + + 171 -
    +
    +
    + - + uint64(state.FORKID_ETROG): syncTrustedStateEtrog, +
    +
    + 172 + +
    + - + uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog, +
    +
    + 173 + +
    + - + uint64(state.FORKID_ELDERBERRY_2): syncTrustedStateEtrog, +
    +
    + 174 + +
      -
    + }, res.state)
    - + + 175 -
    +
    +
      -
    + }
    - + + 176 -
    +
    +
      -
    + var l1checkerL2Blocks *actions.CheckL2BlockHash
    - + +
    @@ -185,7 +183,7 @@
    -
    +
    + 185 + +
      -
    + log.Errorf("error getting last L2Block number from state. Error: %v", err)
    - + + 186 -
    +
    +
      -
    + return nil, err
    - + + 187 -
    +
    +
      -
    + }
    - + + 188 -
    +
    +
    + - + l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberModulus) +
    +
    + 189 + +
      -
    + if err != nil {
    - + + 190 -
    +
    +
      -
    + log.Error("error creating new instance of checkL2BlockHash. Error: ", err)
    - + + 191 -
    +
    +
      -
    + return nil, err
    - + +
    @@ -196,8 +194,6 @@
    -
    +
    + 196 + +
      -
    + }
    - + + 197 -
    +
    +
     
    - + + 198 -
    +
    +
      -
    + res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks)
    - + + 199 -
    +
    +
    + - + res.blockRangeProcessor = NewBlockRangeProcessLegacy(st, ethMan, res.l1EventProcessors, res) +
    +
    + 200 + +
    + - + res.syncPreRollup = NewSyncPreRollup(ethMan, st, res.blockRangeProcessor, cfg.SyncChunkSize, genesis.BlockNumber) +
    +
    + 201 + +
      -
    + switch cfg.L1SynchronizationMode {
    - + + 202 -
    +
    +
      -
    + case ParallelMode:
    - + + 203 -
    +
    +
      -
    + log.Info("L1SynchronizationMode is parallel")
    - + +
    @@ -232,7 +228,7 @@
    -
    +
    + 232 + +
      -
    + ApplyAfterNumRollupReceived: cfg.L1ParallelSynchronization.PerformanceWarning.ApplyAfterNumRollupReceived,
    - + + 233 -
    +
    +
      -
    + AceptableInacctivityTime: cfg.L1ParallelSynchronization.PerformanceWarning.AceptableInacctivityTime.Duration,
    - + + 234 -
    +
    +
      -
    + }
    - + + 235 -
    +
    +
    + - + L1DataProcessor := l1_parallel_sync.NewL1RollupInfoConsumer(cfgConsumer, sync.blockRangeProcessor, chIncommingRollupInfo) +
    +
    + 236 + +
     
    - + + 237 -
    +
    +
      -
    + cfgProducer := l1_parallel_sync.ConfigProducer{
    - + + 238 -
    +
    +
      -
    + SyncChunkSize: cfg.SyncChunkSize,
    - + +
    @@ -279,91 +275,8 @@
    -
    +
    + 279 + +
      -
    + return err
    - + + 280 -
    +
    +
      -
    + }
    - + + 281 -
    +
    +
     
    - + + 282 -
    -   +
    +
    + - + func (s *ClientSynchronizer) isGenesisProcessed(ctx context.Context, dbTx pgx.Tx) (bool, *state.Block, error) { +
    +
    + 283 + +
    + - + lastEthBlockSynced, err := s.state.GetLastBlock(ctx, dbTx) +
    +
    + 284 + +
    + - + if err != nil && errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 285 + +
    + - + return false, lastEthBlockSynced, nil +
    +
    + 286 + +
    + - + } +
    +
    + 287 + +
    + -
    - + + 288 + +
    + - + if lastEthBlockSynced.BlockNumber >= s.genesis.BlockNumber { +
    +
    + 289 + +
    + - + log.Infof("Genesis block processed. Last block synced: %d >= genesis %d", lastEthBlockSynced.BlockNumber, s.genesis.BlockNumber) +
    +
    + 290 + +
    + - + return true, lastEthBlockSynced, nil +
    +
    + 291 -
    -   -
    +
    +
    + - + }
    - + + 292 -
    -   -
    +
    +
    + - + log.Warnf("Genesis block not processed yet. Last block synced: %d < genesis %d", lastEthBlockSynced.BlockNumber, s.genesis.BlockNumber)
    - + + 293 -
    -   -
    +
    +
    + - + return false, lastEthBlockSynced, nil
    - + + 294 -
    -   -
    +
    +
    + - + }
    - + + 295 -
    -   +
    +
    + -
    - + + 296 -
    -   -
    +
    +
    + - + func (s *ClientSynchronizer) processGenesis() (*state.Block, error) {
    - + + 297 -
    -   -
    +
    +
    + - + log.Info("State is empty, verifying genesis block")
    - + + 298 -
    -   -
    +
    +
    + - + valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.BlockNumber)
    - + + 299 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 300 -
    -   -
    +
    +
    + - + log.Error("error checking genesis block number. Error: ", err)
    - + + 301 -
    -   -
    +
    +
    + - + return nil, err
    - + + 302 -
    -   -
    +
    +
    + - + } else if !valid {
    - + + 303 -
    -   -
    +
    +
    + - + log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")
    - + + 304 -
    -   -
    +
    +
    + - + return nil, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")
    - + + 305 -
    -   -
    +
    +
    + - + }
    - + + 306 -
    -   -
    +
    +
    + - + // Sync pre genesis rollup events
    - + + 307 -
    -   -
    +
    +
    + - + s.syncPreRollup.(*SyncPreRollup).GenesisBlockNumber = s.genesis.BlockNumber
    - + + 308 -
    -   -
    +
    +
    + - + err = s.syncPreRollup.SynchronizePreGenesisRollupEvents(s.ctx)
    - + + 309 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 310 -
    -   -
    +
    +
    + - + log.Error("error synchronizing pre genesis rollup events: ", err)
    - + + 311 -
    -   -
    +
    +
    + - + return nil, err
    - + + 312 -
    -   -
    +
    +
    + - + }
    - + + 313 -
    -   -
    +
    +
    + - + log.Info("Setting genesis block")
    - + + 314 -
    -   -
    +
    +
    + - + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.BlockNumber))
    - + + 315 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 316 -
    -   -
    +
    +
    + - + log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.BlockNumber, err)
    - + + 317 -
    -   -
    +
    +
    + - + return nil, err
    - + + 318 -
    -   -
    +
    +
    + - + }
    - + + 319 -
    -   -
    +
    +
    + - + lastEthBlockSynced := &state.Block{
    - + + 320 -
    -   -
    +
    +
    + - + BlockNumber: header.Number.Uint64(),
    - + + 321 -
    -   -
    +
    +
    + - + BlockHash: header.Hash(),
    - + + 322 -
    -   -
    +
    +
    + - + ParentHash: header.ParentHash,
    - + + 323 -
    -   -
    +
    +
    + - + ReceivedAt: time.Unix(int64(header.Time), 0),
    - + + 324 -
    -   -
    +
    +
    + - + }
    - + + 325 -
    -   -
    +
    +
    + - + dbTx, err := s.state.BeginStateTransaction(s.ctx)
    - + + 326 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 327 -
    -   -
    +
    +
    + - + log.Errorf("error creating db transaction to get latest block. Error: %v", err)
    - + + 328 -
    -   -
    +
    +
    + - + return nil, err
    - + + 329 -
    -   -
    +
    +
    + - + }
    - + + 330 -
    -   -
    +
    +
    + - + genesisRoot, err := s.state.SetGenesis(s.ctx, *lastEthBlockSynced, s.genesis, stateMetrics.SynchronizerCallerLabel, dbTx)
    - + + 331 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 332 -
    -   -
    +
    +
    + - + log.Error("error setting genesis: ", err)
    - + + 333 -
    -   -
    +
    +
    + - + return nil, rollback(s.ctx, dbTx, err)
    - + + 334 -
    -   -
    +
    +
    + - + }
    - + + 335 -
    -   -
    +
    +
    + - + err = s.RequestAndProcessRollupGenesisBlock(dbTx, lastEthBlockSynced)
    - + + 336 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 337 -
    -   -
    +
    +
    + - + log.Error("error processing Rollup genesis block: ", err)
    - + + 338 -
    -   -
    +
    +
    + - + return nil, rollback(s.ctx, dbTx, err)
    - + + 339 -
    -   -
    +
    +
    + - + }
    - + + 340 -
    -   +
    +
    + -
    - + + 341 -
    -   -
    +
    +
    + - + if genesisRoot != s.genesis.Root {
    - + + 342 -
    -   -
    +
    +
    + - + log.Errorf("Calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String())
    - + + 343 -
    -   -
    +
    +
    + - + return nil, rollback(s.ctx, dbTx, err)
    - + + 344 -
    -   -
    +
    +
    + - + }
    - + + 345 -
    -   -
    +
    +
    + - + // Waiting for the flushID to be stored
    - + + 346 -
    -   -
    +
    +
    + - + err = s.checkFlushID(dbTx)
    - + + 347 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 348 -
    -   -
    +
    +
    + - + log.Error("error checking genesis flushID: ", err)
    - + + 349 -
    -   -
    +
    +
    + - + return nil, rollback(s.ctx, dbTx, err)
    - + + 350 -
    -   -
    +
    +
    + - + }
    - + + 351 -
    -   -
    +
    +
    + - + if err := dbTx.Commit(s.ctx); err != nil {
    - + + 352 -
    -   -
    +
    +
    + - + log.Errorf("error genesis committing dbTx, err: %v", err)
    - + + 353 -
    -   -
    +
    +
    + - + return nil, rollback(s.ctx, dbTx, err)
    - + + 354 -
    -   -
    +
    +
    + - + }
    - + + 355 -
    -   -
    +
    +
    + - + log.Info("Genesis root matches! Stored genesis blocks.")
    - + + 356 -
    -   -
    +
    +
    + - + return lastEthBlockSynced, nil
    - + + 357 -
    -   -
    +
    +
    + - + }
    - + + 358 -
    -   +
    +
    + -
    - + + 359 -
    +
    +
      -
    + // Sync function will read the last state synced and will continue from that point.
    - + + 360 -
    +
    +
      -
    + // Sync() will read blockchain events to detect rollup updates
    - + + 361 -
    -   -
    +
    +
    + - + // 1. Check if genesisProcess is done
    - + + 362 -
    -   -
    +
    +
    + - + // 2. If not, process genesis
    - + + 363 -
    -   -
    +
    +
    + - + // 2.1 -There are blocks previous to the genesis block? -> go on with process of InfoRootTree
    - + + 364 -
    -   -
    +
    +
    + - + // 2.2 -There are no blocks previous to the genesis block? -> get ETROG Upgrade block and start there to process of InfoRootTree
    - + + 365 -
    -   -
    +
    +
    + - + // 3. Setup genesis data
    - + + 366 -
    -   -
    +
    +
    + - + // 4. Start sync as usual
    - + + 367 -
    +
    +
      -
    + func (s *ClientSynchronizer) Sync() error {
    - + + 368 -
    +
    +
      -
    + startInitialization := time.Now()
    - + + 369 -
    +
    +
      -
    + // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block
    - - -
    -   -
    -
    +
    +
    @@ -378,19 +291,92 @@
    - + + 378 -
    +
    +
      -
    + log.Errorf("error creating db transaction to get latest block. Error: %v", err)
    - + + 379 -
    +
    +
      -
    + return err
    - + + 380 -
    +
    +
      -
    + }
    - + + 381 -
    -   -
    +
    +
    + - + genesisDone, lastEthBlockSynced, err := s.isGenesisProcessed(s.ctx, dbTx)
    - + + 382 -
    +
    +
      -
    + if err != nil {
    - + + 383 -
    -   -
    +
    +
    + - + log.Errorf("error checking if genesis is processed. Error: %v", err)
    - + + 384 -
    -   -
    +
    +
    + - + return err
    - + + 385 -
    -   -
    +
    +
    + - + }
    - + + 386 -
    -   -
    +
    +
    + - + if !genesisDone {
    - + + 387 -
    -   -
    +
    +
    + - + lastEthBlockSynced, err = s.processGenesis()
    - + + 388 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 389 -
    -   -
    +
    +
    + - + log.Errorf("error processing genesis. Error: %v", err)
    - + + 390 -
    +
    +
      -
    + return err
    - + + 391 -
    +
    +
      -
    + }
    - + + 392 -
    +
    +
      + } +
    +
    + 393 + +
    + -
    - + + 394 -
    +
    +
      -
    + initBatchNumber, err := s.state.GetLastBatchNumber(s.ctx, dbTx)
    - + + 395 -
    +
    +
      -
    + if err != nil {
    - + + 396 -
    +
    +
      -
    + log.Error("error getting latest batchNumber synced. Error: ", err)
    - + +
    @@ -622,7 +608,7 @@
    -
    +
    + 622 + +
     
    - + + 623 -
    +
    +
      -
    + for {
    - + + 624 -
    +
    +
      -
    + if toBlock > lastKnownBlock.Uint64() {
    - + + 625 -
    +
    +
    + - + log.Debug("Setting toBlock to the lastKnownBlock: ", lastKnownBlock) +
    +
    + 626 + +
      -
    + toBlock = lastKnownBlock.Uint64()
    - + + 627 -
    +
    +
      -
    + }
    - + + 628 -
    +
    +
      -
    + if fromBlock > toBlock {
    - + +
    @@ -690,7 +676,7 @@
    -
    +
    + 690 + +
      -
    + }
    - + + 691 -
    +
    +
     
    - + + 692 -
    +
    +
      -
    + start = time.Now()
    - + + 693 -
    +
    +
    + - + err = s.blockRangeProcessor.ProcessBlockRange(s.ctx, blocks, order) +
    +
    + 694 + +
      -
    + metrics.ProcessL1DataTime(time.Since(start))
    - + + 695 -
    +
    +
      -
    + if err != nil {
    - + + 696 -
    +
    +
      -
    + return lastEthBlockSynced, err
    - + +
    @@ -1013,7 +999,7 @@
    -
    +
    + 1013 + +
      -
    + log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String())
    - + + 1014 -
    +
    +
     
    - + + 1015 -
    +
    +
      -
    + // Compare hashes
    - + + 1016 -
    +
    +
    + - + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.BlockNumber { +
    +
    + 1017 + +
      -
    + log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash)
    - + + 1018 -
    +
    +
      -
    + log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber)
    - + + 1019 -
    +
    +
      -
    + log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash)
    +
    +
    +
    +
    + + + + + - - - - - - @@ -210919,183 +292284,238 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - + + + + + + + + + - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - @@ -211119,121 +292539,141 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - + + + - - - - - + - + + - - - - - - - - @@ -212089,627 +293529,968 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    +
    - + + 79 -
    +
    +
      -
    + syncTrustedStateExecutor syncinterfaces.SyncTrustedStateExecutor
    - + + 80 -
    +
    +
      -
    + halter syncinterfaces.CriticalErrorHandler
    - + + 81 -
    +
    +
      -
    + asyncL1BlockChecker syncinterfaces.L1BlockCheckerIntegrator
    - + + 82 -
    +
    +
      -
    + }
    - + + 83 -
    +
    +
     
    - + + 84 -
    +
    +
      -
    + // NewSynchronizer creates and initializes an instance of Synchronizer
    - + +
     
    -
    +
    + 166 + +
     
    - + + 167 -
    +
    +
      -
    + syncTrustedStateEtrog := l2_shared.NewTrustedBatchesRetrieve(executor, zkEVMClient, res.state, *sync, *l2_shared.NewTrustedStateManager(syncCommon.DefaultTimeProvider{}, timeOfLiveBatchOnCache))
    - + + 168 -
    +
    +
      -
    + res.syncTrustedStateExecutor = l2_shared.NewSyncTrustedStateExecutorSelector(map[uint64]syncinterfaces.SyncTrustedStateExecutor{
    - + + 169 -
    +
    +
    + + + uint64(state.FORKID_ETROG): syncTrustedStateEtrog, +
    +
    + 170 + +
    + + + uint64(state.FORKID_ELDERBERRY): syncTrustedStateEtrog, +
    +
    + 171 + +
    + + + uint64(state.FORKID_9): syncTrustedStateEtrog, +
    +
    + 172 + +
      -
    + }, res.state)
    - + + 173 -
    +
    +
      -
    + }
    - + + 174 -
    +
    +
      -
    + var l1checkerL2Blocks *actions.CheckL2BlockHash
    - + +
     
    -
    +
    + 183 + +
      -
    + log.Errorf("error getting last L2Block number from state. Error: %v", err)
    - + + 184 -
    +
    +
      -
    + return nil, err
    - + + 185 -
    +
    +
      -
    + }
    - + + 186 -
    +
    +
    + + + l1checkerL2Blocks, err = actions.NewCheckL2BlockHash(res.state, res.zkEVMClientEthereumCompatible, initialL2Block, cfg.L1SyncCheckL2BlockNumberhModulus) +
    +
    + 187 + +
      -
    + if err != nil {
    - + + 188 -
    +
    +
      -
    + log.Error("error creating new instance of checkL2BlockHash. Error: ", err)
    - + + 189 -
    +
    +
      -
    + return nil, err
    - + +
     
    -
    +
    + 194 + +
      -
    + }
    - + + 195 -
    +
    +
     
    - + + 196 -
    +
    +
      -
    + res.l1EventProcessors = defaultsL1EventProcessors(res, l1checkerL2Blocks)
    - + + 197 -
    +
    +
      -
    + switch cfg.L1SynchronizationMode {
    - + + 198 -
    +
    +
      -
    + case ParallelMode:
    - + + 199 -
    +
    +
      -
    + log.Info("L1SynchronizationMode is parallel")
    - + +
     
    -
    +
    + 228 + +
      -
    + ApplyAfterNumRollupReceived: cfg.L1ParallelSynchronization.PerformanceWarning.ApplyAfterNumRollupReceived,
    - + + 229 -
    +
    +
      -
    + AceptableInacctivityTime: cfg.L1ParallelSynchronization.PerformanceWarning.AceptableInacctivityTime.Duration,
    - + + 230 -
    +
    +
      -
    + }
    - + + 231 -
    +
    +
    + + + L1DataProcessor := l1_parallel_sync.NewL1RollupInfoConsumer(cfgConsumer, sync, chIncommingRollupInfo) +
    +
    + 232 + +
     
    - + + 233 -
    +
    +
      -
    + cfgProducer := l1_parallel_sync.ConfigProducer{
    - + + 234 -
    +
    +
      -
    + SyncChunkSize: cfg.SyncChunkSize,
    - + +
     
    -
    +
    + 275 + +
      -
    + return err
    - + + 276 -
    +
    +
      -
    + }
    - + + 277 -
    +
    +
     
    @@ -212009,23 +293449,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 278 -
    +
    +
      -
    + // Sync function will read the last state synced and will continue from that point.
    - + + 279 -
    +
    +
      -
    + // Sync() will read blockchain events to detect rollup updates
    - + + 280 -
    +
    +
      -
    + func (s *ClientSynchronizer) Sync() error {
    - + + 281 -
    +
    +
      -
    + startInitialization := time.Now()
    - + + 282 -
    +
    +
      -
    + // If there is no lastEthereumBlock means that sync from the beginning is necessary. If not, it continues from the retrieved ethereum block
    - + +
     
    -
    +
    + 291 + +
      -
    + log.Errorf("error creating db transaction to get latest block. Error: %v", err)
    - + + 292 -
    +
    +
      -
    + return err
    - + + 293 -
    +
    +
      -
    + }
    - + + 294 -
    +
    +
    + + + lastEthBlockSynced, err := s.state.GetLastBlock(s.ctx, dbTx) +
    +
    + 295 + +
      + if err != nil { +
    +
    + 296 + +
    + + + if errors.Is(err, state.ErrStateNotSynchronized) { +
    +
    + 297 + +
    + + + log.Info("State is empty, verifying genesis block") +
    +
    + 298 + +
    + + + valid, err := s.etherMan.VerifyGenBlockNumber(s.ctx, s.genesis.RollupBlockNumber) +
    +
    + 299 + +
    + + + if err != nil { +
    +
    + 300 + +
    + + + log.Error("error checking genesis block number. Error: ", err) +
    +
    + 301 + +
    + + + return rollback(s.ctx, dbTx, err) +
    +
    + 302 + +
    + + + } else if !valid { +
    +
    + 303 + +
    + + + log.Error("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed") +
    +
    + 304 + +
    + + + return rollback(s.ctx, dbTx, fmt.Errorf("genesis Block number configured is not valid. It is required the block number where the PolygonZkEVM smc was deployed")) +
    +
    + 305 + +
    + + + } +
    +
    + 306 + +
    + +
    - + + 307 + +
    + + + // Sync events from RollupManager that happen before rollup creation +
    +
    + 308 + +
    + + + log.Info("synchronizing events from RollupManager that happen before rollup creation") +
    +
    + 309 + +
    + + + for i := s.genesis.RollupManagerBlockNumber; true; i += s.cfg.SyncChunkSize { +
    +
    + 310 + +
    + + + toBlock := min(i+s.cfg.SyncChunkSize-1, s.genesis.RollupBlockNumber-1) +
    +
    + 311 + +
    + + + blocks, order, err := s.etherMan.GetRollupInfoByBlockRange(s.ctx, i, &toBlock) +
    +
    + 312 + +
    + + + if err != nil { +
    +
    + 313 + +
    + + + log.Error("error getting rollupInfoByBlockRange before rollup genesis: ", err) +
    +
    + 314 + +
    + + + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 315 + +
    + + + if rollbackErr != nil { +
    +
    + 316 + +
    + + + log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    + 317 + +
    + + + return rollbackErr +
    +
    + 318 + +
    + + + } +
    +
    + 319 + +
    + + + return err +
    +
    + 320 + +
    + + + } +
    +
    + 321 + +
    + + + err = s.ProcessBlockRange(blocks, order) +
    +
    + 322 + +
    + + + if err != nil { +
    +
    + 323 + +
    + + + log.Error("error processing blocks before the genesis: ", err) +
    +
    + 324 + +
    + + + rollbackErr := dbTx.Rollback(s.ctx) +
    +
    + 325 + +
    + + + if rollbackErr != nil { +
    +
    + 326 + +
    + + + log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error()) +
    +
    + 327 + +
    + + + return rollbackErr +
    +
    + 328 + +
    + + + } +
    +
    + 329 + +
    + + + return err +
    +
    + 330 -
    -   -
    +
    +
    + + + }
    - + + 331 -
    -   -
    +
    +
    + + + if toBlock == s.genesis.RollupBlockNumber-1 {
    - + + 332 -
    -   -
    +
    +
    + + + break
    - + + 333 -
    -   -
    +
    +
    + + + }
    - + + 334 -
    -   -
    +
    +
    + + + }
    - + + 335 -
    -   +
    +
    + +
    - + + 336 -
    -   -
    +
    +
    + + + header, err := s.etherMan.HeaderByNumber(s.ctx, big.NewInt(0).SetUint64(s.genesis.RollupBlockNumber))
    - + + 337 -
    -   -
    +
    +
    + + + if err != nil {
    - + + 338 -
    -   -
    +
    +
    + + + log.Errorf("error getting l1 block header for block %d. Error: %v", s.genesis.RollupBlockNumber, err)
    - + + 339 -
    -   -
    +
    +
    + + + return rollback(s.ctx, dbTx, err)
    - - -
    -   -
    -
    +
    + 340
    -
    + +
    + + + }
    -
    -
    - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -212719,162 +294500,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + - - - - - - - - - - @@ -212884,1557 +294650,1535 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + +
    -
     
    - 2 + + 341 +
    -   -
    + + + log.Info("synchronizing rollup creation block")
    - 3 + + 342 +
    -   - import ( + + + lastEthBlockSynced = &state.Block{
    - 4 + + 343 +
    -   - context "context" + + + BlockNumber: header.Number.Uint64(),
    - 5 + 344
    + - "math" + BlockHash: header.Hash(),
    - 6 + + 345 +
    -   - "math/big" + + + ParentHash: header.ParentHash,
    - 7 + + 346 +
    -   - "testing" + + + ReceivedAt: time.Unix(int64(header.Time), 0),
    - 8 + + 347 +
    -   - "time" + + + }
    -
     
    +
    + 348 + +
    + + + genesisRoot, err := s.state.SetGenesis(s.ctx, *lastEthBlockSynced, s.genesis, stateMetrics.SynchronizerCallerLabel, dbTx) +
    - 19 + + 349 +
    -   - syncMocks "github.com/0xPolygonHermez/zkevm-node/synchronizer/mocks" + + + if err != nil {
    - 20 + + 350 +
    -   - "github.com/ethereum/go-ethereum/common" + + + log.Error("error setting genesis: ", err)
    - 21 + + 351 +
    -   - ethTypes "github.com/ethereum/go-ethereum/core/types" + + + return rollback(s.ctx, dbTx, err)
    - 22 + 352
    + - "github.com/ethereum/go-ethereum/rpc" + }
    - 23 + + 353 +
    -   - "github.com/jackc/pgx/v4" + + + err = s.RequestAndProcessRollupGenesisBlock(dbTx, lastEthBlockSynced)
    - 24 + + 354 +
    -   - "github.com/stretchr/testify/assert" + + + if err != nil {
    - 25 + + 355 +
    -   - "github.com/stretchr/testify/mock" + + + log.Error("error processing Rollup genesis block: ", err)
    -
     
    +
    + 356 + +
    + + + return rollback(s.ctx, dbTx, err) +
    - 34 + + 357 +
    -   - ) + + + }
    - 35 + + 358 +
    -   + +
    - 36 + + 359 +
    -   - type mocks struct { + + + if genesisRoot != s.genesis.Root {
    - 37 + + 360 +
    + - Etherman *mock_syncinterfaces.EthermanFullInterface + log.Errorf("Calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String())
    - 38 + + 361 +
    + - State *mock_syncinterfaces.StateFullInterface + return rollback(s.ctx, dbTx, fmt.Errorf("calculated newRoot should be %s instead of %s", s.genesis.Root.String(), genesisRoot.String()))
    - 39 + + 362 +
    + - Pool *mock_syncinterfaces.PoolInterface + }
    - 40 + + 363 +
    + - EthTxManager *mock_syncinterfaces.EthTxManager + // Waiting for the flushID to be stored
    - 41 + + 364 +
    + - DbTx *syncMocks.DbTxMock + err = s.checkFlushID(dbTx)
    - 42 + + 365 +
    + - ZKEVMClient *mock_syncinterfaces.ZKEVMClientInterface + if err != nil {
    - 43 + 366
    + - zkEVMClientEthereumCompatible *mock_syncinterfaces.ZKEVMClientEthereumCompatibleInterface + log.Error("error checking genesis flushID: ", err)
    - 44 + + 367 +
    -   - //EventLog *eventLogMock + + + return rollback(s.ctx, dbTx, err)
    - 45 + + 368 +
    -   - } + + + }
    - 46 + + 369 +
    -   -
    + + + log.Debug("Genesis root matches!")
    -
     
    -
    - 50 + + 370 +
    -   - func TestGivenPermissionlessNodeWhenSyncronizeAgainSameBatchThenUseTheOneInMemoryInstaeadOfGettingFromDb(t *testing.T) { + + + } else {
    - 51 + + 371 +
    -   - genesis, cfg, m := setupGenericTest(t) + + + log.Error("unexpected error getting the latest ethereum block. Error: ", err)
    - 52 + + 372 +
    -   - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + + + rollbackErr := dbTx.Rollback(s.ctx)
    - 53 + + 373 +
    + - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) + if rollbackErr != nil {
    - 54 + + 374 +
    -   - require.NoError(t, err) + + + log.Errorf("error rolling back state. RollbackErr: %v, err: %s", rollbackErr, err.Error())
    - 55 + + 375 +
    -   - sync, ok := syncInterface.(*ClientSynchronizer) + + + return rollbackErr
    - 56 + + 376 +
    -   - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") + + + }
    -
     
    -
    - 90 + 377
      - func TestGivenPermissionlessNodeWhenSyncronizeFirstTimeABatchThenStoreItInALocalVar(t *testing.T) { + return err
    - 91 + 378
      - genesis, cfg, m := setupGenericTest(t) + }
    - 92 + 379
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + }
    - 93 + + -
    - + - syncInterface, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, *genesis, *cfg, false) +
    +
    +   +
    - 94 + 380
      - require.NoError(t, err) + initBatchNumber, err := s.state.GetLastBatchNumber(s.ctx, dbTx)
    - 95 + 381
      - sync, ok := syncInterface.(*ClientSynchronizer) + if err != nil {
    - 96 + 382
      - require.EqualValues(t, true, ok, "Can't convert to underlaying struct the interface of syncronizer") + log.Error("error getting latest batchNumber synced. Error: ", err)
    - 122 + 608
      - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 +
    - 123 + 609
      - func TestForcedBatchEtrog(t *testing.T) { + for {
    - 124 + 610
      - genesis := state.Genesis{ + if toBlock > lastKnownBlock.Uint64() {
    - 125 + 611
    + - RollupBlockNumber: uint64(0), + log.Debug("Setting toBlock to the lastKnownBlock")
    - 126 + 612
      - } + toBlock = lastKnownBlock.Uint64()
    - 127 + 613
      - cfg := Config{ + }
    - 128 + 614
      - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + if fromBlock > toBlock {
    +
     
    +
    - 129 + 676
      - SyncChunkSize: 10, + }
    - 130 + 677
      - L1SynchronizationMode: SequentialMode, -
    -
    - 131 - -
    - + - SyncBlockProtection: "latest", -
    -
    - 132 - -
    - + - L1BlockCheck: L1BlockCheckConfig{ +
    - 133 + + 678 +
    - + - Enable: false, +   + start = time.Now()
    - 134 + + 679 +
    + - }, + err = s.ProcessBlockRange(blocks, order)
    - 135 + 680
      - } + metrics.ProcessL1DataTime(time.Since(start))
    - 136 + 681
      -
    + if err != nil {
    - 137 + 682
      - m := mocks{ + return lastEthBlockSynced, err
    - 142 + 999
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + log.Infof("[checkReorg function] reorgedBlockNumber: %d reorgedBlockHash already synced: %s", reorgedBlock.BlockNumber, reorgedBlock.BlockHash.String())
    - 143 + 1000
      - } +
    - 144 + 1001
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + // Compare hashes
    - 145 + 1002
    + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + if (block.BlockHash != reorgedBlock.BlockHash || block.ParentHash != reorgedBlock.ParentHash) && reorgedBlock.BlockNumber > s.genesis.RollupBlockNumber {
    - 146 + 1003
      - require.NoError(t, err) + log.Infof("checkReorg: Bad block %d hashOk %t parentHashOk %t", reorgedBlock.BlockNumber, block.BlockHash == reorgedBlock.BlockHash, block.ParentHash == reorgedBlock.ParentHash)
    - 147 + 1004
      -
    + log.Debug("[checkReorg function] => latestBlockNumber: ", reorgedBlock.BlockNumber)
    - 148 + 1005
      - // state preparation + log.Debug("[checkReorg function] => latestBlockHash: ", reorgedBlock.BlockHash)
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
     
    -
    - 158 - -
    -   - Run(func(args mock.Arguments) { -
    +
    @@ -1,122 +0,0 @@
    - 159 + + 1 +
    -   - ctx := args[0].(context.Context) + - + package synchronizer
    - 160 + + 2 +
    -   - parentHash := common.HexToHash("0x111") + - +
    - 161 + + 3 +
    - + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + - + import (
    - 162 + + 4 +
    - + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + - + "context"
    - 163 + + 5 +
    - + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + - + "errors"
    - 164 + + 6 +
    - + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + - + "time"
    - 165 + + 7 +
    - + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + - +
    - 166 + + 8 +
    - + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 167 + + 9 +
    -   -
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 168 + + 10 +
    -   - m.State. + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 169 + + 11 +
    -   - On("GetForkIDByBatchNumber", mock.Anything). + - + "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces"
    - 170 + + 12 +
    -   - Return(uint64(7), nil). + - + "github.com/jackc/pgx/v4"
    - 171 + + 13 +
    -   - Maybe() + - + )
    - 172 + + 14 +
    - + + -
    - 173 + + 15 +
    -   - m.State. + - + const (
    - 174 + + 16 +
    -   - On("GetLastBlock", ctx, m.DbTx). + - + pregenesisSyncLogPrefix = "sync pregenesis:"
    - 175 + + 17 +
    - + - Return(lastBlock0, nil). + - + )
    - 176 + + 18 +
    -   - Once() + - +
    - 177 + + 19 +
    -   -
    + - + // SyncPreRollup is the struct for synchronizing pre genesis rollup events.
    - 178 + + 20 +
    -   - m.State. + - + // Implements: syncinterfaces.SyncPreRollupSyncer
    -
     
    -
    - 208 + + 21 +
    -   - Return(nil) + - + type SyncPreRollup struct {
    - 209 + + 22 +
    -   -
    + - + etherman syncinterfaces.EthermanPreRollup
    - 210 + + 23 +
    -   - m.Etherman. + - + state syncinterfaces.StateLastBlockGetter
    - 211 + + 24 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + - + blockRangeProcessor syncinterfaces.BlockRangeProcessor
    - 212 + + 25 +
    - + - Return(ethBlock0, nil). + - + SyncChunkSize uint64
    - 213 + + 26 +
    - + - Times(2) + - + GenesisBlockNumber uint64
    - 214 + + 27 +
    -   -
    + - + }
    - 215 + + 28 +
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) + - +
    - 216 + + 29 +
    -   - m.Etherman. + - + // NewSyncPreRollup creates a new SyncPreRollup
    - 217 + + 30 +
    -   - On("HeaderByNumber", mock.Anything, n). + - + func NewSyncPreRollup(
    - 218 + + 31 +
    - + - Return(ethHeader1, nil). + - + etherman syncinterfaces.EthermanPreRollup,
    - 219 + + 32 +
    -   - Once() + - + state syncinterfaces.StateLastBlockGetter,
    - 220 + + 33 +
    -   -
    + - + blockRangeProcessor syncinterfaces.BlockRangeProcessor,
    - 221 + + 34 +
    -   - t := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + - + syncChunkSize uint64,
    -
     
    -
    - 234 + + 35 +
    -   - } + - + genesisBlockNumber uint64,
    - 235 + + 36 +
    -   -
    + - + ) *SyncPreRollup {
    - 236 + + 37 +
    -   - forceb := []etherman.ForcedBatch{{ + - + return &SyncPreRollup{
    - 237 + + 38 +
    - + - BlockNumber: lastBlock1.BlockNumber, + - + etherman: etherman,
    - 238 + + 39 +
    -   - ForcedBatchNumber: 1, + - + state: state,
    - 239 + + 40 +
    -   - Sequencer: sequencedBatch.Coinbase, + - + blockRangeProcessor: blockRangeProcessor,
    - 240 + + 41 +
    -   - GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + SyncChunkSize: syncChunkSize,
    -
     
    -
    - 242 + + 42 +
    -   - ForcedAt: time.Unix(int64(sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), + - + GenesisBlockNumber: genesisBlockNumber,
    - 243 + + 43 +
    -   - }} + - + }
    - 244 + + 44 +
    -   -
    + - + }
    - 245 + + 45 +
    - + - ethermanBlock0 := etherman.Block{ + - +
    - 246 + + 46 +
    - + - BlockNumber: 0, + - + // SynchronizePreGenesisRollupEvents sync pre-rollup events
    - 247 + + 47 +
    - + - ReceivedAt: t, + - + func (s *SyncPreRollup) SynchronizePreGenesisRollupEvents(ctx context.Context) error {
    - 248 + + 48 +
    - + - BlockHash: ethBlock0.Hash(), + - + // Sync events from RollupManager that happen before rollup creation
    - 249 + + 49 +
    - + - } + - + log.Info(pregenesisSyncLogPrefix + "synchronizing events from RollupManager that happen before rollup creation")
    - 250 + + 50 +
    - + - ethermanBlock1 := etherman.Block{ + - + needToUpdate, fromBlock, err := s.getStartingL1Block(ctx, nil)
    - 251 + + 51 +
    -   - BlockNumber: 1, + - + if err != nil {
    - 252 + + 52 +
    -   - ReceivedAt: t, + - + log.Errorf(pregenesisSyncLogPrefix+"error getting starting L1 block. Error: %v", err)
    - 253 + + 53 +
    - + - BlockHash: ethBlock1.Hash(), + - + return err
    - 254 + + 54 +
    -   - SequencedBatches: [][]etherman.SequencedBatch{{sequencedBatch}}, + - + }
    - 255 + + 55 +
    -   - ForcedBatches: forceb, + - + if needToUpdate {
    - 256 + + 56 +
    -   - } + - + return s.ProcessL1InfoRootEvents(ctx, fromBlock, s.GenesisBlockNumber-1, s.SyncChunkSize)
    - 257 + + 57 +
    - + - blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} + - + } else {
    - 258 + + 58 +
    -   - order := map[common.Hash][]etherman.Order{ + - + log.Infof(pregenesisSyncLogPrefix+"No need to process blocks before the genesis block %d", s.GenesisBlockNumber)
    - 259 + + 59 +
    - + - ethBlock1.Hash(): { + - + return nil
    - 260 + + 60 +
    -   - { + - + }
    - 261 + + 61 +
    -   - Name: etherman.ForcedBatchesOrder, + - + }
    - 262 + + 62 +
    -   - Pos: 0, + - +
    -
     
    -
    - 268 + + 63 +
    -   - }, + - + // getStartingL1Block find if need to update and if yes the starting point:
    - 269 + + 64 +
    -   - } + - + // bool -> need to process blocks
    - 270 + + 65 +
    -   -
    + - + // uint64 -> first block to synchronize
    - 271 + + 66 +
    - + - fromBlock := ethBlock0.NumberU64() + - + // error -> error
    - 272 + + 67 +
    -   - toBlock := fromBlock + cfg.SyncChunkSize + - + // 1. First try to get last block on DB, if there are could be fully synced or pending blocks
    - 273 + + 68 +
    - + - if toBlock > ethBlock1.NumberU64() { + - + // 2. If DB is empty the LxLy upgrade block as starting point
    - 274 + + 69 +
    - + - toBlock = ethBlock1.NumberU64() + - + func (s *SyncPreRollup) getStartingL1Block(ctx context.Context, dbTx pgx.Tx) (bool, uint64, error) {
    - 275 + + 70 +
    - + - } + - + lastBlock, err := s.state.GetLastBlock(ctx, dbTx)
    - 276 + + 71 +
    -   - m.Etherman. + - + if err != nil && errors.Is(err, state.ErrStateNotSynchronized) {
    - 277 + + 72 +
    -   - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + - + // No block on DB
    - 278 + + 73 +
    -   - Return(blocks, order, nil). + - + upgradeLxLyBlockNumber, err := s.etherman.GetL1BlockUpgradeLxLy(ctx, s.GenesisBlockNumber)
    -
     
    -
    - 288 + + 74 +
    -   - Once() + - + if err != nil && errors.Is(err, etherman.ErrNotFound) {
    - 289 + + 75 +
    -   -
    + - + log.Infof(pregenesisSyncLogPrefix+"LxLy upgrade not detected before genesis block %d, it'll be sync as usual. Nothing to do yet", s.GenesisBlockNumber)
    - 290 + + 76 +
    -   - stateBlock := &state.Block{ + - + return false, 0, nil
    - 291 + + 77 +
    - + - BlockNumber: ethermanBlock1.BlockNumber, + - + } else if err != nil {
    - 292 + + 78 +
    - + - BlockHash: ethermanBlock1.BlockHash, + - + log.Errorf(pregenesisSyncLogPrefix+"error getting LxLy upgrade block. Error: %v", err)
    - 293 + + 79 +
    - + - ParentHash: ethermanBlock1.ParentHash, + - + return false, 0, err
    - 294 + + 80 +
    - + - ReceivedAt: ethermanBlock1.ReceivedAt, + - + }
    - 295 + + 81 +
    - + - Checked: true, + - + log.Infof(pregenesisSyncLogPrefix+"No block on DB, starting from LxLy upgrade block %d", upgradeLxLyBlockNumber)
    - 296 + + 82 +
    -   - } + - + return true, upgradeLxLyBlockNumber, nil
    - 297 + + 83 +
    -   -
    + - + } else if err != nil {
    - 298 + + 84 +
    -   - executionResponse := executor.ProcessBatchResponseV2{ + - + log.Errorf("Error getting last Block on DB err:%v", err)
    -
     
    -
    - 304 + + 85 +
    -   - Return(&executionResponse, nil). + - + return false, 0, err
    - 305 + + 86 +
    -   - Times(1) + - + }
    - 306 + + 87 +
    -   -
    + - + if lastBlock.BlockNumber >= s.GenesisBlockNumber-1 {
    - 307 + + 88 +
    - + - m.Etherman. + - + log.Warnf(pregenesisSyncLogPrefix+"Last block processed is %d, which is greater or equal than the previous genesis block %d", lastBlock, s.GenesisBlockNumber)
    - 308 + + 89 +
    - + - On("GetFinalizedBlockNumber", ctx). + - + return false, 0, nil
    - 309 + + 90 +
    - + - Return(ethBlock1.NumberU64(), nil). + - + }
    - 310 + + 91 +
    - + - Once() + - + log.Infof(pregenesisSyncLogPrefix+"Continue processing pre-genesis blocks, last block processed on DB is %d", lastBlock.BlockNumber)
    - 311 + + 92 +
    - + -
    + - + return true, lastBlock.BlockNumber, nil
    - 312 + + 93 +
    -   - m.State. + - + }
    - 313 + + 94 +
    -   - On("AddBlock", ctx, stateBlock, m.DbTx). + - +
    - 314 + + 95 +
    -   - Return(nil). + - + // ProcessL1InfoRootEvents processes the L1InfoRoot events for a range for L1 blocks
    - 315 + + 96 +
    -   - Once() + - + func (s *SyncPreRollup) ProcessL1InfoRootEvents(ctx context.Context, fromBlock uint64, toBlock uint64, syncChunkSize uint64) error {
    - 316 + + 97 +
    -   -
    + - + startTime := time.Now()
    - 317 + + 98 +
    -   - fb := []state.ForcedBatch{{ + - + log.Info(pregenesisSyncLogPrefix + "synchronizing L1InfoRoot events")
    - 318 + + 99 +
    - + - BlockNumber: lastBlock1.BlockNumber, + - + log.Infof(pregenesisSyncLogPrefix+"Starting syncing pre genesis LxLy events from block %d to block %d (total %d blocks)",
    - 319 + + 100 +
    -   - ForcedBatchNumber: 1, + - + fromBlock, toBlock, toBlock-fromBlock+1)
    - 320 + + 101 +
    -   - Sequencer: sequencedBatch.Coinbase, + - + for i := fromBlock; true; i += syncChunkSize {
    - 321 + + 102 +
    -   - GlobalExitRoot: sequencedBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + toBlockReq := min(i+syncChunkSize-1, toBlock)
    -
     
    -
    - 350 + + 103 +
    -   - BatchNumber: sequencedBatch.BatchNumber, + - + percent := float32(toBlockReq-fromBlock+1) * 100.0 / float32(toBlock-fromBlock+1) // nolint:gomnd
    - 351 + + 104 +
    -   - TxHash: sequencedBatch.TxHash, + - + log.Infof(pregenesisSyncLogPrefix+"sync L1InfoTree events from %d to %d percent:%3.1f %% pending_blocks:%d", i, toBlockReq, percent, toBlock-toBlockReq)
    - 352 + + 105 +
    -   - Coinbase: sequencedBatch.Coinbase, + - + blocks, order, err := s.etherman.GetRollupInfoByBlockRangePreviousRollupGenesis(ctx, i, &toBlockReq)
    - 353 + + 106 +
    - + - BlockNumber: ethermanBlock1.BlockNumber, + - + if err != nil {
    - 354 + + 107 +
    -   - TimestampBatchEtrog: &t, + - + log.Error(pregenesisSyncLogPrefix+"error getting rollupInfoByBlockRange before rollup genesis: ", err)
    - 355 + + 108 +
    -   - L1InfoRoot: &forcedGER, + - + return err
    - 356 + + 109 +
    -   - } + - + }
    -
     
    -
    - 396 + + 110 +
    -   - // but it used a feature that is not implemented in new one that is asking beyond the last block on L1 + - + err = s.blockRangeProcessor.ProcessBlockRange(ctx, blocks, order)
    - 397 + + 111 +
    -   - func TestSequenceForcedBatchIncaberry(t *testing.T) { + - + if err != nil {
    - 398 + + 112 +
    -   - genesis := state.Genesis{ + - + log.Error(pregenesisSyncLogPrefix+"error processing blocks before the genesis: ", err)
    - 399 + + 113 +
    - + - RollupBlockNumber: uint64(123456), + - + return err
    - 400 + + 114 +
    -   - } + - + }
    - 401 + + 115 +
    -   - cfg := Config{ + - + if toBlockReq == toBlock {
    - 402 + + 116 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + - + break
    - 403 + + 117 +
    -   - SyncChunkSize: 10, + - + }
    - 404 + + 118 +
    -   - L1SynchronizationMode: SequentialMode, + - + }
    - 405 + + 119 +
    - + - SyncBlockProtection: "latest", + - + elapsedTime := time.Since(startTime)
    - 406 + + 120 +
    -   - } + - + log.Infof(pregenesisSyncLogPrefix+"sync L1InfoTree finish: from %d to %d total_block %d done in %s", fromBlock, toBlock, toBlock-fromBlock+1, &elapsedTime)
    - 407 + + 121 +
    -   -
    + - + return nil
    - 408 + + 122 +
    -   - m := mocks{ + - + }
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -214478,166 +296222,161 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
     
    - 413 + + -
    +
    +
      - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    - 414 + + -
    +
    +
      - } +
    - 415 + + -
    +
    +
      - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 416 + + -
    - + - sync, err := NewSynchronizer(true, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    +   +
    - 417 + + -
    +
    +
      - require.NoError(t, err) +
    - 418 + + -
    +
    +
     
    - 419 + + -
    +
    +
      - // state preparation +
    -
     
    -
    - 423 + + -
    +
    +
      - Run(func(args mock.Arguments) { +
    - 424 + + -
    +
    +
      - ctx := args[0].(context.Context) +
    - 425 + + -
    +
    +
      - parentHash := common.HexToHash("0x111") +
    - 426 + + -
    - + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    +   +
    - 427 + + -
    - + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    +   +
    - 428 + + -
    - + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    +   +
    - 429 + + -
    - + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    +   +
    - 430 + + -
    - + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    +   +
    - 431 + + -
    - + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    +   +
    - 432 + + -
    +
    +
      - m.State. +
    - 433 + + -
    +
    +
      - On("GetForkIDByBatchNumber", mock.Anything). +
    - 434 + + -
    +
    +
      - Return(uint64(1), nil). +
    - 435 + + -
    +
    +
      - Maybe() +
    - 436 + + -
    +
    +
     
    - 437 + + -
    +
    +
      - m.State. +
    - 438 + + -
    +
    +
      - On("GetLastBlock", ctx, m.DbTx). +
    - 439 + + -
    - + - Return(lastBlock0, nil). +
    +
    +   +
    - 440 + + -
    +
    +
      - Once() +
    - 441 + + -
    +
    +
     
    - 442 + + -
    +
    +
      - m.State. +
    -
     
    -
    - 474 + + -
    +
    +
      - Return(nil). +
    - 475 + + -
    +
    +
      - Once() +
    - 476 + + -
    +
    +
     
    - 477 + + -
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    +   +
    - 478 - -
    +
    + + +
      - m.Etherman. +
    - 479 + + -
    - + - On("HeaderByNumber", ctx, n). +
    +
    +   +
    - 480 + + -
    - + - Return(ethHeader1, nil). +
    +
    +   +
    - 481 + + -
    +
    +
      - Once() +
    - 482 + + -
    +
    +
     
    @@ -214653,4678 +296392,4789 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 483 + + -
    +
    +
      - m.Etherman. +
    - 484 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 485 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 486 + + -
    +
    +
      - Once() +
    - 487 + + -
    +
    +
     
    - 488 + + -
    +
    +
      - sequencedForceBatch := etherman.SequencedForceBatch{ +
    -
     
    -
    - 498 + + -
    +
    +
      - } +
    - 499 + + -
    +
    +
     
    - 500 + + -
    +
    +
      - forceb := []etherman.ForcedBatch{{ +
    - 501 + + -
    - + - BlockNumber: lastBlock1.BlockNumber, +
    +
    +   +
    - 502 + + -
    +
    +
      - ForcedBatchNumber: 1, +
    - 503 + + -
    +
    +
      - Sequencer: sequencedForceBatch.Coinbase, +
    - 504 + + -
    +
    +
      - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    -
     
    -
    - 506 + + -
    +
    +
      - ForcedAt: time.Unix(int64(sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedTimestamp), 0), +
    - 507 + + -
    +
    +
      - }} +
    - 508 + + -
    +
    +
     
    - 509 + + -
    - + - ethermanBlock0 := etherman.Block{ +
    +
    +   +
    - 510 + + -
    - + - BlockNumber: ethBlock0.NumberU64(), +
    +
    +   +
    - 511 + + -
    - + - BlockHash: ethBlock0.Hash(), +
    +
    +   +
    - 512 + + -
    - + - ParentHash: ethBlock0.ParentHash(), +
    +
    +   +
    - 513 + + -
    - + - } +
    +
    +   +
    - 514 + + -
    - + - ethermanBlock1 := etherman.Block{ +
    +
    +   +
    - 515 + + -
    - + - BlockNumber: ethBlock1.NumberU64(), +
    +
    +   +
    - 516 + + -
    - + - BlockHash: ethBlock1.Hash(), +
    +
    +   +
    - 517 + + -
    - + - ParentHash: ethBlock1.ParentHash(), +
    +
    +   +
    - 518 + + -
    +
    +
      - SequencedForceBatches: [][]etherman.SequencedForceBatch{{sequencedForceBatch}}, +
    - 519 + + -
    +
    +
      - ForcedBatches: forceb, +
    - 520 + + -
    +
    +
      - } +
    - 521 + + -
    - + - blocks := []etherman.Block{ethermanBlock0, ethermanBlock1} +
    +
    +   +
    - 522 + + -
    +
    +
      - order := map[common.Hash][]etherman.Order{ +
    - 523 + + -
    - + - ethBlock1.Hash(): { +
    +
    +   +
    - 524 + + -
    +
    +
      - { +
    - 525 + + -
    +
    +
      - Name: etherman.ForcedBatchesOrder, +
    - 526 + + -
    +
    +
      - Pos: 0, +
    -
     
    -
    - 532 + + -
    +
    +
      - }, +
    - 533 + + -
    +
    +
      - } +
    - 534 + + -
    +
    +
     
    - 535 + + -
    - + - fromBlock := ethBlock0.NumberU64() +
    +
    +   +
    - 536 + + -
    +
    +
      - toBlock := fromBlock + cfg.SyncChunkSize +
    - 537 + + -
    - + - if toBlock > ethBlock1.NumberU64() { +
    +
    +   +
    - 538 + + -
    - + - toBlock = ethBlock1.NumberU64() +
    +
    +   +
    - 539 + + -
    - + - } +
    +
    +   +
    - 540 + + -
    +
    +
      - m.Etherman. +
    - 541 + + -
    +
    +
      - On("GetRollupInfoByBlockRange", ctx, fromBlock, &toBlock). +
    - 542 + + -
    +
    +
      - Return(blocks, order, nil). +
    - 543 + + -
    +
    +
      - Once() +
    - 544 + + -
    +
    +
     
    - 545 + + -
    - + - m.Etherman. +
    +
    +   +
    - 546 + + -
    - + - On("GetFinalizedBlockNumber", ctx). +
    +
    +   +
    - 547 + + -
    - + - Return(ethBlock1.NumberU64(), nil). +
    +
    +   +
    - 548 + + -
    - + - Once() +
    +
    +   +
    - 549 + + -
    - + +
    +
    +  
    - 550 + + -
    +
    +
      - m.State. +
    - 551 + + -
    +
    +
      - On("BeginStateTransaction", ctx). +
    - 552 + + -
    +
    +
      - Return(m.DbTx, nil). +
    - 553 + + -
    +
    +
      - Once() +
    - 554 + + -
    +
    +
     
    - 555 + + -
    +
    +
      - stateBlock := &state.Block{ +
    - 556 + + -
    - + - BlockNumber: ethermanBlock1.BlockNumber, +
    +
    +   +
    - 557 + + -
    - + - BlockHash: ethermanBlock1.BlockHash, +
    +
    +   +
    - 558 + + -
    - + - ParentHash: ethermanBlock1.ParentHash, +
    +
    +   +
    - 559 + + -
    - + - ReceivedAt: ethermanBlock1.ReceivedAt, +
    +
    +   +
    - 560 + + -
    - + - Checked: true, +
    +
    +   +
    - 561 + + -
    +
    +
      - } +
    - 562 + + -
    +
    +
     
    - 563 + + -
    +
    +
      - m.State. +
    -
     
    -
    - 565 + + -
    +
    +
      - Return(nil). +
    - 566 + + -
    +
    +
      - Once() +
    - 567 + + -
    +
    +
     
    - 568 + + -
    - + - m.State. +
    +
    +   +
    - 569 + + -
    - + - On("GetForkIDByBlockNumber", stateBlock.BlockNumber). +
    +
    +   +
    - 570 + + -
    - + - Return(uint64(9), nil). +
    +
    +   +
    - 571 + + -
    - + - Once() +
    +
    +   +
    - 572 + + -
    - + +
    +
    +  
    - 573 + + -
    +
    +
      - fb := []state.ForcedBatch{{ +
    - 574 + + -
    - + - BlockNumber: lastBlock1.BlockNumber, +
    +
    +   +
    - 575 + + -
    +
    +
      - ForcedBatchNumber: 1, +
    - 576 + + -
    +
    +
      - Sequencer: sequencedForceBatch.Coinbase, +
    - 577 + + -
    +
    +
      - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, +
    -
     
    -
    - 603 + + -
    +
    +
      - processingContext := state.ProcessingContext{ +
    - 604 + + -
    +
    +
      - BatchNumber: sequencedForceBatch.BatchNumber, +
    +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_pre_rollup_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -1,89 +0,0 @@
    - 605 + + 1 +
    -   - Coinbase: sequencedForceBatch.Coinbase, + - + package synchronizer
    - 606 + + 2 +
    - + - Timestamp: ethBlock1.ReceivedAt, + - +
    - 607 + + 3 +
    -   - GlobalExitRoot: sequencedForceBatch.PolygonRollupBaseEtrogBatchData.ForcedGlobalExitRoot, + - + import (
    - 608 + + 4 +
    -   - ForcedBatchNum: &f, + - + "context"
    - 609 + + 5 +
    -   - BatchL2Data: &sequencedForceBatch.PolygonRollupBaseEtrogBatchData.Transactions, + - + "testing"
    -
     
    -
    - 618 + + 6 +
    -   - TxHash: sequencedForceBatch.TxHash, + - +
    - 619 + + 7 +
    -   - Coinbase: sequencedForceBatch.Coinbase, + - + "github.com/0xPolygonHermez/zkevm-node/etherman"
    - 620 + + 8 +
    -   - SequencerAddr: sequencedForceBatch.Coinbase, + - + "github.com/0xPolygonHermez/zkevm-node/log"
    - 621 + + 9 +
    - + - BlockNumber: ethermanBlock1.BlockNumber, + - + "github.com/0xPolygonHermez/zkevm-node/state"
    - 622 + + 10 +
    -   - } + - + mock_syncinterfaces "github.com/0xPolygonHermez/zkevm-node/synchronizer/common/syncinterfaces/mocks"
    - 623 + + 11 +
    -   -
    + - + "github.com/ethereum/go-ethereum/common"
    - 624 + + 12 +
    -   - m.State. + - + "github.com/stretchr/testify/mock"
    -
     
    -
    - 642 + + 13 -
    -   -
    +
    +
    + - + "github.com/stretchr/testify/require"
    - 643 + + 14 +
    -   - m.DbTx. + - + )
    - 644 + + 15 +
    -   - On("Commit", ctx). + - +
    - 645 + + 16 +
    - + - Run(func(args mock.Arguments) { + - + func TestSyncPreRollupProcessL1InfoRootEventsAskForAllBlocks(t *testing.T) {
    - 646 + + 17 +
    - + - sync.Stop() + - + mockProcessor := mock_syncinterfaces.NewBlockRangeProcessor(t)
    - 647 + + 18 +
    - + - ctx.Done() + - + mockEtherman := mock_syncinterfaces.NewEthermanFullInterface(t)
    - 648 + + 19 +
    - + - }). + - + sync := &SyncPreRollup{
    - 649 + + 20 +
    -   - Return(nil). + - + etherman: mockEtherman,
    - 650 + + 21 +
    -   - Once() + - + blockRangeProcessor: mockProcessor,
    - 651 + + 22 +
    -   - }). + - + SyncChunkSize: 10,
    -
     
    -
    - 658 + + 23 +
    -   -
    + - + GenesisBlockNumber: 1234,
    - 659 + + 24 +
    -   - func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) { + - + }
    - 660 + + 25 +
    -   - genesis := state.Genesis{ + - +
    - 661 + + 26 +
    - + - RollupBlockNumber: uint64(123456), + - + ctx := context.Background()
    - 662 + + 27 +
    -   - } + - + fromBlock := uint64(1)
    - 663 + + 28 +
    -   - cfg := Config{ + - + toBlock := uint64(31)
    - 664 + + 29 +
    -   - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + - + syncChunkSize := uint64(10)
    - 665 + + 30 +
    -   - SyncChunkSize: 10, + - + previousBlockNumber := uint64(1)
    - 666 + + 31 +
    -   - L1SynchronizationMode: SequentialMode, + - + for _, i := range []uint64{10, 20, 30, 31} {
    - 667 + + 32 +
    - + - SyncBlockProtection: "latest", + - + // Mocking the call to GetRollupInfoByBlockRangePreviousRollupGenesis
    - 668 + + 33 +
    -   - L1ParallelSynchronization: L1ParallelSynchronizationConfig{ + - + v := i
    - 669 + + 34 +
    -   - MaxClients: 2, + - + mockEtherman.EXPECT().GetRollupInfoByBlockRangePreviousRollupGenesis(ctx, previousBlockNumber, &v).
    - 670 + + 35 +
    -   - MaxPendingNoProcessedBlocks: 2, + - + Return(getRollupTest()).Once()
    -
     
    +
    + 36 + +
    + - + previousBlockNumber = i + 1 +
    - 679 + + 37 +
    -   + - }
    - 680 + + 38 +
    -   + -
    - 681 + + 39 +
    -   - m := mocks{ + - + mockProcessor.EXPECT().ProcessBlockRange(ctx, mock.Anything, mock.Anything).Return(nil).Maybe()
    - 682 + + 40 +
    - + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + - + err := sync.ProcessL1InfoRootEvents(ctx, fromBlock, toBlock, syncChunkSize)
    - 683 + + 41 +
    - + - State: mock_syncinterfaces.NewStateFullInterface(t), + - + require.NoError(t, err)
    - 684 + + 42 +
    - + - Pool: mock_syncinterfaces.NewPoolInterface(t), + - + }
    - 685 + + 43 +
    - + - DbTx: syncMocks.NewDbTxMock(t), + - +
    - 686 + + 44 +
    - + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + - + func getRollupTest() ([]etherman.Block, map[common.Hash][]etherman.Order, error) {
    - 687 + + 45 +
    - + - zkEVMClientEthereumCompatible: mock_syncinterfaces.NewZKEVMClientEthereumCompatibleInterface(t), + - + return nil, nil, nil
    - 688 + + 46 +
    - + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + - + }
    - 689 + + 47 +
    -   - //EventLog: newEventLogMock(t), + - +
    - 690 + + 48 +
    -   - } + - + func TestSyncPreRollupGetStartingL1Block(t *testing.T) {
    - 691 + + 49 +
    -   - return &genesis, &cfg, &m + - + mockState := mock_syncinterfaces.NewStateFullInterface(t)
    -
     
    -
    - 919 + + 50 +
    -   - Return(nil). + - + mockEtherman := mock_syncinterfaces.NewEthermanFullInterface(t)
    - 920 + + 51 +
    -   - Once() + - + sync := &SyncPreRollup{
    - 921 + + 52 +
    -   - } + - + state: mockState,
    - 922 + + 53 +
    - + -
    + - + etherman: mockEtherman,
    - 923 + + 54 +
    - + - func TestReorg(t *testing.T) { + - + GenesisBlockNumber: 1234,
    - 924 + + 55 +
    - + - genesis := state.Genesis{ + - + }
    - 925 + + 56 +
    - + - RollupBlockNumber: uint64(0), + - +
    - 926 + + 57 +
    - + - } + - + ctx := context.Background()
    - 927 + + 58 +
    - + - cfg := Config{ + - +
    - 928 + + 59 +
    - + - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + - + for idx, testCase := range []struct {
    - 929 + + 60 +
    - + - SyncChunkSize: 3, + - + name string
    - 930 + + 61 +
    - + - L1SynchronizationMode: SequentialMode, + - + upgradeLxLyBlockNumber uint64
    - 931 + + 62 +
    - + - SyncBlockProtection: "latest", + - + blockNumber uint64
    - 932 + + 63 +
    - + - L1BlockCheck: L1BlockCheckConfig{ + - + expectedError bool
    - 933 + + 64 +
    - + - Enable: false, + - + expectedNeedToUpdate bool
    - 934 + + 65 +
    - + - }, + - + expectedBlockNumber uint64
    - 935 + + 66 +
    - + - } + - + }{
    - 936 + + 67 +
    - + -
    + - + {name: "mid block", upgradeLxLyBlockNumber: 1000, blockNumber: 1001, expectedError: false, expectedNeedToUpdate: true, expectedBlockNumber: 1001},
    - 937 + + 68 +
    - + - m := mocks{ + - + {name: "pre block", upgradeLxLyBlockNumber: 1000, blockNumber: 999, expectedError: false, expectedNeedToUpdate: true, expectedBlockNumber: 999},
    - 938 + + 69 +
    - + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + - + {name: "same genesis", upgradeLxLyBlockNumber: 1000, blockNumber: sync.GenesisBlockNumber, expectedError: false, expectedNeedToUpdate: false},
    - 939 + + 70 +
    - + - State: mock_syncinterfaces.NewStateFullInterface(t), + - + {name: "genesis-1", upgradeLxLyBlockNumber: 1000, blockNumber: 1233, expectedError: false, expectedNeedToUpdate: false},
    - 940 + + 71 +
    - + - Pool: mock_syncinterfaces.NewPoolInterface(t), + - + } {
    - 941 + + 72 +
    - + - DbTx: syncMocks.NewDbTxMock(t), + - + log.Info("Running test case ", idx+1)
    - 942 + + 73 +
    - + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + - + block := state.Block{
    - 943 + + 74 +
    - + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + - + BlockNumber: testCase.blockNumber,
    - 944 + + 75 +
    - + - } + - + }
    - 945 + + 76 +
    - + - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + - + mockEtherman.EXPECT().GetL1BlockUpgradeLxLy(ctx, sync.GenesisBlockNumber).Return(testCase.upgradeLxLyBlockNumber, nil).Maybe()
    - 946 + + 77 +
    - + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + - + mockState.EXPECT().GetLastBlock(ctx, mock.Anything).Return(&block, nil).Once()
    - 947 + + 78 +
    - + - require.NoError(t, err) + - + needToUpdate, blockNumber, err := sync.getStartingL1Block(ctx, nil)
    - 948 + + 79 +
    - + -
    + - + if testCase.expectedError {
    - 949 + + 80 +
    - + - // state preparation + - + require.Error(t, err, testCase.name)
    - 950 + + 81 +
    - + - ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + - + } else {
    - 951 + + 82 +
    - + - forkIdInterval := state.ForkIDInterval{ + - + require.NoError(t, err, testCase.name)
    - 952 + + 83 +
    - + - ForkId: 9, + - + require.Equal(t, testCase.expectedNeedToUpdate, needToUpdate, testCase.name)
    - 953 + + 84 +
    - + - FromBatchNumber: 0, + - + if needToUpdate {
    - 954 + + 85 +
    - + - ToBatchNumber: math.MaxUint64, + - + require.Equal(t, testCase.blockNumber, blockNumber, testCase.name)
    - 955 + + 86 +
    - + - } + - + }
    - 956 + + 87 +
    - + - m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + - + }
    - 957 + + 88 +
    - + -
    + - + }
    - 958 + + 89 +
    - + - m.State. + - + }
    - 959 - -
    - + - On("BeginStateTransaction", ctxMatchBy). +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
     
    - 960 + + -
    - + - Run(func(args mock.Arguments) { +
    +
    +   +
    - 961 + + -
    - + - ctx := args[0].(context.Context) +
    +
    +   +
    - 962 + + -
    - + - parentHash := common.HexToHash("0x111") +
    +
    +   +
    - 963 + + -
    - + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    +   +
    - 964 + + -
    - + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    +   +
    - 965 + + -
    - + - ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} +
    +
    +   +
    - 966 + + -
    - + - ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    +   +
    - 967 + + -
    - + - ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} +
    +
    +   +
    - 968 + + -
    - + - ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) +
    +
    +   +
    - 969 + + -
    - + - ethHeader3bis := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2bis.Hash()} +
    +
    +   +
    - 970 + + -
    - + - ethBlock3bis := ethTypes.NewBlockWithHeader(ethHeader3bis) +
    +
    +   +
    - 971 + + -
    - + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    +   +
    - 972 + + -
    - + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    +   +
    - 973 + + -
    - + - ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    +   +
    - 974 + + -
    - + - ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    +   +
    - 975 + + -
    - + - ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    +   +
    - 976 + + -
    - + - ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    +   +
    - 977 + + -
    - + +
    +
    +  
    - 978 + + -
    - + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    +   +
    - 979 + + -
    - + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    +   +
    - 980 + + -
    - + +
    +
    +  
    - 981 + + -
    - + - m.State. +
    +
    +   +
    - 982 + + -
    - + - On("GetForkIDByBatchNumber", mock.Anything). +
    +
    +   +
    - 983 + + -
    - + - Return(uint64(9), nil). +
    +
    +   +
    - 984 + + -
    - + - Maybe() +
    +
    +   +
    - 985 + + -
    - + - m.State. +
    +
    +   +
    - 986 + + -
    - + - On("GetLastBlock", ctx, m.DbTx). +
    +
    +   +
    - 987 + + -
    - + - Return(lastBlock1, nil). +
    +
    +   +
    - 988 + + -
    - + - Once() +
    +
    +   +
    - 989 + + -
    - + +
    +
    +  
    - 990 + + -
    - + - m.State. +
    +
    +   +
    - 991 + + -
    - + - On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    +   +
    - 992 + + -
    - + - Return(uint64(10), nil). +
    +
    +   +
    - 993 + + -
    - + - Once() +
    +
    +   +
    - 994 + + -
    - + +
    +
    +  
    - 995 + + -
    - + - m.State. +
    +
    +   +
    - 996 + + -
    - + - On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    +   +
    - 997 + + -
    - + - Return(nil). +
    +
    +   +
    - 998 + + -
    - + - Once() +
    +
    +   +
    - 999 + + -
    - + +
    +
    +  
    - 1000 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1001 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1002 + + -
    - + - Return(nil). +
    +
    +   +
    - 1003 + + -
    - + - Once() +
    +
    +   +
    - 1004 + + -
    - + +
    +
    +  
    - 1005 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1006 + + -
    - + - On("GetLatestBatchNumber"). +
    +
    +   +
    - 1007 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1008 + + -
    - + +
    +
    +  
    - 1009 + + -
    - + - var nilDbTx pgx.Tx +
    +
    +   +
    - 1010 + + -
    - + - m.State. +
    +
    +   +
    - 1011 + + -
    - + - On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    +   +
    - 1012 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1013 + + -
    - + +
    +
    +  
    - 1014 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1015 + + -
    - + - On("GetLatestVerifiedBatchNum"). +
    +
    +   +
    - 1016 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1017 + + -
    - + +
    +
    +  
    - 1018 + + -
    - + - m.State. +
    +
    +   +
    - 1019 + + -
    - + - On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    +   +
    - 1020 + + -
    - + - Return(nil) +
    +
    +   +
    - 1021 + + -
    - + +
    +
    +  
    - 1022 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1023 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    +   +
    - 1024 + + -
    - + - Return(ethBlock1, nil). +
    +
    +   +
    - 1025 + + -
    - + - Once() +
    +
    +   +
    - 1026 + + -
    - + +
    +
    +  
    - 1027 + + -
    - + - m.ZKEVMClient. +
    +
    +   +
    - 1028 + + -
    - + - On("BatchNumber", ctx). +
    +
    +   +
    - 1029 + + -
    - + - Return(uint64(1), nil). +
    +
    +   +
    - 1030 + + -
    - + - Once() +
    +
    +   +
    - 1031 + + -
    - + +
    +
    +  
    - 1032 + + -
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    +   +
    - 1033 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1034 + + -
    - + - On("HeaderByNumber", mock.Anything, n). +
    +
    +   +
    - 1035 + + -
    - + - Return(ethHeader3bis, nil). +
    +
    +   +
    - 1036 + + -
    - + - Once() +
    +
    +   +
    - 1037 + + -
    - + +
    +
    +  
    - 1038 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1039 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    +   +
    - 1040 + + -
    - + - Return(ethBlock1, nil). +
    +
    +   +
    - 1041 + + -
    - + - Once() +
    +
    +   +
    - 1042 + + -
    - + +
    +
    +  
    - 1043 + + -
    - + - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    +   +
    - 1044 + + -
    - + +
    +
    +  
    - 1045 + + -
    - + - ethermanBlock1bis := etherman.Block{ +
    +
    +   +
    - 1046 + + -
    - + - BlockNumber: 1, +
    +
    +   +
    - 1047 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1048 + + -
    - + - BlockHash: ethBlock1bis.Hash(), +
    +
    +   +
    - 1049 - -
    - + - ParentHash: ethBlock1bis.ParentHash(), +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -31,7 +31,6 @@
    - 1050 + + 31 +
    - + - } +   + ETROG_MODE_FLAG = true
    - 1051 + + 32 +
    - + - ethermanBlock2bis := etherman.Block{ +   + RETRIEVE_BATCH_FROM_DB_FLAG = true
    - 1052 + + 33 +
    - + - BlockNumber: 2, +   + RETRIEVE_BATCH_FROM_CACHE_FLAG = false
    - 1053 + + 34 +
    - + - ReceivedAt: ti, + - + PROCESS_BATCH_SELECTOR_ENABLED = false
    - 1054 + + 35 +
    - + - BlockHash: ethBlock2bis.Hash(), +   + )
    - 1055 + + 36 +
    - + - ParentHash: ethBlock2bis.ParentHash(), +   +
    - 1056 + + 37 +
    - + - } +   + type mocks struct {
    - 1057 - -
    - + - blocks := []etherman.Block{ethermanBlock1bis, ethermanBlock2bis} -
    +
    +
    @@ -123,7 +122,7 @@
    - 1058 + + 123 +
    - + - order := map[common.Hash][]etherman.Order{} +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
    - 1059 + + 124 +
    - + -
    +   + func TestForcedBatchEtrog(t *testing.T) {
    - 1060 + + 125 +
    - + - fromBlock := ethBlock1.NumberU64() +   + genesis := state.Genesis{
    - 1061 + + 126 +
    - + - toBlock := fromBlock + cfg.SyncChunkSize + - + BlockNumber: uint64(0),
    - 1062 + + 127 +
    - + - if toBlock > ethBlock3.NumberU64() { +   + }
    - 1063 + + 128 +
    - + - toBlock = ethBlock3.NumberU64() +   + cfg := Config{
    - 1064 + + 129 +
    - + - } +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1065 - -
    - + - m.Etherman. -
    +
    +
    @@ -226,7 +225,7 @@
    - 1066 + + 226 +
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +   + Coinbase: common.HexToAddress("0x222"),
    - 1067 + + 227 +
    - + - Return(blocks, order, nil). +   + SequencerAddr: common.HexToAddress("0x00"),
    - 1068 + + 228 +
    - + - Once() +   + TxHash: common.HexToHash("0x333"),
    - 1069 + + 229 +
    - + -
    + - + PolygonRollupBaseEtrogBatchData: &etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1070 + + 230 +
    - + - m.State. +   + Transactions: []byte{},
    - 1071 + + 231 +
    - + - On("BeginStateTransaction", ctx). +   + ForcedGlobalExitRoot: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
    - 1072 + + 232 +
    - + - Return(m.DbTx, nil). +   + ForcedTimestamp: uint64(t.Unix()),
    - 1073 + +
    @@ -397,7 +396,7 @@
    +
    + 397 +
    - + - Once() +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
    - 1074 + + 398 +
    - + -
    +   + func TestSequenceForcedBatchIncaberry(t *testing.T) {
    - 1075 + + 399 +
    - + - var depth uint64 = 1 +   + genesis := state.Genesis{
    - 1076 + + 400 +
    - + - stateBlock0 := &state.Block{ + - + BlockNumber: uint64(0),
    - 1077 + + 401 +
    - + - BlockNumber: ethBlock0.NumberU64(), +   + }
    - 1078 + + 402 +
    - + - BlockHash: ethBlock0.Hash(), +   + cfg := Config{
    - 1079 + + 403 +
    - + - ParentHash: ethBlock0.ParentHash(), +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1080 + +
    @@ -490,7 +489,7 @@
    +
    + 490 +
    - + - ReceivedAt: ti, +   + BatchNumber: uint64(2),
    - 1081 + + 491 +
    - + - } +   + Coinbase: common.HexToAddress("0x222"),
    - 1082 + + 492 +
    - + - m.State. +   + TxHash: common.HexToHash("0x333"),
    - 1083 + + 493 +
    - + - On("GetPreviousBlock", ctx, depth, m.DbTx). + - + PolygonRollupBaseEtrogBatchData: etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1084 + + 494 +
    - + - Return(stateBlock0, nil). +   + Transactions: []byte{},
    - 1085 + + 495 +
    - + - Once() +   + ForcedGlobalExitRoot: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
    - 1086 + + 496 +
    - + -
    +   + ForcedTimestamp: 1000, //ForcedBatch
    - 1087 + +
    @@ -659,7 +658,7 @@
    +
    + 659 +
    - + - m.DbTx. +   +
    - 1088 + + 660 +
    - + - On("Commit", ctx). +   + func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
    - 1089 + + 661 +
    - + - Return(nil). +   + genesis := state.Genesis{
    - 1090 + + 662 +
    - + - Once() + - + BlockNumber: uint64(123456),
    - 1091 + + 663 +
    - + -
    +   + }
    - 1092 + + 664 +
    - + - m.Etherman. +   + cfg := Config{
    - 1093 + + 665 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1094 + +
    @@ -761,11 +760,9 @@
    +
    + 761 +
    - + - Return(ethBlock0, nil). +   + transactions := []types.TransactionOrHash{}
    - 1095 + + 762 +
    - + - Once() +   + for nBlock := 0; nBlock < howManyBlocks; nBlock++ {
    - 1096 + + 763 +
    - + -
    +   + block := state.L2BlockRaw{
    - 1097 + + 764 +
    - + - m.State. + - + ChangeL2BlockHeader: state.ChangeL2BlockHeader{
    - 1098 + + 765 +
    - + - On("BeginStateTransaction", ctx). + - + DeltaTimestamp: 123,
    - 1099 + + 766 +
    - + - Return(m.DbTx, nil). + - + IndexL1InfoTree: 456,
    - 1100 + + 767 +
    - + - Once() + - + },
    - 1101 + + 768 +
    - + -
    + - + Transactions: []state.L2TxRaw{},
    - 1102 + + 769 +
    - + - m.State. +   + }
    - 1103 + + 770 +
    - + - On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +   + for i := 0; i < howManyTx; i++ {
    - 1104 + + 771 +
    - + - Return(nil). +   + tx := createTransaction(uint64(i + 1))
    - 1105 + +
    @@ -925,7 +922,7 @@
    +
    + 925 +
    - + - Once() +   +
    - 1106 + + 926 +
    - + -
    +   + func TestReorg(t *testing.T) {
    - 1107 + + 927 +
    - + - m.EthTxManager. +   + genesis := state.Genesis{
    - 1108 + + 928 +
    - + - On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + - + BlockNumber: uint64(0),
    - 1109 + + 929 +
    - + - Return(nil). +   + }
    - 1110 + + 930 +
    - + - Once() +   + cfg := Config{
    - 1111 + + 931 +
    - + -
    +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1112 + +
    @@ -1245,7 +1242,7 @@
    +
    + 1245 +
    - + - m.DbTx. +   +
    - 1113 + + 1246 +
    - + - On("Commit", ctx). +   + func TestLatestSyncedBlockEmpty(t *testing.T) {
    - 1114 + + 1247 +
    - + - Return(nil). +   + genesis := state.Genesis{
    - 1115 + + 1248 +
    - + - Once() + - + BlockNumber: uint64(0),
    - 1116 + + 1249 +
    - + -
    +   + }
    - 1117 + + 1250 +
    - + - m.Etherman. +   + cfg := Config{
    - 1118 + + 1251 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1119 + +
    @@ -1459,7 +1456,7 @@
    +
    + 1459 +
    - + - Return(ethBlock0, nil). +   +
    - 1120 + + 1460 +
    - + - Once() +   + func TestRegularReorg(t *testing.T) {
    - 1121 + + 1461 +
    - + -
    +   + genesis := state.Genesis{
    - 1122 + + 1462 +
    - + - m.ZKEVMClient. + - + BlockNumber: uint64(0),
    - 1123 + + 1463 +
    - + - On("BatchNumber", ctx). +   + }
    - 1124 + + 1464 +
    - + - Return(uint64(1), nil). +   + cfg := Config{
    - 1125 + + 1465 +
    - + - Once() +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1126 + +
    @@ -1741,7 +1738,7 @@
    +
    + 1741 +
    - + +  
    - 1127 + + 1742 +
    - + - m.Etherman. +   + func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) {
    - 1128 + + 1743 +
    - + - On("HeaderByNumber", mock.Anything, n). +   + genesis := state.Genesis{
    - 1129 + + 1744 +
    - + - Return(ethHeader3bis, nil). + - + BlockNumber: uint64(0),
    - 1130 + + 1745 +
    - + - Once() +   + }
    - 1131 + + 1746 +
    - + -
    +   + cfg := Config{
    - 1132 + + 1747 +
    - + - m.Etherman. +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1133 + +
    @@ -2017,13 +2014,16 @@
    +
    + 2017 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +   +
    - 1134 + + 2018 +
    - + - Return(ethBlock0, nil). +   + func TestCallFromEmptyBlockAndReorg(t *testing.T) {
    - 1135 + + 2019 +
    - + - Once() +   + genesis := state.Genesis{
    - 1136 + + 2020 +
    - + -
    + - + BlockNumber: uint64(0),
    - 1137 + + 2021 +
    - + - ethermanBlock0 := etherman.Block{ +   + }
    - 1138 + + 2022 +
    - + - BlockNumber: 0, +   + cfg := Config{
    - 1139 + + 2023 +
    - + - ReceivedAt: ti, +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1140 + + 2024 +
    - + - BlockHash: ethBlock0.Hash(), +   + SyncChunkSize: 3,
    - 1141 + + 2025 +
    - + - ParentHash: ethBlock0.ParentHash(), +   + L1SynchronizationMode: SequentialMode,
    - 1142 + + 2026 +
    - + - } +   + SyncBlockProtection: "latest",
    - 1143 + + -
    - + - ethermanBlock3bis := etherman.Block{ +
    +
    +   +
    - 1144 + + -
    - + - BlockNumber: 3, +
    +
    +   +
    - 1145 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1146 + + 2027 +
    - + - BlockHash: ethBlock3bis.Hash(), +   + }
    - 1147 + + 2028 +
    - + - ParentHash: ethBlock3bis.ParentHash(), +   +
    - 1148 + + 2029 +
    - + - } +   + m := mocks{
    - 1149 + +
    @@ -2129,6 +2129,11 @@
    +
    + 2129 +
    - + - fromBlock = 0 +   + Return(ethHeader2bis, nil).
    - 1150 + + 2130 +
    - + - blocks2 := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis, ethermanBlock3bis} +   + Once()
    - 1151 + + 2131 +
    - + - m.Etherman. +   +
    - 1152 + + -
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    +   +
    - 1153 + + -
    - + - Return(blocks2, order, nil). +
    +
    +   +
    - 1154 + + -
    - + - Once() +
    +
    +   +
    - 1155 + + -
    - + +
    +
    +  
    - 1156 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1157 + + 2132 +
    - + - On("GetFinalizedBlockNumber", ctx). +   + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC)
    - 1158 + + 2133 +
    - + - Return(ethBlock2bis.NumberU64(), nil). +   +
    - 1159 + + 2134 +
    - + - Once() +   + ethermanBlock0 := etherman.Block{ +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
     
    - 1160 + + 31 +
    - + -
    +   + ETROG_MODE_FLAG = true
    - 1161 + + 32 +
    - + - m.State. +   + RETRIEVE_BATCH_FROM_DB_FLAG = true
    - 1162 + + 33 +
    - + - On("BeginStateTransaction", ctx). +   + RETRIEVE_BATCH_FROM_CACHE_FLAG = false
    - 1163 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1164 + + 34 +
    - + - Once() +   + )
    - 1165 + + 35 +
    - + +  
    - 1166 + + 36 +
    - + - stateBlock1bis := &state.Block{ +   + type mocks struct {
    - 1167 - -
    - + - BlockNumber: ethermanBlock1bis.BlockNumber, -
    +
    +
     
    - 1168 + + 122 +
    - + - BlockHash: ethermanBlock1bis.BlockHash, +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
    - 1169 + + 123 +
    - + - ParentHash: ethermanBlock1bis.ParentHash, +   + func TestForcedBatchEtrog(t *testing.T) {
    - 1170 + + 124 +
    - + - ReceivedAt: ethermanBlock1bis.ReceivedAt, +   + genesis := state.Genesis{
    - 1171 + + 125 +
    + - Checked: true, + RollupBlockNumber: uint64(0),
    - 1172 + + 126 +
    - + - } +   + }
    - 1173 + + 127 +
    - + - m.State. +   + cfg := Config{
    - 1174 + + 128 +
    - + - On("AddBlock", ctx, stateBlock1bis, m.DbTx). +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1175 + +
     
    +
    + 225 +
    - + - Return(nil). +   + Coinbase: common.HexToAddress("0x222"),
    - 1176 + + 226 +
    - + - Once() +   + SequencerAddr: common.HexToAddress("0x00"),
    - 1177 + + 227 +
    - + -
    +   + TxHash: common.HexToHash("0x333"),
    - 1178 + + 228 +
    + - m.State. + PolygonRollupBaseEtrogBatchData: &polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1179 + + 229 +
    - + - On("GetStoredFlushID", ctx). +   + Transactions: []byte{},
    - 1180 + + 230 +
    - + - Return(uint64(1), cProverIDExecution, nil). +   + ForcedGlobalExitRoot: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
    - 1181 + + 231 +
    - + - Once() +   + ForcedTimestamp: uint64(t.Unix()),
    - 1182 + +
     
    +
    + 396 +
    - + -
    +   + // but it used a feature that is not implemented in new one that is asking beyond the last block on L1
    - 1183 + + 397 +
    - + - m.DbTx. +   + func TestSequenceForcedBatchIncaberry(t *testing.T) {
    - 1184 + + 398 +
    - + - On("Commit", ctx). +   + genesis := state.Genesis{
    - 1185 + + 399 +
    + - Return(nil). + RollupBlockNumber: uint64(123456),
    - 1186 + + 400 +
    - + - Once() +   + }
    - 1187 + + 401 +
    - + -
    +   + cfg := Config{
    - 1188 + + 402 +
    - + - m.State. +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1189 + +
     
    +
    + 489 +
    - + - On("BeginStateTransaction", ctx). +   + BatchNumber: uint64(2),
    - 1190 + + 490 +
    - + - Return(m.DbTx, nil). +   + Coinbase: common.HexToAddress("0x222"),
    - 1191 + + 491 +
    - + - Once() +   + TxHash: common.HexToHash("0x333"),
    - 1192 + + 492 +
    + -
    + PolygonRollupBaseEtrogBatchData: polygonzkevm.PolygonRollupBaseEtrogBatchData{
    - 1193 + + 493 +
    - + - stateBlock2bis := &state.Block{ +   + Transactions: []byte{},
    - 1194 + + 494 +
    - + - BlockNumber: ethermanBlock2bis.BlockNumber, +   + ForcedGlobalExitRoot: [32]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
    - 1195 + + 495 +
    - + - BlockHash: ethermanBlock2bis.BlockHash, +   + ForcedTimestamp: 1000, //ForcedBatch
    - 1196 + +
     
    +
    + 658 +
    - + - ParentHash: ethermanBlock2bis.ParentHash, +   +
    - 1197 + + 659 +
    - + - ReceivedAt: ethermanBlock2bis.ReceivedAt, +   + func setupGenericTest(t *testing.T) (*state.Genesis, *Config, *mocks) {
    - 1198 + + 660 +
    - + - Checked: true, +   + genesis := state.Genesis{
    - 1199 + + 661 +
    + - } + RollupBlockNumber: uint64(123456),
    - 1200 + + 662 +
    - + - m.State. +   + }
    - 1201 + + 663 +
    - + - On("AddBlock", ctx, stateBlock2bis, m.DbTx). +   + cfg := Config{
    - 1202 + + 664 +
    - + - Return(nil). +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1203 + +
     
    +
    + 760 +
    - + - Once() +   + transactions := []types.TransactionOrHash{}
    - 1204 + + 761 +
    - + -
    +   + for nBlock := 0; nBlock < howManyBlocks; nBlock++ {
    - 1205 + + 762 +
    - + - m.DbTx. +   + block := state.L2BlockRaw{
    - 1206 + + 763 +
    + - On("Commit", ctx). + DeltaTimestamp: 123,
    - 1207 + + 764 +
    + - Return(nil). + IndexL1InfoTree: 456,
    - 1208 + + 765 +
    + - Once() + Transactions: []state.L2TxRaw{},
    - 1209 + + -
    - + +
    +
    +  
    - 1210 + + -
    - + - m.State. +
    +
    +   +
    - 1211 + + 766 +
    - + - On("BeginStateTransaction", ctx). +   + }
    - 1212 + + 767 +
    - + - Return(m.DbTx, nil). +   + for i := 0; i < howManyTx; i++ {
    - 1213 + + 768 +
    - + - Once() +   + tx := createTransaction(uint64(i + 1))
    - 1214 + +
     
    +
    + 922 +
    - + +  
    - 1215 + + 923 +
    - + - stateBlock3bis := &state.Block{ +   + func TestReorg(t *testing.T) {
    - 1216 + + 924 +
    - + - BlockNumber: ethermanBlock3bis.BlockNumber, +   + genesis := state.Genesis{
    - 1217 + + 925 +
    + - BlockHash: ethermanBlock3bis.BlockHash, + RollupBlockNumber: uint64(0),
    - 1218 + + 926 +
    - + - ParentHash: ethermanBlock3bis.ParentHash, +   + }
    - 1219 + + 927 +
    - + - ReceivedAt: ethermanBlock3bis.ReceivedAt, +   + cfg := Config{
    - 1220 + + 928 +
    - + - Checked: false, +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1221 + +
     
    +
    + 1242 +
    - + - } +   +
    - 1222 + + 1243 +
    - + - m.State. +   + func TestLatestSyncedBlockEmpty(t *testing.T) {
    - 1223 + + 1244 +
    - + - On("AddBlock", ctx, stateBlock3bis, m.DbTx). +   + genesis := state.Genesis{
    - 1224 + + 1245 +
    + - Return(nil). + RollupBlockNumber: uint64(0),
    - 1225 + + 1246 +
    - + - Once() +   + }
    - 1226 + + 1247 +
    - + -
    +   + cfg := Config{
    - 1227 + + 1248 +
    - + - m.DbTx. +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1228 + +
     
    +
    + 1456 +
    - + - On("Commit", ctx). +   +
    - 1229 + + 1457 +
    - + - Return(nil). +   + func TestRegularReorg(t *testing.T) {
    - 1230 + + 1458 +
    - + - Run(func(args mock.Arguments) { +   + genesis := state.Genesis{
    - 1231 + + 1459 +
    + - sync.Stop() + RollupBlockNumber: uint64(0),
    - 1232 + + 1460 +
    - + - ctx.Done() +   + }
    - 1233 + + 1461 +
    - + - }). +   + cfg := Config{
    - 1234 + + 1462 +
    - + - Once() +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1235 + +
     
    +
    + 1738 +
    - + - }). +   +
    - 1236 + + 1739 +
    - + - Return(m.DbTx, nil). +   + func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) {
    - 1237 + + 1740 +
    - + - Once() +   + genesis := state.Genesis{
    - 1238 + + 1741 +
    + -
    + RollupBlockNumber: uint64(0),
    - 1239 + + 1742 +
    - + - err = sync.Sync() +   + }
    - 1240 + + 1743 +
    - + - require.NoError(t, err) +   + cfg := Config{
    - 1241 + + 1744 +
    - + - } +   + SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1242 + +
     
    +
    + 2014 +
    - + +  
    - 1243 + + 2015 +
    - + - func TestLatestSyncedBlockEmpty(t *testing.T) { +   + func TestCallFromEmptyBlockAndReorg(t *testing.T) {
    - 1244 + + 2016 +
    - + +   genesis := state.Genesis{
    - 1245 + + 2017 +
    + - RollupBlockNumber: uint64(0), + RollupBlockNumber: uint64(0),
    - 1246 + + 2018 +
    - + +   }
    - 1247 + + 2019 +
    - + +   cfg := Config{
    - 1248 + + 2020 +
    - + +   SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second},
    - 1249 + + 2021 +
    - + +   SyncChunkSize: 3,
    - 1250 + + 2022 +
    - + +   L1SynchronizationMode: SequentialMode,
    - 1251 + + 2023 +
    - + +   SyncBlockProtection: "latest",
    - 1252 + 2024
    @@ -219334,7 +301184,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1253 + 2025
    @@ -219344,7 +301194,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1254 + 2026
    @@ -219353,488 +301203,536 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1255 + + 2027 +
    - + +   }
    - 1256 + + 2028 +
    - + +  
    - 1257 + + 2029 +
    - + +   m := mocks{
    - 1258 + +
     
    +
    + 2129 +
    - + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +   + Return(ethHeader2bis, nil).
    - 1259 + + 2130 +
    - + - State: mock_syncinterfaces.NewStateFullInterface(t), +   + Once()
    - 1260 + + 2131 +
    - + - Pool: mock_syncinterfaces.NewPoolInterface(t), +   +
    - 1261 + 2132
    + - DbTx: syncMocks.NewDbTxMock(t), + // m.Etherman.
    - 1262 + 2133
    + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + // On("EthBlockByNumber", ctx, lastBlock1.BlockNumber).
    - 1263 + 2134
    + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + // Return(ethBlock1, nil).
    - 1264 + 2135
    + - } + // Once()
    - 1265 + 2136
    + - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    - 1266 + + 2137 +
    - + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +   + ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC)
    - 1267 + + 2138 +
    - + - require.NoError(t, err) +   +
    - 1268 + + 2139 +
    - + -
    +   + ethermanBlock0 := etherman.Block{
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -0,0 +1,24 @@
    +
    - 1269 + + -
    - + - // state preparation +
    +
    +   +
    - 1270 + + -
    - + - ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    +   +
    - 1271 + + -
    - + - forkIdInterval := state.ForkIDInterval{ +
    +
    +   +
    - 1272 + + -
    - + - ForkId: 9, +
    +
    +   +
    - 1273 + + -
    - + - FromBatchNumber: 0, +
    +
    +   +
    - 1274 + + -
    - + - ToBatchNumber: math.MaxUint64, +
    +
    +   +
    - 1275 + + -
    - + - } +
    +
    +   +
    - 1276 + + -
    - + - m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    +   +
    - 1277 + + -
    - + +
    +
    +  
    - 1278 + + -
    - + - m.State. +
    +
    +   +
    - 1279 + + -
    - + - On("BeginStateTransaction", ctxMatchBy). +
    +
    +   +
    - 1280 + + -
    - + - Run(func(args mock.Arguments) { +
    +
    +   +
    - 1281 + + -
    - + - ctx := args[0].(context.Context) +
    +
    +   +
    - 1282 + + -
    - + - parentHash := common.HexToHash("0x111") +
    +
    +   +
    - 1283 + + -
    - + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    +   +
    - 1284 + + -
    - + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    +   +
    - 1285 + + -
    - + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    +   +
    - 1286 + + -
    - + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    +   +
    - 1287 + + -
    - + - ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    +   +
    - 1288 + + -
    - + - ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    +   +
    - 1289 + + -
    - + - ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    +   +
    - 1290 + + -
    - + - ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    +   +
    - 1291 + + -
    - + +
    +
    +  
    - 1292 + + -
    - + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    +   +
    +
    +
    +
    +
    +
    + + + + + + + +
    +
     
    - 1293 + 1
    + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + // SPDX-License-Identifier: MIT
    - 1294 + 2
    + -
    + pragma solidity >=0.7.0 <0.9.0;
    - 1295 + 3
    + - m.State. +
    - 1296 + 4
    + - On("GetForkIDByBatchNumber", mock.Anything). + contract customModExp {
    - 1297 + 5
    + - Return(uint64(9), nil). + bytes32 hashResult;
    - 1298 + 6
    + - Maybe() + address retEcrecover;
    - 1299 + 7
    + - m.State. + bytes dataResult;
    - 1300 + 8
    + - On("GetLastBlock", ctx, m.DbTx). + uint256 dataRes;
    - 1301 + 9
    + - Return(lastBlock1, nil). +
    - 1302 + 10
    + - Once() + bytes32[10] arrayStorage;
    - 1303 + 11
    @@ -219844,5357 +301742,5423 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1304 + 12
    + - m.State. + function modExpGeneric(bytes memory input) public {
    - 1305 + 13
    + - On("GetLastBatchNumber", ctx, m.DbTx). + bytes32[10] memory output;
    - 1306 + 14
    + - Return(uint64(10), nil). +
    - 1307 + 15
    + - Once() + assembly {
    - 1308 + 16
    + -
    + let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140)
    - 1309 + 17
    + - m.State. + sstore(0x00, success)
    - 1310 + 18
    + - On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + }
    - 1311 + 19
    + - Return(nil). +
    - 1312 + 20
    + - Once() + for (uint i = 0; i < 10; i++) {
    - 1313 + 21
    + -
    + arrayStorage[i] = output[i];
    - 1314 + 22
    + - m.DbTx. + }
    - 1315 + 23
    + - On("Commit", ctx). + }
    - 1316 + 24
    + - Return(nil). + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -2,7 +2,7 @@
    - 1317 + + 2 +
    - + - Once() +   + networks:
    - 1318 + + 3 +
    - + -
    +   + default:
    - 1319 + + 4 +
    - + - m.Etherman. +   + name: zkevm
    - 1320 + + 5 +
    - + - On("GetLatestBatchNumber"). + - +
    - 1321 + + 6 +
    - + - Return(uint64(10), nil) +   + services:
    - 1322 + + 7 +
    - + -
    +   + grafana:
    - 1323 + + 8 +
    - + - var nilDbTx pgx.Tx +   + container_name: grafana
    - 1324 + +
    @@ -453,9 +453,7 @@
    +
    + 453 +
    - + - m.State. +   +
    - 1325 + + 454 +
    - + - On("GetLastBatchNumber", ctx, nilDbTx). +   + zkevm-mock-l1-network:
    - 1326 + + 455 +
    - + - Return(uint64(10), nil) +   + container_name: zkevm-mock-l1-network
    - 1327 + + 456 +
    - + -
    + - + # This image contains the contracts upgraded to Feijoa, disabled
    - 1328 + + 457 +
    - + - m.Etherman. + - + image: hermeznetwork/geth-zkevm-contracts:elderberry-fork.9-geth1.13.11
    - 1329 + + 458 +
    - + - On("GetLatestVerifiedBatchNum"). + - + # image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0
    - 1330 + + 459 +
    - + - Return(uint64(10), nil) +   + ports:
    - 1331 + + 460 +
    - + -
    +   + - 8545:8545
    - 1332 + + 461 +
    - + - m.State. +   + - 8546:8546
    - 1333 + +
    @@ -515,15 +513,14 @@
    +
    + 515 +
    - + - On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +   +
    - 1334 + + 516 +
    - + - Return(nil) +   + zkevm-prover:
    - 1335 + + 517 +
    - + -
    +   + container_name: zkevm-prover
    - 1336 + + 518 +
    - + - m.Etherman. + - + #image: hermeznetwork/zkevm-prover:v7.0.0-RC4
    - 1337 + + 519 +
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +   + image: hermeznetwork/zkevm-prover:v6.0.0
    - 1338 + + 520 +
    - + - Return(ethBlock1, nil). +   + ports:
    - 1339 + + 521 +
    - + - Once() +   + - 50061:50061 # MT
    - 1340 + + 522 +
    - + -
    +   + - 50071:50071 # Executor
    - 1341 + + 523 +
    - + - m.ZKEVMClient. + - + environment:
    - 1342 + + 524 +
    - + - On("BatchNumber", ctx). + - + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
    - 1343 + + 525 +
    - + - Return(uint64(1), nil). +   + volumes:
    - 1344 + + 526 +
    - + - Once() +   + - ./config/test.prover.config.json:/usr/src/app/config.json
    - 1345 + + -
    - + +
    +
    +  
    - 1346 + + -
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    +   +
    - 1347 + + 527 +
    - + - m.Etherman. +   + command: >
    - 1348 + + 528 +
    - + - On("HeaderByNumber", mock.Anything, n). +   + zkProver -c /usr/src/app/config.json
    - 1349 + + 529 +
    - + - Return(ethHeader3, nil). +   +
    - 1350 - -
    - + - Once() -
    +
    +
    @@ -607,17 +604,16 @@
    - 1351 + + 607 +
    - + +  
    - 1352 + + 608 +
    - + - m.Etherman. +   + zkevm-permissionless-prover:
    - 1353 + + 609 +
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +   + container_name: zkevm-permissionless-prover
    - 1354 + + 610 +
    - + - Return(ethBlock1, nil). + - + #image: hermeznetwork/zkevm-prover:v7.0.0-RC4
    - 1355 + + 611 +
    - + - Once() +   + image: hermeznetwork/zkevm-prover:v6.0.0
    - 1356 + + 612 +
    - + -
    +   + ports:
    - 1357 + + 613 +
    - + - blocks := []etherman.Block{} +   + # - 50058:50058 # Prover
    - 1358 + + 614 +
    - + - order := map[common.Hash][]etherman.Order{} +   + - 50059:50052 # Mock prover
    - 1359 + + 615 +
    - + -
    +   + - 50068:50061 # MT
    - 1360 + + 616 +
    - + - fromBlock := ethBlock1.NumberU64() +   + - 50078:50071 # Executor
    - 1361 + + 617 +
    - + - toBlock := fromBlock + cfg.SyncChunkSize + - + environment:
    - 1362 + + 618 +
    - + - if toBlock > ethBlock3.NumberU64() { + - + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
    - 1363 + + 619 +
    - + - toBlock = ethBlock3.NumberU64() +   + volumes:
    - 1364 + + 620 +
    - + - } +   + - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json
    - 1365 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1366 + + -
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    +   +
    - 1367 + + 621 +
    - + - Return(blocks, order, nil). +   + command: >
    - 1368 + + 622 +
    - + - Once() +   + zkProver -c /usr/src/app/config.json
    - 1369 + + 623 +
    - + +  
    - 1370 - -
    - + - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) -
    +
    +
    @@ -636,7 +632,7 @@
    - 1371 + + 636 +
    - + - var depth uint64 = 1 +   + zkevm-sh:
    - 1372 + + 637 +
    - + - stateBlock0 := &state.Block{ +   + container_name: zkevm-sh
    - 1373 + + 638 +
    - + - BlockNumber: ethBlock0.NumberU64(), +   + image: zkevm-node
    - 1374 + + 639 +
    - + - BlockHash: ethBlock0.Hash(), + - + stdin_open: true
    - 1375 + + 640 +
    - + - ParentHash: ethBlock0.ParentHash(), +   + tty: true
    - 1376 + + 641 +
    - + - ReceivedAt: ti, +   + environment:
    - 1377 + + 642 +
    - + - } +   + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db
    - 1378 - -
    - + - m.State. -
    +
    +
    @@ -646,3 +642,51 @@
    - 1379 + + 646 +
    - + - On("GetPreviousBlock", ctx, depth, nil). +   + - ./config/test.genesis.config.json:/app/genesis.json
    - 1380 + + 647 +
    - + - Return(stateBlock0, nil). +   + command:
    - 1381 + + 648 +
    - + - Once() +   + - "/bin/sh"
    - 1382 + + -
    - + +
    +
    +  
    - 1383 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1384 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1385 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1386 + + -
    - + - Once() +
    +
    +   +
    - 1387 + + -
    - + +
    +
    +  
    - 1388 + + -
    - + - m.State. +
    +
    +   +
    - 1389 + + -
    - + - On("BeginStateTransaction", ctx). +
    +
    +   +
    - 1390 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1391 + + -
    - + - Once() +
    +
    +   +
    - 1392 + + -
    - + +
    +
    +  
    - 1393 + + -
    - + - m.State. +
    +
    +   +
    - 1394 + + -
    - + - On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    +   +
    - 1395 + + -
    - + - Return(nil). +
    +
    +   +
    - 1396 + + -
    - + - Once() +
    +
    +   +
    - 1397 + + -
    - + +
    +
    +  
    - 1398 + + -
    - + - m.EthTxManager. +
    +
    +   +
    - 1399 + + -
    - + - On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    +   +
    - 1400 + + -
    - + - Return(nil). +
    +
    +   +
    - 1401 + + -
    - + - Once() +
    +
    +   +
    - 1402 + + -
    - + +
    +
    +  
    - 1403 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1404 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1405 + + -
    - + - Return(nil). +
    +
    +   +
    - 1406 + + -
    - + - Once() +
    +
    +   +
    - 1407 + + -
    - + +
    +
    +  
    - 1408 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1409 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1410 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1411 + + -
    - + - Once() +
    +
    +   +
    - 1412 + + -
    - + +
    +
    +  
    - 1413 + + -
    - + - m.ZKEVMClient. +
    +
    +   +
    - 1414 + + -
    - + - On("BatchNumber", ctx). +
    +
    +   +
    - 1415 + + -
    - + - Return(uint64(1), nil). +
    +
    +   +
    - 1416 + + -
    - + - Once() +
    +
    +   +
    - 1417 + + -
    - + +
    +
    +  
    - 1418 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1419 + + -
    - + - On("HeaderByNumber", mock.Anything, n). +
    +
    +   +
    - 1420 + + -
    - + - Return(ethHeader3, nil). +
    +
    +   +
    - 1421 + + -
    - + - Once() +
    +
    +   +
    - 1422 + + -
    - + +
    +
    +  
    - 1423 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1424 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1425 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1426 + + -
    - + - Once() +
    +
    +   +
    - 1427 + + -
    - + +
    +
    +  
    - 1428 + + -
    - + - ethermanBlock0 := etherman.Block{ +
    +
    +   +
    - 1429 + + -
    - + - BlockNumber: 0, +
    +
    +   +
    - 1430 - -
    - + - ReceivedAt: ti, +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - + + +
    +
     
    - 1431 + + 2 +
    - + - BlockHash: ethBlock0.Hash(), +   + networks:
    - 1432 + + 3 +
    - + - ParentHash: ethBlock0.ParentHash(), +   + default:
    - 1433 + + 4 +
    - + - } +   + name: zkevm
    - 1434 + + 5 +
    + - blocks = []etherman.Block{ethermanBlock0} +
    - 1435 + + 6 +
    - + - fromBlock = 0 +   + services:
    - 1436 + + 7 +
    - + - m.Etherman. +   + grafana:
    - 1437 + + 8 +
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +   + container_name: grafana
    - 1438 + +
     
    +
    + 453 +
    - + - Return(blocks, order, nil). +   +
    - 1439 + + 454 +
    - + - Once() +   + zkevm-mock-l1-network:
    - 1440 + + 455 +
    - + -
    +   + container_name: zkevm-mock-l1-network
    - 1441 + + 456 +
    + - m.Etherman. + image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.13.11
    - 1442 + + -
    - + - On("GetFinalizedBlockNumber", ctx). +
    +
    +   +
    - 1443 + + -
    - + - Return(ethBlock3.NumberU64(), nil). +
    +
    +   +
    - 1444 + + 457 +
    - + - Run(func(args mock.Arguments) { +   + ports:
    - 1445 + + 458 +
    - + - sync.Stop() +   + - 8545:8545
    - 1446 + + 459 +
    - + - ctx.Done() +   + - 8546:8546
    - 1447 + +
     
    +
    + 513 +
    - + - }). +   +
    - 1448 + + 514 +
    - + - Once() +   + zkevm-prover:
    - 1449 + + 515 +
    - + - }). +   + container_name: zkevm-prover
    - 1450 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1451 + + 516 +
    - + - Once() +   + image: hermeznetwork/zkevm-prover:v6.0.0
    - 1452 + + 517 +
    - + -
    +   + ports:
    - 1453 + + 518 +
    - + - err = sync.Sync() +   + - 50061:50061 # MT
    - 1454 + + 519 +
    - + - require.NoError(t, err) +   + - 50071:50071 # Executor
    - 1455 + + -
    - + - } +
    +
    +   +
    - 1456 + + -
    - + +
    +
    +  
    - 1457 + + 520 +
    - + - func TestRegularReorg(t *testing.T) { +   + volumes:
    - 1458 + + 521 +
    - + - genesis := state.Genesis{ +   + - ./config/test.prover.config.json:/usr/src/app/config.json
    - 1459 + 522
    + - RollupBlockNumber: uint64(0), + environment:
    - 1460 + 523
    + - } + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
    - 1461 + + 524 +
    - + - cfg := Config{ +   + command: >
    - 1462 + + 525 +
    - + - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +   + zkProver -c /usr/src/app/config.json
    - 1463 + + 526 +
    - + - SyncChunkSize: 3, +   +
    - 1464 + +
     
    +
    + 604 +
    - + - L1SynchronizationMode: SequentialMode, +   +
    - 1465 + + 605 +
    - + - SyncBlockProtection: "latest", +   + zkevm-permissionless-prover:
    - 1466 + + 606 +
    - + - L1BlockCheck: L1BlockCheckConfig{ +   + container_name: zkevm-permissionless-prover
    - 1467 + + -
    - + - Enable: false, +
    +
    +   +
    - 1468 + + 607 +
    - + - }, +   + image: hermeznetwork/zkevm-prover:v6.0.0
    - 1469 + + 608 +
    - + - } +   + ports:
    - 1470 + + 609 +
    - + -
    +   + # - 50058:50058 # Prover
    - 1471 + + 610 +
    - + - m := mocks{ +   + - 50059:50052 # Mock prover
    - 1472 + + 611 +
    - + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +   + - 50068:50061 # MT
    - 1473 + + 612 +
    - + - State: mock_syncinterfaces.NewStateFullInterface(t), +   + - 50078:50071 # Executor
    - 1474 + + -
    - + - Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    +   +
    - 1475 + + -
    - + - DbTx: syncMocks.NewDbTxMock(t), +
    +
    +   +
    - 1476 + + 613 +
    - + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +   + volumes:
    - 1477 + + 614 +
    - + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +   + - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json
    - 1478 + 615
    + - } + environment:
    - 1479 + 616
    + - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1
    - 1480 + + 617 +
    - + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +   + command: >
    - 1481 + + 618 +
    - + - require.NoError(t, err) +   + zkProver -c /usr/src/app/config.json
    - 1482 + + 619 +
    - + +  
    - 1483 - -
    - + - // state preparation -
    +
    +
     
    - 1484 + + 632 +
    - + - ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +   + zkevm-sh:
    - 1485 + + 633 +
    - + - forkIdInterval := state.ForkIDInterval{ +   + container_name: zkevm-sh
    - 1486 + + 634 +
    - + - ForkId: 9, +   + image: zkevm-node
    - 1487 + + 635 +
    + - FromBatchNumber: 0, + stdin_open: true
    - 1488 + + 636 +
    - + - ToBatchNumber: math.MaxUint64, +   + tty: true
    - 1489 + + 637 +
    - + - } +   + environment:
    - 1490 + + 638 +
    - + - m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +   + - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db
    - 1491 - -
    - + -
    -
    +
    +
     
    - 1492 + + 642 +
    - + - m.State. +   + - ./config/test.genesis.config.json:/app/genesis.json
    - 1493 + + 643 +
    - + - On("BeginStateTransaction", ctxMatchBy). +   + command:
    - 1494 + + 644 +
    - + - Run(func(args mock.Arguments) { +   + - "/bin/sh"
    - 1495 + 645
    + - ctx := args[0].(context.Context) +
    - 1496 + 646
    + - parentHash := common.HexToHash("0x111") + zkevm-node-forced-DAC:
    - 1497 + 647
    + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + container_name: zkevm-node-forced-DAC
    - 1498 + 648
    + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + image: zkevm-node
    - 1499 + 649
    + - ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} + ports:
    - 1500 + 650
    + - ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) + - 8125:8125
    - 1501 + 651
    + - ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} + environment:
    - 1502 + 652
    + - ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) + - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false
    - 1503 + 653
    + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + - ZKEVM_NODE_STATEDB_USER=test_user
    - 1504 + 654
    + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + - ZKEVM_NODE_STATEDB_PASSWORD=test_password
    - 1505 + 655
    + - ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + - ZKEVM_NODE_STATEDB_NAME=state_db
    - 1506 + 656
    + - ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) + - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db
    - 1507 + 657
    + -
    + - ZKEVM_NODE_POOL_DB_USER=test_user
    - 1508 + 658
    + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + - ZKEVM_NODE_POOL_DB_PASSWORD=test_password
    - 1509 + 659
    + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + - ZKEVM_NODE_POOL_DB_NAME=pool_db
    - 1510 + 660
    + -
    + - ZKEVM_NODE_POOL_DB_HOST=zkevm-permissionless-db
    - 1511 + 661
    + - m.State. + - ZKEVM_NODE_RPC_PORT=8125
    - 1512 + 662
    + - On("GetForkIDByBatchNumber", mock.Anything). + - ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-node-json-rpc:8123
    - 1513 + 663
    + - Return(uint64(9), nil). + - ZKEVM_NODE_SYNCHRONIZER_TRUSTEDSEQUENCERURL=http://you-cant-touch-this:8123
    - 1514 + 664
    + - Maybe() + - ZKEVM_NODE_MTCLIENT_URI=zkevm-permissionless-prover:50061
    - 1515 + 665
    + - m.State. + - ZKEVM_NODE_EXECUTOR_URI=zkevm-permissionless-prover:50071
    - 1516 + 666
    + - On("GetLastBlock", ctx, m.DbTx). + volumes:
    - 1517 + 667
    + - Return(lastBlock1, nil). + - ./config/test.node.config.toml:/app/config.toml
    - 1518 + 668
    + - Once() + - ./config/test.genesis.config.json:/app/genesis.json
    - 1519 + 669
    + -
    + command:
    - 1520 + 670
    + - // After a ResetState get lastblock that must be block 0 + - "/bin/sh"
    - 1521 + 671
    + - m.State. + - "-c"
    - 1522 + 672
    + - On("GetLastBlock", ctx, nil). + - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\""
    - 1523 + 673
    + - Return(lastBlock0, nil). +
    - 1524 + 674
    + - Once() + zkevm-data-node-db:
    - 1525 + 675
    + -
    + container_name: zkevm-data-node-db
    - 1526 + 676
    + - m.State. + restart: unless-stopped
    - 1527 + 677
    + - On("GetLastBatchNumber", ctx, m.DbTx). + image: postgres
    - 1528 + 678
    + - Return(uint64(10), nil). + healthcheck:
    - 1529 + 679
    + - Once() + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
    - 1530 + 680
    + -
    + interval: 10s
    - 1531 + 681
    + - m.State. + timeout: 5s
    - 1532 + 682
    + - On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). + retries: 5
    - 1533 + 683
    + - Return(nil). + ports:
    - 1534 + 684
    + - Once() + - 5444:5432
    - 1535 + 685
    + -
    + environment:
    - 1536 + 686
    + - m.DbTx. + - POSTGRES_USER=committee_user
    - 1537 + 687
    + - On("Commit", ctx). + - POSTGRES_PASSWORD=committee_password
    - 1538 + 688
    + - Return(nil). + - POSTGRES_DB=committee_db
    - 1539 + 689
    + - Once() + command:
    - 1540 + 690
    + -
    + - "postgres"
    - 1541 + 691
    + - m.Etherman. + - "-N"
    - 1542 + 692
    + - On("GetLatestBatchNumber"). + - "500" +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    +
    @@ -0,0 +1,270 @@
    - 1543 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1544 + + -
    - + +
    +
    +  
    - 1545 + + -
    - + - var nilDbTx pgx.Tx +
    +
    +   +
    - 1546 + + -
    - + - m.State. +
    +
    +   +
    - 1547 + + -
    - + - On("GetLastBatchNumber", ctx, nilDbTx). +
    +
    +   +
    - 1548 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1549 + + -
    - + +
    +
    +  
    - 1550 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1551 + + -
    - + - On("GetLatestVerifiedBatchNum"). +
    +
    +   +
    - 1552 + + -
    - + - Return(uint64(10), nil) +
    +
    +   +
    - 1553 + + -
    - + +
    +
    +  
    - 1554 + + -
    - + - m.State. +
    +
    +   +
    - 1555 + + -
    - + - On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +
    +
    +   +
    - 1556 + + -
    - + - Return(nil) +
    +
    +   +
    - 1557 + + -
    - + +
    +
    +  
    - 1558 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1559 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    +   +
    - 1560 + + -
    - + - Return(ethBlock1, nil). +
    +
    +   +
    - 1561 + + -
    - + - Once() +
    +
    +   +
    - 1562 + + -
    - + +
    +
    +  
    - 1563 + + -
    - + - m.ZKEVMClient. +
    +
    +   +
    - 1564 + + -
    - + - On("BatchNumber", ctx). +
    +
    +   +
    - 1565 + + -
    - + - Return(uint64(1), nil). +
    +
    +   +
    - 1566 + + -
    - + - Once() +
    +
    +   +
    - 1567 + + -
    - + +
    +
    +  
    - 1568 + + -
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) +
    +
    +   +
    - 1569 + + -
    - + +
    +
    +  
    - 1570 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1571 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +
    +
    +   +
    - 1572 + + -
    - + - Return(ethBlock1bis, nil). +
    +
    +   +
    - 1573 + + -
    - + - Once() +
    +
    +   +
    - 1574 + + -
    - + +
    +
    +  
    - 1575 + + -
    - + - m.State. +
    +
    +   +
    - 1576 + + -
    - + - On("BeginStateTransaction", ctx). +
    +
    +   +
    - 1577 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1578 + + -
    - + - Once() +
    +
    +   +
    - 1579 + + -
    - + +
    +
    +  
    - 1580 + + -
    - + - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +
    +
    +   +
    - 1581 + + -
    - + - var depth uint64 = 1 +
    +
    +   +
    - 1582 + + -
    - + - stateBlock0 := &state.Block{ +
    +
    +   +
    - 1583 + + -
    - + - BlockNumber: ethBlock0.NumberU64(), +
    +
    +   +
    - 1584 + + -
    - + - BlockHash: ethBlock0.Hash(), +
    +
    +   +
    - 1585 + + -
    - + - ParentHash: ethBlock0.ParentHash(), +
    +
    +   +
    - 1586 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1587 + + -
    - + - } +
    +
    +   +
    - 1588 + + -
    - + - m.State. +
    +
    +   +
    - 1589 + + -
    - + - On("GetPreviousBlock", ctx, depth, m.DbTx). +
    +
    +   +
    - 1590 + + -
    - + - Return(stateBlock0, nil). +
    +
    +   +
    - 1591 + + -
    - + - Once() +
    +
    +   +
    - 1592 + + -
    - + +
    +
    +  
    - 1593 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1594 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1595 + + -
    - + - Return(nil). +
    +
    +   +
    - 1596 + + -
    - + - Once() +
    +
    +   +
    - 1597 + + -
    - + +
    +
    +  
    - 1598 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1599 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1600 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1601 + + -
    - + - Once() +
    +
    +   +
    - 1602 + + -
    - + +
    +
    +  
    - 1603 + + -
    - + - m.State. +
    +
    +   +
    - 1604 + + -
    - + - On("BeginStateTransaction", ctx). +
    +
    +   +
    - 1605 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1606 + + -
    - + - Once() +
    +
    +   +
    - 1607 + + -
    - + +
    +
    +  
    - 1608 + + -
    - + - m.State. +
    +
    +   +
    - 1609 + + -
    - + - On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +
    +
    +   +
    - 1610 + + -
    - + - Return(nil). +
    +
    +   +
    - 1611 + + -
    - + - Once() +
    +
    +   +
    - 1612 + + -
    - + +
    +
    +  
    - 1613 + + -
    - + - m.EthTxManager. +
    +
    +   +
    - 1614 + + -
    - + - On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +
    +
    +   +
    - 1615 + + -
    - + - Return(nil). +
    +
    +   +
    - 1616 + + -
    - + - Once() +
    +
    +   +
    - 1617 + + -
    - + +
    +
    +  
    - 1618 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1619 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1620 + + -
    - + - Return(nil). +
    +
    +   +
    - 1621 + + -
    - + - Once() +
    +
    +   +
    - 1622 + + -
    - + +
    +
    +  
    - 1623 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1624 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1625 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1626 + + -
    - + - Once() +
    +
    +   +
    - 1627 + + -
    - + +
    +
    +  
    - 1628 + + -
    - + - m.ZKEVMClient. +
    +
    +   +
    - 1629 + + -
    - + - On("BatchNumber", ctx). +
    +
    +   +
    - 1630 + + -
    - + - Return(uint64(1), nil). +
    +
    +   +
    - 1631 + + -
    - + - Once() +
    +
    +   +
    - 1632 + + -
    - + +
    +
    +  
    - 1633 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1634 + + -
    - + - On("HeaderByNumber", mock.Anything, n). +
    +
    +   +
    - 1635 + + -
    - + - Return(ethHeader2bis, nil). +
    +
    +   +
    - 1636 + + -
    - + - Once() +
    +
    +   +
    - 1637 + + -
    - + +
    +
    +  
    - 1638 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1639 + + -
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +
    +
    +   +
    - 1640 + + -
    - + - Return(ethBlock0, nil). +
    +
    +   +
    - 1641 + + -
    - + - Once() +
    +
    +   +
    - 1642 + + -
    - + +
    +
    +  
    - 1643 + + -
    - + - ethermanBlock0 := etherman.Block{ +
    +
    +   +
    - 1644 + + -
    - + - BlockNumber: 0, +
    +
    +   +
    - 1645 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1646 + + -
    - + - BlockHash: ethBlock0.Hash(), +
    +
    +   +
    - 1647 + + -
    - + - ParentHash: ethBlock0.ParentHash(), +
    +
    +   +
    - 1648 + + -
    - + - } +
    +
    +   +
    - 1649 + + -
    - + - ethermanBlock1bis := etherman.Block{ +
    +
    +   +
    - 1650 + + -
    - + - BlockNumber: 1, +
    +
    +   +
    - 1651 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1652 + + -
    - + - BlockHash: ethBlock1bis.Hash(), +
    +
    +   +
    - 1653 + + -
    - + - ParentHash: ethBlock1bis.ParentHash(), +
    +
    +   +
    - 1654 - -
    - + - } +
    + + +
    +   +
    - 1655 + + -
    - + - ethermanBlock2bis := etherman.Block{ +
    +
    +   +
    - 1656 + + -
    - + - BlockNumber: 2, +
    +
    +   +
    - 1657 + + -
    - + - ReceivedAt: ti, +
    +
    +   +
    - 1658 + + -
    - + - BlockHash: ethBlock2bis.Hash(), +
    +
    +   +
    - 1659 + + -
    - + - ParentHash: ethBlock2bis.ParentHash(), +
    +
    +   +
    - 1660 + + -
    - + - } +
    +
    +   +
    - 1661 + + -
    - + - blocks := []etherman.Block{ethermanBlock0, ethermanBlock1bis, ethermanBlock2bis} +
    +
    +   +
    - 1662 + + -
    - + - order := map[common.Hash][]etherman.Order{} +
    +
    +   +
    - 1663 + + -
    - + +
    +
    +  
    - 1664 + + -
    - + - fromBlock := ethBlock0.NumberU64() +
    +
    +   +
    - 1665 + + -
    - + - toBlock := fromBlock + cfg.SyncChunkSize +
    +
    +   +
    - 1666 + + -
    - + - if toBlock > ethBlock2.NumberU64() { +
    +
    +   +
    - 1667 + + -
    - + - toBlock = ethBlock2.NumberU64() +
    +
    +   +
    - 1668 + + -
    - + - } +
    +
    +   +
    - 1669 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1670 + + -
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +
    +
    +   +
    - 1671 + + -
    - + - Return(blocks, order, nil). +
    +
    +   +
    - 1672 + + -
    - + - Once() +
    +
    +   +
    - 1673 + + -
    - + +
    +
    +  
    - 1674 + + -
    - + - m.Etherman. +
    +
    +   +
    - 1675 + + -
    - + - On("GetFinalizedBlockNumber", ctx). +
    +
    +   +
    - 1676 + + -
    - + - Return(ethBlock2bis.NumberU64(), nil). +
    +
    +   +
    - 1677 + + -
    - + - Once() +
    +
    +   +
    - 1678 + + -
    - + +
    +
    +  
    - 1679 + + -
    - + - m.State. +
    +
    +   +
    - 1680 + + -
    - + - On("BeginStateTransaction", ctx). +
    +
    +   +
    - 1681 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1682 + + -
    - + - Once() +
    +
    +   +
    - 1683 + + -
    - + +
    +
    +  
    - 1684 + + -
    - + - stateBlock1bis := &state.Block{ +
    +
    +   +
    - 1685 + + -
    - + - BlockNumber: ethermanBlock1bis.BlockNumber, +
    +
    +   +
    - 1686 + + -
    - + - BlockHash: ethermanBlock1bis.BlockHash, +
    +
    +   +
    - 1687 + + -
    - + - ParentHash: ethermanBlock1bis.ParentHash, +
    +
    +   +
    - 1688 + + -
    - + - ReceivedAt: ethermanBlock1bis.ReceivedAt, +
    +
    +   +
    - 1689 + + -
    - + - Checked: true, +
    +
    +   +
    - 1690 + + -
    - + - } +
    +
    +   +
    - 1691 + + -
    - + - m.State. +
    +
    +   +
    - 1692 + + -
    - + - On("AddBlock", ctx, stateBlock1bis, m.DbTx). +
    +
    +   +
    - 1693 + + -
    - + - Return(nil). +
    +
    +   +
    - 1694 + + -
    - + - Once() +
    +
    +   +
    - 1695 + + -
    - + +
    +
    +  
    - 1696 + + -
    - + - m.State. +
    +
    +   +
    - 1697 + + -
    - + - On("GetStoredFlushID", ctx). +
    +
    +   +
    - 1698 + + -
    - + - Return(uint64(1), cProverIDExecution, nil). +
    +
    +   +
    - 1699 + + -
    - + - Once() +
    +
    +   +
    - 1700 + + -
    - + +
    +
    +  
    - 1701 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1702 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1703 + + -
    - + - Return(nil). +
    +
    +   +
    - 1704 + + -
    - + - Once() +
    +
    +   +
    - 1705 + + -
    - + +
    +
    +  
    - 1706 + + -
    - + - m.State. +
    +
    +   +
    - 1707 + + -
    - + - On("BeginStateTransaction", ctx). +
    +
    +   +
    - 1708 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1709 + + -
    - + - Once() +
    +
    +   +
    - 1710 + + -
    - + +
    +
    +  
    - 1711 + + -
    - + - stateBlock2bis := &state.Block{ +
    +
    +   +
    - 1712 + + -
    - + - BlockNumber: ethermanBlock2bis.BlockNumber, +
    +
    +   +
    - 1713 + + -
    - + - BlockHash: ethermanBlock2bis.BlockHash, +
    +
    +   +
    - 1714 + + -
    - + - ParentHash: ethermanBlock2bis.ParentHash, +
    +
    +   +
    - 1715 + + -
    - + - ReceivedAt: ethermanBlock2bis.ReceivedAt, +
    +
    +   +
    - 1716 + + -
    - + - Checked: true, +
    +
    +   +
    - 1717 + + -
    - + - } +
    +
    +   +
    - 1718 + + -
    - + - m.State. +
    +
    +   +
    - 1719 + + -
    - + - On("AddBlock", ctx, stateBlock2bis, m.DbTx). +
    +
    +   +
    - 1720 + + -
    - + - Return(nil). +
    +
    +   +
    - 1721 + + -
    - + - Once() +
    +
    +   +
    - 1722 + + -
    - + +
    +
    +  
    - 1723 + + -
    - + - m.DbTx. +
    +
    +   +
    - 1724 + + -
    - + - On("Commit", ctx). +
    +
    +   +
    - 1725 + + -
    - + - Run(func(args mock.Arguments) { +
    +
    +   +
    - 1726 + + -
    - + - sync.Stop() +
    +
    +   +
    - 1727 + + -
    - + - ctx.Done() +
    +
    +   +
    - 1728 + + -
    - + - }). +
    +
    +   +
    - 1729 + + -
    - + - Return(nil). +
    +
    +   +
    - 1730 + + -
    - + - Once() +
    +
    +   +
    - 1731 + + -
    - + - }). +
    +
    +   +
    - 1732 + + -
    - + - Return(m.DbTx, nil). +
    +
    +   +
    - 1733 + + -
    - + - Once() +
    +
    +   +
    - 1734 + + -
    - + +
    +
    +  
    - 1735 + + -
    - + - err = sync.Sync() +
    +
    +   +
    - 1736 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1737 + + -
    - + - } +
    +
    +   +
    - 1738 + + -
    - + +
    +
    +  
    - 1739 + + -
    - + - func TestLatestSyncedBlockEmptyWithExtraReorg(t *testing.T) { +
    +
    +   +
    - 1740 + + -
    - + - genesis := state.Genesis{ +
    +
    +   +
    - 1741 + + -
    - + - RollupBlockNumber: uint64(0), +
    +
    +   +
    - 1742 + + -
    - + - } +
    +
    +   +
    - 1743 + + -
    - + - cfg := Config{ +
    +
    +   +
    - 1744 + + -
    - + - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, +
    +
    +   +
    - 1745 + + -
    - + - SyncChunkSize: 3, +
    +
    +   +
    - 1746 + + -
    - + - L1SynchronizationMode: SequentialMode, +
    +
    +   +
    - 1747 + + -
    - + - SyncBlockProtection: "latest", +
    +
    +   +
    - 1748 + + -
    - + - L1BlockCheck: L1BlockCheckConfig{ +
    +
    +   +
    - 1749 + + -
    - + - Enable: false, +
    +
    +   +
    - 1750 + + -
    - + - }, +
    +
    +   +
    - 1751 + + -
    - + - } +
    +
    +   +
    - 1752 + + -
    - + +
    +
    +  
    - 1753 + + -
    - + - m := mocks{ +
    +
    +   +
    - 1754 + + -
    - + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), +
    +
    +   +
    - 1755 + + -
    - + - State: mock_syncinterfaces.NewStateFullInterface(t), +
    +
    +   +
    - 1756 + + -
    - + - Pool: mock_syncinterfaces.NewPoolInterface(t), +
    +
    +   +
    - 1757 + + -
    - + - DbTx: syncMocks.NewDbTxMock(t), +
    +
    +   +
    - 1758 + + -
    - + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), +
    +
    +   +
    - 1759 + + -
    - + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), +
    +
    +   +
    - 1760 + + -
    - + - } +
    +
    +   +
    - 1761 + + -
    - + - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} +
    +
    +   +
    - 1762 + + -
    - + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) +
    +
    +   +
    - 1763 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 1764 + + -
    - + +
    +
    +  
    - 1765 + + -
    - + - // state preparation +
    +
    +   +
    - 1766 + + -
    - + - ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) +
    +
    +   +
    - 1767 + + -
    - + - forkIdInterval := state.ForkIDInterval{ +
    +
    +   +
    - 1768 + + -
    - + - ForkId: 9, +
    +
    +   +
    - 1769 + + -
    - + - FromBatchNumber: 0, +
    +
    +   +
    - 1770 + + -
    - + - ToBatchNumber: math.MaxUint64, +
    +
    +   +
    - 1771 + + -
    - + - } +
    +
    +   +
    - 1772 + + -
    - + - m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) +
    +
    +   +
    - 1773 + + -
    - + +
    +
    +  
    - 1774 + + -
    - + - m.State. +
    +
    +   +
    - 1775 + + -
    - + - On("BeginStateTransaction", ctxMatchBy). +
    +
    +   +
    - 1776 + + -
    - + - Run(func(args mock.Arguments) { +
    +
    +   +
    - 1777 + + -
    - + - ctx := args[0].(context.Context) +
    +
    +   +
    - 1778 + + -
    - + - parentHash := common.HexToHash("0x111") +
    +
    +   +
    - 1779 + + -
    - + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} +
    +
    +   +
    - 1780 + + -
    - + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) +
    +
    +   +
    - 1781 + + -
    - + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} +
    +
    +   +
    - 1782 + + -
    - + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) +
    +
    +   +
    - 1783 + + -
    - + - ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 0, GasUsed: 10} +
    +
    +   +
    - 1784 + + -
    - + - ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    +
    +   +
    - 1785 + + -
    - + - ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} +
    +
    +   +
    - 1786 + + -
    - + - ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    +
    +   +
    - 1787 + + -
    - + - ethHeader3 := &ethTypes.Header{Number: big.NewInt(3), ParentHash: ethBlock2.Hash()} +
    +
    +   +
    - 1788 + + -
    - + - ethBlock3 := ethTypes.NewBlockWithHeader(ethHeader3) +
    +
    +   +
    - 1789 + + -
    - + +
    +
    +  
    - 1790 + + -
    - + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} +
    +
    +   +
    - 1791 + + -
    - + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} +
    +
    +   +
    - 1792 + + -
    - + - lastBlock2 := &state.Block{BlockHash: ethBlock2.Hash(), BlockNumber: ethBlock2.Number().Uint64(), ParentHash: ethBlock2.ParentHash()} +
    +
    +   +
    - 1793 + + -
    - + +
    +
    +  
    - 1794 + + -
    - + - m.State. +
    +
    +   +
    - 1795 + + -
    - + - On("GetForkIDByBatchNumber", mock.Anything). +
    +
    +   +
    - 1796 + + -
    - + - Return(uint64(9), nil). +
    +
    +   +
    - 1797 + + -
    - + - Maybe() +
    +
    +   +
    - 1798 + + -
    - + - m.State. +
    +
    +   +
    - 1799 + + -
    - + - On("GetLastBlock", ctx, m.DbTx). +
    +
    +   +
    - 1800 + + -
    - + - Return(lastBlock2, nil). +
    +
    +   +
    - 1801 + + -
    - + - Once() +
    +
    +   +
    - 1802 + + -
    - + +
    +
    +  
    - 1803 + + -
    - + - m.State. +
    +
    +   +
    - 1804 + + -
    - + - On("GetLastBatchNumber", ctx, m.DbTx). +
    +
    +   +
    - 1805 + + -
    - + - Return(uint64(10), nil). +
    +
    +   +
    - 1806 + + -
    - + - Once() +
    +
    +   +
    - 1807 + + -
    - + +
    +
    +  
    - 1808 + + -
    - + - m.State. +
    +
    +   +
    - 1809 + + -
    - + - On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +
    +
    +   +
    - 1810 + + -
    - + - Return(nil). +
    +
    +   +
    - 1811 + + -
    - + - Once() +
    +
    +   +
    - 1812 + + -
    - + +
    +
    +  
    - 1813 - -
    - + - m.DbTx. +
    +
    +
    +
    + + + + + + + +
    +
     
    - 1814 + 1
    + - On("Commit", ctx). + package e2e
    - 1815 + 2
    + - Return(nil). +
    - 1816 + 3
    + - Once() + import (
    - 1817 + 4
    + -
    + "context"
    - 1818 + 5
    + - m.Etherman. + "crypto/ecdsa"
    - 1819 + 6
    + - On("GetLatestBatchNumber"). + "encoding/json"
    - 1820 + 7
    + - Return(uint64(10), nil) + "fmt"
    - 1821 + 8
    + -
    + "math/big"
    - 1822 + 9
    + - var nilDbTx pgx.Tx + "os"
    - 1823 + 10
    + - m.State. + "os/exec"
    - 1824 + 11
    + - On("GetLastBatchNumber", ctx, nilDbTx). + "sort"
    - 1825 + 12
    + - Return(uint64(10), nil) + "strconv"
    - 1826 + 13
    + -
    + "strings"
    - 1827 + 14
    + - m.Etherman. + "testing"
    - 1828 + 15
    + - On("GetLatestVerifiedBatchNum"). + "time"
    - 1829 + 16
    + - Return(uint64(10), nil) +
    - 1830 + 17
    + -
    + "github.com/0xPolygon/cdk-data-availability/config"
    - 1831 + 18
    + - m.State. + cTypes "github.com/0xPolygon/cdk-data-availability/config/types"
    - 1832 + 19
    + - On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). + "github.com/0xPolygon/cdk-data-availability/db"
    - 1833 + 20
    + - Return(nil) + "github.com/0xPolygon/cdk-data-availability/rpc"
    - 1834 + 21
    + -
    + "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee"
    - 1835 + 22
    + - m.Etherman. + "github.com/0xPolygonHermez/zkevm-node/log"
    - 1836 + 23
    + - On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). + "github.com/0xPolygonHermez/zkevm-node/test/operations"
    - 1837 + 24
    + - Return(ethBlock2, nil). + "github.com/ethereum/go-ethereum"
    - 1838 + 25
    + - Once() + eTypes "github.com/ethereum/go-ethereum/core/types"
    - 1839 + 26
    @@ -225204,1877 +307168,1877 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1840 + 27
    + - m.ZKEVMClient. + "github.com/ethereum/go-ethereum/accounts/keystore"
    - 1841 + 28
    + - On("BatchNumber", ctx). + "github.com/ethereum/go-ethereum/common"
    - 1842 + 29
    + - Return(uint64(1), nil). + "github.com/ethereum/go-ethereum/crypto"
    - 1843 + 30
    + - Once() + "github.com/ethereum/go-ethereum/ethclient"
    - 1844 + 31
    + -
    + "github.com/stretchr/testify/assert"
    - 1845 + 32
    + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) + "github.com/stretchr/testify/require"
    - 1846 + 33
    + - m.Etherman. + )
    - 1847 + 34
    + - On("HeaderByNumber", mock.Anything, n). +
    - 1848 + 35
    + - Return(ethHeader3, nil). + func TestDataCommittee(t *testing.T) {
    - 1849 + 36
    + - Once() + const (
    - 1850 + 37
    + -
    + nSignatures = 4
    - 1851 + 38
    + - m.Etherman. + mMembers = 5
    - 1852 + 39
    + - On("EthBlockByNumber", ctx, lastBlock2.BlockNumber). + ksFile = "/tmp/pkey"
    - 1853 + 40
    + - Return(ethBlock2, nil). + cfgFile = "/tmp/dacnodeconfigfile.json"
    - 1854 + 41
    + - Once() + ksPass = "pass"
    - 1855 + 42
    + -
    + dacNodeContainer = "hermeznetwork/cdk-data-availability:v0.0.4"
    - 1856 + 43
    + - blocks := []etherman.Block{} + )
    - 1857 + 44
    + - order := map[common.Hash][]etherman.Order{} +
    - 1858 + 45
    + -
    + // Setup
    - 1859 + 46
    + - fromBlock := ethBlock2.NumberU64() + var err error
    - 1860 + 47
    + - toBlock := fromBlock + cfg.SyncChunkSize + if testing.Short() {
    - 1861 + 48
    + - if toBlock > ethBlock3.NumberU64() { + t.Skip()
    - 1862 + 49
    + - toBlock = ethBlock3.NumberU64() + }
    - 1863 + 50
    + - } + ctx := context.Background()
    - 1864 + 51
    + - m.Etherman. + defer func() {
    - 1865 + 52
    + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + require.NoError(t, operations.Teardown())
    - 1866 + 53
    + - Return(blocks, order, nil). + }()
    - 1867 + 54
    + - Once() + err = operations.Teardown()
    - 1868 + 55
    + -
    + require.NoError(t, err)
    - 1869 + 56
    + - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) + opsCfg := operations.GetDefaultOperationsConfig()
    - 1870 + 57
    + - var depth uint64 = 1 + opsCfg.State.MaxCumulativeGasUsed = 80000000000
    - 1871 + 58
    + - stateBlock1 := &state.Block{ + opsman, err := operations.NewManager(ctx, opsCfg)
    - 1872 + 59
    + - BlockNumber: ethBlock1.NumberU64(), + require.NoError(t, err)
    - 1873 + 60
    + - BlockHash: ethBlock1.Hash(), + defer func() {
    - 1874 + 61
    + - ParentHash: ethBlock1.ParentHash(), + require.NoError(t, opsman.StopDACDB())
    - 1875 + 62
    + - ReceivedAt: ti, + }()
    - 1876 + 63
    + - } + err = opsman.Setup()
    - 1877 + 64
    + - m.State. + require.NoError(t, err)
    - 1878 + 65
    + - On("GetPreviousBlock", ctx, depth, nil). + require.NoError(t, opsman.StartDACDB())
    - 1879 + 66
    + - Return(stateBlock1, nil). + time.Sleep(5 * time.Second)
    - 1880 + 67
    + - Once() + authL2, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID)
    - 1881 + 68
    + -
    + require.NoError(t, err)
    - 1882 + 69
    + - m.Etherman. + authL1, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID)
    - 1883 + 70
    + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). + require.NoError(t, err)
    - 1884 + 71
    + - Return(ethBlock1bis, nil). + clientL2, err := ethclient.Dial(operations.DefaultL2NetworkURL)
    - 1885 + 72
    + - Once() + require.NoError(t, err)
    - 1886 + 73
    + -
    + clientL1, err := ethclient.Dial(operations.DefaultL1NetworkURL)
    - 1887 + 74
    + - m.State. + require.NoError(t, err)
    - 1888 + 75
    + - On("BeginStateTransaction", ctx). + dacSC, err := polygondatacommittee.NewPolygondatacommittee(
    - 1889 + 76
    + - Return(m.DbTx, nil). + common.HexToAddress(operations.DefaultL1DataCommitteeContract),
    - 1890 + 77
    + - Once() + clientL1,
    - 1891 + 78
    + -
    + )
    - 1892 + 79
    + - stateBlock0 := &state.Block{ + require.NoError(t, err)
    - 1893 + 80
    + - BlockNumber: ethBlock0.NumberU64(), +
    - 1894 + 81
    + - BlockHash: ethBlock0.Hash(), + // Register committee with N / M signatures
    - 1895 + 82
    + - ParentHash: ethBlock0.ParentHash(), + membs := members{}
    - 1896 + 83
    + - ReceivedAt: ti, + addrsBytes := []byte{}
    - 1897 + 84
    + - } + urls := []string{}
    - 1898 + 85
    + - m.State. + for i := 0; i < mMembers; i++ {
    - 1899 + 86
    + - On("GetPreviousBlock", ctx, depth, m.DbTx). + pk, err := crypto.GenerateKey()
    - 1900 + 87
    + - Return(stateBlock0, nil). + require.NoError(t, err)
    - 1901 + 88
    + - Once() + membs = append(membs, member{
    - 1902 + 89
    + -
    + addr: crypto.PubkeyToAddress(pk.PublicKey),
    - 1903 + 90
    + - m.DbTx. + pk: pk,
    - 1904 + 91
    + - On("Commit", ctx). + url: fmt.Sprintf("http://cdk-data-availability-%d:420%d", i, i),
    - 1905 + 92
    + - Return(nil). + i: i,
    - 1906 + 93
    + - Once() + })
    - 1907 + 94
    + -
    + }
    - 1908 + 95
    + - m.Etherman. + sort.Sort(membs)
    - 1909 + 96
    + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + for _, m := range membs {
    - 1910 + 97
    + - Return(ethBlock0, nil). + addrsBytes = append(addrsBytes, m.addr.Bytes()...)
    - 1911 + 98
    + - Once() + urls = append(urls, m.url)
    - 1912 + 99
    + -
    + }
    - 1913 + 100
    + - m.State. + tx, err := dacSC.SetupCommittee(authL1, big.NewInt(nSignatures), urls, addrsBytes)
    - 1914 + 101
    + - On("BeginStateTransaction", ctx). + for _, m := range membs {
    - 1915 + 102
    + - Return(m.DbTx, nil). + fmt.Println(m.addr)
    - 1916 + 103
    + - Once() + }
    - 1917 + 104
    + -
    + require.NoError(t, err)
    - 1918 + 105
    + - m.State. + err = operations.WaitTxToBeMined(ctx, clientL1, tx, operations.DefaultTimeoutTxToBeMined)
    - 1919 + 106
    + - On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). + require.NoError(t, err)
    - 1920 + 107
    + - Return(nil). +
    - 1921 + 108
    + - Once() + // Spin up M DAC nodes
    - 1922 + 109
    + -
    + dacNodeConfig := config.Config{
    - 1923 + 110
    + - m.EthTxManager. + L1: config.L1Config{
    - 1924 + 111
    + - On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). + RpcURL: "http://zkevm-mock-l1-network:8545",
    - 1925 + 112
    + - Return(nil). + WsURL: "ws://zkevm-mock-l1-network:8546",
    - 1926 + 113
    + - Once() + PolygonValidiumAddress: operations.DefaultL1ZkEVMSmartContract,
    - 1927 + 114
    + -
    + DataCommitteeAddress: operations.DefaultL1DataCommitteeContract,
    - 1928 + 115
    + - m.DbTx. + Timeout: cTypes.Duration{Duration: time.Second},
    - 1929 + 116
    + - On("Commit", ctx). + RetryPeriod: cTypes.Duration{Duration: time.Second},
    - 1930 + 117
    + - Return(nil). + },
    - 1931 + 118
    + - Once() + PrivateKey: cTypes.KeystoreFileConfig{
    - 1932 + 119
    + -
    + Path: ksFile,
    - 1933 + 120
    + - m.Etherman. + Password: ksPass,
    - 1934 + 121
    + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + },
    - 1935 + 122
    + - Return(ethBlock0, nil). + DB: db.Config{
    - 1936 + 123
    + - Once() + Name: "committee_db",
    - 1937 + 124
    + -
    + User: "committee_user",
    - 1938 + 125
    + - m.ZKEVMClient. + Password: "committee_password",
    - 1939 + 126
    + - On("BatchNumber", ctx). + Host: "zkevm-data-node-db",
    - 1940 + 127
    + - Return(uint64(1), nil). + Port: "5432",
    - 1941 + 128
    + - Once() + EnableLog: false,
    - 1942 + 129
    + -
    + MaxConns: 10,
    - 1943 + 130
    + - m.Etherman. + },
    - 1944 + 131
    + - On("HeaderByNumber", mock.Anything, n). + RPC: rpc.Config{
    - 1945 + 132
    + - Return(ethHeader3, nil). + Host: "0.0.0.0",
    - 1946 + 133
    + - Once() + MaxRequestsPerIPAndSecond: 100,
    - 1947 + 134
    + -
    + },
    - 1948 + 135
    + - m.Etherman. + }
    - 1949 + 136
    + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + defer func() {
    - 1950 + 137
    + - Return(ethBlock0, nil). + // Remove tmp files
    - 1951 + 138
    + - Once() + assert.NoError(t,
    - 1952 + 139
    + -
    + exec.Command("rm", cfgFile).Run(),
    - 1953 + 140
    + - ethermanBlock0 := etherman.Block{ + )
    - 1954 + 141
    + - BlockNumber: 0, + assert.NoError(t,
    - 1955 + 142
    + - ReceivedAt: ti, + exec.Command("rmdir", ksFile+"_").Run(),
    - 1956 + 143
    + - BlockHash: ethBlock0.Hash(), + )
    - 1957 + 144
    + - ParentHash: ethBlock0.ParentHash(), + assert.NoError(t,
    - 1958 + 145
    + - } + exec.Command("rm", ksFile).Run(),
    - 1959 + 146
    + - ethermanBlock1bis := etherman.Block{ + )
    - 1960 + 147
    + - BlockNumber: 1, + // Stop DAC nodes
    - 1961 + 148
    + - ReceivedAt: ti, + for i := 0; i < mMembers; i++ {
    - 1962 + 149
    + - BlockHash: ethBlock1.Hash(), + assert.NoError(t, exec.Command(
    - 1963 + 150
    + - ParentHash: ethBlock1.ParentHash(), + "docker", "kill", "cdk-data-availability-"+strconv.Itoa(i),
    - 1964 + 151
    + - } + ).Run())
    - 1965 + 152
    + - blocks = []etherman.Block{ethermanBlock0, ethermanBlock1bis} + assert.NoError(t, exec.Command(
    - 1966 + 153
    + - fromBlock = 0 + "docker", "rm", "cdk-data-availability-"+strconv.Itoa(i),
    - 1967 + 154
    + - m.Etherman. + ).Run())
    - 1968 + 155
    + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). + }
    - 1969 + 156
    + - Return(blocks, order, nil). + // Stop permissionless node
    - 1970 + 157
    + - Once() + require.NoError(t, opsman.StopPermissionlessNodeForcedToSYncThroughDAC())
    - 1971 + 158
    + -
    + }()
    - 1972 + 159
    + - m.Etherman. + // Start permissionless node
    - 1973 + 160
    + - On("GetFinalizedBlockNumber", ctx). + require.NoError(t, opsman.StartPermissionlessNodeForcedToSYncThroughDAC())
    - 1974 + 161
    + - Return(ethBlock3.NumberU64(), nil). + // Star DAC nodes
    - 1975 + 162
    + - Once() + for _, m := range membs {
    - 1976 + 163
    + -
    + // Set correct port
    - 1977 + 164
    + - m.State. + port := 4200 + m.i
    - 1978 + 165
    + - On("BeginStateTransaction", ctx). + dacNodeConfig.RPC.Port = port
    - 1979 + 166
    + - Return(m.DbTx, nil). + // Write config file
    - 1980 + 167
    + - Once() + file, err := json.MarshalIndent(dacNodeConfig, "", " ")
    - 1981 + 168
    + -
    + require.NoError(t, err)
    - 1982 + 169
    + - stateBlock1bis := &state.Block{ + err = os.WriteFile(cfgFile, file, 0644)
    - 1983 + 170
    + - BlockNumber: ethermanBlock1bis.BlockNumber, + require.NoError(t, err)
    - 1984 + 171
    + - BlockHash: ethermanBlock1bis.BlockHash, + // Write private key keystore file
    - 1985 + 172
    + - ParentHash: ethermanBlock1bis.ParentHash, + err = createKeyStore(m.pk, ksFile, ksPass)
    - 1986 + 173
    + - ReceivedAt: ethermanBlock1bis.ReceivedAt, + require.NoError(t, err)
    - 1987 + 174
    + - Checked: true, + // Run DAC node
    - 1988 + 175
    + - } + cmd := exec.Command(
    - 1989 + 176
    + - m.State. + "docker", "run", "-d",
    - 1990 + 177
    + - On("AddBlock", ctx, stateBlock1bis, m.DbTx). + "--name", "cdk-data-availability-"+strconv.Itoa(m.i),
    - 1991 + 178
    + - Return(nil). + "-v", cfgFile+":/app/config.json",
    - 1992 + 179
    + - Once() + "-v", ksFile+":"+ksFile,
    - 1993 + 180
    + -
    + "--network", "zkevm",
    - 1994 + 181
    + - m.State. + dacNodeContainer,
    - 1995 + 182
    + - On("GetStoredFlushID", ctx). + "/bin/sh", "-c",
    - 1996 + 183
    + - Return(uint64(1), cProverIDExecution, nil). + "/app/cdk-data-availability run --cfg /app/config.json",
    - 1997 + 184
    + - Once() + )
    - 1998 + 185
    + -
    + out, err := cmd.CombinedOutput()
    - 1999 + 186
    + - m.DbTx. + require.NoError(t, err, string(out))
    - 2000 + 187
    + - On("Commit", ctx). + log.Infof("DAC node %d started", m.i)
    - 2001 + 188
    + - Return(nil). + time.Sleep(time.Second * 5)
    - 2002 + 189
    + - Run(func(args mock.Arguments) { + }
    - 2003 + 190
    + - sync.Stop() +
    - 2004 + 191
    + - ctx.Done() + // Send txs
    - 2005 + 192
    + - }). + nTxs := 10
    - 2006 + 193
    + - Once() + amount := big.NewInt(10000)
    - 2007 + 194
    + - }). + toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8")
    - 2008 + 195
    + - Return(m.DbTx, nil). + _, err = clientL2.BalanceAt(ctx, authL2.From, nil)
    - 2009 + 196
    + - Once() + require.NoError(t, err)
    - 2010 + 197
    + -
    + _, err = clientL2.PendingNonceAt(ctx, authL2.From)
    - 2011 + 198
    + - err = sync.Sync() + require.NoError(t, err)
    - 2012 + 199
    + - require.NoError(t, err) +
    - 2013 + 200
    + - } + gasLimit, err := clientL2.EstimateGas(ctx, ethereum.CallMsg{From: authL2.From, To: &toAddress, Value: amount})
    - 2014 + 201
    + -
    + require.NoError(t, err)
    - 2015 + 202
    + - func TestCallFromEmptyBlockAndReorg(t *testing.T) { +
    - 2016 + 203
    + - genesis := state.Genesis{ + gasPrice, err := clientL2.SuggestGasPrice(ctx)
    - 2017 + 204
    + - RollupBlockNumber: uint64(0), + require.NoError(t, err)
    - 2018 + 205
    + - } +
    - 2019 + 206
    + - cfg := Config{ + nonce, err := clientL2.PendingNonceAt(ctx, authL2.From)
    - 2020 + 207
    + - SyncInterval: cfgTypes.Duration{Duration: 1 * time.Second}, + require.NoError(t, err)
    - 2021 + 208
    + - SyncChunkSize: 3, +
    - 2022 + 209
    + - L1SynchronizationMode: SequentialMode, + txs := make([]*eTypes.Transaction, 0, nTxs)
    - 2023 + 210
    + - SyncBlockProtection: "latest", + for i := 0; i < nTxs; i++ {
    - 2024 + 211
    + - L1BlockCheck: L1BlockCheckConfig{ + tx := eTypes.NewTransaction(nonce+uint64(i), toAddress, amount, gasLimit, gasPrice, nil)
    - 2025 + 212
    + - Enable: false, + log.Infof("generating tx %d / %d: %s", i+1, nTxs, tx.Hash().Hex())
    - 2026 + 213
    + - }, + txs = append(txs, tx)
    - 2027 + 214
    @@ -227084,7 +309048,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2028 + 215
    @@ -227094,2895 +309058,2991 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2029 + 216
    + - m := mocks{ + // Wait for verification
    - 2030 + 217
    + - Etherman: mock_syncinterfaces.NewEthermanFullInterface(t), + _, err = operations.ApplyL2Txs(ctx, txs, authL2, clientL2, operations.VerifiedConfirmationLevel)
    - 2031 + 218
    + - State: mock_syncinterfaces.NewStateFullInterface(t), + require.NoError(t, err)
    - 2032 + 219
    + - Pool: mock_syncinterfaces.NewPoolInterface(t), +
    - 2033 + 220
    + - DbTx: syncMocks.NewDbTxMock(t), + // Assert that he permissionless node is fully synced (through the DAC)
    - 2034 + 221
    + - ZKEVMClient: mock_syncinterfaces.NewZKEVMClientInterface(t), + time.Sleep(30 * time.Second) // Give some time for the permissionless node to get synced
    - 2035 + 222
    + - EthTxManager: mock_syncinterfaces.NewEthTxManager(t), + clientL2Permissionless, err := ethclient.Dial(operations.PermissionlessL2NetworkURL)
    - 2036 + 223
    + - } + require.NoError(t, err)
    - 2037 + 224
    + - ethermanForL1 := []syncinterfaces.EthermanFullInterface{m.Etherman} + expectedBlock, err := clientL2.BlockByNumber(ctx, nil)
    - 2038 + 225
    + - sync, err := NewSynchronizer(false, m.Etherman, ethermanForL1, m.State, m.Pool, m.EthTxManager, m.ZKEVMClient, m.zkEVMClientEthereumCompatible, nil, genesis, cfg, false) + require.NoError(t, err)
    - 2039 + 226
    + - require.NoError(t, err) + actualBlock, err := clientL2Permissionless.BlockByNumber(ctx, nil)
    - 2040 + 227
    + -
    + require.NoError(t, err)
    - 2041 + 228
    + - // state preparation + // je, err := expectedBlock.Header().MarshalJSON()
    - 2042 + 229
    + - ctxMatchBy := mock.MatchedBy(func(ctx context.Context) bool { return ctx != nil }) + // require.NoError(t, err)
    - 2043 + 230
    + - forkIdInterval := state.ForkIDInterval{ + // log.Info(string(je))
    - 2044 + 231
    + - ForkId: 9, + // ja, err := actualBlock.Header().MarshalJSON()
    - 2045 + 232
    + - FromBatchNumber: 0, + // require.NoError(t, err)
    - 2046 + 233
    + - ToBatchNumber: math.MaxUint64, + // log.Info(string(ja))
    - 2047 + 234
    + - } + // require.Equal(t, string(je), string(ja))
    - 2048 + 235
    + - m.State.EXPECT().GetForkIDInMemory(uint64(9)).Return(&forkIdInterval) + require.Equal(t, expectedBlock.Root().Hex(), actualBlock.Root().Hex())
    - 2049 + 236
    + -
    + }
    - 2050 + 237
    + - m.State. +
    - 2051 + 238
    + - On("BeginStateTransaction", ctxMatchBy). + type member struct {
    - 2052 + 239
    + - Run(func(args mock.Arguments) { + addr common.Address
    - 2053 + 240
    + - ctx := args[0].(context.Context) + pk *ecdsa.PrivateKey
    - 2054 + 241
    + - parentHash := common.HexToHash("0x111") + url string
    - 2055 + 242
    + - ethHeader0 := &ethTypes.Header{Number: big.NewInt(0), ParentHash: parentHash} + i int
    - 2056 + 243
    + - ethBlock0 := ethTypes.NewBlockWithHeader(ethHeader0) + }
    - 2057 + 244
    + - ethHeader1bis := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash(), Time: 10, GasUsed: 20, Root: common.HexToHash("0x234")} + type members []member
    - 2058 + 245
    + - ethBlock1bis := ethTypes.NewBlockWithHeader(ethHeader1bis) +
    - 2059 + 246
    + - ethHeader2bis := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1bis.Hash()} + func (s members) Len() int { return len(s) }
    - 2060 + 247
    + - ethBlock2bis := ethTypes.NewBlockWithHeader(ethHeader2bis) + func (s members) Less(i, j int) bool {
    - 2061 + 248
    + - ethHeader1 := &ethTypes.Header{Number: big.NewInt(1), ParentHash: ethBlock0.Hash()} + return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex())
    - 2062 + 249
    + - ethBlock1 := ethTypes.NewBlockWithHeader(ethHeader1) + }
    - 2063 + 250
    + - ethHeader2 := &ethTypes.Header{Number: big.NewInt(2), ParentHash: ethBlock1.Hash()} + func (s members) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
    - 2064 + 251
    + - ethBlock2 := ethTypes.NewBlockWithHeader(ethHeader2) +
    - 2065 + 252
    + -
    + func createKeyStore(pk *ecdsa.PrivateKey, outputDir, password string) error {
    - 2066 + 253
    + - lastBlock0 := &state.Block{BlockHash: ethBlock0.Hash(), BlockNumber: ethBlock0.Number().Uint64(), ParentHash: ethBlock0.ParentHash()} + ks := keystore.NewKeyStore(outputDir+"_", keystore.StandardScryptN, keystore.StandardScryptP)
    - 2067 + 254
    + - lastBlock1 := &state.Block{BlockHash: ethBlock1.Hash(), BlockNumber: ethBlock1.Number().Uint64(), ParentHash: ethBlock1.ParentHash()} + _, err := ks.ImportECDSA(pk, password)
    - 2068 + 255
    + -
    + if err != nil {
    - 2069 + 256
    + - m.State. + return err
    - 2070 + 257
    + - On("GetForkIDByBatchNumber", mock.Anything). + }
    - 2071 + 258
    + - Return(uint64(9), nil). + fileNameB, err := exec.Command("ls", outputDir+"_/").CombinedOutput()
    - 2072 + 259
    + - Maybe() + fileName := strings.TrimSuffix(string(fileNameB), "\n")
    - 2073 + 260
    + - m.State. + if err != nil {
    - 2074 + 261
    + - On("GetLastBlock", ctx, m.DbTx). + fmt.Println(fileName)
    - 2075 + 262
    + - Return(lastBlock1, nil). + return err
    - 2076 + 263
    + - Once() + }
    - 2077 + 264
    + -
    + out, err := exec.Command("mv", outputDir+"_/"+fileName, outputDir).CombinedOutput()
    - 2078 + 265
    + - m.State. + if err != nil {
    - 2079 + 266
    + - On("GetLastBatchNumber", ctx, m.DbTx). + fmt.Println(string(out))
    - 2080 + 267
    + - Return(uint64(10), nil). + return err
    - 2081 + 268
    + - Once() + }
    - 2082 + 269
    + -
    + return nil
    - 2083 + 270
    + - m.State. + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -36,7 +36,7 @@
    - 2084 + + 36 +
    - + - On("SetInitSyncBatch", ctx, uint64(10), m.DbTx). +   + authSequencer *bind.TransactOpts
    - 2085 + + 37 +
    - + - Return(nil). +   + authForcedBatch *bind.TransactOpts
    - 2086 + + 38 +
    - + - Once() +   + zkEvmAddr common.Address
    - 2087 + + 39 +
    - + -
    + - + zkEvm *etrogpolygonzkevm.Etrogpolygonzkevm
    - 2088 + + 40 +
    - + - m.DbTx. +   + }
    - 2089 + + 41 +
    - + - On("Commit", ctx). +   +
    - 2090 + + 42 +
    - + - Return(nil). +   + type l2Stuff struct {
    - 2091 + +
    @@ -186,7 +186,7 @@
    +
    + 186 +
    - + - Once() +   + require.NoError(t, err)
    - 2092 + + 187 +
    - + +  
    - 2093 + + 188 +
    - + - m.Etherman. +   + zkEvmAddr := common.HexToAddress(operations.DefaultL1ZkEVMSmartContract)
    - 2094 + + 189 +
    - + - On("GetLatestBatchNumber"). + - + zkEvm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(zkEvmAddr, ethClient)
    - 2095 + + 190 +
    - + - Return(uint64(10), nil) +   + require.NoError(t, err)
    - 2096 + + 191 +
    - + -
    +   + return &l1Stuff{ethClient: ethClient, authSequencer: authSequencer, authForcedBatch: authForcedBatch, zkEvmAddr: zkEvmAddr, zkEvm: zkEvm}
    - 2097 + + 192 +
    - + - var nilDbTx pgx.Tx +   + }
    - 2098 + +
    @@ -196,7 +196,7 @@
    +
    + 196 +
    - + - m.State. +   + require.NoError(t, err)
    - 2099 + + 197 +
    - + - On("GetLastBatchNumber", ctx, nilDbTx). +   + genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr)
    - 2100 + + 198 +
    - + - Return(uint64(10), nil) +   + require.NoError(t, err)
    - 2101 + + 199 +
    - + -
    + - + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
    - 2102 + + 200 +
    - + - m.Etherman. +   + err = opsman.Setup()
    - 2103 + + 201 +
    - + - On("GetLatestVerifiedBatchNum"). +   + require.NoError(t, err)
    - 2104 + + 202 +
    - + - Return(uint64(10), nil) +   + time.Sleep(5 * time.Second)
    - 2105 + +
    @@ -216,7 +216,7 @@
    +
    + 216 +
    - + -
    +   + log.Info("Number of forceBatches in the smc: ", num)
    - 2106 + + 217 +
    - + - m.State. +   +
    - 2107 + + 218 +
    - + - On("SetLastBatchInfoSeenOnEthereum", ctx, uint64(10), uint64(10), nilDbTx). +   + rollupManagerAddr := common.HexToAddress(operations.DefaultL1RollupManagerSmartContract)
    - 2108 + + 219 +
    - + - Return(nil) + - + rollupManager, err := etrogpolygonrollupmanager.NewEtrogpolygonrollupmanager(rollupManagerAddr, l1.ethClient)
    - 2109 + + 220 +
    - + -
    +   + require.NoError(t, err)
    - 2110 + + 221 +
    - + - m.Etherman. +   +
    - 2111 + + 222 +
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +   + // Get tip
    - 2112 + +
    @@ -226,7 +226,7 @@
    +
    + 226 +
    - + - Return(ethBlock1, nil). +   + managerAddress, err := l1.zkEvm.GlobalExitRootManager(&bind.CallOpts{Pending: false})
    - 2113 + + 227 +
    - + - Once() +   + require.NoError(t, err)
    - 2114 + + 228 +
    - + +  
    - 2115 + + 229 +
    - + - m.ZKEVMClient. + - + manager, err := etrogpolygonzkevmglobalexitroot.NewEtrogpolygonzkevmglobalexitroot(managerAddress, l1.ethClient)
    - 2116 + + 230 +
    - + - On("BatchNumber", ctx). +   + require.NoError(t, err)
    - 2117 + + 231 +
    - + - Return(uint64(1), nil). +   +
    - 2118 + + 232 +
    - + - Once() +   + rootInContract, err := manager.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false})
    - 2119 + +
    @@ -299,7 +299,7 @@
    +
    + 299 +
    - + -
    +   + return forcedBatch, nil
    - 2120 + + 300 +
    - + - n := big.NewInt(rpc.LatestBlockNumber.Int64()) +   + }
    - 2121 + + 301 +
    - + +  
    - 2122 + + 302 +
    - + - m.Etherman. + - + func findForcedBatchInL1Logs(ctx context.Context, t *testing.T, fromBlock *big.Int, l1 *l1Stuff) (*etrogpolygonzkevm.EtrogpolygonzkevmForceBatch, *types.Log, error) {
    - 2123 + + 303 +
    - + - On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +   + query := ethereum.FilterQuery{
    - 2124 + + 304 +
    - + - Return(ethBlock1, nil). +   + FromBlock: fromBlock,
    - 2125 + + 305 +
    - + - Once() +   + Addresses: []common.Address{l1.zkEvmAddr}, +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
     
    - 2126 + + 36 +
    - + -
    +   + authSequencer *bind.TransactOpts
    - 2127 + + 37 +
    - + - m.Etherman. +   + authForcedBatch *bind.TransactOpts
    - 2128 + + 38 +
    - + - On("HeaderByNumber", mock.Anything, n). +   + zkEvmAddr common.Address
    - 2129 + + 39 +
    + - Return(ethHeader2bis, nil). + zkEvm *polygonzkevm.Polygonzkevm
    - 2130 + + 40 +
    - + - Once() +   + }
    - 2131 + + 41 +
    - + +  
    - 2132 + + 42 +
    - + - // m.Etherman. +   + type l2Stuff struct {
    - 2133 + +
     
    +
    + 186 +
    - + - // On("EthBlockByNumber", ctx, lastBlock1.BlockNumber). +   + require.NoError(t, err)
    - 2134 + + 187 +
    - + - // Return(ethBlock1, nil). +   +
    - 2135 + + 188 +
    - + - // Once() +   + zkEvmAddr := common.HexToAddress(operations.DefaultL1ZkEVMSmartContract)
    - 2136 + + 189 +
    + -
    + zkEvm, err := polygonzkevm.NewPolygonzkevm(zkEvmAddr, ethClient)
    - 2137 + + 190 +
    - + - ti := time.Date(2024, 1, 1, 1, 0, 0, 0, time.UTC) +   + require.NoError(t, err)
    - 2138 + + 191 +
    - + -
    +   + return &l1Stuff{ethClient: ethClient, authSequencer: authSequencer, authForcedBatch: authForcedBatch, zkEvmAddr: zkEvmAddr, zkEvm: zkEvm}
    - 2139 + + 192 +
    - + - ethermanBlock0 := etherman.Block{ +   + }
    - 2140 + +
     
    +
    + 196 +
    - + - BlockNumber: 0, +   + require.NoError(t, err)
    - 2141 + + 197 +
    - + - ReceivedAt: ti, +   + genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr)
    - 2142 + + 198 +
    - + - BlockHash: ethBlock0.Hash(), +   + require.NoError(t, err)
    - 2143 + + 199 +
    + - ParentHash: ethBlock0.ParentHash(), + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6))
    - 2144 + + 200 +
    - + - } +   + err = opsman.Setup()
    - 2145 + + 201 +
    - + - ethermanBlock2bis := etherman.Block{ +   + require.NoError(t, err)
    - 2146 + + 202 +
    - + - BlockNumber: 2, +   + time.Sleep(5 * time.Second)
    - 2147 - -
    - + - ReceivedAt: ti, -
    +
    +
     
    - 2148 + + 216 +
    - + - BlockHash: ethBlock2bis.Hash(), +   + log.Info("Number of forceBatches in the smc: ", num)
    - 2149 + + 217 +
    - + - ParentHash: ethBlock2bis.ParentHash(), +   +
    - 2150 + + 218 +
    - + - } +   + rollupManagerAddr := common.HexToAddress(operations.DefaultL1RollupManagerSmartContract)
    - 2151 + + 219 +
    + - blocks := []etherman.Block{ethermanBlock2bis} + rollupManager, err := polygonrollupmanager.NewPolygonrollupmanager(rollupManagerAddr, l1.ethClient)
    - 2152 + + 220 +
    - + - order := map[common.Hash][]etherman.Order{} +   + require.NoError(t, err)
    - 2153 + + 221 +
    - + +  
    - 2154 + + 222 +
    - + - fromBlock := ethBlock1.NumberU64() +   + // Get tip
    - 2155 - -
    - + - toBlock := fromBlock + cfg.SyncChunkSize -
    +
    +
     
    - 2156 + + 226 +
    - + - if toBlock > ethBlock2.NumberU64() { +   + managerAddress, err := l1.zkEvm.GlobalExitRootManager(&bind.CallOpts{Pending: false})
    - 2157 + + 227 +
    - + - toBlock = ethBlock2.NumberU64() +   + require.NoError(t, err)
    - 2158 + + 228 +
    - + - } +   +
    - 2159 + + 229 +
    + - m.Etherman. + manager, err := polygonzkevmglobalexitroot.NewPolygonzkevmglobalexitroot(managerAddress, l1.ethClient)
    - 2160 + + 230 +
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +   + require.NoError(t, err)
    - 2161 + + 231 +
    - + - Return(blocks, order, nil). +   +
    - 2162 + + 232 +
    - + - Once() +   + rootInContract, err := manager.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false})
    - 2163 - -
    - + -
    -
    +
    +
     
    - 2164 + + 299 +
    - + - m.State. +   + return forcedBatch, nil
    - 2165 + + 300 +
    - + - On("BeginStateTransaction", ctx). +   + }
    - 2166 + + 301 +
    - + - Return(m.DbTx, nil). +   +
    - 2167 + + 302 +
    + - Once() + func findForcedBatchInL1Logs(ctx context.Context, t *testing.T, fromBlock *big.Int, l1 *l1Stuff) (*polygonzkevm.PolygonzkevmForceBatch, *types.Log, error) {
    - 2168 + + 303 +
    - + -
    +   + query := ethereum.FilterQuery{
    - 2169 + + 304 +
    - + - var depth uint64 = 1 +   + FromBlock: fromBlock,
    - 2170 + + 305 +
    - + - stateBlock0 := &state.Block{ +   + Addresses: []common.Address{l1.zkEvmAddr},
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + + +
    +
    @@ -63,8 +63,8 @@
    +
    - 2171 + + 63 +
    - + - BlockNumber: ethBlock0.NumberU64(), +   + log.Info("# Setting Genesis #")
    - 2172 + + 64 +
    - + - BlockHash: ethBlock0.Hash(), +   + log.Info("###################")
    - 2173 + + 65 +
    - + - ParentHash: ethBlock0.ParentHash(), +   + genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
    - 2174 + + 66 +
    - + - ReceivedAt: ti, + - + require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.BlockNumber, genesisActions))
    - 2175 + + 67 +
    - + - } + - + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6))
    - 2176 + + 68 +
    - + - m.State. +   + actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil)
    - 2177 + + 69 +
    - + - On("GetPreviousBlock", ctx, depth, m.DbTx). +   + require.NoError(t, err)
    - 2178 + + 70 +
    - + - Return(stateBlock0, nil). +   + require.NoError(t, opsman.Setup()) +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + + +
    +
     
    - 2179 + + 63 +
    - + - Once() +   + log.Info("# Setting Genesis #")
    - 2180 + + 64 +
    - + -
    +   + log.Info("###################")
    - 2181 + + 65 +
    - + - m.DbTx. +   + genesisActions := vectors.GenerateGenesisActions(testCase.Genesis)
    - 2182 + + 66 +
    + - On("Commit", ctx). + require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.RollupBlockNumber, genesisActions))
    - 2183 + + 67 +
    + - Return(nil). + require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6))
    - 2184 + + 68 +
    - + - Once() +   + actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil)
    - 2185 + + 69 +
    - + -
    +   + require.NoError(t, err)
    - 2186 + + 70 +
    - + - m.Etherman. +   + require.NoError(t, opsman.Setup()) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc1_test.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - + + +
    +
    @@ -71,7 +71,6 @@
    - 2187 + + 71 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). +   + }
    - 2188 + + 72 +
    - + - Return(ethBlock0, nil). +   + ctx := context.Background()
    - 2189 + + 73 +
    - + - Once() +   + setup()
    - 2190 + + 74 +
    - + + -
    - 2191 + + 75 +
    - + - m.State. +   + defer teardown()
    - 2192 + + 76 +
    - + - On("BeginStateTransaction", ctx). +   + for _, network := range networks {
    - 2193 + + 77 +
    - + - Return(m.DbTx, nil). +   + // test newBlockFilter creation
    - 2194 - -
    - + - Once() -
    +
    +
    @@ -88,9 +87,9 @@
    - 2195 + + 88 +
    - + +  
    - 2196 + + 89 +
    - + - m.State. +   + // test newFilter creation with block range and block hash
    - 2197 + + 90 +
    - + - On("Reset", ctx, ethBlock0.NumberU64(), m.DbTx). +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2198 + + 91 +
    - + - Return(nil). + - + "blockHash": common.HexToHash("0x1"),
    - 2199 + + 92 +
    - + - Once() + - + "fromBlock": "0x1",
    - 2200 + + 93 +
    - + -
    + - + "toBlock": "0x2",
    - 2201 + + 94 +
    - + - m.EthTxManager. +   + })
    - 2202 + + 95 +
    - + - On("Reorg", ctx, ethBlock0.NumberU64()+1, m.DbTx). +   + require.NoError(t, err)
    - 2203 + + 96 +
    - + - Return(nil). +   + require.NotNil(t, response.Error)
    - 2204 - -
    - + - Once() -
    +
    +
    @@ -99,11 +98,11 @@
    - 2205 + + 99 +
    - + +  
    - 2206 + + 100 +
    - + - m.DbTx. +   + // test newFilter creation with block hash
    - 2207 + + 101 +
    - + - On("Commit", ctx). +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2208 + + 102 +
    - + - Return(nil). + - + "blockHash": common.HexToHash("0x1"),
    - 2209 + + 103 +
    - + - Once() + - + "address": []common.Address{
    - 2210 + + 104 +
    - + -
    +   + common.HexToAddress("0x2"),
    - 2211 + + 105 +
    - + - m.Etherman. +   + },
    - 2212 + + 106 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + - + "topics": [][]common.Hash{
    - 2213 + + 107 +
    - + - Return(ethBlock0, nil). +   + {common.HexToHash("0x3")},
    - 2214 + + 108 +
    - + - Once() +   + },
    - 2215 + + 109 +
    - + -
    +   + })
    - 2216 - -
    - + - m.ZKEVMClient. -
    +
    +
    @@ -118,12 +117,12 @@
    - 2217 + + 118 +
    - + - On("BatchNumber", ctx). +   +
    - 2218 + + 119 +
    - + - Return(uint64(1), nil). +   + // test newFilter creation with block range
    - 2219 + + 120 +
    - + - Once() +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2220 + + 121 +
    - + -
    + - + "fromBlock": "0x1",
    - 2221 + + 122 +
    - + - m.Etherman. + - + "toBlock": "0x2",
    - 2222 + + 123 +
    - + - On("EthBlockByNumber", ctx, lastBlock0.BlockNumber). + - + "address": []common.Address{
    - 2223 + + 124 +
    - + - Return(ethBlock0, nil). +   + common.HexToAddress("0x2"),
    - 2224 + + 125 +
    - + - Once() +   + },
    - 2225 + + 126 +
    - + -
    + - + "topics": [][]common.Hash{
    - 2226 + + 127 +
    - + - m.Etherman. +   + {common.HexToHash("0x3")},
    - 2227 + + 128 +
    - + - On("HeaderByNumber", mock.Anything, n). +   + },
    - 2228 + + 129 +
    - + - Return(ethHeader2bis, nil). +   + })
    - 2229 + +
    @@ -211,7 +210,7 @@
    +
    + 211 +
    - + - Once() +   + require.NoError(t, err)
    - 2230 + + 212 +
    - + +  
    - 2231 + + 213 +
    - + - blocks = []etherman.Block{ethermanBlock0, ethermanBlock2bis} +   + assert.NotEqual(t, blockBeforeFilterHash.String(), blockFilterChanges[0].String())
    - 2232 + + 214 +
    - + - fromBlock = ethBlock0.NumberU64() + - + assert.Equal(t, blockAfterFilterHash.String(), blockFilterChanges[len(blockFilterChanges)-1].String(), "network: "+network.Name+"blockAfterFilterHash")
    - 2233 + + 215 +
    - + - toBlock = fromBlock + cfg.SyncChunkSize +   +
    - 2234 + + 216 +
    - + - if toBlock > ethBlock2.NumberU64() { +   + // test getFilterChanges for a logFilter ID
    - 2235 + + 217 +
    - + - toBlock = ethBlock2.NumberU64() +   + // create a SC to emit some logs
    - 2236 - -
    - + - } -
    +
    +
    @@ -221,7 +220,7 @@
    - 2237 + + 221 +
    - + - m.Etherman. +   + require.NoError(t, err)
    - 2238 + + 222 +
    - + - On("GetRollupInfoByBlockRange", mock.Anything, fromBlock, &toBlock). +   +
    - 2239 + + 223 +
    - + - Return(blocks, order, nil). +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2240 + + 224 +
    - + - Once() + - + "address": []common.Address{scAddr},
    - 2241 + + 225 +
    - + -
    +   + })
    - 2242 + + 226 +
    - + - m.Etherman. +   + require.NoError(t, err)
    - 2243 + + 227 +
    - + - On("GetFinalizedBlockNumber", ctx). +   + require.Nil(t, response.Error)
    - 2244 - -
    - + - Return(ethBlock2bis.NumberU64(), nil). -
    +
    +
    @@ -277,7 +276,7 @@
    - 2245 + + 277 +
    - + - Once() +   + require.NoError(t, err)
    - 2246 + + 278 +
    - + +  
    - 2247 + + 279 +
    - + - m.State. +   + assert.Equal(t, 30, len(logs))
    - 2248 + + 280 +
    - + - On("BeginStateTransaction", ctx). + - + assert.Equal(t, 20, len(logFilterChanges), "network: "+network.Name+" logFilterChanges")
    - 2249 + + 281 +
    - + - Return(m.DbTx, nil). +   + }
    - 2250 + + 282 +
    - + - Once() +   + }
    - 2251 + + 283 +
    - + +  
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - -
    +
     
    +
    - 2252 + + 71 +
    - + - stateBlock2bis := &state.Block{ +   + }
    - 2253 + + 72 +
    - + - BlockNumber: ethermanBlock2bis.BlockNumber, +   + ctx := context.Background()
    - 2254 + + 73 +
    - + - BlockHash: ethermanBlock2bis.BlockHash, +   + setup()
    - 2255 + + -
    - + - ParentHash: ethermanBlock2bis.ParentHash, +
    +
    +   +
    - 2256 + + 74 +
    - + - ReceivedAt: ethermanBlock2bis.ReceivedAt, +   + defer teardown()
    - 2257 + + 75 +
    - + - Checked: true, +   + for _, network := range networks {
    - 2258 + + 76 +
    - + - } +   + // test newBlockFilter creation
    - 2259 + +
     
    +
    + 87 +
    - + - m.State. +   +
    - 2260 + + 88 +
    - + - On("AddBlock", ctx, stateBlock2bis, m.DbTx). +   + // test newFilter creation with block range and block hash
    - 2261 + + 89 +
    - + - Return(nil). +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2262 + + 90 +
    + - Once() + "BlockHash": common.HexToHash("0x1"),
    - 2263 + + 91 +
    + -
    + "FromBlock": "0x1",
    - 2264 + + 92 +
    + - m.State. + "ToBlock": "0x2",
    - 2265 + + 93 +
    - + - On("GetStoredFlushID", ctx). +   + })
    - 2266 + + 94 +
    - + - Return(uint64(1), cProverIDExecution, nil). +   + require.NoError(t, err)
    - 2267 + + 95 +
    - + - Once() +   + require.NotNil(t, response.Error)
    - 2268 + +
     
    +
    + 98 +
    - + +  
    - 2269 + + 99 +
    - + - m.DbTx. +   + // test newFilter creation with block hash
    - 2270 + + 100 +
    - + - On("Commit", ctx). +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2271 + + 101 +
    + - Run(func(args mock.Arguments) { + "BlockHash": common.HexToHash("0x1"),
    - 2272 + + 102 +
    + - sync.Stop() + "Addresses": []common.Address{
    - 2273 + + 103 +
    - + - ctx.Done() +   + common.HexToAddress("0x2"),
    - 2274 + + 104 +
    - + - }). +   + },
    - 2275 + + 105 +
    + - Return(nil). + "Topics": [][]common.Hash{
    - 2276 + + 106 +
    - + - Once() +   + {common.HexToHash("0x3")},
    - 2277 + + 107 +
    - + - }). +   + },
    - 2278 + + 108 +
    - + - Return(m.DbTx, nil). +   + })
    - 2279 + +
     
    +
    + 117 +
    - + - Once() +   +
    - 2280 + + 118 +
    - + -
    +   + // test newFilter creation with block range
    - 2281 + + 119 +
    - + - err = sync.Sync() +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 2282 + + 120 +
    + - require.NoError(t, err) + "FromBlock": "0x1",
    - 2283 + + 121 +
    + - } -
    -
    -
    + "ToBlock": "0x2",
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/CounterAndBlock.sol - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - -
    -
    @@ -0,0 +1,15 @@
    - + + 122 -
    -   -
    +
    +
    + + + "Addresses": []common.Address{
    - + + 123 -
    +
    +
      -
    + common.HexToAddress("0x2"),
    - + + 124 -
    +
    +
      -
    + },
    - + + 125 -
    -   -
    +
    +
    + + + "Topics": [][]common.Hash{
    - + + 126 -
    +
    +
      -
    + {common.HexToHash("0x3")},
    - + + 127 -
    +
    +
      -
    + },
    - + + 128 -
    +
    +
      -
    + })
    - - -
    -   -
    -
    +
    +
     
    - + + 210 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 211 -
    +
    +
     
    - + + 212 -
    +
    +
      -
    + assert.NotEqual(t, blockBeforeFilterHash.String(), blockFilterChanges[0].String())
    - + + 213 -
    -   -
    +
    +
    + + + assert.Equal(t, blockAfterFilterHash.String(), blockFilterChanges[len(blockFilterChanges)-1].String())
    - + + 214 -
    +
    +
     
    - + + 215 -
    +
    +
      -
    + // test getFilterChanges for a logFilter ID
    - + + 216 -
    +
    +
      -
    + // create a SC to emit some logs
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - @@ -229992,12 +312052,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/auto/customModExp.sol + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/shared.go RENAMED
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
     
    - 1 + + 220 +
    - + - // SPDX-License-Identifier: GPL-3.0 +   + require.NoError(t, err)
    - 2 + + 221 +
    - + +  
    - 3 + + 222 +
    - + - pragma solidity >=0.7.0 <0.9.0; +   + response, err = client.JSONRPCCall(network.URL, "eth_newFilter", map[string]interface{}{
    - 4 + + 223 +
    + -
    + "Addresses": []common.Address{scAddr},
    - 5 + + 224 +
    - + - contract CounterAndBlock { +   + })
    - 6 + + 225 +
    - + - uint public count; +   + require.NoError(t, err)
    - 7 + + 226 +
    - + -
    +   + require.Nil(t, response.Error)
    - 8 - -
    - + - function increment() external { -
    +
    +
     
    - 9 + + 276 +
    - + - count += 1; +   + require.NoError(t, err)
    - 10 + + 277 +
    - + - } +   +
    - 11 + + 278 +
    - + -
    +   + assert.Equal(t, 30, len(logs))
    - 12 + + 279 +
    + - function getCount() public view returns (uint, uint) { + assert.Equal(t, 20, len(logFilterChanges))
    - 13 + + 280 +
    - + - return (count, block.timestamp); +   + }
    - 14 + + 281 +
    - + - } +   + }
    - 15 + + 282 +
    - + - } +   +
    -
    @@ -0,0 +1,24 @@
    -
    - - -
    -   -
    -
    +
    @@ -141,11 +141,11 @@
    - + + 141 -
    +
    +
     
    - + + 142 -
    +
    +
      -
    + // Create smc client
    - + + 143 -
    +
    +
      -
    + zkEvmAddr := common.HexToAddress(operations.DefaultL1ZkEVMSmartContract)
    - + + 144 -
    -   -
    +
    +
    + - + zkEvm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(zkEvmAddr, ethClient)
    - + + 145 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 146 -
    +
    +
     
    - + + 147 -
    +
    +
      -
    + rollupManagerAddr := common.HexToAddress(operations.DefaultL1RollupManagerSmartContract)
    - + + 148 -
    -   -
    +
    +
    + - + rollupManager, err := etrogpolygonrollupmanager.NewEtrogpolygonrollupmanager(rollupManagerAddr, ethClient)
    - + + 149 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 150 -
    +
    +
     
    - + + 151 -
    +
    +
      -
    + auth, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID)
    - - -
    -   -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - @@ -230259,6 +312313,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
     
    - + + 141 -
    +
    +
     
    - + + 142 -
    +
    +
      -
    + // Create smc client
    - + + 143 -
    +
    +
      -
    + zkEvmAddr := common.HexToAddress(operations.DefaultL1ZkEVMSmartContract)
    - + + 144 -
    -   -
    +
    +
    + + + zkEvm, err := polygonzkevm.NewPolygonzkevm(zkEvmAddr, ethClient)
    - + + 145 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 146 -
    +
    +
     
    - + + 147 -
    +
    +
      -
    + rollupManagerAddr := common.HexToAddress(operations.DefaultL1RollupManagerSmartContract)
    - + + 148 -
    -   -
    +
    +
    + + + rollupManager, err := polygonrollupmanager.NewPolygonrollupmanager(rollupManagerAddr, ethClient)
    - + + 149 -
    +
    +
      -
    + require.NoError(t, err)
    - + + 150 -
    +
    +
     
    - + + 151 -
    +
    +
      -
    + auth, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID)
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go + RENAMED + +
    +
    @@ -230266,246 +312335,160 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
     
    -
    - 1 - -
    - + - // SPDX-License-Identifier: MIT -
    -
    - 2 - -
    - + - pragma solidity >=0.7.0 <0.9.0; -
    -
    - 3 - -
    - + -
    -
    -
    - 4 - -
    - + - contract customModExp { -
    -
    - 5 - -
    - + - bytes32 hashResult; -
    -
    - 6 - -
    - + - address retEcrecover; -
    +
    @@ -59,7 +59,7 @@
    - 7 + + 59 +
    - + - bytes dataResult; +   + for _, gacc := range testCase.GenesisAccounts {
    - 8 + + 60 +
    - + - uint256 dataRes; +   + genesisAccounts[gacc.Address] = gacc.Balance.Int
    - 9 + + 61 +
    - + -
    +   + }
    - 10 + + 62 +
    - + - bytes32[10] arrayStorage; + - + require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.BlockNumber, genesisAccounts))
    - 11 + + 63 +
    - + +  
    - 12 + + 64 +
    - + - function modExpGeneric(bytes memory input) public { +   + // Check initial root
    - 13 + + 65 +
    - + - bytes32[10] memory output; +   + require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot))
    - 14 - -
    - + -
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - @@ -230515,12 +312498,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    +
    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/CounterAndBlock/CounterAndBlock.go + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile RENAMED
    - - + + + - - + + + - + - + + - - - - @@ -230598,63 +312606,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -230668,63 +312681,68 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - @@ -230738,61 +312756,66 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - @@ -231688,173 +313751,183 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - @@ -231868,11 +313941,11 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - + + +
    +
     
    - 15 + + 59 +
    - + - assembly { +   + for _, gacc := range testCase.GenesisAccounts {
    - 16 + + 60 +
    - + - let success := staticcall(gas(), 0x05, add(input, 32), mload(input), output, 0x140) +   + genesisAccounts[gacc.Address] = gacc.Balance.Int
    - 17 + + 61 +
    - + - sstore(0x00, success) +   + }
    - 18 + + 62 +
    + - } + require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.RollupBlockNumber, genesisAccounts))
    - 19 + + 63 +
    - + +  
    - 20 - -
    - + - for (uint i = 0; i < 10; i++) { -
    -
    - 21 - -
    - + - arrayStorage[i] = output[i]; -
    -
    - 22 - -
    - + - } -
    -
    - 23 + + 64 +
    - + - } +   + // Check initial root
    - 24 + + 65 +
    - + - } +   + require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot))
    -
    @@ -0,0 +1,287 @@
    +
    @@ -1,4 +1,4 @@
    - + + 1 -
    +
    +
    + - + DOCKERCOMPOSE := docker compose -f docker-compose.yml +
    +
    + 2 + +
      -
    + DOCKERCOMPOSEAPPSEQ := zkevm-sequencer
    - + + 3 -
    +
    +
    +   + DOCKERCOMPOSEAPPSEQV1TOV2 := zkevm-sequencer-v1tov2 +
    +
    + 4 + +
      -
    + DOCKERCOMPOSEAPPSEQSENDER := zkevm-sequence-sender
    - + +
    @@ -26,6 +26,7 @@
    -
    +
    + 26 + +
      -
    + DOCKERCOMPOSEZKPROVER := zkevm-prover
    - + + 27 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db
    - + + 28 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node
    - + + 29 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover
    - + + 30 -
    +
    +
      -
    + DOCKERCOMPOSENODEAPPROVE := zkevm-approve
    - + + 31 -
    +
    +
      -
    + DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2
    - + +
    @@ -62,6 +63,7 @@
    -
    +
    + 62 + +
     
    - + + 63 -
    +
    +
      -
    + RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB)
    - + + 64 -
    +
    +
      -
    + RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE)
    - + + 65 -
    +
    +
      -
    + RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
    - + + 66 -
    +
    +
     
    - + + 67 -
    +
    +
      -
    + RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE)
    - + +
    @@ -101,6 +103,7 @@
    -
    +
    + 101 + +
     
    - + + 102 -
    +
    +
      -
    + STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB)
    - + + 103 -
    +
    +
      -
    + STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE)
    - + + 104 -
    +
    +
      -
    + STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
    - + + 105 -
    +
    +
     
    - + + 106 -
    +
    +
      -
    + STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE)
    - + +
    @@ -110,6 +113,9 @@
    -
    +
    + 110 + +
     
    - + + 111 -
    +
    +
      -
    + STOP := $(DOCKERCOMPOSE) down --remove-orphans
    - + + 112 -
    +
    +
     
    @@ -230828,281 +312851,291 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 113 -
    +
    +
      -
    + .PHONY: test-full-non-e2e
    - + + 114 -
    +
    +
      -
    + test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions
    - + + 115 -
    +
    +
      -
    + $(RUNSTATEDB)
    - + +
    @@ -122,22 +128,7 @@
    -
    +
    + 122 + +
      -
    + sleep 15
    - + + 123 -
    +
    +
      -
    + docker ps -a
    - + + 124 -
    +
    +
      -
    + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 125 -
    -   -
    +
    +
    + - + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -short -race -p 1 -covermode=atomic -coverprofile=../coverage.out -coverpkg ./... -timeout 200s ../...
    - + + 126 -
    -   +
    +
    + -
    - + + 127 -
    -   -
    +
    +
    + - + .PHONY: test-full-non-e2e-sonar
    - + + 128 -
    -   -
    +
    +
    + - + test-full-non-e2e-sonar: stop ## Runs non-e2e tests checking race conditions
    - + + 129 -
    -   -
    +
    +
    + - + $(RUNSTATEDB)
    - + + 130 -
    -   -
    +
    +
    + - + $(RUNPOOLDB)
    - + + 131 -
    -   -
    +
    +
    + - + $(RUNEVENTDB)
    - + + 132 -
    -   -
    +
    +
    + - + sleep 2
    - + + 133 -
    -   -
    +
    +
    + - + $(RUNZKPROVER)
    - + + 134 -
    -   -
    +
    +
    + - + sleep 7
    - + + 135 -
    -   -
    +
    +
    + - + $(RUNL1NETWORK)
    - + + 136 -
    -   -
    +
    +
    + - + sleep 15
    - + + 137 -
    -   -
    +
    +
    + - + docker ps -a
    - + + 138 -
    -   -
    +
    +
    + - + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 139 -
    -   -
    +
    +
    + - + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -short -race -p 1 -covermode=atomic -coverprofile=../coverage.out -coverpkg ./... -timeout 200s ../... -json > ../report.json
    - + + 140 -
    -   +
    +
    + -
    - + + 141 -
    +
    +
     
    - + + 142 -
    +
    +
      -
    + .PHONY: test-e2e-group-1
    - + + 143 -
    +
    +
      -
    + test-e2e-group-1: stop ## Runs group 1 e2e tests checking race conditions
    - + +
    @@ -263,6 +254,17 @@
    -
    +
    + 263 + +
      -
    + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 264 -
    +
    +
      -
    + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/...
    - + + 265 -
    +
    +
     
    @@ -231218,453 +313251,483 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 266 -
    +
    +
      -
    + .PHONY: benchmark-sequencer-eth-transfers
    - + + 267 -
    +
    +
      -
    + benchmark-sequencer-eth-transfers: stop
    - + + 268 -
    +
    +
      -
    + $(RUNL1NETWORK)
    - + +
    @@ -379,7 +381,7 @@
    -
    +
    + 379 + +
      -
    + $(STOPZKPROVER)
    - + + 380 -
    +
    +
     
    - + + 381 -
    +
    +
      -
    + .PHONY: run-l1-explorer
    - + + 382 -
    -   -
    +
    +
    + - + run-l1-explorer: ## Runs L1 blockscan explorer
    - + + 383 -
    +
    +
      -
    + $(RUNEXPLORERL1DB)
    - + + 384 -
    +
    +
      -
    + $(RUNEXPLORERL1)
    - + + 385 -
    +
    +
     
    - + +
    @@ -449,7 +451,7 @@
    -
    +
    + 449 + +
      -
    + .PHONY: stop-seqsender-v1tov2
    - + + 450 -
    +
    +
      -
    + stop-seqsender-v1tov2: ## stops the sequencer sender
    - + + 451 -
    +
    +
      -
    + $(STOPV1TOV2SEQUENCESENDER)
    - + + 452 -
    -   -
    +
    +
    + - +
    - + + 453 -
    +
    +
      -
    + .PHONY: run-sync
    - + + 454 -
    +
    +
      -
    + run-sync: ## runs the synchronizer
    - + + 455 -
    +
    +
      -
    + $(RUNSYNC)
    - + +
    @@ -513,7 +515,7 @@
    -
    +
    + 513 + +
      -
    + .PHONY: stop-eth-tx-manager-v1tov2
    - + + 514 -
    +
    +
      -
    + stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service
    - + + 515 -
    +
    +
      -
    + $(STOPV1TOV2ETHTXMANAGER)
    - + + 516 -
    -   -
    +
    +
    + - +
    - + + 517 -
    +
    +
      -
    + .PHONY: run-agg
    - + + 518 -
    +
    +
      -
    + run-agg: ## Runs the aggregator service
    - + + 519 -
    +
    +
      -
    + $(RUNAGGREGATOR)
    - + +
    @@ -555,7 +557,7 @@
    -
    +
    + 555 + +
      -
    + $(RUNPERMISSIONLESSDB)
    - + + 556 -
    +
    +
      -
    + sleep 3
    - + + 557 -
    +
    +
      -
    + $(RUNPERMISSIONLESSZKPROVER)
    - + + 558 -
    -   -
    +
    +
    + - +
    - + + 559 -
    +
    +
     
    - + + 560 -
    +
    +
      -
    + PHONY: stop-permissionless-dependencies
    - + + 561 -
    +
    +
      -
    + stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node
    - + +
    @@ -644,7 +646,7 @@
    -
    +
    + 644 + +
      -
    + go run ./scripts/init_network/main.go .
    - + + 645 -
    +
    +
     
    - + + 646 -
    +
    +
      -
    + .PHONY: show-logs
    - + + 647 -
    -   -
    +
    +
    + - + show-logs: ## Show logs for running docker
    - + + 648 -
    +
    +
      -
    + $(DOCKERCOMPOSE) logs
    - + + 649 -
    +
    +
     
    - + + 650 -
    +
    +
      -
    + .PHONY: deploy-sc
    - + +
    @@ -700,10 +702,12 @@
    -
    +
    + 700 + +
      -
    + .PHONY: generate-mocks-synchronizer
    - + + 701 -
    +
    +
      -
    + generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool
    - + + 702 -
    +
    +
      -
    + ## mocks for synchronizer
    - + + 703 -
    -   -
    +
    +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
    - + + 704 -
    -   -
    +
    +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS}
    - + + 705 -
    -   -
    +
    +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethTxManager --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS}
    - + + 706 -
    -   -
    +
    +
    + - + #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
    - + + 707 -
    +
    +
      -
    + for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \
    - + + 708 -
    +
    +
      -
    + camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \
    - + + 709 -
    +
    +
      -
    + echo $$camelcase ; \
    - + +
    @@ -712,7 +716,7 @@
    -
    +
    + 712 + +
     
    - + + 713 -
    +
    +
      -
    + rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks
    - + + 714 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS}
    - + + 715 -
    -   -
    +
    +
    + - +
    - + + 716 -
    +
    +
      -
    + rm -Rf ../synchronizer/l2_sync/l2_shared/mocks
    - + + 717 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS}
    - + + 718 -
    +
    +
      -
    +
    - + +
    @@ -732,23 +736,20 @@
    -
    +
    + 732 + +
      -
    + .PHONY: generate-mocks-etherman
    - + + 733 -
    +
    +
      -
    + generate-mocks-etherman: ## Generates mocks for etherman , using mockery tool
    - + + 734 -
    +
    +
      -
    + ## mocks for etherman
    - + + 735 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=GasPricer --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=etherscanMock --filename=mock_etherscan.go ${COMMON_MOCKERY_PARAMS}
    - + + 736 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=GasPricer --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ethGasStationMock --filename=mock_ethgasstation.go ${COMMON_MOCKERY_PARAMS}
    - + + 737 -
    +
    +
     
    - + + 738 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ChainReader --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ChainReaderMock --filename=mock_chainreader.go ${COMMON_MOCKERY_PARAMS}
    - + + 739 -
    +
    +
     
    @@ -231898,251 +313971,261 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 740 -
    +
    +
     
    - + + 741 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=ethermanMock --filename=mock_etherman_test.go ${COMMON_MOCKERY_PARAMS}
    - + + 742 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=stateMock --filename=mock_state_test.go ${COMMON_MOCKERY_PARAMS}
    - + + 743 -
    +
    +
     
    - + + 744 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
    - + + 745 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
    - + + 746 -
    +
    +
     
    - + + 747 -
    -   -
    +
    +
    + - + rm -Rf ../etherman/mockseth
    - + + 748 -
    -   -
    +
    +
    + - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../etherman/ --output ../etherman/mockseth --outpkg mockseth ${COMMON_MOCKERY_PARAMS}
    - + + 749 -
    -   -
    +
    +
    + - +
    - + + 750 -
    -   +
    +
    + -
    - + + 751 -
    -   -
    +
    +
    + - + .PHONY: generate-mocks-aggregator
    - + + 752 -
    +
    +
      -
    + generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
    - + + 753 -
    +
    +
      -
    + ## mocks for the aggregator tests
    - + + 754 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go
    - + +
    @@ -758,7 +759,7 @@
    -
    +
    + 758 + +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go
    - + + 759 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go
    - + + 760 -
    +
    +
     
    - + + 761 -
    -   -
    +
    +
    + - + .PHONY: generate-mocks-state
    - + + 762 -
    +
    +
      -
    + generate-mocks-state: ## Generates mocks for state , using mockery tool
    - + + 763 -
    +
    +
      -
    + ## mocks for the aggregator tests
    - + + 764 -
    +
    +
      -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter
    - + +
    @@ -770,6 +771,27 @@
    -
    +
    + 770 + +
      -
    + run-benchmarks: run-db ## Runs benchmars
    - + + 771 -
    +
    +
      -
    + go test -bench=. ./state/tree
    - + + 772 -
    +
    +
     
    @@ -232358,413 +314441,452 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 773 -
    +
    +
      -
    + .PHONY: compile-scs
    - + + 774 -
    +
    +
      -
    + compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml
    - + + 775 -
    +
    +
      -
    + go run ./scripts/cmd... compilesc --input ./contracts +
    +
    +
    +
    +
    + + + + + - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - + - + + - - - - - - @@ -232918,2292 +315040,2376 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - -
    +
     
    - + + 1 -
    -   -
    +
    +
    + + + DOCKERCOMPOSE := docker compose -f docker-compose.yml
    - + + 2 -
    +
    +
      -
    + DOCKERCOMPOSEAPPSEQ := zkevm-sequencer
    - + + 3 -
    +
    +
      -
    + DOCKERCOMPOSEAPPSEQV1TOV2 := zkevm-sequencer-v1tov2
    - + + 4 -
    +
    +
      -
    + DOCKERCOMPOSEAPPSEQSENDER := zkevm-sequence-sender
    - + +
     
    -
    +
    + 26 + +
      -
    + DOCKERCOMPOSEZKPROVER := zkevm-prover
    - + + 27 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db
    - + + 28 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node
    - + + 29 -
    -   -
    +
    +
    + + + DOCKERCOMPOSEPERMISSIONLESSNODEDAC := zkevm-node-forced-DAC
    - + + 30 -
    +
    +
      -
    + DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover
    - + + 31 -
    +
    +
      -
    + DOCKERCOMPOSENODEAPPROVE := zkevm-approve
    - + + 32 -
    +
    +
      -
    + DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2
    - + +
     
    -
    +
    + 63 + +
     
    - + + 64 -
    +
    +
      -
    + RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB)
    - + + 65 -
    +
    +
      -
    + RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE)
    - + + 66 -
    -   -
    +
    +
    + + + RUNPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC)
    - + + 67 -
    +
    +
      -
    + RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
    - + + 68 -
    +
    +
     
    - + + 69 -
    +
    +
      -
    + RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE)
    - + +
     
    -
    +
    + 103 + +
     
    - + + 104 -
    +
    +
      -
    + STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB)
    - + + 105 -
    +
    +
      -
    + STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE)
    - + + 106 -
    -   -
    +
    +
    + + + STOPPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC)
    - + + 107 -
    +
    +
      -
    + STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER)
    - + + 108 -
    +
    +
     
    - + + 109 -
    +
    +
      -
    + STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE)
    - + +
     
    -
    +
    + 113 + +
     
    - + + 114 -
    +
    +
      -
    + STOP := $(DOCKERCOMPOSE) down --remove-orphans
    - + + 115 -
    +
    +
     
    - + + 116 -
    -   -
    +
    +
    + + + RUNDACDB := docker-compose up -d zkevm-data-node-db
    - + + 117 -
    -   -
    +
    +
    + + + STOPDACDB := docker-compose stop zkevm-data-node-db && docker-compose rm -f zkevm-data-node-db
    - + + 118 -
    -   +
    +
    + +
    - + + 119 -
    +
    +
      -
    + .PHONY: test-full-non-e2e
    - + + 120 -
    +
    +
      -
    + test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions
    - + + 121 -
    +
    +
      -
    + $(RUNSTATEDB)
    - + +
     
    -
    +
    + 128 + +
      -
    + sleep 15
    - + + 129 -
    +
    +
      -
    + docker ps -a
    - + + 130 -
    +
    +
      -
    + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 131 -
    -   -
    +
    +
    + + + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -short -race -p 1 -covermode=atomic -coverprofile=../coverage.out -coverpkg ./... -timeout 70s ../...
    - + + 132 -
    +
    +
     
    - + + 133 -
    +
    +
      -
    + .PHONY: test-e2e-group-1
    - + + 134 -
    +
    +
      -
    + test-e2e-group-1: stop ## Runs group 1 e2e tests checking race conditions
    - + +
     
    -
    +
    + 254 + +
      -
    + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 255 -
    +
    +
      -
    + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/...
    - + + 256 -
    +
    +
     
    - + + 257 -
    -   -
    +
    +
    + + + .PHONY: test-e2e-group-cdk-validium-1
    - + + 258 -
    -   -
    +
    +
    + + + test-e2e-group-cdk-validium-1: stop ## Runs cdk-validium-1 e2e tests checking race conditions
    - + + 259 -
    -   -
    +
    +
    + + + $(RUNSTATEDB)
    - + + 260 -
    -   -
    +
    +
    + + + $(RUNPOOLDB)
    - + + 261 -
    -   -
    +
    +
    + + + $(RUNEVENTDB)
    - + + 262 -
    -   -
    +
    +
    + + + sleep 5
    - + + 263 -
    -   -
    +
    +
    + + + $(RUNZKPROVER)
    - + + 264 -
    -   -
    +
    +
    + + + docker ps -a
    - + + 265 -
    -   -
    +
    +
    + + + docker logs $(DOCKERCOMPOSEZKPROVER)
    - + + 266 -
    -   -
    +
    +
    + + + trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -race -v -p 1 -timeout 2000s ../ci/e2e-group-cdk-validium-1/...
    - + + 267 -
    -   +
    +
    + +
    - + + 268 -
    +
    +
      -
    + .PHONY: benchmark-sequencer-eth-transfers
    - + + 269 -
    +
    +
      -
    + benchmark-sequencer-eth-transfers: stop
    - + + 270 -
    +
    +
      -
    + $(RUNL1NETWORK)
    - - -
    -   -
    -
    +
    +
     
    - + + 381 -
    +
    +
      -
    + $(STOPZKPROVER)
    - + + 382 -
    +
    +
     
    - + + 383 -
    +
    +
      -
    + .PHONY: run-l1-explorer
    - + + 384 -
    -   -
    +
    +
    + + + run-l1-explorer: ## Runs L1 blockscan explorer
    - + + 385 -
    +
    +
      -
    + $(RUNEXPLORERL1DB)
    - + + 386 -
    +
    +
      -
    + $(RUNEXPLORERL1)
    - + + 387 -
    +
    +
     
    - + +
     
    -
    +
    + 451 + +
      -
    + .PHONY: stop-seqsender-v1tov2
    - + + 452 -
    +
    +
      -
    + stop-seqsender-v1tov2: ## stops the sequencer sender
    - + + 453 -
    +
    +
      -
    + $(STOPV1TOV2SEQUENCESENDER)
    - + + 454 -
    -   +
    +
    + +
    - + + 455 -
    +
    +
      -
    + .PHONY: run-sync
    - + + 456 -
    +
    +
      -
    + run-sync: ## runs the synchronizer
    - + + 457 -
    +
    +
      -
    + $(RUNSYNC)
    - + +
     
    -
    +
    + 515 + +
      -
    + .PHONY: stop-eth-tx-manager-v1tov2
    - + + 516 -
    +
    +
      -
    + stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service
    - + + 517 -
    +
    +
      -
    + $(STOPV1TOV2ETHTXMANAGER)
    - + + 518 -
    -   +
    +
    + +
    - + + 519 -
    +
    +
      -
    + .PHONY: run-agg
    - + + 520 -
    +
    +
      -
    + run-agg: ## Runs the aggregator service
    - + + 521 -
    +
    +
      -
    + $(RUNAGGREGATOR)
    - + +
     
    -
    +
    + 557 + +
      -
    + $(RUNPERMISSIONLESSDB)
    - + + 558 -
    +
    +
      -
    + sleep 3
    - + + 559 -
    +
    +
      -
    + $(RUNPERMISSIONLESSZKPROVER)
    - + + 560 -
    -   +
    +
    + +
    - + + 561 -
    +
    +
     
    - + + 562 -
    +
    +
      -
    + PHONY: stop-permissionless-dependencies
    - + + 563 -
    +
    +
      -
    + stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node
    -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + + +
     
    - 1 + + 646 +
    - + - // Code generated - DO NOT EDIT. +   + go run ./scripts/init_network/main.go .
    - 2 + + 647 +
    - + - // This file is a generated binding and any manual changes will be lost. +   +
    - 3 + + 648 +
    - + -
    +   + .PHONY: show-logs
    - 4 + + 649 +
    + - package CounterAndBlock + show-logs: ## Show logs for running docker
    - 5 + + 650 +
    - + -
    +   + $(DOCKERCOMPOSE) logs
    - 6 + + 651 +
    - + - import ( +   +
    - 7 + + 652 +
    - + - "errors" +   + .PHONY: deploy-sc
    - 8 - -
    - + - "math/big" -
    +
    +
     
    - 9 + + 702 +
    - + - "strings" +   + .PHONY: generate-mocks-synchronizer
    - 10 + + 703 +
    - + -
    +   + generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool
    - 11 + + 704 +
    - + - ethereum "github.com/ethereum/go-ethereum" +   + ## mocks for synchronizer
    - 12 + + 705 +
    + - "github.com/ethereum/go-ethereum/accounts/abi" + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
    - 13 + + 706 +
    + - "github.com/ethereum/go-ethereum/accounts/abi/bind" + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StateFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS}
    - 14 + + 707 +
    + - "github.com/ethereum/go-ethereum/common" + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS}
    - 15 + + 708 +
    + - "github.com/ethereum/go-ethereum/core/types" + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=PoolInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
    - 16 + 709
    + - "github.com/ethereum/go-ethereum/event" + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Factory --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientFactoryMock --filename=mock_datacommitteeclientfactory.go ${COMMON_MOCKERY_PARAMS}
    - 17 + 710
    + - ) + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Client --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientMock --filename=mock_datacommitteeclient.go ${COMMON_MOCKERY_PARAMS}
    - 18 + + 711 +
    - + -
    +   + for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \
    - 19 + + 712 +
    - + - // Reference imports to suppress errors if they are not otherwise used. +   + camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \
    - 20 + + 713 +
    - + - var ( +   + echo $$camelcase ; \
    - 21 - -
    - + - _ = errors.New -
    +
    +
     
    - 22 + + 716 +
    - + - _ = big.NewInt +   +
    - 23 + + 717 +
    - + - _ = strings.NewReader +   + rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks
    - 24 + + 718 +
    - + - _ = ethereum.NotFound +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS}
    - 25 + + 719 +
    + - _ = bind.Bind +
    - 26 + + 720 +
    - + - _ = common.Big1 +   + rm -Rf ../synchronizer/l2_sync/l2_shared/mocks
    - 27 + + 721 +
    - + - _ = types.BloomLookup +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS}
    - 28 + + 722 +
    - + - _ = event.NewSubscription +   +
    - 29 - -
    - + - _ = abi.ConvertType -
    +
    +
     
    - 30 + + 736 +
    - + - ) +   + .PHONY: generate-mocks-etherman
    - 31 + + 737 +
    - + -
    +   + generate-mocks-etherman: ## Generates mocks for etherman , using mockery tool
    - 32 + + 738 +
    - + - // CounterAndBlockMetaData contains all meta data concerning the CounterAndBlock contract. +   + ## mocks for etherman
    - 33 + + 739 +
    + - var CounterAndBlockMetaData = &bind.MetaData{ + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=GasPricer --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=etherscanMock --filename=mock_etherscan.go
    - 34 + + 740 +
    + - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"increment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=GasPricer --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ethGasStationMock --filename=mock_ethgasstation.go
    - 35 + + 741 +
    - + - Bin: "0x608060405234801561001057600080fd5b5060eb8061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c806306661abd146041578063a87d942c14605c578063d09de08a146071575b600080fd5b604960005481565b6040519081526020015b60405180910390f35b60005460408051918252426020830152016053565b60776079565b005b6001600080828254608991906090565b9091555050565b6000821982111560b057634e487b7160e01b600052601160045260246000fd5b50019056fea26469706673582212205aa9aebefdfb857d27d7bdc8475c08138617cc37e78c2e6bd98acb9a1484994964736f6c634300080c0033", +   +
    - 36 + + 742 +
    + - } + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=ethermanMock --filename=mock_etherman_test.go
    - 37 + 743
    + -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=stateMock --filename=mock_state_test.go
    - 38 + + 744 +
    - + - // CounterAndBlockABI is the input ABI used to generate the binding from. +   +
    - 39 + 745
    + - // Deprecated: Use CounterAndBlockMetaData.ABI instead. + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go
    - 40 + 746
    + - var CounterAndBlockABI = CounterAndBlockMetaData.ABI + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
    - 41 + + 747 +
    - + +  
    - 42 + + 748 +
    + - // CounterAndBlockBin is the compiled bytecode used for deploying new contracts. + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=dataAvailabilityProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=daMock --filename=mock_da.go
    - 43 + + 749 +
    + - // Deprecated: Use CounterAndBlockMetaData.Bin instead. + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=stateMock --filename=mock_state.go
    - 44 + + 750 +
    - + - var CounterAndBlockBin = CounterAndBlockMetaData.Bin +   +
    - 45 + + -
    - + +
    +
    +  
    - 46 + + -
    - + - // DeployCounterAndBlock deploys a new Ethereum contract, binding an instance of CounterAndBlock to it. +
    +
    +   +
    - 47 + + 751 +
    - + - func DeployCounterAndBlock(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CounterAndBlock, error) { +   +
    - 48 + + 752 +
    + - parsed, err := CounterAndBlockMetaData.GetAbi() + .PHONY: generate-mocks-aggregator
    - 49 + + -
    - + - if err != nil { +
    +
    +   +
    - 50 + + -
    - + - return common.Address{}, nil, nil, err +
    +
    +   +
    - 51 + + -
    - + - } +
    +
    +   +
    - 52 + + -
    - + - if parsed == nil { +
    +
    +   +
    - 53 + + 753 +
    - + - return common.Address{}, nil, nil, errors.New("GetABI returned nil") +   + generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool
    - 54 + + 754 +
    - + - } +   + ## mocks for the aggregator tests
    - 55 + + 755 +
    - + -
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go
    - 56 - -
    - + - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CounterAndBlockBin), backend) -
    +
    +
     
    - 57 + + 759 +
    - + - if err != nil { +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go
    - 58 + + 760 +
    - + - return common.Address{}, nil, nil, err +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go
    - 59 + + 761 +
    - + - } +   +
    - 60 + + 762 +
    + - return address, tx, &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil + .PHONY: generate-mocks-state
    - 61 + + 763 +
    - + - } +   + generate-mocks-state: ## Generates mocks for state , using mockery tool
    - 62 + + 764 +
    - + -
    +   + ## mocks for the aggregator tests
    - 63 + + 765 +
    - + - // CounterAndBlock is an auto generated Go binding around an Ethereum contract. +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter
    - 64 - -
    - + - type CounterAndBlock struct { -
    +
    +
     
    - 65 + + 771 +
    - + - CounterAndBlockCaller // Read-only binding to the contract +   + run-benchmarks: run-db ## Runs benchmars
    - 66 + + 772 +
    - + - CounterAndBlockTransactor // Write-only binding to the contract +   + go test -bench=. ./state/tree
    - 67 + + 773 +
    - + - CounterAndBlockFilterer // Log filterer for contract events +   +
    - 68 + 774
    + - } + .PHONY: run-dac-db
    - 69 + 775
    + -
    + run-dac-db: ## Suns the DAC DB
    - 70 + 776
    + - // CounterAndBlockCaller is an auto generated read-only Go binding around an Ethereum contract. + $(RUNDACDB)
    - 71 + 777
    + - type CounterAndBlockCaller struct { +
    - 72 + 778
    + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + .PHONY: stop-dac-db
    - 73 + 779
    + - } + stop-dac-db: ## Stops the DAC DB
    - 74 + 780
    + -
    + $(STOPDACDB)
    - 75 + 781
    + - // CounterAndBlockTransactor is an auto generated write-only Go binding around an Ethereum contract. +
    - 76 + 782
    + - type CounterAndBlockTransactor struct { + .PHONY: run-permissionless-dac
    - 77 + 783
    + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + run-permissionless-dac: ## Runs a permissionless node that is forced to sync through DAC
    - 78 + 784
    + - } + $(RUNPERMISSIONLESSDB)
    - 79 + 785
    + -
    + sleep 1
    - 80 + 786
    + - // CounterAndBlockFilterer is an auto generated log filtering Go binding around an Ethereum contract events. + $(RUNPERMISSIONLESSZKPROVER)
    - 81 + 787
    + - type CounterAndBlockFilterer struct { + $(RUNPERMISSIONLESSNODEDAC)
    - 82 + 788
    + - contract *bind.BoundContract // Generic contract wrapper for the low level calls +
    - 83 + 789
    + - } + .PHONY: stop-permissionless-dac
    - 84 + 790
    + -
    + stop-permissionless-dac: ## Stops the permissionless node that is forced to sync through DAC
    - 85 + 791
    + - // CounterAndBlockSession is an auto generated Go binding around an Ethereum contract, + $(STOPPERMISSIONLESSNODEDAC)
    - 86 + 792
    + - // with pre-set call and transact options. + $(STOPPERMISSIONLESSZKPROVER)
    - 87 + 793
    + - type CounterAndBlockSession struct { + $(STOPPERMISSIONLESSDB)
    - 88 + 794
    + - Contract *CounterAndBlock // Generic contract binding to set the session for +
    - 89 + + 795 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session +   + .PHONY: compile-scs
    - 90 + + 796 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +   + compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml
    - 91 + + 797 +
    - + - } +   + go run ./scripts/cmd... compilesc --input ./contracts
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -46,6 +46,7 @@
    +
    - 92 + + 46 +
    - + -
    +   + DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
    - 93 + + 47 +
    - + - // CounterAndBlockCallerSession is an auto generated read-only Go binding around an Ethereum contract, +   + DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
    - 94 + + 48 +
    - + - // with pre-set call options. +   + DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
    - 95 + + -
    - + - type CounterAndBlockCallerSession struct { +
    +
    +   +
    - 96 + + 49 +
    - + - Contract *CounterAndBlockCaller // Generic contract caller binding to set the session for +   + DefaultL1NetworkURL = "http://localhost:8545"
    - 97 + + 50 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session +   + DefaultL1NetworkWebSocketURL = "ws://localhost:8546"
    - 98 + + 51 +
    - + - } +   + DefaultL1ChainID uint64 = 1337
    - 99 + +
    @@ -263,7 +264,6 @@
    +
    + 263 +
    - + -
    +   + if confirmationLevel == PoolConfirmationLevel {
    - 100 + + 264 +
    - + - // CounterAndBlockTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +   + return nil, nil
    - 101 + + 265 +
    - + - // with pre-set transact options. +   + }
    - 102 + + 266 +
    - + - type CounterAndBlockTransactorSession struct { + - +
    - 103 + + 267 +
    - + - Contract *CounterAndBlockTransactor // Generic contract transactor binding to set the session for +   + l2BlockNumbers := make([]*big.Int, 0, len(sentTxs))
    - 104 + + 268 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +   + for _, tx := range sentTxs {
    - 105 + + 269 +
    - + - } +   + // check transaction nonce against transaction reported L2 block number
    - 106 + +
    @@ -503,11 +503,7 @@
    +
    + 503 +
    - + -
    +   + if err != nil {
    - 107 + + 504 +
    - + - // CounterAndBlockRaw is an auto generated low-level Go binding around an Ethereum contract. +   + panic(err)
    - 108 + + 505 +
    - + - type CounterAndBlockRaw struct { +   + }
    - 109 + + 506 +
    - + - Contract *CounterAndBlock // Generic contract binding to access the raw methods on + - + mtr, err := l1infotree.NewL1InfoTreeRecursive(32)
    - 110 + + 507 +
    - + - } + - + if err != nil {
    - 111 + + 508 +
    - + -
    + - + panic(err)
    - 112 + + 509 +
    - + - // CounterAndBlockCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. + - + }
    - 113 + + 510 +
    - + - type CounterAndBlockCallerRaw struct { + - + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, mt, mtr)
    - 114 + + 511 +
    - + - Contract *CounterAndBlockCaller // Generic read-only contract binding to access the raw methods on +   + return st, nil
    - 115 + + 512 +
    - + +   }
    - 116 + + 513 +
    - + +  
    - 117 + +
    @@ -666,3 +662,23 @@
    +
    + 666 +
    - + - // CounterAndBlockTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +   + panic(err)
    - 118 + + 667 +
    - + - type CounterAndBlockTransactorRaw struct { +   + }
    - 119 + + 668 +
    - + - Contract *CounterAndBlockTransactor // Generic write-only contract binding to access the raw methods on +   + }
    - 120 + + -
    - + - } +
    +
    +   +
    - 121 + + -
    - + +
    +
    +  
    - 122 + + -
    - + - // NewCounterAndBlock creates a new instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    +   +
    - 123 + + -
    - + - func NewCounterAndBlock(address common.Address, backend bind.ContractBackend) (*CounterAndBlock, error) { +
    +
    +   +
    - 124 + + -
    - + - contract, err := bindCounterAndBlock(address, backend, backend, backend) +
    +
    +   +
    - 125 + + -
    - + - if err != nil { +
    +
    +   +
    - 126 + + -
    - + - return nil, err +
    +
    +   +
    - 127 + + -
    - + - } +
    +
    +   +
    - 128 + + -
    - + - return &CounterAndBlock{CounterAndBlockCaller: CounterAndBlockCaller{contract: contract}, CounterAndBlockTransactor: CounterAndBlockTransactor{contract: contract}, CounterAndBlockFilterer: CounterAndBlockFilterer{contract: contract}}, nil +
    +
    +   +
    - 129 + + -
    - + - } +
    +
    +   +
    - 130 + + -
    - + +
    +
    +  
    - 131 + + -
    - + - // NewCounterAndBlockCaller creates a new read-only instance of CounterAndBlock, bound to a specific deployed contract. +
    +
    +   +
    - 132 + + -
    - + - func NewCounterAndBlockCaller(address common.Address, caller bind.ContractCaller) (*CounterAndBlockCaller, error) { +
    +
    +   +
    - 133 + + -
    - + - contract, err := bindCounterAndBlock(address, caller, nil, nil) +
    +
    +   +
    - 134 + + -
    - + - if err != nil { +
    +
    +   +
    - 135 + + -
    - + - return nil, err +
    +
    +   +
    - 136 + + -
    - + - } +
    +
    +   +
    - 137 + + -
    - + - return &CounterAndBlockCaller{contract: contract}, nil +
    +
    +   +
    - 138 + + -
    - + - } +
    +
    +   +
    - 139 + + -
    - + +
    +
    +  
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - + + - - + + + + + + - - - - - - - + - + + - - - - - - - - - - - - - - + + + - - - - - + - + + - - - - + + +
    +
     
    +
    - 140 + + 46 +
    - + - // NewCounterAndBlockTransactor creates a new write-only instance of CounterAndBlock, bound to a specific deployed contract. +   + DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d"
    - 141 + + 47 +
    - + - func NewCounterAndBlockTransactor(address common.Address, transactor bind.ContractTransactor) (*CounterAndBlockTransactor, error) { +   + DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e"
    - 142 + + 48 +
    - + - contract, err := bindCounterAndBlock(address, nil, transactor, nil) +   + DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3"
    - 143 + 49
    + - if err != nil { + DefaultL1DataCommitteeContract = "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE"
    - 144 + + 50 +
    - + - return nil, err +   + DefaultL1NetworkURL = "http://localhost:8545"
    - 145 + + 51 +
    - + - } +   + DefaultL1NetworkWebSocketURL = "ws://localhost:8546"
    - 146 + + 52 +
    - + - return &CounterAndBlockTransactor{contract: contract}, nil +   + DefaultL1ChainID uint64 = 1337
    - 147 + +
     
    +
    + 264 +
    - + - } +   + if confirmationLevel == PoolConfirmationLevel {
    - 148 + + 265 +
    - + +   + return nil, nil +
    +
    + 266 + +
    +   + } +
    +
    + + +
    +  
    - 149 + + 267 +
    - + - // NewCounterAndBlockFilterer creates a new log filterer instance of CounterAndBlock, bound to a specific deployed contract. +   + l2BlockNumbers := make([]*big.Int, 0, len(sentTxs))
    - 150 + + 268 +
    - + - func NewCounterAndBlockFilterer(address common.Address, filterer bind.ContractFilterer) (*CounterAndBlockFilterer, error) { +   + for _, tx := range sentTxs {
    - 151 + + 269 +
    - + - contract, err := bindCounterAndBlock(address, nil, nil, filterer) +   + // check transaction nonce against transaction reported L2 block number
    - 152 + +
     
    +
    + 503 +
    - + +   if err != nil {
    - 153 + + 504 +
    - + - return nil, err +   + panic(err)
    - 154 + + 505 +
    - + +   }
    - 155 + + 506 +
    + - return &CounterAndBlockFilterer{contract: contract}, nil + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, mt)
    - 156 + + -
    - + - } +
    +
    +   +
    - 157 + + -
    - + +
    +
    +  
    - 158 + + -
    - + - // bindCounterAndBlock binds a generic wrapper to an already deployed contract. +
    +
    +   +
    - 159 + + + +
    +   +
    +
    +
    + 507 +
    - + - func bindCounterAndBlock(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { +   + return st, nil
    - 160 + + 508 +
    - + - parsed, err := CounterAndBlockMetaData.GetAbi() +   + }
    - 161 + + 509 +
    - + - if err != nil { +   +
    - 162 + +
     
    +
    + 662 +
    - + - return nil, err +   + panic(err)
    - 163 + + 663 +
    - + +   }
    - 164 + + 664 +
    - + - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +   + }
    - 165 + 665
    + - } +
    - 166 + 666
    + -
    + // StartDACDB starts the data availability node DB
    - 167 + 667
    + - // Call invokes the (constant) contract method with params as input values and + func (m *Manager) StartDACDB() error {
    - 168 + 668
    + - // sets the output to result. The result type might be a single field for simple + return StartComponent("dac-db", func() (bool, error) { return true, nil })
    - 169 + 669
    + - // returns, a slice of interfaces for anonymous returns and a struct for named + }
    - 170 + 670
    + - // returns. +
    - 171 + 671
    + - func (_CounterAndBlock *CounterAndBlockRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + // StopDACDB stops the data availability node DB
    - 172 + 672
    + - return _CounterAndBlock.Contract.CounterAndBlockCaller.contract.Call(opts, result, method, params...) + func (m *Manager) StopDACDB() error {
    - 173 + 673
    + - } + return StopComponent("dac-db")
    - 174 + 674
    + -
    + }
    - 175 + 675
    + - // Transfer initiates a plain transaction to move funds to the contract, calling +
    - 176 + 676
    + - // its default method if one is available. + // StartPermissionlessNodeForcedToSYncThroughDAC starts a permissionless node that is froced to sync through the DAC
    - 177 + 677
    + - func (_CounterAndBlock *CounterAndBlockRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + func (m *Manager) StartPermissionlessNodeForcedToSYncThroughDAC() error {
    - 178 + 678
    + - return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transfer(opts) + return StartComponent("permissionless-dac", func() (bool, error) { return true, nil })
    - 179 + 679
    @@ -235213,7 +317419,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 180 + 680
    @@ -235223,37 +317429,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 181 + 681
    + - // Transact invokes the (paid) contract method with params as input values. + // StopPermissionlessNodeForcedToSYncThroughDAC stops the permissionless node that is froced to sync through the DAC
    - 182 + 682
    + - func (_CounterAndBlock *CounterAndBlockRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + func (m *Manager) StopPermissionlessNodeForcedToSYncThroughDAC() error {
    - 183 + 683
    + - return _CounterAndBlock.Contract.CounterAndBlockTransactor.contract.Transact(opts, method, params...) + return StopComponent("permissionless-dac")
    - 184 + 684
    @@ -235261,2064 +317467,2204 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
    @@ -111,7 +111,7 @@
    +
    - 185 + + 111 +
    - + -
    +   + return err
    - 186 + + 112 +
    - + - // Call invokes the (constant) contract method with params as input values and +   + }
    - 187 + + 113 +
    - + - // sets the output to result. The result type might be a single field for simple +   +
    - 188 + + 114 +
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named + - + ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config)
    - 189 + + 115 +
    - + - // returns. +   + if err != nil {
    - 190 + + 116 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +   + return err
    - 191 + + 117 +
    - + - return _CounterAndBlock.Contract.contract.Call(opts, result, method, params...) +   + }
    - 192 + +
    @@ -183,7 +183,7 @@
    +
    + 183 +
    - + - } +   + // send to L1
    - 193 + + 184 +
    - + -
    +   + firstSequence := seqs[0]
    - 194 + + 185 +
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +   + lastSequence := seqs[len(seqs)-1]
    - 195 + + 186 +
    - + - // its default method if one is available. + - + to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From)
    - 196 + + 187 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +   + if err != nil {
    - 197 + + 188 +
    - + - return _CounterAndBlock.Contract.contract.Transfer(opts) +   + return err
    - 198 + + 189 +
    - + - } +   + }
    - 199 + +
    @@ -289,7 +289,7 @@
    +
    + 289 +
    - + -
    +   + switch vLog.Topics[0] {
    - 200 + + 290 +
    - + - // Transact invokes the (paid) contract method with params as input values. +   + case etherman.SequencedBatchesSigHash():
    - 201 + + 291 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +   + if vLog.TxHash == tx.Hash() { // ignore other txs happening on L1
    - 202 + + 292 +
    - + - return _CounterAndBlock.Contract.contract.Transact(opts, method, params...) + - + sb, err := ethMan.EtrogZkEVM.ParseSequenceBatches(vLog)
    - 203 + + 293 +
    - + - } +   + if err != nil {
    - 204 + + 294 +
    - + -
    +   + return err
    - 205 + + 295 +
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. +   + }
    - 206 + +
    @@ -302,7 +302,7 @@
    +
    + 302 +
    - + - // +   + }
    - 207 + + 303 +
    - + - // Solidity: function count() view returns(uint256) +   + }
    - 208 + + 304 +
    - + - func (_CounterAndBlock *CounterAndBlockCaller) Count(opts *bind.CallOpts) (*big.Int, error) { +   + case etherman.TrustedVerifyBatchesSigHash():
    - 209 + + 305 +
    - + - var out []interface{} + - + vb, err := ethMan.EtrogZkEVM.ParseVerifyBatches(vLog)
    - 210 + + 306 +
    - + - err := _CounterAndBlock.contract.Call(opts, &out, "count") +   + if err != nil {
    - 211 + + 307 +
    - + -
    +   + return err
    - 212 + + 308 +
    - + - if err != nil { +   + } +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - + + +
    +
     
    - 213 + + 111 +
    - + - return *new(*big.Int), err +   + return err
    - 214 + + 112 +
    - + +   }
    - 215 + + 113 +
    - + +  
    - 216 + + 114 +
    + - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, nil, nil)
    - 217 + + 115 +
    - + -
    +   + if err != nil {
    - 218 + + 116 +
    - + - return out0, err +   + return err
    - 219 + + 117 +
    - + -
    +   + }
    - 220 + +
     
    +
    + 183 +
    - + - } +   + // send to L1
    - 221 + + 184 +
    - + -
    +   + firstSequence := seqs[0]
    - 222 + + 185 +
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. +   + lastSequence := seqs[len(seqs)-1]
    - 223 + + 186 +
    + - // + to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From, nil)
    - 224 + + 187 +
    - + - // Solidity: function count() view returns(uint256) +   + if err != nil {
    - 225 + + 188 +
    - + - func (_CounterAndBlock *CounterAndBlockSession) Count() (*big.Int, error) { +   + return err
    - 226 + + 189 +
    - + - return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) +   + }
    - 227 + +
     
    +
    + 289 +
    - + - } +   + switch vLog.Topics[0] {
    - 228 + + 290 +
    - + -
    +   + case etherman.SequencedBatchesSigHash():
    - 229 + + 291 +
    - + - // Count is a free data retrieval call binding the contract method 0x06661abd. +   + if vLog.TxHash == tx.Hash() { // ignore other txs happening on L1
    - 230 + + 292 +
    + - // + sb, err := ethMan.ZkEVM.ParseSequenceBatches(vLog)
    - 231 + + 293 +
    - + - // Solidity: function count() view returns(uint256) +   + if err != nil {
    - 232 + + 294 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerSession) Count() (*big.Int, error) { +   + return err
    - 233 + + 295 +
    - + - return _CounterAndBlock.Contract.Count(&_CounterAndBlock.CallOpts) +   + }
    - 234 + +
     
    +
    + 302 +
    - + - } +   + }
    - 235 + + 303 +
    - + -
    +   + }
    - 236 + + 304 +
    - + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +   + case etherman.TrustedVerifyBatchesSigHash():
    - 237 + + 305 +
    + - // + vb, err := ethMan.ZkEVM.ParseVerifyBatches(vLog)
    - 238 + + 306 +
    - + - // Solidity: function getCount() view returns(uint256, uint256) +   + if err != nil {
    - 239 + + 307 +
    - + - func (_CounterAndBlock *CounterAndBlockCaller) GetCount(opts *bind.CallOpts) (*big.Int, *big.Int, error) { +   + return err
    - 240 + + 308 +
    - + - var out []interface{} +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/deploy_sc/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -132,6 +132,12 @@
    - 241 + + 132 +
    - + - err := _CounterAndBlock.contract.Call(opts, &out, "getCount") +   + log.Debugf("Sending TX to transfer ETH")
    - 242 + + 133 +
    - + -
    +   + to := common.HexToAddress(receiverAddr)
    - 243 + + 134 +
    - + - if err != nil { +   + tx = ethTransfer(ctx, client, auth, to, transferAmount, nil)
    - 244 + + -
    - + - return *new(*big.Int), *new(*big.Int), err +
    +
    +   +
    - 245 + + -
    - + - } +
    +
    +   +
    - 246 + + -
    - + +
    +
    +  
    - 247 + + -
    - + - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) +
    +
    +   +
    - 248 + + -
    - + - out1 := *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) +
    +
    +   +
    - 249 + + -
    - + +
    +
    +  
    - 250 + + 135 +
    - + - return out0, out1, err +   + err = operations.WaitTxToBeMined(ctx, client, tx, txTimeout)
    - 251 + + 136 +
    - + -
    +   + chkErr(err)
    - 252 + + 137 +
    - + - } +   + fmt.Println() +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - + + +
    +
     
    - 253 + + 132 +
    - + -
    +   + log.Debugf("Sending TX to transfer ETH")
    - 254 + + 133 +
    - + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. +   + to := common.HexToAddress(receiverAddr)
    - 255 + + 134 +
    - + - // +   + tx = ethTransfer(ctx, client, auth, to, transferAmount, nil)
    - 256 + 135
    + - // Solidity: function getCount() view returns(uint256, uint256) + fmt.Println()
    - 257 + 136
    + - func (_CounterAndBlock *CounterAndBlockSession) GetCount() (*big.Int, *big.Int, error) { +
    - 258 + 137
    + - return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) + // Invalid ETH Transfer
    - 259 + 138
    + - } + log.Debugf("Sending Invalid TX to transfer ETH")
    - 260 + 139
    + -
    + nonce := tx.Nonce() + 1
    - 261 + 140
    + - // GetCount is a free data retrieval call binding the contract method 0xa87d942c. + ethTransfer(ctx, client, auth, to, transferAmount, &nonce)
    - 262 + + 141 +
    - + - // +   + err = operations.WaitTxToBeMined(ctx, client, tx, txTimeout)
    - 263 + + 142 +
    - + - // Solidity: function getCount() view returns(uint256, uint256) +   + chkErr(err)
    - 264 + + 143 +
    - + - func (_CounterAndBlock *CounterAndBlockCallerSession) GetCount() (*big.Int, *big.Int, error) { +   + fmt.Println() +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/hash_compare/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
    @@ -1,124 +0,0 @@
    - 265 + + 1 +
    - + - return _CounterAndBlock.Contract.GetCount(&_CounterAndBlock.CallOpts) + - + package main
    - 266 + + 2 +
    - + - } + - +
    - 267 + + 3 +
    - + -
    + - + import (
    - 268 + + 4 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. + - + "context"
    - 269 + + 5 +
    - + - // + - + "errors"
    - 270 + + 6 +
    - + - // Solidity: function increment() returns() + - + "fmt"
    - 271 + + 7 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactor) Increment(opts *bind.TransactOpts) (*types.Transaction, error) { + - + "math/big"
    - 272 + + 8 +
    - + - return _CounterAndBlock.contract.Transact(opts, "increment") + - + "sync"
    - 273 + + 9 +
    - + - } + - + "time"
    - 274 + + 10 +
    - + + -
    - 275 + + 11 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. + - + "github.com/ethereum/go-ethereum"
    - 276 + + 12 +
    - + - // + - + "github.com/ethereum/go-ethereum/core/types"
    - 277 + + 13 +
    - + - // Solidity: function increment() returns() + - + "github.com/ethereum/go-ethereum/ethclient"
    - 278 + + 14 +
    - + - func (_CounterAndBlock *CounterAndBlockSession) Increment() (*types.Transaction, error) { + - + )
    - 279 + + 15 +
    - + - return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) + - +
    - 280 + + 16 +
    - + - } + - + // add here the url of the nodes you want to check
    - 281 + + 17 +
    - + -
    + - + // against the trusted node
    - 282 + + 18 +
    - + - // Increment is a paid mutator transaction binding the contract method 0xd09de08a. + - + var networkURLsToCheck = []string{
    - 283 + + 19 +
    - + - // + - + // "https://add.your.node.url.here",
    - 284 + + 20 +
    - + - // Solidity: function increment() returns() + - + // "https://add.your.node.url.here",
    - 285 + + 21 +
    - + - func (_CounterAndBlock *CounterAndBlockTransactorSession) Increment() (*types.Transaction, error) { + - + // "https://add.your.node.url.here",
    - 286 + + 22 +
    - + - return _CounterAndBlock.Contract.Increment(&_CounterAndBlock.TransactOpts) + - + }
    - 287 + + 23 +
    - + - } + - +
    -
    + + + 24 + + +
    + - + // set the from and to block numbers you want to verify
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/customModExp/customModExp.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -0,0 +1,224 @@
    - + + 25 -
    -   -
    +
    +
    + - + const fromBlockNumber uint64 = 10
    - + + 26 -
    -   -
    +
    +
    + - + const toBlockNumber uint64 = 20
    - + + 27 -
    -   +
    +
    + -
    - + + 28 -
    -   -
    +
    +
    + - + // pick the correct trusted Node URL depending on the network you are testing
    - + + 29 -
    -   +
    +
    + -
    - + + 30 -
    -   -
    +
    +
    + - + // mainnet
    - + + 31 -
    -   -
    +
    +
    + - + const trustedNodeURL = "https://zkevm-rpc.com"
    - + + 32 -
    -   +
    +
    + -
    - - -
    -   -
    +
    + 33 + +
    + - + // cardona
    - + + 34 -
    -   -
    +
    +
    + - + // const trustedNodeURL = "https://rpc.cardona.zkevm-rpc.com/"
    - + + 35 -
    -   +
    +
    + -
    - + + 36 -
    -   -
    +
    +
    + - + func main() {
    - + + 37 -
    -   -
    +
    +
    + - + fmt.Printf("connecting to network: %v ...", trustedNodeURL)
    - + + 38 -
    -   -
    +
    +
    + - + trustedNodeClient, err := ethclient.Dial(trustedNodeURL)
    - + + 39 -
    -   -
    +
    +
    + - + chkErr(err)
    - + + 40 -
    -   -
    +
    +
    + - + fmt.Print("connected")
    - + + 41 -
    -   -
    +
    +
    + - + fmt.Println()
    - + + 42 -
    -   +
    +
    + -
    - + + 43 -
    -   -
    +
    +
    + - + networkClients := map[string]*ethclient.Client{}
    - + + 44 -
    -   -
    +
    +
    + - + for _, networkURL := range networkURLsToCheck {
    - + + 45 -
    -   -
    +
    +
    + - + fmt.Printf("connecting to network: %v ...", networkURL)
    - + + 46 -
    -   -
    +
    +
    + - + client, err := ethclient.Dial(networkURL)
    - + + 47 -
    -   -
    +
    +
    + - + chkErr(err)
    - + + 48 -
    -   -
    +
    +
    + - + networkClients[networkURL] = client
    - + + 49 -
    -   -
    +
    +
    + - + fmt.Print("connected")
    - + + 50 -
    -   -
    +
    +
    + - + fmt.Println()
    - + + 51 -
    -   -
    +
    +
    + - + }
    - + + 52 -
    -   +
    +
    + -
    - + + 53 -
    -   -
    +
    +
    + - + for blockNumberU64 := fromBlockNumber; blockNumberU64 <= toBlockNumber; blockNumberU64++ {
    - + + 54 -
    -   -
    +
    +
    + - + ctx := context.Background()
    - + + 55 -
    -   -
    +
    +
    + - + blockNumber := big.NewInt(0).SetUint64(blockNumberU64)
    - + + 56 -
    -   -
    +
    +
    + - + fmt.Println()
    - + + 57 -
    -   -
    +
    +
    + - + fmt.Println("block to verify: ", blockNumberU64)
    - + + 58 -
    -   +
    +
    + -
    - + + 59 -
    -   -
    +
    +
    + - + // load blocks from trusted node
    - + + 60 -
    -   -
    +
    +
    + - + trustedNodeBlockHeader, err := trustedNodeClient.HeaderByNumber(ctx, blockNumber)
    - + + 61 -
    -   -
    +
    +
    + - + chkErr(err)
    - + + 62 -
    -   -
    +
    +
    + - + const logPattern = "block: %v hash: %v parentHash: %v network: %v\n"
    - + + 63 -
    -   -
    +
    +
    + - + trustedNodeBlockHash := trustedNodeBlockHeader.Hash().String()
    - + + 64 -
    -   -
    +
    +
    + - + trustedNodeParentBlockHash := trustedNodeBlockHeader.ParentHash.String()
    - + + 65 -
    -   +
    +
    + -
    - + + 66 -
    -   -
    +
    +
    + - + // load blocks from networks to verify
    - + + 67 -
    -   -
    +
    +
    + - + blocks := sync.Map{}
    - + + 68 -
    -   -
    +
    +
    + - + wg := sync.WaitGroup{}
    - + + 69 -
    -   -
    +
    +
    + - + wg.Add(len(networkURLsToCheck))
    - + + 70 -
    -   -
    +
    +
    + - + for _, networkURL := range networkURLsToCheck {
    - + + 71 -
    -   -
    +
    +
    + - + go func(networkURL string) {
    - + + 72 -
    -   -
    +
    +
    + - + defer wg.Done()
    - + + 73 -
    -   -
    +
    +
    + - + c := networkClients[networkURL]
    - + + 74 -
    -   +
    +
    + -
    - + + 75 -
    -   -
    +
    +
    + - + blockHeader, err := c.HeaderByNumber(ctx, blockNumber)
    - + + 76 -
    -   -
    +
    +
    + - + if errors.Is(err, ethereum.NotFound) {
    - + + 77 -
    -   -
    +
    +
    + - + return
    - + + 78 -
    -   -
    +
    +
    + - + } else {
    - + + 79 -
    -   -
    +
    +
    + - + chkErr(err)
    - + + 80 -
    -   -
    +
    +
    + - + }
    - + + 81 -
    -   +
    +
    + -
    - + + 82 -
    -   -
    +
    +
    + - + blocks.Store(networkURL, blockHeader)
    - + + 83 -
    -   -
    +
    +
    + - + }(networkURL)
    - + + 84 -
    -   -
    +
    +
    + - + }
    - + + 85 -
    -   -
    +
    +
    + - + wg.Wait()
    - + + 86 -
    -   +
    +
    + -
    - + + 87 -
    -   -
    +
    +
    + - + failed := false
    - + + 88 -
    -   -
    +
    +
    + - + blocks.Range(func(networkURLValue, blockValue any) bool {
    - + + 89 -
    -   -
    +
    +
    + - + networkURL, block := networkURLValue.(string), blockValue.(*types.Header)
    - + + 90 -
    -   +
    +
    + -
    - + + 91 -
    -   -
    +
    +
    + - + // when block is not found
    - + + 92 -
    -   -
    +
    +
    + - + if block == nil {
    - + + 93 -
    -   -
    +
    +
    + - + fmt.Printf(logPattern, blockNumberU64, "NOT FOUND", "NOT FOUND", networkURL)
    - + + 94 -
    -   -
    +
    +
    + - + return true
    - + + 95 -
    -   -
    +
    +
    + - + }
    - + + 96 -
    -   +
    +
    + -
    - + + 97 -
    -   -
    +
    +
    + - + blockHash := block.Hash().String()
    - + + 98 -
    -   -
    +
    +
    + - + parentBlockHash := block.ParentHash.String()
    - + + 99 -
    -   +
    +
    + -
    - + + 100 -
    -   -
    +
    +
    + - + if trustedNodeBlockHash != blockHash || trustedNodeParentBlockHash != parentBlockHash {
    - + + 101 -
    -   -
    +
    +
    + - + failed = true
    - + + 102 -
    -   -
    +
    +
    + - + fmt.Printf(logPattern, blockNumberU64, trustedNodeBlockHash, trustedNodeParentBlockHash, trustedNodeURL)
    - + + 103 -
    -   -
    +
    +
    + - + fmt.Printf(logPattern, blockNumberU64, blockHash, parentBlockHash, networkURL)
    - + + 104 -
    -   -
    +
    +
    + - + fmt.Printf("ERROR block information mismatch for network: %v\n", networkURL)
    - + + 105 -
    -   -
    +
    +
    + - + } else {
    - + + 106 -
    -   -
    +
    +
    + - + fmt.Printf("%v: OK\n", networkURL)
    - + + 107 -
    -   -
    +
    +
    + - + }
    - + + 108 -
    -   +
    +
    + -
    - + + 109 -
    -   -
    +
    +
    + - + return true
    - + + 110 -
    -   -
    +
    +
    + - + })
    - + + 111 -
    -   -
    +
    +
    + - + if failed {
    - + + 112 -
    -   -
    +
    +
    + - + panic("block information mismatch")
    - + + 113 -
    -   -
    +
    +
    + - + }
    - + + 114 -
    -   +
    +
    + -
    - + + 115 -
    -   -
    +
    +
    + - + // avoid getting blocked by request rate limit
    - + + 116 -
    -   -
    +
    +
    + - + time.Sleep(time.Second)
    - + + 117 -
    -   -
    +
    +
    + - + }
    - + + 118 -
    -   -
    +
    +
    + - + }
    - + + 119 -
    -   +
    +
    + -
    - + + 120 -
    -   -
    +
    +
    + - + func chkErr(err error) {
    - + + 121 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 122 -
    -   -
    +
    +
    + - + panic(err)
    - + + 123 -
    -   -
    +
    +
    + - + }
    - + + 124 -
    -   -
    +
    +
    + - + } +
    +
    +
    +
    +
    + + + + +
    +
     
    @@ -238565,6 +320911,21 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/hash_gen/main.go + RENAMED + +
    +
    @@ -238572,2638 +320933,2870 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    +
    @@ -1,188 +0,0 @@
    + 1 +
    - + - // Code generated - DO NOT EDIT. + - + package main
    + 2 +
    - + - // This file is a generated binding and any manual changes will be lost. + - +
    + 3 +
    - + -
    + - + import (
    + 4 +
    - + - package customModExp + - + "encoding/json"
    + 5 +
    - + -
    + - + "fmt"
    + 6 +
    - + - import ( + - +
    + 7 +
    - + - "errors" + - + "github.com/0xPolygonHermez/zkevm-node/hex"
    + 8 +
    - + - "math/big" + - + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/client"
    + 9 +
    - + - "strings" + - + "github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
    + 10 +
    - + -
    + - + "github.com/0xPolygonHermez/zkevm-node/log"
    + 11 +
    - + - ethereum "github.com/ethereum/go-ethereum" + - + "github.com/ethereum/go-ethereum/common"
    + 12 +
    - + - "github.com/ethereum/go-ethereum/accounts/abi" + - + ethTypes "github.com/ethereum/go-ethereum/core/types"
    + 13 +
    - + - "github.com/ethereum/go-ethereum/accounts/abi/bind" + - + "github.com/ethereum/go-ethereum/trie"
    + 14 +
    - + - "github.com/ethereum/go-ethereum/common" + - + )
    + 15 +
    - + - "github.com/ethereum/go-ethereum/core/types" + - +
    + 16 +
    - + - "github.com/ethereum/go-ethereum/event" + - + const (
    + 17 +
    - + - ) + - + networkURL = "https://zkevm-rpc.com"
    + 18 +
    - + -
    + - + startBlockNumber uint64 = 10
    + 19 +
    - + - // Reference imports to suppress errors if they are not otherwise used. + - + endBlockNumber uint64 = 20
    + 20 +
    - + - var ( + - + )
    + 21 +
    - + - _ = errors.New + - +
    + 22 +
    - + - _ = big.NewInt + - + func main() {
    + 23 +
    - + - _ = strings.NewReader + - + for blockNumber := startBlockNumber; blockNumber <= endBlockNumber; blockNumber++ {
    + 24 +
    - + - _ = ethereum.NotFound + - + printfLn("getting block: %v", blockNumber)
    + 25 +
    - + - _ = bind.Bind + - + blockResponse, err := client.JSONRPCCall(networkURL, "eth_getBlockByNumber", hex.EncodeUint64(blockNumber), true)
    + 26 +
    - + - _ = common.Big1 + - + chkErr(err)
    + 27 +
    - + - _ = types.BloomLookup + - + chkRespErr(blockResponse.Error)
    + 28 +
    - + - _ = event.NewSubscription + - +
    + 29 +
    - + - _ = abi.ConvertType + - + rawBlock := map[string]interface{}{}
    + 30 +
    - + - ) + - + err = json.Unmarshal(blockResponse.Result, &rawBlock)
    + 31 +
    - + -
    + - + chkErr(err)
    + 32 +
    - + - // CustomModExpMetaData contains all meta data concerning the CustomModExp contract. + - +
    + 33 +
    - + - var CustomModExpMetaData = &bind.MetaData{ + - + // create header
    + 34 +
    - + - ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"modExpGeneric\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + - + rawBlockHash := rawBlock["hash"].(string)
    + 35 +
    - + - Bin: "0x608060405234801561001057600080fd5b50610208806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5665d6f14610030575b600080fd5b61004361003e3660046100e2565b610045565b005b61004d6100ad565b6101408183516020850160055afa60009081555b600a8110156100a8578181600a811061007c5761007c610193565b6020020151600482600a811061009457610094610193565b0155806100a0816101a9565b915050610061565b505050565b604051806101400160405280600a906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156100f457600080fd5b813567ffffffffffffffff8082111561010c57600080fd5b818401915084601f83011261012057600080fd5b813581811115610132576101326100cc565b604051601f8201601f19908116603f0116810190838211818310171561015a5761015a6100cc565b8160405282815287602084870101111561017357600080fd5b826020860160208301376000928101602001929092525095945050505050565b634e487b7160e01b600052603260045260246000fd5b60006000198214156101cb57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212206c4940b4c9a7086754420734c8b4921cdb547ec8b31fc3bf8cd884ad9778a5b364736f6c634300080c0033", + - + number := hex.DecodeBig(rawBlock["number"].(string))
    + 36 +
    - + - } + - + parentHash := common.HexToHash(rawBlock["parentHash"].(string))
    + 37 +
    - + -
    + - + coinbase := common.HexToAddress(rawBlock["miner"].(string))
    + 38 +
    - + - // CustomModExpABI is the input ABI used to generate the binding from. + - + root := common.HexToHash(rawBlock["stateRoot"].(string))
    + 39 +
    - + - // Deprecated: Use CustomModExpMetaData.ABI instead. + - + gasUsed := hex.DecodeUint64(rawBlock["gasUsed"].(string))
    + 40 +
    - + - var CustomModExpABI = CustomModExpMetaData.ABI + - + gasLimit := hex.DecodeUint64(rawBlock["gasLimit"].(string))
    + 41 +
    - + -
    + - + timeStamp := hex.DecodeUint64(rawBlock["timestamp"].(string))
    + 42 +
    - + - // CustomModExpBin is the compiled bytecode used for deploying new contracts. + - +
    + 43 +
    - + - // Deprecated: Use CustomModExpMetaData.Bin instead. + - + header := &ethTypes.Header{
    + 44 +
    - + - var CustomModExpBin = CustomModExpMetaData.Bin + - + Number: number, ParentHash: parentHash, Coinbase: coinbase,
    + 45 +
    - + -
    + - + Root: root, GasUsed: gasUsed, GasLimit: gasLimit, Time: timeStamp,
    + 46 +
    - + - // DeployCustomModExp deploys a new Ethereum contract, binding an instance of CustomModExp to it. + - + }
    + 47 +
    - + - func DeployCustomModExp(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CustomModExp, error) { + - +
    + 48 +
    - + - parsed, err := CustomModExpMetaData.GetAbi() + - + // create txs and receipts
    + 49 +
    - + - if err != nil { + - + rawTransactions := rawBlock["transactions"].([]interface{})
    + 50 +
    - + - return common.Address{}, nil, nil, err + - + txs := make([]*ethTypes.Transaction, 0, len(rawTransactions))
    + 51 +
    - + - } + - + receipts := make([]*ethTypes.Receipt, 0, len(rawTransactions))
    + 52 +
    - + - if parsed == nil { + - + for i, rawTransaction := range rawTransactions {
    + 53 +
    - + - return common.Address{}, nil, nil, errors.New("GetABI returned nil") + - + if i == 1 {
    + 54 +
    - + - } + - + continue
    + 55 +
    - + -
    + - + }
    + 56 +
    - + - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CustomModExpBin), backend) + - + rawTransactionMap := rawTransaction.(map[string]interface{})
    + 57 +
    - + - if err != nil { + - +
    + 58 +
    - + - return common.Address{}, nil, nil, err + - + nonce := hex.DecodeUint64(rawTransactionMap["nonce"].(string))
    + 59 +
    - + - } + - + gasPrice := hex.DecodeBig(rawTransactionMap["gasPrice"].(string))
    + 60 +
    - + - return address, tx, &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil + - + gas := hex.DecodeUint64(rawTransactionMap["gas"].(string))
    + 61 +
    - + - } + - + var to *common.Address
    + 62 +
    - + -
    + - + if rawTransactionMap["to"] != nil {
    + 63 +
    - + - // CustomModExp is an auto generated Go binding around an Ethereum contract. + - + aux := common.HexToAddress(rawTransactionMap["to"].(string))
    + 64 +
    - + - type CustomModExp struct { + - + to = &aux
    + 65 +
    - + - CustomModExpCaller // Read-only binding to the contract + - + }
    + 66 +
    - + - CustomModExpTransactor // Write-only binding to the contract + - + value := hex.DecodeBig(rawTransactionMap["value"].(string))
    + 67 +
    - + - CustomModExpFilterer // Log filterer for contract events + - + data, _ := hex.DecodeHex(rawTransactionMap["input"].(string))
    + 68 +
    - + - } + - + v := hex.DecodeBig(rawTransactionMap["v"].(string))
    + 69 +
    - + -
    + - + r := hex.DecodeBig(rawTransactionMap["r"].(string))
    + 70 +
    - + - // CustomModExpCaller is an auto generated read-only Go binding around an Ethereum contract. + - + s := hex.DecodeBig(rawTransactionMap["s"].(string))
    + 71 +
    - + - type CustomModExpCaller struct { + - +
    + 72 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + - + tx := ethTypes.NewTx(&ethTypes.LegacyTx{
    + 73 +
    - + - } + - + Nonce: nonce, GasPrice: gasPrice, Gas: gas, To: to,
    + 74 +
    - + -
    + - + Value: value, Data: data, V: v, R: r, S: s,
    + 75 +
    - + - // CustomModExpTransactor is an auto generated write-only Go binding around an Ethereum contract. + - + })
    + 76 +
    - + - type CustomModExpTransactor struct { + - + txs = append(txs, tx)
    + 77 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + - +
    + 78 +
    - + - } + - + hash := rawTransactionMap["hash"].(string)
    + 79 +
    - + -
    + - + printfLn("getting receipt for tx: %v", hash)
    + 80 +
    - + - // CustomModExpFilterer is an auto generated log filtering Go binding around an Ethereum contract events. + - + receiptResponse, err := client.JSONRPCCall(networkURL, "eth_getTransactionReceipt", hash)
    + 81 +
    - + - type CustomModExpFilterer struct { + - + chkErr(err)
    + 82 +
    - + - contract *bind.BoundContract // Generic contract wrapper for the low level calls + - + chkRespErr(receiptResponse.Error)
    + 83 +
    - + - } + - +
    + 84 +
    - + -
    + - + rawReceipt := map[string]interface{}{}
    + 85 +
    - + - // CustomModExpSession is an auto generated Go binding around an Ethereum contract, + - + err = json.Unmarshal(receiptResponse.Result, &rawReceipt)
    + 86 +
    - + - // with pre-set call and transact options. + - + chkErr(err)
    + 87 +
    - + - type CustomModExpSession struct { + - +
    + 88 +
    - + - Contract *CustomModExp // Generic contract binding to set the session for + - + receiptType := uint8(hex.DecodeUint64(rawReceipt["type"].(string)))
    + 89 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session + - + postState := common.HexToHash(rawReceipt["root"].(string)).Bytes()
    + 90 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session + - + status := hex.DecodeUint64(rawReceipt["status"].(string))
    + 91 +
    - + - } + - + cumulativeGasUsed := hex.DecodeUint64(rawReceipt["cumulativeGasUsed"].(string))
    + 92 +
    - + -
    + - + txHash := common.HexToHash(rawReceipt["transactionHash"].(string))
    + 93 +
    - + - // CustomModExpCallerSession is an auto generated read-only Go binding around an Ethereum contract, + - + var contractAddress common.Address
    + 94 +
    - + - // with pre-set call options. + - + if rawReceipt["contractAddress"] != nil {
    + 95 +
    - + - type CustomModExpCallerSession struct { + - + contractAddress = common.HexToAddress(rawReceipt["contractAddress"].(string))
    + 96 +
    - + - Contract *CustomModExpCaller // Generic contract caller binding to set the session for + - + }
    + 97 +
    - + - CallOpts bind.CallOpts // Call options to use throughout this session + - + gasUsed := hex.DecodeUint64(rawReceipt["gasUsed"].(string))
    + 98 +
    - + - } + - + blockHash := common.HexToHash(rawReceipt["blockHash"].(string))
    + 99 +
    - + -
    + - + blockNumber := hex.DecodeBig(rawReceipt["blockNumber"].(string))
    + 100 +
    - + - // CustomModExpTransactorSession is an auto generated write-only Go binding around an Ethereum contract, + - + transactionIndex := uint(hex.DecodeUint64(rawReceipt["transactionIndex"].(string)))
    + 101 +
    - + - // with pre-set transact options. + - +
    + 102 +
    - + - type CustomModExpTransactorSession struct { + - + receipt := &ethTypes.Receipt{
    + 103 +
    - + - Contract *CustomModExpTransactor // Generic contract transactor binding to set the session for + - + Type: receiptType, PostState: postState, Status: status, CumulativeGasUsed: cumulativeGasUsed,
    + 104 +
    - + - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session + - + TxHash: txHash, ContractAddress: contractAddress, GasUsed: gasUsed,
    + 105 +
    - + - } + - + BlockHash: blockHash, BlockNumber: blockNumber, TransactionIndex: transactionIndex,
    + 106 +
    - + -
    + - + }
    + 107 +
    - + - // CustomModExpRaw is an auto generated low-level Go binding around an Ethereum contract. + - +
    + 108 +
    - + - type CustomModExpRaw struct { + - + rawLogs := rawReceipt["logs"].([]interface{})
    + 109 +
    - + - Contract *CustomModExp // Generic contract binding to access the raw methods on + - + logs := make([]*ethTypes.Log, 0, len(rawLogs))
    + 110 +
    - + - } + - + printfLn("logs: %v", len(rawLogs))
    + 111 +
    - + -
    + - + for _, rawLog := range rawLogs {
    + 112 +
    - + - // CustomModExpCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. + - + rawLogMap := rawLog.(map[string]interface{})
    + 113 +
    - + - type CustomModExpCallerRaw struct { + - +
    + 114 +
    - + - Contract *CustomModExpCaller // Generic read-only contract binding to access the raw methods on + - + address := common.HexToAddress(rawLogMap["address"].(string))
    + 115 +
    - + - } + - + data, _ := hex.DecodeHex(rawLogMap["data"].(string))
    + 116 +
    - + -
    + - + blockNumber := hex.DecodeUint64(rawLogMap["blockNumber"].(string))
    + 117 +
    - + - // CustomModExpTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. + - + txHash := common.HexToHash(rawLogMap["transactionHash"].(string))
    + 118 +
    - + - type CustomModExpTransactorRaw struct { + - + txIndex := uint(hex.DecodeUint64(rawLogMap["transactionIndex"].(string)))
    + 119 +
    - + - Contract *CustomModExpTransactor // Generic write-only contract binding to access the raw methods on + - + blockHash := common.HexToHash(rawLogMap["blockHash"].(string))
    + 120 +
    - + - } + - + index := uint(hex.DecodeUint64(rawLogMap["logIndex"].(string)))
    + 121 +
    - + -
    + - + removed := rawLogMap["removed"].(bool)
    + 122 +
    - + - // NewCustomModExp creates a new instance of CustomModExp, bound to a specific deployed contract. + - +
    + 123 +
    - + - func NewCustomModExp(address common.Address, backend bind.ContractBackend) (*CustomModExp, error) { + - + log := &ethTypes.Log{
    + 124 +
    - + - contract, err := bindCustomModExp(address, backend, backend, backend) + - + Address: address,
    + 125 +
    - + - if err != nil { + - + Data: data,
    + 126 +
    - + - return nil, err + - + BlockNumber: blockNumber,
    + 127 +
    - + - } + - + TxHash: txHash,
    + 128 +
    - + - return &CustomModExp{CustomModExpCaller: CustomModExpCaller{contract: contract}, CustomModExpTransactor: CustomModExpTransactor{contract: contract}, CustomModExpFilterer: CustomModExpFilterer{contract: contract}}, nil + - + TxIndex: txIndex,
    + 129 +
    - + - } + - + BlockHash: blockHash,
    + 130 +
    - + -
    + - + Index: index,
    + 131 +
    - + - // NewCustomModExpCaller creates a new read-only instance of CustomModExp, bound to a specific deployed contract. + - + Removed: removed,
    + 132 +
    - + - func NewCustomModExpCaller(address common.Address, caller bind.ContractCaller) (*CustomModExpCaller, error) { + - + }
    + 133 +
    - + - contract, err := bindCustomModExp(address, caller, nil, nil) + - + logs = append(logs, log)
    + 134 +
    - + - if err != nil { + - +
    + 135 +
    - + - return nil, err + - + rawTopics := rawLogMap["topics"].([]interface{})
    + 136 +
    - + - } + - + topics := make([]common.Hash, 0, len(rawTopics))
    + 137 +
    - + - return &CustomModExpCaller{contract: contract}, nil + - + for _, rawTopic := range rawTopics {
    + 138 +
    - + - } + - + topic := common.HexToHash(rawTopic.(string))
    + 139 +
    - + -
    + - + topics = append(topics, topic)
    + 140 +
    - + - // NewCustomModExpTransactor creates a new write-only instance of CustomModExp, bound to a specific deployed contract. + - + }
    + 141 +
    - + - func NewCustomModExpTransactor(address common.Address, transactor bind.ContractTransactor) (*CustomModExpTransactor, error) { + - + log.Topics = topics
    + 142 +
    - + - contract, err := bindCustomModExp(address, nil, transactor, nil) + - + }
    + 143 +
    - + - if err != nil { + - + receipt.Logs = logs
    + 144 +
    - + - return nil, err + - +
    + 145 +
    - + - } + - + // RPC is not setting the receipt bloom when computing the block hash
    + 146 +
    - + - return &CustomModExpTransactor{contract: contract}, nil + - + // receipt.Bloom = ethTypes.CreateBloom([]*ethTypes.Receipt{receipt})
    + 147 +
    - + - } + - +
    + 148 +
    - + -
    + - + receipts = append(receipts, receipt)
    + 149 +
    - + - // NewCustomModExpFilterer creates a new log filterer instance of CustomModExp, bound to a specific deployed contract. + - + }
    + 150 +
    - + - func NewCustomModExpFilterer(address common.Address, filterer bind.ContractFilterer) (*CustomModExpFilterer, error) { + - +
    + 151 +
    - + - contract, err := bindCustomModExp(address, nil, nil, filterer) + - + uncles := []*ethTypes.Header{}
    + 152 +
    - + - if err != nil { + - +
    + 153 +
    - + - return nil, err + - + builtBlock := ethTypes.NewBlock(header, txs, uncles, receipts, &trie.StackTrie{})
    + 154 +
    - + - } + - +
    + 155 +
    - + - return &CustomModExpFilterer{contract: contract}, nil + - + match := rawBlockHash == builtBlock.Hash().String()
    + 156 +
    - + - } + - +
    + 157 +
    - + -
    + - + log.Infof(" RPC block hash: %v", rawBlockHash)
    + 158 +
    - + - // bindCustomModExp binds a generic wrapper to an already deployed contract. + - + log.Infof("Computed block hash: %v", builtBlock.Hash().String())
    + 159 +
    - + - func bindCustomModExp(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + - + if !match {
    + 160 +
    - + - parsed, err := CustomModExpMetaData.GetAbi() + - + log.Errorf(" block hashes DO NOT match")
    + 161 +
    - + - if err != nil { + - + } else {
    + 162 +
    - + - return nil, err + - + log.Infof(" block hashes MATCH")
    + 163 +
    - + - } + - + }
    + 164 +
    - + - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + - + }
    + 165 +
    - + + - }
    + 166 +
    - + + -
    + 167 +
    - + - // Call invokes the (constant) contract method with params as input values and + - + func chkRespErr(err *types.ErrorObject) {
    + 168 +
    - + - // sets the output to result. The result type might be a single field for simple + - + if err != nil {
    + 169 +
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named + - + errMsg := fmt.Sprintf("%v %v", err.Code, err.Message)
    + 170 +
    - + - // returns. + - + errorfLn(errMsg)
    + 171 +
    - + - func (_CustomModExp *CustomModExpRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + - + panic(err)
    + 172 +
    - + - return _CustomModExp.Contract.CustomModExpCaller.contract.Call(opts, result, method, params...) + - + }
    + 173 +
    - + + - + } +
    +
    + 174 + +
    + - +
    +
    +
    + 175 + +
    + - + func chkErr(err error) { +
    +
    + 176 + +
    + - + if err != nil { +
    +
    + 177 + +
    + - + errorfLn(err.Error()) +
    +
    + 178 + +
    + - + panic(err) +
    +
    + 179 + +
    + - + } +
    +
    + 180 + +
    + - + } +
    +
    + 181 + +
    + - +
    +
    +
    + 182 + +
    + - + func errorfLn(format string, args ...interface{}) { +
    +
    + 183 + +
    + - + printfLn("ERROR: "+format, args...) +
    +
    + 184 + +
    + - + } +
    +
    + 185 + +
    + - +
    +
    +
    + 186 + +
    + - + func printfLn(format string, args ...interface{}) { +
    +
    + 187 + +
    + - + fmt.Printf(format+" \n", args...) +
    +
    + 188 + +
    + - }
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    +
     
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    - 174 + + -
    - + +
    +
    +  
    - 175 + + -
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    +   +
    - 176 + + -
    - + - // its default method if one is available. +
    +
    +   +
    - 177 + + -
    - + - func (_CustomModExp *CustomModExpRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    +   +
    - 178 + + -
    - + - return _CustomModExp.Contract.CustomModExpTransactor.contract.Transfer(opts) +
    +
    +   +
    - 179 + + -
    - + - } +
    +
    +   +
    - 180 + + -
    - + +
    +
    +  
    - 181 + + -
    - + - // Transact invokes the (paid) contract method with params as input values. +
    +
    +   +
    - 182 + + -
    - + - func (_CustomModExp *CustomModExpRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    +   +
    - 183 + + -
    - + - return _CustomModExp.Contract.CustomModExpTransactor.contract.Transact(opts, method, params...) +
    +
    +   +
    - 184 + + -
    - + - } +
    +
    +   +
    - 185 + + -
    - + +
    +
    +  
    - 186 + + -
    - + - // Call invokes the (constant) contract method with params as input values and +
    +
    +   +
    - 187 + + -
    - + - // sets the output to result. The result type might be a single field for simple +
    +
    +   +
    - 188 + + -
    - + - // returns, a slice of interfaces for anonymous returns and a struct for named +
    +
    +   +
    - 189 + + -
    - + - // returns. +
    +
    +   +
    - 190 + + -
    - + - func (_CustomModExp *CustomModExpCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { +
    +
    +   +
    - 191 + + -
    - + - return _CustomModExp.Contract.contract.Call(opts, result, method, params...) +
    +
    +   +
    - 192 + + -
    - + - } +
    +
    +   +
    - 193 + + -
    - + +
    +
    +  
    - 194 + + -
    - + - // Transfer initiates a plain transaction to move funds to the contract, calling +
    +
    +   +
    - 195 + + -
    - + - // its default method if one is available. +
    +
    +   +
    - 196 + + -
    - + - func (_CustomModExp *CustomModExpTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { +
    +
    +   +
    - 197 + + -
    - + - return _CustomModExp.Contract.contract.Transfer(opts) +
    +
    +   +
    - 198 + + -
    - + - } +
    +
    +   +
    - 199 + + -
    - + +
    +
    +  
    - 200 + + -
    - + - // Transact invokes the (paid) contract method with params as input values. +
    +
    +   +
    - 201 + + -
    - + - func (_CustomModExp *CustomModExpTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { +
    +
    +   +
    - 202 + + -
    - + - return _CustomModExp.Contract.contract.Transact(opts, method, params...) +
    +
    +   +
    - 203 + + -
    - + - } +
    +
    +   +
    - 204 + + -
    - + +
    +
    +  
    - 205 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 206 + + -
    - + - // +
    +
    +   +
    - 207 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 208 + + -
    - + - func (_CustomModExp *CustomModExpTransactor) ModExpGeneric(opts *bind.TransactOpts, input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 209 + + -
    - + - return _CustomModExp.contract.Transact(opts, "modExpGeneric", input) +
    +
    +   +
    - 210 + + -
    - + - } +
    +
    +   +
    - 211 + + -
    - + +
    +
    +  
    - 212 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 213 + + -
    - + - // +
    +
    +   +
    - 214 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 215 + + -
    - + - func (_CustomModExp *CustomModExpSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 216 + + -
    - + - return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    +   +
    - 217 + + -
    - + - } +
    +
    +   +
    - 218 + + -
    - + +
    +
    +  
    - 219 + + -
    - + - // ModExpGeneric is a paid mutator transaction binding the contract method 0xd5665d6f. +
    +
    +   +
    - 220 + + -
    - + - // +
    +
    +   +
    - 221 + + -
    - + - // Solidity: function modExpGeneric(bytes input) returns() +
    +
    +   +
    - 222 + + -
    - + - func (_CustomModExp *CustomModExpTransactorSession) ModExpGeneric(input []byte) (*types.Transaction, error) { +
    +
    +   +
    - 223 + + -
    - + - return _CustomModExp.Contract.ModExpGeneric(&_CustomModExp.TransactOpts, input) +
    +
    +   +
    - 224 - -
    - + - } -
    +
    +
    -
    + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/contracts/bin/triggerErrors/triggerErrors.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -32,7 +32,7 @@
    - 32 + + -
    +
    +
      - // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. +
    - 33 + + -
    +
    +
      - var TriggerErrorsMetaData = &bind.MetaData{ +
    - 34 + + -
    +
    +
      - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    - 35 + + -
    - - - Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea264697066735822122097beacfaa873e4896937143dfea406cc278b929a28023f7e7020b6dea6e9fc7364736f6c634300080c0033", +
    +
    +   +
    - 36 + + -
    +
    +
      - } +
    - 37 + + -
    +
    +
     
    - 38 + + -
    +
    +
      - // TriggerErrorsABI is the input ABI used to generate the binding from. -
    -
    -
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 32 + + -
    +
    +
      - // TriggerErrorsMetaData contains all meta data concerning the TriggerErrors contract. +
    - 33 + + -
    +
    +
      - var TriggerErrorsMetaData = &bind.MetaData{ +
    - 34 + + -
    +
    +
      - ABI: "[{\"inputs\":[],\"name\":\"count\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersKeccaks\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"test\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersPoseidon\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfCountersSteps\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"outOfGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +
    - 35 + + -
    - + - Bin: "0x60806040526000805534801561001457600080fd5b5061016c806100246000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306661abd1461005c5780632621002a1461007757806331fe52e8146100835780638bd7b5381461008d578063cb4e8cd114610095575b600080fd5b61006560005481565b60405190815260200160405180910390f35b620f4240600020610065565b61008b61009d565b005b61008b6100c3565b61008b6100e9565b60005b60648110156100c0578060005580806100b89061010d565b9150506100a0565b50565b60005b620186a08110156100c0576104d2600052806100e18161010d565b9150506100c6565b60005b61c3508110156100c0578060005580806101059061010d565b9150506100ec565b600060001982141561012f57634e487b7160e01b600052601160045260246000fd5b506001019056fea26469706673582212208f01c5dc055b1f376f5da5deb33e2c96ee776174bf48874c5ebba0f606de2ac564736f6c634300080c0033", +
    +
    +   +
    - 36 + + -
    +
    +
      - } +
    - 37 + + -
    +
    +
     
    - 38 + + -
    +
    +
      - // TriggerErrorsABI is the input ABI used to generate the binding from. -
    -
    -
    +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/docker-compose.yml - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - @@ -241227,68 +323820,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - @@ -241312,143 +323910,123 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -241931,1913 +324509,1858 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -2,7 +2,7 @@
    - 2 + + -
    +
    +
      - networks: +
    - 3 + + -
    +
    +
      - default: +
    - 4 + + -
    +
    +
      - name: zkevm +
    - 5 + + -
    - - - +
    +
    +   +
    - 6 + + -
    +
    +
      - services: +
    - 7 + + -
    +
    +
      - grafana: +
    - 8 + + -
    +
    +
      - container_name: grafana +
    -
    @@ -453,7 +453,7 @@
    +
    + + +
    +   +
    +
    - 453 + + -
    +
    +
     
    - 454 + + -
    +
    +
      - zkevm-mock-l1-network: +
    - 455 + + -
    +
    +
      - container_name: zkevm-mock-l1-network +
    - 456 + + -
    - - - image: hermeznetwork/geth-zkevm-contracts:v2.1.3-fork.8-geth1.12.0 +
    +
    +   +
    - 457 + + -
    +
    +
      - ports: +
    - 458 + + -
    +
    +
      - - 8545:8545 +
    - 459 + + -
    +
    +
      - - 8546:8546 +
    -
    @@ -519,6 +519,8 @@
    +
    + + +
    +   +
    +
    - 519 + + -
    +
    +
      - - 50071:50071 # Executor +
    - 520 + + -
    +
    +
      - volumes: +
    - 521 + + -
    +
    +
      - - ./config/test.prover.config.json:/usr/src/app/config.json +
    - 522 + + -
    +
    +
      - command: > +
    - 523 + + -
    +
    +
      - zkProver -c /usr/src/app/config.json +
    - 524 + + -
    +
    +
     
    -
    @@ -610,6 +612,8 @@
    +
    + + +
    +   +
    +
    - 610 + + -
    +
    +
      - - 50078:50071 # Executor +
    - 611 + + -
    +
    +
      - volumes: +
    - 612 + + -
    +
    +
      - - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json +
    - 613 + + -
    +
    +
      - command: > +
    - 614 + + -
    +
    +
      - zkProver -c /usr/src/app/config.json +
    - 615 + + -
    +
    +
     
    -
    @@ -628,7 +632,7 @@
    -
    - 628 + + -
    +
    +
      - zkevm-sh: +
    - 629 + + -
    +
    +
      - container_name: zkevm-sh +
    - 630 + + -
    +
    +
      - image: zkevm-node -
    -
    - 631 - -
    - - - stdin_open: true +
    - 632 + + -
    +
    +
      - tty: true +
    - 633 + + -
    +
    +
      - environment: +
    - 634 + + -
    +
    +
      - - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db +
    -
    @@ -638,3 +642,51 @@
    -
    - 638 + + -
    +
    +
      - - ./config/test.genesis.config.json:/app/genesis.json +
    - 639 + + -
    +
    +
      - command: +
    - 640 + + -
    +
    +
      - - "/bin/sh" +
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + + +
    -
     
    -
    - 2 + + -
    +
    +
      - networks: +
    - 3 + + -
    +
    +
      - default: +
    - 4 + + -
    +
    +
      - name: zkevm -
    -
    - 5 - -
    - +
    - 6 + + -
    +
    +
      - services: +
    - 7 + + -
    +
    +
      - grafana: +
    - 8 + + -
    +
    +
      - container_name: grafana +
    -
     
    -
    - 453 + + -
    +
    +
     
    - 454 + + -
    +
    +
      - zkevm-mock-l1-network: +
    - 455 + + -
    +
    +
      - container_name: zkevm-mock-l1-network -
    -
    - 456 - -
    - + - image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.14.3 +
    - 457 + + -
    +
    +
      - ports: +
    - 458 + + -
    +
    +
      - - 8545:8545 +
    - 459 + + -
    +
    +
      - - 8546:8546 +
    -
     
    -
    - 519 + + -
    +
    +
      - - 50071:50071 # Executor +
    - 520 + + -
    +
    +
      - volumes: +
    - 521 - -
    +
    + + +
      - - ./config/test.prover.config.json:/usr/src/app/config.json +
    - 522 + + -
    - + - environment: +
    +
    +   +
    - 523 + + -
    - + - - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 +
    +
    +   +
    - 524 + + -
    +
    +
      - command: > +
    - 525 + + -
    +
    +
      - zkProver -c /usr/src/app/config.json +
    - 526 + + -
    +
    +
     
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/http_ws_sync/main.go + RENAMED + +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    @@ -1,161 +0,0 @@
    - 612 + + 1 +
    -   - - 50078:50071 # Executor + - + package main
    - 613 + + 2 +
    -   - volumes: + - +
    - 614 + + 3 +
    -   - - ./config/test.permissionless.prover.config.json:/usr/src/app/config.json + - + import (
    - 615 + + 4 +
    - + - environment: + - + "context"
    - 616 + + 5 +
    - + - - EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1 + - + "fmt"
    - 617 + + 6 +
    -   - command: > + - + "math/big"
    - 618 + + 7 +
    -   - zkProver -c /usr/src/app/config.json + - + "os"
    - 619 + + 8 +
    -   -
    + - + "os/signal"
    -
     
    -
    - 632 + + 9 +
    -   - zkevm-sh: + - + "sync"
    - 633 + + 10 +
    -   - container_name: zkevm-sh + - + "sync/atomic"
    - 634 + + 11 +
    -   - image: zkevm-node + - + "syscall"
    - 635 + + 12 +
    - + - stdin_open: true + - + "time"
    - 636 + + 13 +
    -   - tty: true + - +
    - 637 + + 14 +
    -   - environment: + - + "github.com/ethereum/go-ethereum"
    - 638 + + 15 +
    -   - - ZKEVM_NODE_STATE_DB_HOST=zkevm-state-db + - + "github.com/ethereum/go-ethereum/core/types"
    -
     
    -
    - 642 + + 16 +
    -   - - ./config/test.genesis.config.json:/app/genesis.json + - + "github.com/ethereum/go-ethereum/ethclient"
    - 643 + + 17 +
    -   - command: + - + "github.com/ethereum/go-ethereum/rpc"
    - 644 + + 18 +
    -   - - "/bin/sh" + - + )
    - 645 + + 19 +
    - + + -
    - 646 + + 20 +
    - + - zkevm-node-forced-DAC: + - + func main() {
    - 647 + + 21 +
    - + - container_name: zkevm-node-forced-DAC + - + const httpUrl = "https://zkevm-rpc.com"
    - 648 + + 22 +
    - + - image: zkevm-node + - + const wsUrl = "wss://ws.zkevm-rpc.com"
    - 649 + + 23 +
    - + - ports: + - +
    - 650 + + 24 +
    - + - - 8125:8125 + - + const numberOfConnections = 10
    - 651 + + 25 +
    - + - environment: + - + const intervalToCheckBlockNumber = 2 * time.Second
    - 652 + + 26 +
    - + - - ZKEVM_NODE_ISTRUSTEDSEQUENCER=false + - +
    - 653 + + 27 +
    - + - - ZKEVM_NODE_STATEDB_USER=test_user + - + const enableLogSubscription = true
    - 654 + + 28 +
    - + - - ZKEVM_NODE_STATEDB_PASSWORD=test_password + - +
    - 655 + + 29 +
    - + - - ZKEVM_NODE_STATEDB_NAME=state_db + - + wg := sync.WaitGroup{}
    - 656 + + 30 +
    - + - - ZKEVM_NODE_STATEDB_HOST=zkevm-permissionless-db + - + wg.Add(numberOfConnections)
    - 657 + + 31 +
    - + - - ZKEVM_NODE_POOL_DB_USER=test_user + - + for connID := 0; connID < numberOfConnections; connID++ {
    - 658 + + 32 +
    - + - - ZKEVM_NODE_POOL_DB_PASSWORD=test_password + - + go func(connID int) {
    - 659 + + 33 +
    - + - - ZKEVM_NODE_POOL_DB_NAME=pool_db + - + ctx := context.Background()
    - 660 + + 34 +
    - + - - ZKEVM_NODE_POOL_DB_HOST=zkevm-permissionless-db + - +
    - 661 + + 35 +
    - + - - ZKEVM_NODE_RPC_PORT=8125 + - + logf(connID, "connecting to: %v\n", httpUrl)
    - 662 + + 36 +
    - + - - ZKEVM_NODE_RPC_SEQUENCERNODEURI=http://zkevm-node-json-rpc:8123 + - + httpClient, err := ethclient.Dial(httpUrl)
    - 663 + + 37 +
    - + - - ZKEVM_NODE_SYNCHRONIZER_TRUSTEDSEQUENCERURL=http://you-cant-touch-this:8123 + - + chkErr(connID, err)
    - 664 + + 38 +
    - + - - ZKEVM_NODE_MTCLIENT_URI=zkevm-permissionless-prover:50061 + - + logf(connID, "connected to: %v\n", httpUrl)
    - 665 + + 39 +
    - + - - ZKEVM_NODE_EXECUTOR_URI=zkevm-permissionless-prover:50071 + - +
    - 666 + + 40 +
    - + - volumes: + - + latestBlockNumber, err := httpClient.BlockNumber(ctx)
    - 667 + + 41 +
    - + - - ./config/test.node.config.toml:/app/config.toml + - + chkErr(connID, err)
    - 668 + + 42 +
    - + - - ./config/test.genesis.config.json:/app/genesis.json + - +
    - 669 + + 43 +
    - + - command: + - + logf(connID, "connecting to: %v\n", wsUrl)
    - 670 + + 44 +
    - + - - "/bin/sh" + - + wsClient, err := ethclient.Dial(wsUrl)
    - 671 + + 45 +
    - + - - "-c" + - + chkErr(connID, err)
    - 672 + + 46 +
    - + - - "/app/zkevm-node run --network custom --custom-network-file /app/genesis.json --cfg /app/config.toml --components \"rpc,synchronizer\"" + - + logf(connID, "connected to: %v\n", wsUrl)
    - 673 + + 47 +
    - + + -
    - 674 + + 48 +
    - + - zkevm-data-node-db: + - + signals := make(chan os.Signal, 100)
    - 675 + + 49 +
    - + - container_name: zkevm-data-node-db + - + signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
    - 676 + + 50 +
    - + - restart: unless-stopped + - +
    - 677 + + 51 +
    - + - image: postgres + - + lastWSBlockNumber := uint64(0)
    - 678 + + 52 +
    - + - healthcheck: + - + numberOfLogsReceived := uint64(0)
    - 679 + + 53 +
    - + - test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] + - +
    - 680 + + 54 +
    - + - interval: 10s + - + // concurrently check block synchronization and logs received
    - 681 + + 55 +
    - + - timeout: 5s + - + go func(connID int, httpClient *ethclient.Client) {
    - 682 + + 56 +
    - + - retries: 5 + - + for {
    - 683 + + 57 +
    - + - ports: + - + if lastWSBlockNumber != 0 {
    - 684 + + 58 +
    - + - - 5444:5432 + - + httpBlockNumber, err := httpClient.BlockNumber(ctx)
    - 685 + + 59 +
    - + - environment: + - + if err != nil {
    - 686 + + 60 +
    - + - - POSTGRES_USER=committee_user + - + logf(connID, "%v failed to check block sync, retrying...\n", time.Now().Format(time.RFC3339Nano))
    - 687 + + 61 +
    - + - - POSTGRES_PASSWORD=committee_password + - + time.Sleep(intervalToCheckBlockNumber)
    - 688 + + 62 +
    - + - - POSTGRES_DB=committee_db + - + continue
    - 689 + + 63 +
    - + - command: + - + }
    - 690 + + 64 +
    - + - - "postgres" + - +
    - 691 + + 65 +
    - + - - "-N" + - + wsBlockNumber := atomic.LoadUint64(&lastWSBlockNumber)
    - 692 + + 66 +
    - + - - "500" -
    -
    -
    + - +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/datacommittee_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    -
    @@ -0,0 +1,270 @@
    - + + 67 -
    -   -
    +
    +
    + - + diff := httpBlockNumber - wsBlockNumber
    - + + 68 -
    -   -
    +
    +
    + - + logf(connID, "%v wsBlockNumber: %v httpBlockNumber: %v diff: %v\n", time.Now().Format(time.RFC3339Nano), wsBlockNumber, httpBlockNumber, diff)
    - + + 69 -
    -   -
    +
    +
    + - + }
    - + + 70 -
    -   -
    +
    +
    + - + if numberOfLogsReceived > 0 {
    - + + 71 -
    -   -
    +
    +
    + - + logf(connID, "%v logs received: %v\n", time.Now().Format(time.RFC3339Nano), numberOfLogsReceived)
    - + + 72 -
    -   -
    +
    +
    + - + }
    - + + 73 -
    -   +
    +
    + -
    - + + 74 -
    -   -
    +
    +
    + - + time.Sleep(intervalToCheckBlockNumber)
    - + + 75 -
    -   -
    +
    +
    + - + }
    - + + 76 -
    -   -
    +
    +
    + - + }(connID, httpClient)
    - + + 77 -
    -   +
    +
    + -
    - + + 78 -
    -   -
    +
    +
    + - + newHeaders := make(chan *types.Header)
    - + + 79 -
    -   -
    +
    +
    + - + subHeaders, err := wsClient.SubscribeNewHead(ctx, newHeaders)
    - + + 80 -
    -   -
    +
    +
    + - + chkErr(connID, err)
    - + + 81 -
    -   -
    +
    +
    + - + logf(connID, "subscribed to newHeads\n")
    - + + 82 -
    -   +
    +
    + -
    - + + 83 -
    -   -
    +
    +
    + - + newLogs := make(chan types.Log)
    - + + 84 -
    -   -
    +
    +
    + - + var subLogs ethereum.Subscription = &rpc.ClientSubscription{}
    - + + 85 -
    -   -
    +
    +
    + - + if enableLogSubscription {
    - + + 86 -
    -   -
    +
    +
    + - + subLogs, err = wsClient.SubscribeFilterLogs(ctx, ethereum.FilterQuery{
    - + + 87 -
    -   -
    +
    +
    + - + FromBlock: big.NewInt(0).SetUint64(latestBlockNumber),
    - + + 88 -
    -   -
    +
    +
    + - + ToBlock: big.NewInt(0).SetUint64(latestBlockNumber + 10000),
    - + + 89 -
    -   -
    +
    +
    + - + }, newLogs)
    - + + 90 -
    -   -
    +
    +
    + - + chkErr(connID, err)
    - + + 91 -
    -   -
    +
    +
    + - + logf(connID, "subscribed to filterLogs\n")
    - - -
    -   -
    +
    + 92 + +
    + - + }
    - + + 93 -
    -   +
    +
    + -
    - + + 94 -
    -   -
    +
    +
    + - + // concurrently infinite sending messages
    - + + 95 -
    -   -
    +
    +
    + - + go func(connID int, ctx context.Context, wsClient *ethclient.Client) {
    - + + 96 -
    -   -
    +
    +
    + - + for {
    - + + 97 -
    -   -
    +
    +
    + - + //bn, err := wsClient.BlockNumber(ctx)
    - + + 98 -
    -   -
    +
    +
    + - + _, err := wsClient.BlockNumber(ctx)
    - + + 99 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 100 -
    -   -
    +
    +
    + - + errorf(connID, "ERROR: %v\n", err.Error())
    - + + 101 -
    -   -
    +
    +
    + - + }
    - + + 102 -
    -   -
    +
    +
    + - + // logf(connID, "block number retrieved via message: %v\n", bn)
    - + + 103 -
    -   -
    +
    +
    + - + time.Sleep(time.Second)
    - + + 104 -
    -   -
    +
    +
    + - + }
    - + + 105 -
    -   -
    +
    +
    + - + }(connID, ctx, wsClient)
    - + + 106 -
    -   +
    +
    + -
    - + + 107 -
    -   -
    +
    +
    + - + out:
    - + + 108 -
    -   -
    +
    +
    + - + for {
    - + + 109 -
    -   -
    +
    +
    + - + select {
    - + + 110 -
    -   -
    +
    +
    + - + case err := <-subHeaders.Err():
    - + + 111 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 112 -
    -   -
    +
    +
    + - + errorf(connID, "%v\n", err.Error())
    - + + 113 -
    -   -
    +
    +
    + - + wg.Done()
    - + + 114 -
    -   -
    +
    +
    + - + break out
    - + + 115 -
    -   -
    +
    +
    + - + }
    - + + 116 -
    -   -
    +
    +
    + - + case err := <-subLogs.Err():
    - + + 117 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 118 -
    -   -
    +
    +
    + - + errorf(connID, "%v\n", err.Error())
    - + + 119 -
    -   -
    +
    +
    + - + wg.Done()
    - + + 120 -
    -   -
    +
    +
    + - + break out
    - + + 121 -
    -   -
    +
    +
    + - + }
    - + + 122 -
    -   -
    +
    +
    + - + case header := <-newHeaders:
    - + + 123 -
    -   -
    +
    +
    + - + atomic.StoreUint64(&lastWSBlockNumber, header.Number.Uint64())
    - + + 124 -
    -   -
    +
    +
    + - + // logf(connID, "%v L2 Block Received: %v\n", time.Now().Format(time.RFC3339Nano), header.Number.Uint64())
    - + + 125 -
    -   -
    +
    +
    + - + case <-newLogs:
    - + + 126 -
    -   -
    +
    +
    + - + atomic.AddUint64(&numberOfLogsReceived, 1)
    - + + 127 -
    -   -
    +
    +
    + - + // logf(connID, "%v Log Received: %v - %v\n", time.Now().Format(time.RFC3339Nano), log.TxHash.String(), log.Index)
    - + + 128 -
    -   -
    +
    +
    + - + case <-signals:
    - + + 129 -
    -   -
    +
    +
    + - + subHeaders.Unsubscribe()
    - + + 130 -
    -   -
    +
    +
    + - + if enableLogSubscription {
    - + + 131 -
    -   -
    +
    +
    + - + subLogs.Unsubscribe()
    - + + 132 -
    -   -
    +
    +
    + - + }
    - + + 133 -
    -   -
    +
    +
    + - + logf(connID, "unsubscribed\n")
    - + + 134 -
    -   -
    +
    +
    + - + close(newHeaders)
    - + + 135 -
    -   -
    +
    +
    + - + close(newLogs)
    - + + 136 -
    -   -
    +
    +
    + - + wg.Done()
    - + + 137 -
    -   -
    +
    +
    + - + break out
    - + + 138 -
    -   -
    +
    +
    + - + }
    - + + 139 -
    -   -
    +
    +
    + - + }
    - + + 140 -
    -   -
    +
    +
    + - + }(connID)
    - + + 141 -
    -   -
    +
    +
    + - + }
    - + + 142 -
    -   -
    +
    +
    + - + wg.Wait()
    - + + 143 -
    -   -
    +
    +
    + - + }
    - + + 144 -
    -   +
    +
    + -
    - + + 145 -
    -   -
    +
    +
    + - + func chkErr(connID int, err error) {
    - + + 146 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 147 -
    -   -
    +
    +
    + - + errorf(connID, err.Error())
    - + + 148 -
    -   -
    +
    +
    + - + os.Exit(0)
    - + + 149 -
    -   -
    +
    +
    + - + }
    - + + 150 -
    -   -
    +
    +
    + - + }
    - + + 151 -
    -   +
    +
    + -
    - + + 152 -
    -   -
    +
    +
    + - + func logf(connID int, format string, args ...any) {
    - + + 153 -
    -   -
    +
    +
    + - + msg := fmt.Sprintf(format, args...)
    - + + 154 -
    -   -
    +
    +
    + - + fmt.Printf("[connID: %v] %v", connID, msg)
    - + + 155 -
    -   -
    +
    +
    + - + }
    - + + 156 -
    -   +
    +
    + -
    - + + 157 -
    -   -
    +
    +
    + - + func errorf(connID int, format string, args ...any) {
    - + + 158 -
    -   -
    +
    +
    + - + msg := fmt.Sprintf(format, args...)
    - + + 159 -
    -   -
    +
    +
    + - + msg = fmt.Sprintf("*****ERROR: %v", msg)
    - + + 160 -
    -   -
    +
    +
    + - + logf(connID, msg)
    - + + 161 -
    -   -
    +
    +
    + - + }
    - - -
    -   -
    +
    +
    +
    +
    + + + + + + + +
    +
     
    @@ -245449,134 +327972,163 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/sendForcedBatch/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -245594,2702 +328146,2814 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    - - - - - - - - - - - - - - + + + - - - - - - - - - - + + +
    +
    @@ -125,13 +125,13 @@
    +
    - + + 125 -
    +
    +
      -
    + }
    - + + 126 -
    +
    +
      -
    + // Create smc client
    - + + 127 -
    +
    +
      -
    + zkevmAddr := common.HexToAddress(cliCtx.String(flagZkevmAddrName))
    - + + 128 -
    -   -
    +
    +
    + - + zkevm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(zkevmAddr, ethClient)
    - + + 129 -
    +
    +
      -
    + if err != nil {
    - + + 130 -
    +
    +
      -
    + return err
    - + + 131 -
    +
    +
      -
    + }
    - + + 132 -
    +
    +
     
    - + + 133 -
    +
    +
      -
    + rollupManagerAddr := common.HexToAddress(cliCtx.String(flagRollupManagerAddrName))
    - + + 134 -
    -   -
    +
    +
    + - + rollupManager, err := etrogpolygonrollupmanager.NewEtrogpolygonrollupmanager(rollupManagerAddr, ethClient)
    - + + 135 -
    +
    +
      -
    + if err != nil {
    - + + 136 -
    +
    +
      -
    + return err
    - + + 137 -
    +
    +
      -
    + }
    - 1 + + 125 +
    - + - package e2e +   + }
    - 2 + + 126 +
    - + -
    +   + // Create smc client
    - 3 + + 127 +
    - + - import ( +   + zkevmAddr := common.HexToAddress(cliCtx.String(flagZkevmAddrName))
    - 4 + + 128 +
    + - "context" + zkevm, err := polygonzkevm.NewPolygonzkevm(zkevmAddr, ethClient)
    - 5 + + 129 +
    - + - "crypto/ecdsa" +   + if err != nil {
    - 6 + + 130 +
    - + - "encoding/json" +   + return err
    - 7 + + 131 +
    - + - "fmt" +   + } +
    +
    + 132 + +
    +   +
    - 8 + + 133 +
    - + - "math/big" +   + rollupManagerAddr := common.HexToAddress(cliCtx.String(flagRollupManagerAddrName))
    - 9 + + 134 +
    + - "os" + rollupManager, err := polygonrollupmanager.NewPolygonrollupmanager(rollupManagerAddr, ethClient)
    - 10 + + 135 +
    - + - "os/exec" +   + if err != nil {
    - 11 + + 136 +
    - + - "sort" +   + return err
    - 12 + + 137 +
    - + - "strconv" +   + } +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/sequenceForcedBatch/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
    @@ -98,8 +98,8 @@
    - 13 + + 98 +
    - + - "strings" +   + return err
    - 14 + + 99 +
    - + - "testing" +   + }
    - 15 + + 100 +
    - + - "time" +   + // Create smc client
    - 16 + + 101 +
    - + -
    + - + zkevmAddr := common.HexToAddress(cliCtx.String(flagSmcAddrName))
    - 17 + + 102 +
    - + - "github.com/0xPolygon/cdk-data-availability/config" + - + zkevm, err := etrogpolygonzkevm.NewEtrogpolygonzkevm(zkevmAddr, ethClient)
    - 18 + + 103 +
    - + - cTypes "github.com/0xPolygon/cdk-data-availability/config/types" +   + if err != nil {
    - 19 + + 104 +
    - + - "github.com/0xPolygon/cdk-data-availability/db" +   + return err
    - 20 + + 105 +
    - + - "github.com/0xPolygon/cdk-data-availability/rpc" +   + }
    - 21 + +
    @@ -111,7 +111,7 @@
    +
    + 111 +
    - + - "github.com/0xPolygonHermez/zkevm-node/etherman/smartcontracts/polygondatacommittee" +   +
    - 22 + + 112 +
    - + - "github.com/0xPolygonHermez/zkevm-node/log" +   + log.Info("Using address: ", auth.From)
    - 23 + + 113 +
    - + - "github.com/0xPolygonHermez/zkevm-node/test/operations" +   +
    - 24 + + 114 +
    - + - "github.com/ethereum/go-ethereum" + - + num, err := zkevm.LastForceBatch(&bind.CallOpts{Pending: false})
    - 25 + + 115 +
    - + - eTypes "github.com/ethereum/go-ethereum/core/types" +   + if err != nil {
    - 26 + + 116 +
    - + -
    +   + log.Error("error getting lastForBatch number. Error : ", err)
    - 27 + + 117 +
    - + - "github.com/ethereum/go-ethereum/accounts/keystore" +   + return err
    - 28 + +
    @@ -130,14 +130,14 @@
    +
    + 130 +
    - + - "github.com/ethereum/go-ethereum/common" +   + log.Error("error decoding txs. Error: ", err)
    - 29 + + 131 +
    - + - "github.com/ethereum/go-ethereum/crypto" +   + return err
    - 30 + + 132 +
    - + - "github.com/ethereum/go-ethereum/ethclient" +   + }
    - 31 + + 133 +
    - + - "github.com/stretchr/testify/assert" + - + fbData := []etrogpolygonzkevm.PolygonRollupBaseEtrogBatchData{{
    - 32 + + 134 +
    - + - "github.com/stretchr/testify/require" +   + Transactions: transactions,
    - 33 + + 135 +
    - + - ) +   + ForcedGlobalExitRoot: common.HexToHash(cliCtx.String(flagGerName)),
    - 34 + + 136 +
    - + -
    +   + ForcedTimestamp: cliCtx.Uint64(flagTimestampName),
    - 35 + + 137 +
    - + - func TestDataCommittee(t *testing.T) { +   + }}
    - 36 + + 138 +
    - + - const ( +   + log.Warnf("%v, %+v", cliCtx.String(flagTransactionsName), fbData)
    - 37 + + 139 +
    - + - nSignatures = 4 +   + // Send forceBatch
    - 38 + + 140 +
    - + - mMembers = 5 + - + tx, err := zkevm.SequenceForceBatches(auth, fbData)
    - 39 + + 141 +
    - + - ksFile = "/tmp/pkey" +   + if err != nil {
    - 40 + + 142 +
    - + - cfgFile = "/tmp/dacnodeconfigfile.json" +   + log.Error("error sending forceBatch. Error: ", err)
    - 41 + + 143 +
    - + - ksPass = "pass" +   + return err +
    +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    +
     
    - 42 + + 98 +
    - + - dacNodeContainer = "0xpolygon/cdk-data-availability:latest" +   + return err
    - 43 + + 99 +
    - + - ) +   + }
    - 44 + + 100 +
    - + -
    +   + // Create smc client
    - 45 + + 101 +
    + - // Setup + poeAddr := common.HexToAddress(cliCtx.String(flagSmcAddrName))
    - 46 + + 102 +
    + - var err error + poe, err := polygonzkevm.NewPolygonzkevm(poeAddr, ethClient)
    - 47 + + 103 +
    - + - if testing.Short() { +   + if err != nil {
    - 48 + + 104 +
    - + - t.Skip() +   + return err
    - 49 + + 105 +
    - + +   }
    - 50 + +
     
    +
    + 111 +
    - + - ctx := context.Background() +   +
    - 51 + + 112 +
    - + - defer func() { +   + log.Info("Using address: ", auth.From)
    - 52 + + 113 +
    - + - require.NoError(t, operations.Teardown()) +   +
    - 53 + + 114 +
    + - }() + num, err := poe.LastForceBatch(&bind.CallOpts{Pending: false})
    - 54 + + 115 +
    - + - err = operations.Teardown() +   + if err != nil {
    - 55 + + 116 +
    - + - require.NoError(t, err) +   + log.Error("error getting lastForBatch number. Error : ", err)
    - 56 + + 117 +
    - + - opsCfg := operations.GetDefaultOperationsConfig() +   + return err
    - 57 + +
     
    +
    + 130 +
    - + - opsCfg.State.MaxCumulativeGasUsed = 80000000000 +   + log.Error("error decoding txs. Error: ", err)
    - 58 + + 131 +
    - + - opsman, err := operations.NewManager(ctx, opsCfg) +   + return err
    - 59 + + 132 +
    - + - require.NoError(t, err) +   + }
    - 60 + + 133 +
    + - defer func() { + fbData := []polygonzkevm.PolygonRollupBaseEtrogBatchData{{
    - 61 + + 134 +
    - + - require.NoError(t, opsman.StopDACDB()) +   + Transactions: transactions,
    - 62 + + 135 +
    - + - }() +   + ForcedGlobalExitRoot: common.HexToHash(cliCtx.String(flagGerName)),
    - 63 + + 136 +
    - + - err = opsman.Setup() +   + ForcedTimestamp: cliCtx.Uint64(flagTimestampName),
    - 64 + + 137 +
    - + - require.NoError(t, err) +   + }}
    - 65 + + 138 +
    - + - require.NoError(t, opsman.StartDACDB()) +   + log.Warnf("%v, %+v", cliCtx.String(flagTransactionsName), fbData)
    - 66 + + 139 +
    - + - time.Sleep(5 * time.Second) +   + // Send forceBatch
    - 67 + + 140 +
    + - authL2, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL2ChainID) + tx, err := poe.SequenceForceBatches(auth, fbData)
    - 68 + + 141 +
    - + - require.NoError(t, err) +   + if err != nil {
    - 69 + + 142 +
    - + - authL1, err := operations.GetAuth(operations.DefaultSequencerPrivateKey, operations.DefaultL1ChainID) +   + log.Error("error sending forceBatch. Error: ", err)
    - 70 + + 143 +
    - + - require.NoError(t, err) +   + return err +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -248298,21 +330962,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    +
    @@ -63,13 +63,6 @@
    - 71 + + 63 +
    - + - clientL2, err := ethclient.Dial(operations.DefaultL2NetworkURL) +   + Required: true,
    - 72 + + 64 +
    - + - require.NoError(t, err) +   + }
    - 73 + + 65 +
    - + - clientL1, err := ethclient.Dial(operations.DefaultL1NetworkURL) +   +
    - 74 + + 66 +
    - + - require.NoError(t, err) + - + batchFlag = cli.Uint64Flag{
    - 75 + + 67 +
    - + - dacSC, err := polygondatacommittee.NewPolygondatacommittee( + - + Name: "batch",
    - 76 + + 68 +
    - + - common.HexToAddress(operations.DefaultL1DataCommitteeContract), + - + Aliases: []string{"bn"},
    - 77 + + 69 +
    - + - clientL1, + - + Usage: "batch `NUMBER`",
    - 78 + + 70 +
    - + - ) + - + Required: true,
    - 79 + + 71 +
    - + - require.NoError(t, err) + - + }
    - 80 + + 72 +
    - + + -
    - 81 + + 73 +
    - + - // Register committee with N / M signatures +   + updateFileFlag = cli.BoolFlag{
    - 82 + + 74 +
    - + - membs := members{} +   + Name: "update",
    - 83 + + 75 +
    - + - addrsBytes := []byte{} +   + Aliases: []string{"u"},
    - 84 - -
    - + - urls := []string{} -
    +
    +
    @@ -126,16 +119,6 @@
    - 85 + + 126 +
    - + - for i := 0; i < mMembers; i++ { +   + },
    - 86 + + 127 +
    - + - pk, err := crypto.GenerateKey() +   + },
    - 87 + + 128 +
    - + - require.NoError(t, err) +   + {
    - 88 + + 129 +
    - + - membs = append(membs, member{ + - + Name: "decode-batch-offline",
    - 89 + + 130 +
    - + - addr: crypto.PubkeyToAddress(pk.PublicKey), + - + Aliases: []string{},
    - 90 + + 131 +
    - + - pk: pk, + - + Usage: "Decodes a batch offline",
    - 91 + + 132 +
    - + - url: fmt.Sprintf("http://cdk-data-availability-%d:420%d", i, i), + - + Action: decodeBatchOffline,
    - 92 + + 133 +
    - + - i: i, + - + Flags: []cli.Flag{
    - 93 + + 134 +
    - + - }) + - + &configFileFlag,
    - 94 + + 135 +
    - + - } + - + &batchFlag,
    - 95 + + 136 +
    - + - sort.Sort(membs) + - + },
    - 96 + + 137 +
    - + - for _, m := range membs { + - + },
    - 97 + + 138 +
    - + - addrsBytes = append(addrsBytes, m.addr.Bytes()...) + - + {
    - 98 + + 139 +
    - + - urls = append(urls, m.url) +   + Name: "decode-entry",
    - 99 + + 140 +
    - + - } +   + Aliases: []string{},
    - 100 + + 141 +
    - + - tx, err := dacSC.SetupCommittee(authL1, big.NewInt(nSignatures), urls, addrsBytes) +   + Usage: "Decodes an entry",
    - 101 + +
    @@ -156,16 +139,6 @@
    +
    + 156 +
    - + - for _, m := range membs { +   + },
    - 102 + + 157 +
    - + - fmt.Println(m.addr) +   + },
    - 103 + + 158 +
    - + - } +   + {
    - 104 + + 159 +
    - + - require.NoError(t, err) + - + Name: "decode-batch",
    - 105 + + 160 +
    - + - err = operations.WaitTxToBeMined(ctx, clientL1, tx, operations.DefaultTimeoutTxToBeMined) + - + Aliases: []string{},
    - 106 + + 161 +
    - + - require.NoError(t, err) + - + Usage: "Decodes a batch",
    - 107 + + 162 +
    - + -
    + - + Action: decodeBatch,
    - 108 + + 163 +
    - + - // Spin up M DAC nodes + - + Flags: []cli.Flag{
    - 109 + + 164 +
    - + - dacNodeConfig := config.Config{ + - + &configFileFlag,
    - 110 + + 165 +
    - + - L1: config.L1Config{ + - + &batchFlag,
    - 111 + + 166 +
    - + - RpcURL: "http://zkevm-mock-l1-network:8545", + - + },
    - 112 + + 167 +
    - + - WsURL: "ws://zkevm-mock-l1-network:8546", + - + },
    - 113 + + 168 +
    - + - PolygonValidiumAddress: operations.DefaultL1ZkEVMSmartContract, + - + {
    - 114 + + 169 +
    - + - DataCommitteeAddress: operations.DefaultL1DataCommitteeContract, +   + Name: "truncate",
    - 115 + + 170 +
    - + - Timeout: cTypes.Duration{Duration: time.Second}, +   + Aliases: []string{},
    - 116 + + 171 +
    - + - RetryPeriod: cTypes.Duration{Duration: time.Second}, +   + Usage: "Truncates the stream file",
    - 117 + +
    @@ -234,7 +207,7 @@
    +
    + 234 +
    - + - }, +   + stateTree := merkletree.NewStateTree(mtDBServiceClient)
    - 118 + + 235 +
    - + - PrivateKey: cTypes.KeystoreFileConfig{ +   + log.Debug("Connected to the merkle tree")
    - 119 + + 236 +
    - + - Path: ksFile, +   +
    - 120 + + 237 +
    - + - Password: ksPass, + - + stateDB := state.NewState(state.Config{}, stateDBStorage, nil, stateTree, nil, nil, nil)
    - 121 + + 238 +
    - + - }, +   +
    - 122 + + 239 +
    - + - DB: db.Config{ +   + // Calculate intermediate state roots
    - 123 + + 240 +
    - + - Name: "committee_db", +   + var imStateRoots map[uint64][]byte
    - 124 + +
    @@ -326,11 +299,6 @@
    +
    + 326 +
    - + - User: "committee_user", +   + log.Errorf("Error: %v\n", err)
    - 125 + + 327 +
    - + - Password: "committee_password", +   + os.Exit(1)
    - 126 + + 328 +
    - + - Host: "zkevm-data-node-db", +   + }
    - 127 + + 329 +
    - + - Port: "5432", + - +
    - 128 + + 330 +
    - + - EnableLog: false, + - + if common.BytesToHash(imStateRoot.Bytes()) == state.ZeroHash && x != 0 {
    - 129 + + 331 +
    - + - MaxConns: 10, + - + break
    - 130 + + 332 +
    - + - }, + - + }
    - 131 + + 333 +
    - + - RPC: rpc.Config{ + - +
    - 132 + + 334 +
    - + - Host: "0.0.0.0", +   + imStateRootMux.Lock()
    - 133 + + 335 +
    - + - MaxRequestsPerIPAndSecond: 100, +   + (*isStateRoots)[x] = imStateRoot.Bytes()
    - 134 + + 336 +
    - + - }, +   + imStateRootMux.Unlock()
    - 135 + +
    @@ -657,71 +625,6 @@
    +
    + 657 +
    - + - } +   + return nil
    - 136 + + 658 +
    - + - defer func() { +   + }
    - 137 + + 659 +
    - + - // Remove tmp files +   +
    - 138 + + 660 +
    - + - assert.NoError(t, + - + func decodeBatch(cliCtx *cli.Context) error {
    - 139 + + 661 +
    - + - exec.Command("rm", cfgFile).Run(), + - + c, err := config.Load(cliCtx)
    - 140 + + 662 +
    - + - ) + - + if err != nil {
    - 141 + + 663 +
    - + - assert.NoError(t, + - + log.Error(err)
    - 142 + + 664 +
    - + - exec.Command("rmdir", ksFile+"_").Run(), + - + os.Exit(1)
    - 143 + + 665 +
    - + - ) + - + }
    - 144 + + 666 +
    - + - assert.NoError(t, + - +
    - 145 + + 667 +
    - + - exec.Command("rm", ksFile).Run(), + - + log.Init(c.Log)
    - 146 + + 668 +
    - + - ) + - +
    - 147 + + 669 +
    - + - // Stop DAC nodes + - + client, err := datastreamer.NewClient(c.Online.URI, c.Online.StreamType)
    - 148 + + 670 +
    - + - for i := 0; i < mMembers; i++ { + - + if err != nil {
    - 149 + + 671 +
    - + - assert.NoError(t, exec.Command( + - + log.Error(err)
    - 150 + + 672 +
    - + - "docker", "kill", "cdk-data-availability-"+strconv.Itoa(i), + - + os.Exit(1)
    - 151 + + 673 +
    - + - ).Run()) + - + }
    - 152 + + 674 +
    - + - assert.NoError(t, exec.Command( + - +
    - 153 + + 675 +
    - + - "docker", "rm", "cdk-data-availability-"+strconv.Itoa(i), + - + err = client.Start()
    - 154 + + 676 +
    - + - ).Run()) + - + if err != nil {
    - 155 + + 677 +
    - + - } + - + log.Error(err)
    - 156 + + 678 +
    - + - // Stop permissionless node + - + os.Exit(1)
    - 157 + + 679 +
    - + - require.NoError(t, opsman.StopPermissionlessNodeForcedToSYncThroughDAC()) + - + }
    - 158 + + 680 +
    - + - }() + - +
    - 159 + + 681 +
    - + - // Start permissionless node + - + batchNumber := cliCtx.Uint64("batch")
    - 160 + + 682 +
    - + - require.NoError(t, opsman.StartPermissionlessNodeForcedToSYncThroughDAC()) + - +
    - 161 + + 683 +
    - + - // Star DAC nodes + - + bookMark := state.DSBookMark{
    - 162 + + 684 +
    - + - for _, m := range membs { + - + Type: state.BookMarkTypeBatch,
    - 163 + + 685 +
    - + - // Set correct port + - + Value: batchNumber,
    - 164 + + 686 +
    - + - port := 4200 + m.i + - + }
    - 165 + + 687 +
    - + - dacNodeConfig.RPC.Port = port + - +
    - 166 + + 688 +
    - + - // Write config file + - + firstEntry, err := client.ExecCommandGetBookmark(bookMark.Encode())
    - 167 + + 689 +
    - + - file, err := json.MarshalIndent(dacNodeConfig, "", " ") + - + if err != nil {
    - 168 + + 690 +
    - + - require.NoError(t, err) + - + log.Error(err)
    - 169 + + 691 +
    - + - err = os.WriteFile(cfgFile, file, 0644) + - + os.Exit(1)
    - 170 + + 692 +
    - + - require.NoError(t, err) + - + }
    - 171 + + 693 +
    - + - // Write private key keystore file + - + printEntry(firstEntry)
    - 172 + + 694 +
    - + - err = createKeyStore(m.pk, ksFile, ksPass) + - +
    - 173 + + 695 +
    - + - require.NoError(t, err) + - + secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1)
    - 174 + + 696 +
    - + - // Run DAC node + - + if err != nil {
    - 175 + + 697 +
    - + - cmd := exec.Command( + - + log.Error(err)
    - 176 + + 698 +
    - + - "docker", "run", "-d", + - + os.Exit(1)
    - 177 + + 699 +
    - + - "--name", "cdk-data-availability-"+strconv.Itoa(m.i), + - + }
    - 178 + + 700 +
    - + - "-v", cfgFile+":/app/config.json", + - + printEntry(secondEntry)
    - 179 + + 701 +
    - + - "-v", ksFile+":"+ksFile, + - +
    - 180 + + 702 +
    - + - "--network", "zkevm", + - + i := uint64(2) //nolint:gomnd
    - 181 + + 703 +
    - + - dacNodeContainer, + - + for {
    - 182 + + 704 +
    - + - "/bin/sh", "-c", + - + entry, err := client.ExecCommandGetEntry(firstEntry.Number + i)
    - 183 + + 705 +
    - + - "/app/cdk-data-availability run --cfg /app/config.json", + - + if err != nil {
    - 184 + + 706 +
    - + - ) + - + log.Error(err)
    - 185 + + 707 +
    - + - out, err := cmd.CombinedOutput() + - + os.Exit(1)
    - 186 + + 708 +
    - + - require.NoError(t, err, string(out)) + - + }
    - 187 + + 709 +
    - + - log.Infof("DAC node %d started", m.i) + - +
    - 188 + + 710 +
    - + - time.Sleep(time.Second * 5) + - + if entry.Type == state.EntryTypeBookMark {
    - 189 + + 711 +
    - + - } + - + bookMark := state.DSBookMark{}.Decode(entry.Data)
    - 190 + + 712 +
    - + -
    + - + if bookMark.Type == state.BookMarkTypeBatch {
    - 191 + + 713 +
    - + - // Send txs + - + break
    - 192 + + 714 +
    - + - nTxs := 10 + - + }
    - 193 + + 715 +
    - + - amount := big.NewInt(10000) + - + }
    - 194 + + 716 +
    - + - toAddress := common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8") + - +
    - 195 + + 717 +
    - + - _, err = clientL2.BalanceAt(ctx, authL2.From, nil) + - + secondEntry = entry
    - 196 + + 718 +
    - + - require.NoError(t, err) + - + printEntry(secondEntry)
    - 197 + + 719 +
    - + - _, err = clientL2.PendingNonceAt(ctx, authL2.From) + - + i++
    - 198 + + 720 +
    - + - require.NoError(t, err) + - + }
    - 199 + + 721 +
    - + + -
    - 200 + + 722 +
    - + - gasLimit, err := clientL2.EstimateGas(ctx, ethereum.CallMsg{From: authL2.From, To: &toAddress, Value: amount}) + - + return nil
    - 201 + + 723 +
    - + - require.NoError(t, err) + - + }
    - 202 + + 724 +
    - + + -
    - 203 + + 725 +
    - + - gasPrice, err := clientL2.SuggestGasPrice(ctx) +   + func decodeEntryOffline(cliCtx *cli.Context) error {
    - 204 + + 726 +
    - + - require.NoError(t, err) +   + c, err := config.Load(cliCtx)
    - 205 + + 727 +
    - + -
    +   + if err != nil {
    - 206 - -
    - + - nonce, err := clientL2.PendingNonceAt(ctx, authL2.From) -
    +
    +
    @@ -794,64 +697,6 @@
    - 207 + + 794 +
    - + - require.NoError(t, err) +   + printEntry(secondEntry)
    - 208 + + 795 +
    - + -
    +   + i++
    - 209 + + 796 +
    - + - txs := make([]*eTypes.Transaction, 0, nTxs) +   + }
    - 210 + + 797 +
    - + - for i := 0; i < nTxs; i++ { + - +
    - 211 + + 798 +
    - + - tx := eTypes.NewTransaction(nonce+uint64(i), toAddress, amount, gasLimit, gasPrice, nil) + - + return nil
    - 212 + + 799 +
    - + - log.Infof("generating tx %d / %d: %s", i+1, nTxs, tx.Hash().Hex()) + - + }
    - 213 + + 800 +
    - + - txs = append(txs, tx) + - +
    - 214 + + 801 +
    - + - } + - + func decodeBatchOffline(cliCtx *cli.Context) error {
    - 215 + + 802 +
    - + -
    + - + c, err := config.Load(cliCtx)
    - 216 + + 803 +
    - + - // Wait for verification + - + if err != nil {
    - 217 + + 804 +
    - + - _, err = operations.ApplyL2Txs(ctx, txs, authL2, clientL2, operations.VerifiedConfirmationLevel) + - + log.Error(err)
    - 218 + + 805 +
    - + - require.NoError(t, err) + - + os.Exit(1)
    - 219 + + 806 +
    - + -
    + - + }
    - 220 + + 807 +
    - + - // Assert that he permissionless node is fully synced (through the DAC) + - +
    - 221 + + 808 +
    - + - time.Sleep(30 * time.Second) // Give some time for the permissionless node to get synced + - + log.Init(c.Log)
    - 222 + + 809 +
    - + - clientL2Permissionless, err := ethclient.Dial(operations.PermissionlessL2NetworkURL) + - +
    - 223 + + 810 +
    - + - require.NoError(t, err) + - + streamServer, err := initializeStreamServer(c)
    - 224 + + 811 +
    - + - expectedBlock, err := clientL2.BlockByNumber(ctx, nil) + - + if err != nil {
    - 225 + + 812 +
    - + - require.NoError(t, err) + - + log.Error(err)
    - 226 + + 813 +
    - + - actualBlock, err := clientL2Permissionless.BlockByNumber(ctx, nil) + - + os.Exit(1)
    - 227 + + 814 +
    - + - require.NoError(t, err) + - + }
    - 228 + + 815 +
    - + - // je, err := expectedBlock.Header().MarshalJSON() + - +
    - 229 + + 816 +
    - + - // require.NoError(t, err) + - + batchNumber := cliCtx.Uint64("batch")
    - 230 + + 817 +
    - + - // log.Info(string(je)) + - +
    - 231 + + 818 +
    - + - // ja, err := actualBlock.Header().MarshalJSON() + - + bookMark := state.DSBookMark{
    - 232 + + 819 +
    - + - // require.NoError(t, err) + - + Type: state.BookMarkTypeL2Block,
    - 233 + + 820 +
    - + - // log.Info(string(ja)) + - + Value: batchNumber,
    - 234 + + 821 +
    - + - // require.Equal(t, string(je), string(ja)) + - + }
    - 235 + + 822 +
    - + - require.Equal(t, expectedBlock.Root().Hex(), actualBlock.Root().Hex()) + - +
    - 236 + + 823 +
    - + - } + - + firstEntry, err := streamServer.GetFirstEventAfterBookmark(bookMark.Encode())
    - 237 + + 824 +
    - + -
    + - + if err != nil {
    - 238 + + 825 +
    - + - type member struct { + - + log.Error(err)
    - 239 + + 826 +
    - + - addr common.Address + - + os.Exit(1)
    - 240 + + 827 +
    - + - pk *ecdsa.PrivateKey + - + }
    - 241 + + 828 +
    - + - url string + - + printEntry(firstEntry)
    - 242 + + 829 +
    - + - i int + - +
    - 243 + + 830 +
    - + - } + - + secondEntry, err := streamServer.GetEntry(firstEntry.Number + 1)
    - 244 + + 831 +
    - + - type members []member + - + if err != nil {
    - 245 + + 832 +
    - + -
    + - + log.Error(err)
    - 246 + + 833 +
    - + - func (s members) Len() int { return len(s) } + - + os.Exit(1)
    - 247 + + 834 +
    - + - func (s members) Less(i, j int) bool { + - + }
    - 248 + + 835 +
    - + - return strings.ToUpper(s[i].addr.Hex()) < strings.ToUpper(s[j].addr.Hex()) + - +
    - 249 + + 836 +
    - + - } + - + i := uint64(2) //nolint:gomnd
    - 250 + + 837 +
    - + - func (s members) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + - + printEntry(secondEntry)
    - 251 + + 838 +
    - + -
    + - + for {
    - 252 + + 839 +
    - + - func createKeyStore(pk *ecdsa.PrivateKey, outputDir, password string) error { + - + secondEntry, err = streamServer.GetEntry(firstEntry.Number + i)
    - 253 + + 840 +
    - + - ks := keystore.NewKeyStore(outputDir+"_", keystore.StandardScryptN, keystore.StandardScryptP) + - + if err != nil {
    - 254 + + 841 +
    - + - _, err := ks.ImportECDSA(pk, password) + - + log.Error(err)
    - 255 + + 842 +
    - + - if err != nil { + - + os.Exit(1)
    - 256 + + 843 +
    - + - return err + - + }
    - 257 + + 844 +
    - + - } + - +
    - 258 + + 845 +
    - + - fileNameB, err := exec.Command("ls", outputDir+"_/").CombinedOutput() + - + if secondEntry.Type == state.EntryTypeBookMark {
    - 259 + + 846 +
    - + - fileName := strings.TrimSuffix(string(fileNameB), "\n") + - + bookMark := state.DSBookMark{}.Decode(secondEntry.Data)
    - 260 + + 847 +
    - + - if err != nil { + - + if bookMark.Type == state.BookMarkTypeBatch {
    - 261 + + 848 +
    - + - fmt.Println(fileName) + - + break
    - 262 + + 849 +
    - + - return err + - + }
    - 263 + + 850 +
    - + - } + - + }
    - 264 + + 851 +
    - + - out, err := exec.Command("mv", outputDir+"_/"+fileName, outputDir).CombinedOutput() + - +
    - 265 + + 852 +
    - + - if err != nil { + - + printEntry(secondEntry)
    - 266 + + 853 +
    - + - fmt.Println(string(out)) + - + i++
    - 267 + + 854 +
    - + - return err + - + }
    - 268 + + 855 +
    - + - } +   +
    - 269 + + 856 +
    - + +   return nil
    - 270 + + 857 +
    - + +   }
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_test.go - RENAMED - -
    -
    @@ -248320,438 +330969,541 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + + + + + + + + + + - - -
    -
    @@ -196,7 +196,7 @@
    +
     
    - 196 + 63
      - require.NoError(t, err) + Required: true,
    - 197 + 64
      - genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr) + }
    - 198 + 65
      - require.NoError(t, err) +
    - 199 + + -
    - - - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6)) +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 200 + 66
      - err = opsman.Setup() + updateFileFlag = cli.BoolFlag{
    - 201 + 67
      - require.NoError(t, err) + Name: "update",
    - 202 + 68
      - time.Sleep(5 * time.Second) + Aliases: []string{"u"},
    -
    -
    -
    -
    - - - + - - - - - - - - - - -
     
    - 196 + 119
      - require.NoError(t, err) + },
    - 197 + 120
      - genesisConfig, err := config.LoadGenesisFromJSONString(genesisFileAsStr) + },
    - 198 + 121
      - require.NoError(t, err) + {
    - 199 + + -
    - + - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6)) +
    +
    +   +
    - 200 + + -
    +
    +
      - err = opsman.Setup() +
    - 201 + + -
    +
    +
      - require.NoError(t, err) +
    - 202 + + -
    +
    +
      - time.Sleep(5 * time.Second) +
    -
    + + + + + +
    +   +
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/forced_batches_vector_shared.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - -
    -
    @@ -63,8 +63,8 @@
    - 63 + + -
    +
    +
      - log.Info("# Setting Genesis #") +
    - 64 + + -
    +
    +
      - log.Info("###################") +
    - 65 + + -
    +
    +
      - genesisActions := vectors.GenerateGenesisActions(testCase.Genesis) +
    - 66 + + -
    - - - require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.BlockNumber, genesisActions)) +
    +
    +   +
    - 67 + + -
    - - - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.BlockNumber, forkID6)) +
    +
    +   +
    - 68 + 122
      - actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil) + Name: "decode-entry",
    - 69 + 123
      - require.NoError(t, err) + Aliases: []string{},
    - 70 + 124
      - require.NoError(t, opsman.Setup()) + Usage: "Decodes an entry",
    -
    @@ -93,7 +93,7 @@
    +
     
    - 93 + 139
      - } + },
    - 94 + 140
      -
    + },
    - 95 + 141
      - log.Info("#######################") + {
    - 96 + + -
    - - - log.Info("# Verifying new leafs #") +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 97 + 142
      - log.Info("#######################") + Name: "truncate",
    - 98 + 143
      - merkleTree := opsman.State().GetTree() + Aliases: []string{},
    - 99 + 144
      - for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { + Usage: "Truncates the stream file",
    -
    -
    -
    -
    - - - + - - - @@ -248761,221 +331513,237 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + + + + + + + - - -
     
    - 63 + 207
      - log.Info("# Setting Genesis #") + stateTree := merkletree.NewStateTree(mtDBServiceClient)
    - 64 + 208
      - log.Info("###################") + log.Debug("Connected to the merkle tree")
    - 65 + 209
      - genesisActions := vectors.GenerateGenesisActions(testCase.Genesis) -
    -
    - 66 - -
    - + - require.NoError(t, opsman.SetGenesis(genesisConfig.Genesis.RollupBlockNumber, genesisActions)) +
    - 67 + 210
    + - require.NoError(t, opsman.SetForkID(genesisConfig.Genesis.RollupBlockNumber, forkID6)) + stateDB := state.NewState(state.Config{}, stateDBStorage, nil, stateTree, nil, nil)
    - 68 + 211
      - actualOldStateRoot, err := opsman.State().GetLastStateRoot(ctx, nil) +
    - 69 + 212
      - require.NoError(t, err) + // Calculate intermediate state roots
    - 70 + 213
      - require.NoError(t, opsman.Setup()) + var imStateRoots map[uint64][]byte
    - 93 + 299
      - } + log.Errorf("Error: %v\n", err)
    - 94 + 300
      -
    + os.Exit(1)
    - 95 + 301
      - log.Info("#######################") + }
    - 96 + + -
    - + - log.Info("# Verifying new leaves #") +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 97 + 302
      - log.Info("#######################") + imStateRootMux.Lock()
    - 98 + 303
      - merkleTree := opsman.State().GetTree() + (*isStateRoots)[x] = imStateRoot.Bytes()
    - 99 + 304
      - for _, expectedNewLeaf := range testCase.ExpectedNewLeafs { + imStateRootMux.Unlock()
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/jsonrpc2_test.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - @@ -248989,73 +331757,73 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - @@ -249109,248 +331877,283 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + @@ -249505,77 +332308,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -249649,258 +332452,253 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -249984,153 +332782,143 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -250165,32 +332953,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -250198,98 +332986,53 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -456,22 +456,27 @@
    +
     
    - 456 + 625
      - expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 0"}, + return nil
    - 457 + 626
      - }, + }
    - 458 + 627
      - { +
    - 459 + + -
    - - - name: "params has only first parameter", +
    +
    +   +
    - 460 + + -
    - - - params: []interface{}{map[string]interface{}{"value": "0x1"}}, +
    +
    +   +
    - 461 + + -
    - - - expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 1"}, +
    +
    +   +
    - 462 + + -
    +
    +
      - }, +
    - 463 + + -
    +
    +
      - } +
    - 464 + + -
    +
    +
     
    - 465 + + -
    +
    +
      - for _, network := range networks { +
    - 466 + + -
    - - - log.Infof("Network %s", network.Name) +
    +
    +   +
    - 467 + + -
    - - - for _, testCase := range testCases { +
    +
    +   +
    - 468 + + -
    +
    +
      - t.Run(network.Name+testCase.name, func(t *testing.T) { +
    - 469 + + -
    +
    +
      - response, err := client.JSONRPCCall(network.URL, "eth_call", testCase.params...) +
    - 470 + + -
    +
    +
      - require.NoError(t, err) +
    - 471 + + -
    - - - require.NotNil(t, response.Error) +
    +
    +   +
    - 472 + + -
    - - - require.Nil(t, response.Result) +
    +
    +   +
    - 473 + + -
    - - - require.Equal(t, testCase.expectedError.Code, response.Error.Code) +
    +
    +   +
    - 474 + + -
    - - - require.Equal(t, testCase.expectedError.Message, response.Error.Message) +
    +
    +   +
    - 475 + + -
    +
    +
      - }) +
    - 476 + + -
    +
    +
      - } +
    - 477 + + -
    +
    +
      - } +
    -
    @@ -620,24 +625,39 @@
    +
    + + +
    +   +
    +
    - 620 + + -
    +
    +
      - txToMsg, err := sc.Increment(auth) +
    - 621 + + -
    +
    +
      - require.NoError(t, err) +
    - 622 + + -
    +
    +
     
    - 623 + + -
    - - - // add funds to address 0x000...001 used in the test +
    +
    +   +
    - 624 + + -
    - - - nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil) +
    +
    +   +
    - 625 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    - 626 + + -
    - - - value := big.NewInt(1000) +
    +
    +   +
    - 627 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    - 628 + + -
    - - - tx = ethTypes.NewTx(&ethTypes.LegacyTx{ +
    +
    +   +
    - 629 + + -
    - - - Nonce: nonce, +
    +
    +   +
    - 630 + + -
    - - - To: state.Ptr(common.HexToAddress("0x1")), +
    +
    +   +
    - 631 + + -
    - - - Value: value, +
    +
    +   +
    - 632 + + -
    - - - Gas: 24000, +
    +
    +   +
    - 633 + + -
    - - - GasPrice: gasPrice, +
    +
    +   +
    - 634 + + -
    - - - }) +
    +
    +   +
    - 635 + + -
    - - - signedTx, err := auth.Signer(auth.From, tx) +
    +
    +   +
    - 636 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    - 637 + + -
    - - - err = ethereumClient.SendTransaction(ctx, signedTx) +
    +
    +   +
    - 638 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    - 639 + + -
    - - - err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined) +
    +
    +   +
    - 640 + + -
    - - - require.NoError(t, err) +
    +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 641 + 628
      -
    + func decodeEntryOffline(cliCtx *cli.Context) error {
    - 642 + 629
      - type testCase struct { + c, err := config.Load(cliCtx)
    - 643 + 630
      - name string + if err != nil {
    -
    @@ -670,19 +690,15 @@
    +
     
    - 670 + 697
      - name: "with gasPrice set and without from address", + printEntry(secondEntry)
    - 671 + 698
      - address: nil, + i++
    - 672 + 699
      - setGasPrice: true, + }
    - 673 + + -
    - - - expectedError: types.NewRPCError(-32000, "gas required exceeds allowance"), +
    +
    +   +
    - 674 + + -
    +
    +
      - }, +
    - 675 + + -
    - - - // TODO: This test is failing due to geth bug +
    +
    +   +
    - 676 + + -
    - - - // we can uncomment it when updating geth version +
    +
    +   +
    - 677 + + -
    - - - // on l1 image, it's returning error code -32000 when +
    +
    +   +
    - 678 + + -
    - - - // it should be returning error code 3 due to execution message +
    +
    +   +
    - 679 + + -
    - - - // { +
    +
    +   +
    - 680 + + -
    - - - // name: "with gasPrice and value set and address with enough balance", +
    +
    +   +
    - 681 + + -
    - - - // address: state.Ptr(auth.From), +
    +
    +   +
    - 682 + + -
    - - - // value: state.Ptr(int64(1)), +
    +
    +   +
    - 683 + + -
    - - - // setGasPrice: true, +
    +
    +   +
    - 684 + + -
    - - - // expectedError: types.NewRPCError(3, "execution reverted"), +
    +
    +   +
    - 685 + + -
    - - - // }, +
    +
    +   +
    - 686 + + -
    +
    +
      - { +
    - 687 + + -
    +
    +
      - name: "with gasPrice and value set and address without enough balance", +
    - 688 + + -
    +
    +
      - address: state.Ptr(common.HexToAddress("0x1")), +
    -
    @@ -697,13 +713,21 @@
    -
    - 697 + + -
    +
    +
      - setGasPrice: true, +
    - 698 + + -
    +
    +
      - expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), +
    - 699 + + -
    +
    +
      - }, +
    - 700 + + -
    - - - { +
    +
    +   +
    - 701 + + -
    - - - name: "with gasPrice and value set and without from address", +
    +
    +   +
    - 702 + + -
    - - - address: nil, +
    +
    +   +
    - 703 + + -
    - - - value: state.Ptr(int64(-1)), +
    +
    +   +
    - 704 + + -
    - - - setGasPrice: true, +
    +
    +   +
    - 705 + + -
    - - - expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), +
    +
    +   +
    - 706 + + -
    - - - }, +
    +
    +   +
    - 707 + + -
    +
    +
      - { +
    - 708 + + -
    +
    +
      - name: "without gasPrice set and address with enough balance", +
    - 709 + + -
    +
    +
      - address: state.Ptr(auth.From), +
    -
    @@ -746,7 +770,6 @@
    -
    - 746 + + -
    +
    +
      - if testCase.value != nil { +
    - 747 + + -
    +
    +
      - v := *testCase.value +
    - 748 + + -
    +
    +
      - if v == -1 { //set the value as acc balance + 1 to force overflow +
    - 749 + + -
    - - +
    +
    +  
    - 750 + + -
    +
    +
      - msg.Value = common.Big0.Add(balance, common.Big1) +
    - 751 + + -
    +
    +
      - } else { +
    - 752 + + -
    +
    +
      - msg.Value = big.NewInt(0).SetInt64(v) +
    -
    @@ -757,7 +780,10 @@
    -
    - 757 + + -
    +
    +
      - msg.GasPrice = gasPrice +
    - 758 + + -
    +
    +
      - } +
    - 759 + + -
    +
    +
     
    - 760 + + -
    - - - _, err = ethereumClient.EstimateGas(ctx, msg) +
    +
    +   +
    - 761 + 700
      - if testCase.expectedError != nil { +
    - 762 + 701
      - rpcErr := err.(rpc.Error) + return nil
    - 763 + 702
      - errMsg := fmt.Sprintf("[%v] expected: %v %v found: %v %v", network.Name, testCase.expectedError.ErrorCode(), testCase.expectedError.Error(), rpcErr.ErrorCode(), rpcErr.Error()) + }
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    -
     
    -
    - 456 - -
    -   - expectedError: types.ErrorObject{Code: types.InvalidParamsErrorCode, Message: "missing value for required argument 0"}, -
    -
    - 457 - -
    -   - }, -
    -
    - 458 - -
    -   - { -
    -
    - 459 - -
    - + - name: "params has only first parameter", -
    -
    - 460 - -
    - + - params: []interface{}{map[string]interface{}{"value": "0x1", "from": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", "to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92267"}}, -
    -
    - - -
    -   -
    -
    + + +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/Makefile + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + + +
    +
    @@ -27,10 +27,6 @@
    - 461 + 27
      - }, + decode-l2block: ## Runs the tool to decode a given L2 block
    - 462 + 28
      - } + go run main.go decode-l2block -cfg config/tool.config.toml -l2block $(arguments)
    - 463 + 29
    @@ -250298,223 +333041,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 464 + + 30 +
    -   - for _, network := range networks { + - + .PHONY: decode-batch
    - 465 + + 31 +
    - + - t.Logf("Network %s", network.Name) + - + decode-batch: ## Runs the tool to decode a given batch
    - 466 + + 32 +
    - + - for tc, testCase := range testCases { + - + go run main.go decode-batch -cfg config/tool.config.toml -batch $(arguments)
    - 467 + + 33 +
    - + - t.Logf("testCase %d", tc) + - +
    - 468 + 34
      - t.Run(network.Name+testCase.name, func(t *testing.T) { + .PHONY: decode-entry-offline
    - 469 + 35
      - response, err := client.JSONRPCCall(network.URL, "eth_call", testCase.params...) + decode-entry-offline: ## Runs the offline tool to decode a given entry number
    - 470 + 36
      - require.NoError(t, err) -
    -
    - 471 - -
    - + - if (testCase.expectedError != types.ErrorObject{}) { + go run main.go decode-entry-offline -cfg config/tool.config.toml -entry $(arguments)
    - 472 - -
    - + - require.NotNil(t, response.Error) -
    +
    +
    @@ -39,10 +35,6 @@
    - 473 + + 39 +
    - + - require.Nil(t, response.Result) +   + decode-l2block-offline: ## Runs the offline tool to decode a given L2 block
    - 474 + + 40 +
    - + - require.Equal(t, testCase.expectedError.Code, response.Error.Code) +   + go run main.go decode-l2block-offline -cfg config/tool.config.toml -l2block $(arguments)
    - 475 + + 41 +
    - + - require.Equal(t, testCase.expectedError.Message, response.Error.Message) +   +
    - 476 + + 42 +
    - + - } else { + - + .PHONY: decode-batch-offline
    - 477 + + 43 +
    - + - require.Nil(t, response.Error) + - + decode-batch-offline: ## Runs the offline tool to decode a given batch
    - 478 + + 44 +
    - + - require.NotNil(t, response.Result) + - + go run main.go decode-batch-offline -cfg config/tool.config.toml -batch $(arguments)
    - 479 + + 45 +
    - + - } + - +
    - 480 + 46
      - }) + .PHONY: truncate
    - 481 + 47
      - } + truncate: ## Runs the offline tool to truncate the stream file
    - 482 + 48
      - } + go run main.go truncate -cfg config/tool.config.toml -entry $(arguments)
    +
    +
    +
    +
    + + + - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - + + +
     
    - 625 + 27
      - txToMsg, err := sc.Increment(auth) + decode-l2block: ## Runs the tool to decode a given L2 block
    - 626 + 28
      - require.NoError(t, err) + go run main.go decode-l2block -cfg config/tool.config.toml -l2block $(arguments)
    - 627 + 29
    @@ -250523,1432 +333260,1462 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 628 + + -
    - + - // addresses the test needs to have balance +
    +
    +   +
    - 629 + + -
    - + - addressesToAddBalance := map[common.Address]*big.Int{ +
    +
    +   +
    - 630 + + -
    - + - // add funds to address 0x111...111 which is the default address +
    +
    +   +
    - 631 + + -
    - + - // when estimating TXs without specifying the sender +
    +
    +   +
    - 632 + + 30 +
    - + - common.HexToAddress("0x1111111111111111111111111111111111111111"): big.NewInt(3000000000000000), +   + .PHONY: decode-entry-offline
    - 633 + + 31 +
    - + -
    +   + decode-entry-offline: ## Runs the offline tool to decode a given entry number
    - 634 + + 32 +
    - + - // add funds to address 0x000...001 +   + go run main.go decode-entry-offline -cfg config/tool.config.toml -entry $(arguments)
    - 635 + +
     
    +
    + 35 +
    - + - common.HexToAddress("0x1"): big.NewInt(1000), +   + decode-l2block-offline: ## Runs the offline tool to decode a given L2 block
    - 636 + + 36 +
    - + - } +   + go run main.go decode-l2block-offline -cfg config/tool.config.toml -l2block $(arguments)
    - 637 + + 37 +
    - + +  
    - 638 + + -
    - + - for addr, value := range addressesToAddBalance { +
    +
    +   +
    - 639 + + -
    - + - nonce, err := ethereumClient.NonceAt(ctx, auth.From, nil) +
    +
    +   +
    - 640 + + -
    - + - require.NoError(t, err) +
    +
    +   +
    - 641 + + -
    - + - value := value +
    +
    +   +
    - 642 + + 38 +
    - + - require.NoError(t, err) +   + .PHONY: truncate
    - 643 + + 39 +
    - + - tx = ethTypes.NewTx(&ethTypes.LegacyTx{ +   + truncate: ## Runs the offline tool to truncate the stream file
    - 644 + + 40 +
    - + - Nonce: nonce, +   + go run main.go truncate -cfg config/tool.config.toml -entry $(arguments) +
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/egp/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - + + + - - -
    +
    @@ -25,45 +25,36 @@
    - 645 + + 25 +
    - + - To: state.Ptr(addr), +   + )
    - 646 + + 26 +
    - + - Value: value, +   +
    - 647 + + 27 +
    - + - Gas: 24000, +   + var (
    - 648 + + 28 +
    - + - GasPrice: gasPrice, + - + showErrors bool
    - 649 + + 29 +
    - + - }) + - + showLosses bool
    - 650 + + 30 +
    - + - signedTx, err := auth.Signer(auth.From, tx) + - + showReprocess bool
    - 651 + + 31 +
    - + - require.NoError(t, err) + - + showDetail bool
    - 652 + + 32 +
    - + - err = ethereumClient.SendTransaction(ctx, signedTx) + - + showAlways bool
    - 653 + + 33 +
    - + - require.NoError(t, err) + - + showOnlyCfg bool
    - 654 + + 34 +
    - + - err = operations.WaitTxToBeMined(ctx, ethereumClient, signedTx, operations.DefaultTimeoutTxToBeMined) + - + useRealL2GasPrice bool
    - 655 + + 35 +
    - + - require.NoError(t, err) + - + showDiscrepancy uint64
    - 656 + + 36 +
    - + -
    + - + showEncoded bool
    - 657 + + 37 +
    - + - balance, err := ethereumClient.BalanceAt(ctx, addr, nil) +   + )
    - 658 + + 38 +
    - + - require.NoError(t, err) +   +
    - 659 + + 39 +
    - + - log.Debugf("%v balance: %v", addr.String(), balance.String()) +   + const (
    - 660 + + 40 +
    - + - } + - + ethTransferGasValue = 21000
    - 661 + + 41 +
    -   -
    + - + signatureBytes = 0
    - 662 + + 42 +
    -   - type testCase struct { + - + effectivePctBytes = 1
    - 663 + + 43 +
    -   - name string + - + fixedBytesTx = signatureBytes + effectivePctBytes
    -
     
    -
    - 690 + 44
      - name: "with gasPrice set and without from address", + )
    - 691 + 45
      - address: nil, +
    - 692 + 46
      - setGasPrice: true, + type egpConfig struct {
    - 693 + + 47 +
    - + - expectedError: nil, + - + ByteGasCost uint64 // gas cost of 1 byte
    - 694 + + 48 +
    - + - }, + - + ZeroGasCost uint64 // gas cost of 1 byte zero
    - 695 + + 49 +
    - + - { + - + NetProfitFactor float64 // L2 network profit factor
    - 696 + + 50 +
    - + - name: "with gasPrice and value set and address with enough balance", + - + L1GasPriceFactor float64 // L1 gas price factor
    - 697 + + 51 +
    - + - address: state.Ptr(auth.From), + - + L2GasPriceSugFactor float64 // L2 gas price suggester factor
    - 698 + + 52 +
    - + - value: state.Ptr(int64(1)), + - + FinalDeviationPct uint64 // max final deviation percentage
    - 699 + + 53 +
    - + - setGasPrice: true, + - + L2GasPriceSugFactorPreEGP float64 // L2 gas price suggester factor (pre EGP)
    - 700 + + 54 +
    - + - expectedError: types.NewRPCError(-32000, "execution reverted"), + - + EthTransferGasPrice uint64 // Gas price value for transfer (gas == 21000)
    - 701 + + 55 +
    -   - }, + - + EthTransferL1GasPriceFactor float64 // Gas price for transfer (used if EthTransferGasPrice = 0)
    - + + 56 -
    +
    +
      -
    + }
    - + + 57 -
    +
    +
     
    - + + 58 -
    +
    +
      -
    + type egpLogRecord struct {
    - + + 59 -
    +
    +
      -
    + l2BlockNum uint64
    - + + 60 -
    +
    +
      -
    + l2BlockReceived time.Time
    - + + 61 -
    +
    +
      -
    + encoded string
    - + + 62 -
    -   -
    +
    +
    + - + hash string
    - + + 63 -
    +
    +
      -
    + missingLogInfo bool // Flag if egp_log field is empty
    - + + 64 -
    -   -
    +
    +
    + - + realGasPrice float64 // (calculated field) Real price paid by the user (to perform a double check)
    - + + 65 -
    -   -
    +
    +
    + - + txZeroCount uint64 // (calculated field) count transaction zero bytes
    - + + 66 -
    -   -
    +
    +
    + - + txNonZeroCount uint64 // (calculated field) count transaction non zero bytes
    - 702 + 67
      - { + LogError string `json:"Error"`
    - 703 + 68
      - name: "with gasPrice and value set and address without enough balance", + LogEnabled bool `json:"Enabled"`
    - 704 + 69
      - address: state.Ptr(common.HexToAddress("0x1")), + LogL1GasPrice float64 `json:"L1GasPrice"` // L1 gas price
    -
     
    +
    @@ -97,11 +88,10 @@
    - 713 + 97
      - setGasPrice: true, + totalLoss float64 // Total loss gas amount
    - 714 + 98
      - expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), + sumGasFinal float64 // Accumulated sum of final gas (to get average)
    - 715 + 99
      - }, + countGasFinal float64 // Count number of accumulated (to get average)
    - 716 + + 100 +
    - + - // TODO = Review the test below in future versions of geth. + - + sumGasNoEGP float64 // Accumulated sum of gas without EGP
    - 717 + + 101 +
    - + - // + - + countGasNoEGP float64 // Count number of accumulated without EGP (to get average)
    - 718 + + 102 +
    - + - // Geth is returning -32000, "insufficient funds for transfer" +   + sumFee float64
    - 719 + + 103 +
    - + - // zkEVM is returning 3, "execution reverted" + - + sumFeeNoEGP float64
    - 720 + + 104 +
    - + - // + - + sumRealGas float64
    - 721 + + 105 +
    - + - // Since the tx has value, the method increment is not payable +   + }
    - 722 + + 106 +
    - + - // and the default account has balance, the tx should revert +   +
    - 723 + + 107 +
    - + - // +   + func main() {
    - 724 + +
    @@ -140,20 +130,10 @@
    +
    + 140 +
    - + - // { +   + Value: false,
    - 725 + + 141 +
    - + - // name: "with gasPrice and value set and without from address", +   + },
    - 726 + + 142 +
    - + - // address: nil, +   + &cli.BoolFlag{
    - 727 + + 143 +
    - + - // value: state.Ptr(int64(-1)), + - + Name: "showencoded",
    - 728 + + 144 +
    - + - // setGasPrice: true, + - + Usage: "show encoded field when showing detail record",
    - 729 + + 145 +
    - + - // expectedError: types.NewRPCError(-32000, "insufficient funds for transfer"), + - + Value: false,
    - 730 + + 146 +
    - + - // }, + - + },
    - 731 + + 147 +
    -   - { + - + &cli.BoolFlag{
    - 732 + 148
      - name: "without gasPrice set and address with enough balance", + Name: "showalways",
    - 733 + 149
      - address: state.Ptr(auth.From), + Usage: "show always full detailed record",
    -
     
    -
    - 770 + 150
      - if testCase.value != nil { + Value: false,
    - 771 + 151
      - v := *testCase.value + },
    - 772 + + 152 +
    -   - if v == -1 { //set the value as acc balance + 1 to force overflow + - + &cli.Uint64Flag{
    - + + 153 -
    -   -
    +
    +
    + - + Name: "showdiscrepancy", +
    +
    + 154 + +
    + - + Usage: "show discrepancies between real and simulated (0:none, 1:reprocess, 2:gasprice, 3:all)", +
    +
    + 155 + +
    + - + Value: ^uint64(0), +
    +
    + 156 + +
    + - + },
    - 773 + 157
      - msg.Value = common.Big0.Add(balance, common.Big1) + &cli.StringFlag{
    - 774 + 158
      - } else { + Name: "cfg",
    - 775 + 159
      - msg.Value = big.NewInt(0).SetInt64(v) + Aliases: []string{"c"},
    -
     
    +
    @@ -165,11 +145,6 @@
    - 780 + 165
      - msg.GasPrice = gasPrice + Usage: "show only simulation results",
    - 781 + 166
      - } + Value: false,
    - 782 + 167
      -
    + },
    - 783 + + 168 +
    - + - gas, err := ethereumClient.EstimateGas(ctx, msg) + - + &cli.BoolFlag{
    - 784 + + 169 +
    - + - t.Log("testCase: ", testCase.name) + - + Name: "realgasprice",
    - 785 + + 170 +
    - + - t.Log("err: ", err) + - + Usage: "use real L2 gas price from egp-log instead of the calculated simulated value",
    - 786 + + 171 +
    - + - t.Log("gas: ", gas) + - + Value: false, +
    +
    + 172 + +
    + - + },
    - 787 + 173
      - if testCase.expectedError != nil { + &cli.StringFlag{
    - 788 + 174
      - rpcErr := err.(rpc.Error) + Name: "db",
    - 789 + 175
      - errMsg := fmt.Sprintf("[%v] expected: %v %v found: %v %v", network.Name, testCase.expectedError.ErrorCode(), testCase.expectedError.Error(), rpcErr.ErrorCode(), rpcErr.Error()) + Usage: "DB connection string: \"host=xxx port=xxx user=xxx dbname=xxx password=xxx\"",
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/sc_test.go - RENAMED - -
    -
    -
    -
    - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - @@ -251962,702 +334729,688 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -646,3 +647,106 @@
    +
    @@ -189,15 +164,14 @@
    - 646 + 189
      - require.Equal(t, 0, big.NewInt(2).Cmp(value)) + // defaultConfig parses the default configuration values
    - 647 + 190
      - } + func defaultConfig() (*egpConfig, error) {
    - 648 + 191
      - } + cfg := egpConfig{
    - + + 192 -
    -   -
    +
    +
    + - + ByteGasCost: 16, // nolint:gomnd
    - + + 193 -
    -   -
    +
    +
    + - + ZeroGasCost: 4, // nolint:gomnd
    - + + 194 -
    -   -
    +
    +
    + - + NetProfitFactor: 1.0, // nolint:gomnd
    - + + 195 -
    -   -
    +
    +
    + - + L1GasPriceFactor: 0.25, // nolint:gomnd
    - + + 196 -
    -   -
    +
    +
    + - + L2GasPriceSugFactor: 0.5, // nolint:gomnd
    - + + 197 -
    -   -
    +
    +
    + - + FinalDeviationPct: 10, // nolint:gomnd
    - + + 198 -
    -   -
    +
    +
    + - + L2GasPriceSugFactorPreEGP: 0.1, // nolint:gomnd
    - + + 199 -
    -   -
    +
    +
    + - + EthTransferGasPrice: 0, // nolint:gomnd
    - + + 200 -
    -   -
    +
    +
    + - + EthTransferL1GasPriceFactor: 0.10, // nolint:gomnd
    - + + 201 -
    +
    +
      -
    + }
    - + + 202 -
    +
    +
     
    - + + 203 -
    +
    +
      -
    + viper.SetConfigType("toml")
    - - -
    -   -
    -
    +
    +
    @@ -268,9 +242,6 @@
    - + + 268 -
    +
    +
      -
    + showDetail = ctx.Bool("showdetail")
    - + + 269 -
    +
    +
      -
    + showAlways = ctx.Bool("showalways")
    - + + 270 -
    +
    +
      -
    + showOnlyCfg = ctx.Bool("onlycfg")
    - + + 271 -
    -   -
    +
    +
    + - + useRealL2GasPrice = ctx.Bool("realgasprice")
    - + + 272 -
    -   -
    +
    +
    + - + showDiscrepancy = ctx.Uint64("showdiscrepancy")
    - + + 273 -
    -   -
    +
    +
    + - + showEncoded = ctx.Bool("showencoded")
    - + + 274 -
    +
    +
     
    - + + 275 -
    +
    +
      -
    + // Load simulation config file
    - + + 276 -
    +
    +
      -
    + var err error
    - - -
    -   -
    -
    +
    +
    @@ -299,7 +270,7 @@
    - + + 299 -
    +
    +
     
    - + + 300 -
    +
    +
      -
    + // Query data
    - + + 301 -
    +
    +
      -
    + query := fmt.Sprintf(`
    - + + 302 -
    -   -
    +
    +
    + - + select lb.received_at, t.l2_block_num, coalesce(t.egp_log::varchar,'') as egp_log, t.encoded, t.hash
    - + + 303 -
    +
    +
      -
    + from state.transaction t
    - + + 304 -
    +
    +
      -
    + join state.l2block lb on lb.block_num = t.l2_block_num
    - + + 305 -
    +
    +
      -
    + where t.l2_block_num >= %d and t.l2_block_num <= %d`, fromBlock, toBlock)
    - - -
    -   -
    -
    +
    +
    @@ -315,14 +286,14 @@
    - + + 315 -
    +
    +
      -
    + logf("Starting from L2 block %d...", fromBlock)
    - + + 316 -
    +
    +
      -
    + var blockReceived time.Time
    - + + 317 -
    +
    +
      -
    + var l2Block uint64
    - + + 318 -
    -   -
    +
    +
    + - + var egpLog, encoded, hash string
    - + + 319 -
    +
    +
      -
    + var timeFirst, timeLast time.Time
    - + + 320 -
    -   -
    +
    +
    + - + var realStats, simulateStats egpStats
    - + + 321 -
    +
    +
     
    - + + 322 -
    +
    +
      -
    + i := uint64(0)
    - + + 323 -
    +
    +
      -
    + for rows.Next() {
    - + + 324 -
    +
    +
      -
    + // Fetch row
    - + + 325 -
    -   -
    +
    +
    + - + err = rows.Scan(&blockReceived, &l2Block, &egpLog, &encoded, &hash)
    - + + 326 -
    +
    +
      -
    + if err != nil {
    - + + 327 -
    +
    +
      -
    + logf("Error fetching row: %v", err)
    - + + 328 -
    +
    +
      -
    + return err
    - - -
    -   -
    -
    +
    +
    @@ -347,38 +318,31 @@
    - + + 347 -
    +
    +
      -
    + i++
    - + + 348 -
    +
    +
     
    - + + 349 -
    +
    +
      -
    + // Transaction info
    - + + 350 -
    -   -
    +
    +
    + - + egpRealData := egpLogRecord{
    - + + 351 -
    +
    +
      -
    + l2BlockReceived: blockReceived,
    - + + 352 -
    +
    +
      -
    + l2BlockNum: l2Block,
    - + + 353 -
    +
    +
      -
    + encoded: encoded,
    - + + 354 -
    -   -
    +
    +
    + - + hash: hash,
    - + + 355 -
    +
    +
      -
    + missingLogInfo: egpLog == "",
    - + + 356 -
    -   -
    +
    +
    + - + realGasPrice: 0,
    - + + 357 -
    -   -
    +
    +
    + - + txZeroCount: 0,
    - + + 358 -
    -   -
    +
    +
    + - + txNonZeroCount: 0,
    - + + 359 -
    +
    +
      -
    + }
    - + + 360 -
    +
    +
     
    - + + 361 -
    +
    +
      -
    + // Check if EGP info is present
    - + + 362 -
    +
    +
      -
    + if egpLog != "" {
    - + + 363 -
    +
    +
      -
    + // Decode EGP log json
    - + + 364 -
    -   -
    +
    +
    + - + err = json.Unmarshal([]byte(egpLog), &egpRealData)
    - + + 365 -
    +
    +
      -
    + if err != nil {
    - + + 366 -
    +
    +
      -
    + logf("Error decoding json from egp_log field: %v", err)
    - + + 367 -
    +
    +
      -
    + return err
    - + + 368 -
    +
    +
      -
    + }
    - + + 369 -
    -   +
    +
    + -
    - + + 370 -
    -   -
    +
    +
    + - + // Calculated fields
    - + + 371 -
    -   -
    +
    +
    + - + egpRealData.realGasPrice = roundEffectiveGasPrice(egpRealData.LogGasPrice, egpRealData.LogPercentage)
    - + + 372 -
    +
    +
      -
    + }
    - + + 373 -
    +
    +
     
    - + + 374 -
    +
    +
      -
    + // Calculate stats
    - + + 375 -
    -   -
    +
    +
    + - + countStats(i, l2Block, &egpRealData, &realStats, nil, nil)
    - + + 376 -
    +
    +
     
    - + + 377 -
    +
    +
      -
    + // Simulate using alternative config
    - + + 378 -
    +
    +
      -
    + if egpCfg != nil {
    - + + 379 -
    -   -
    +
    +
    + - + egpSimData := egpRealData
    - + + 380 -
    +
    +
      -
    + simulateConfig(&egpSimData, egpCfg)
    - + + 381 -
    -   -
    +
    +
    + - + countStats(i, l2Block, &egpSimData, &simulateStats, egpCfg, &egpRealData)
    - + + 382 -
    +
    +
      -
    + }
    - + + 383 -
    +
    +
      -
    + }
    - + + 384 -
    +
    +
     
    - - -
    -   -
    -
    +
    +
    @@ -389,39 +353,25 @@
    - + + 389 -
    +
    +
      -
    + logf("\nPERIOD [%.2f days]: %v ... %v", diff/24, timeFirst, timeLast) // nolint:gomnd
    - + + 390 -
    +
    +
      -
    + if !showOnlyCfg {
    - + + 391 -
    +
    +
      -
    + logf("\nEGP REAL STATS:")
    - + + 392 -
    -   -
    +
    +
    + - + printStats(&realStats)
    - + + 393 -
    +
    +
      -
    + }
    - + + 394 -
    +
    +
     
    - + + 395 -
    +
    +
      -
    + // Print simulation stats results
    - + + 396 -
    +
    +
      -
    + if egpCfg != nil {
    - + + 397 -
    +
    +
      -
    + logf("\nEGP SIMULATION STATS:")
    - + + 398 -
    +
    +
      -
    + printStats(&simulateStats)
    - + + 399 -
    -   -
    +
    +
    + - + var strL2SugFactor string
    - + + 400 -
    -   -
    +
    +
    + - + if useRealL2GasPrice {
    - + + 401 -
    -   -
    +
    +
    + - + strL2SugFactor = "REAL-GASPRICE-USED"
    - + + 402 -
    -   -
    +
    +
    + - + } else {
    - + + 403 -
    -   -
    +
    +
    + - + strL2SugFactor = fmt.Sprintf("%.4f", egpCfg.L2GasPriceSugFactor)
    - + + 404 -
    -   -
    +
    +
    + - + }
    - + + 405 -
    -   -
    +
    +
    + - + logf("PARAMS: byte[%d] zero[%d] netFactor[%.4f] L1factor[%.4f] L2sugFactor[%s] devPct[%d] L2sugPreEGP[%.4f] EthTrsfPrice[%d] EthTrsfL1Fact[%.4f]", egpCfg.ByteGasCost,
    -
    -
    -
    -
    - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    +
    + 406 + +
    + - + egpCfg.ZeroGasCost, egpCfg.NetProfitFactor, egpCfg.L1GasPriceFactor, strL2SugFactor, egpCfg.FinalDeviationPct, egpCfg.L2GasPriceSugFactorPreEGP, +
    - 647 + + 407 +
    -   - require.Equal(t, 0, big.NewInt(2).Cmp(value)) + - + egpCfg.EthTransferGasPrice, egpCfg.EthTransferL1GasPriceFactor)
    - 648 + 408
    @@ -252667,1529 +335420,1422 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 649 + 409
      - } +
    - 650 + + 410 +
    - + -
    +   + return nil
    - 651 + + 411 +
    - + - func TestCounterAndBlock(t *testing.T) { +   + }
    - 652 + + 412 +
    - + - if testing.Short() { +   +
    - 653 + + 413 +
    - + - t.Skip() +   + // countStats calculates and counts statistics for an EGP record
    - 654 + + 414 +
    - + - } + - + func countStats(i uint64, block uint64, egp *egpLogRecord, stats *egpStats, cfg *egpConfig, compareEgp *egpLogRecord) {
    - 655 + + 415 +
    - + -
    + - + var title string
    - 656 + + 416 +
    - + - var err error + - + if cfg == nil {
    - 657 + + 417 +
    - + - err = operations.Teardown() + - + title = "REAL EGP-LOG"
    - 658 + + 418 +
    - + - require.NoError(t, err) + - + } else {
    - 659 + + 419 +
    - + -
    + - + title = "SIM CONFIG"
    - 660 + + 420 +
    - + - defer func() { require.NoError(t, operations.Teardown()) }() + - + }
    - 661 + + 421 +
    - + + -
    - 662 + + 422 +
    - + - ctx := context.Background() +   + // Show record information
    - 663 + + 423 +
    - + - opsCfg := operations.GetDefaultOperationsConfig() +   + if showAlways {
    - 664 + + 424 +
    - + - opsMan, err := operations.NewManager(ctx, opsCfg) + - + printEgpLogRecord(egp, showEncoded, title, cfg == nil)
    - 665 + + 425 +
    - + - require.NoError(t, err) +   + }
    - 666 + + 426 +
    - + - err = opsMan.Setup() +   +
    - 667 + + 427 +
    - + - require.NoError(t, err) +   + // Total transactions
    - 668 - -
    - + -
    -
    +
    +
    @@ -433,7 +383,7 @@
    - 669 + + 433 +
    - + - for _, network := range networks { +   + if showErrors {
    - 670 + + 434 +
    - + - log.Debugf(network.Name) +   + fmt.Printf("egp-error:#%d:(L2 block [%d] %v):%s\n", i, block, egp.l2BlockReceived, egp.LogError)
    - 671 + + 435 +
    - + - client := operations.MustGetClient(network.URL) +   + if showDetail && !showAlways {
    - 672 + + 436 +
    - + - auth := operations.MustGetAuth(network.PrivateKey, network.ChainID) + - + printEgpLogRecord(egp, showEncoded, title, cfg == nil)
    - 673 + + 437 +
    - + -
    +   + }
    - 674 + + 438 +
    - + - _, scTx, sc, err := CounterAndBlock.DeployCounterAndBlock(auth, client) +   + }
    - 675 + + 439 +
    - + - require.NoError(t, err) +   + }
    - 676 - -
    - + -
    -
    +
    +
    @@ -454,7 +404,7 @@
    - 677 + + 454 +
    - + - logTx(scTx) +   + if showReprocess {
    - 678 + + 455 +
    - + - err = operations.WaitTxToBeMined(ctx, client, scTx, operations.DefaultTimeoutTxToBeMined) +   + fmt.Printf("egp-reprocess:#%d:(L2 block [%d] %v)\n", i, block, egp.l2BlockReceived)
    - 679 + + 456 +
    - + - require.NoError(t, err) +   + if showDetail && !showAlways {
    - 680 + + 457 +
    - + -
    + - + printEgpLogRecord(egp, showEncoded, title, cfg == nil)
    - 681 + + 458 +
    - + - scReceipt, err := client.TransactionReceipt(ctx, scTx.Hash()) +   + }
    - 682 + + 459 +
    - + - require.NoError(t, err) +   + }
    - 683 + + 460 +
    - + -
    +   + }
    - 684 - -
    - + - scBlock, err := client.BlockByNumber(ctx, scReceipt.BlockNumber) -
    +
    +
    @@ -480,7 +430,6 @@
    - 685 + + 480 +
    - + - require.NoError(t, err) +   + // Gas total and average
    - 686 + + 481 +
    - + -
    +   + stats.countGasFinal++
    - 687 + + 482 +
    - + - count, ts, err := sc.GetCount(&bind.CallOpts{Pending: false, BlockNumber: scBlock.Number()}) +   + stats.sumGasFinal += egp.LogValueFinal
    - 688 + + 483 +
    - + - require.NoError(t, err) + - + stats.sumRealGas += egp.realGasPrice
    - 689 + + 484 +
    - + +  
    - 690 + + 485 +
    - + - assert.Equal(t, 0, count.Cmp(big.NewInt(0))) +   + // Gas total and average without EGP
    - 691 + + 486 +
    - + - assert.Equal(t, ts.Uint64(), scBlock.Time()) +   + var l2SugPreEGP float64
    - 692 - -
    - + -
    -
    +
    +
    @@ -490,9 +439,9 @@
    - 693 + + 490 +
    - + - const numberOfIncrements = 5 +   + l2SugPreEGP = 0.1
    - 694 + + 491 +
    - + - type result struct { +   + }
    - 695 + + 492 +
    - + - tx *types.Transaction +   +
    - 696 + + 493 +
    - + - receipt *types.Receipt + - + stats.countGasNoEGP++
    - 697 + + 494 +
    - + - block *types.Block + - + stats.sumGasNoEGP += egp.LogL1GasPrice * l2SugPreEGP
    - 698 + + 495 +
    - + - expectedCount *big.Int + - + stats.sumFeeNoEGP += egp.LogL1GasPrice * l2SugPreEGP * egp.LogGasUsedSecond
    - 699 + + 496 +
    - + - } +   +
    - 700 + + 497 +
    - + -
    +   + // Loss
    - 701 + + 498 +
    - + - results := make([]result, 0, numberOfIncrements) +   + if egp.LogValueFinal == egp.LogGasPrice {
    - 702 + +
    @@ -514,27 +463,10 @@
    +
    + 514 +
    - + - for i := 0; i < numberOfIncrements; i++ { +   + info := fmt.Sprintf("reprocess=%t, final=%.0f, egp1=%.0f, egp2=%.0f, user=%.0f", egp.LogReprocess, egp.LogValueFinal, egp.LogGasUsedFirst, egp.LogGasUsedSecond, egp.LogGasPrice)
    - 703 + + 515 +
    - + - tx, err := sc.Increment(auth) +   + fmt.Printf("egp-loss:#%d:(L2 block [%d] %v):loss=%.0f:info:%s\n", i, block, egp.l2BlockReceived, loss, info)
    - 704 + + 516 +
    - + - require.NoError(t, err) +   + if showDetail && !showAlways {
    - 705 + + 517 +
    - + -
    + - + printEgpLogRecord(egp, showEncoded, title, cfg == nil)
    - 706 + + 518 +
    - + - logTx(tx) +   + }
    - 707 + + 519 +
    - + - err = operations.WaitTxToBeMined(ctx, client, tx, operations.DefaultTimeoutTxToBeMined) +   + }
    - 708 + + 520 +
    - + - require.NoError(t, err) +   + }
    - 709 + + 521 +
    - + + -
    - 710 + + 522 +
    - + - receipt, err := client.TransactionReceipt(ctx, tx.Hash()) + - + // Show discrepancies
    - 711 + + 523 +
    - + - require.NoError(t, err) + - + if showDiscrepancy > 0 && compareEgp != nil {
    - 712 + + 524 +
    - + -
    + - + var discrepancy bool
    - 713 + + 525 +
    - + - block, err := client.BlockByNumber(ctx, receipt.BlockNumber) + - + if (showDiscrepancy == 2 || showDiscrepancy == 3) && egp.realGasPrice != compareEgp.realGasPrice {
    - 714 + + 526 +
    - + - require.NoError(t, err) + - + discrepancy = true
    - 715 + + 527 +
    - + -
    + - + fmt.Printf("egp-disc:realgas:#%d:(L2 block [%d] %v):sim=%0.f, real=%0.f\n", i, block, egp.l2BlockReceived, egp.realGasPrice, compareEgp.realGasPrice)
    - 716 + + 528 +
    - + - results = append(results, result{ + - + }
    - 717 + + 529 +
    - + - tx: tx, + - + if (showDiscrepancy == 1 || showDiscrepancy == 3) && egp.LogReprocess != compareEgp.LogReprocess {
    - 718 + + 530 +
    - + - expectedCount: big.NewInt(int64(i) + 1), + - + discrepancy = true
    - 719 + + 531 +
    - + - receipt: receipt, + - + fmt.Printf("egp-disc:reprocess:#%d:(L2 block [%d] %v):sim=%t, real=%t\n", i, block, egp.l2BlockReceived, egp.LogReprocess, compareEgp.LogReprocess)
    - 720 + + 532 +
    - + - block: block, + - + }
    - 721 + + 533 +
    - + - }) + - + if discrepancy && showDetail && !showAlways {
    - 722 + + 534 +
    - + - } + - + printEgpLogRecord(compareEgp, showEncoded, "REAL", true)
    - 723 + + 535 +
    - + -
    + - + printEgpLogRecord(egp, showEncoded, title, cfg == nil)
    - 724 + + 536 +
    - + - const numberOfChecks = 2 + - + }
    - 725 + + 537 +
    - + -
    + - + }
    - 726 + + 538 +
    - + - // checks against first increment +   + }
    - 727 + + 539 +
    - + - for _, r := range results { +   + }
    - 728 + + 540 +
    - + - for i := 0; i < numberOfChecks; i++ { +   +
    - 729 - -
    - + - count, ts, err = sc.GetCount(&bind.CallOpts{Pending: false, BlockNumber: r.block.Number()}) -
    +
    +
    @@ -545,10 +477,9 @@
    - 730 + + 545 +
    - + - require.NoError(t, err) +   + }
    - 731 + + 546 +
    - + - assert.Equal(t, r.expectedCount.Uint64(), count.Uint64()) +   +
    - 732 + + 547 +
    - + - assert.Equal(t, r.block.Time(), ts.Uint64()) +   + // printEgpLogRecord prints values of egpLogRecord struct
    - 733 + + 548 +
    - + -
    + - + func printEgpLogRecord(record *egpLogRecord, showTxInfo bool, title string, isReal bool) {
    - 734 + + 549 +
    - + - time.Sleep(time.Second) + - + fmt.Printf("%s L2BlockNum: [%d]\n", title, record.l2BlockNum)
    - 735 + + 550 +
    - + - } +   + fmt.Printf(" timestamp: [%v]\n", record.l2BlockReceived)
    - 736 + + 551 +
    - + - } + - + fmt.Printf(" hash: [%s]\n", record.hash)
    - 737 + + 552 +
    - + -
    +   + fmt.Printf(" Error: [%s]\n", record.LogError)
    - 738 + + 553 +
    - + - latestIncrement := results[len(results)-1] +   + fmt.Printf(" Enabled: [%t]\n", record.LogEnabled)
    - 739 + + 554 +
    - + - // checks against second increment with latest block +   + fmt.Printf(" L1GasPrice: [%.0f]\n", record.LogL1GasPrice)
    - 740 - -
    - + - for i := 0; i < numberOfChecks; i++ { -
    +
    +
    @@ -565,11 +496,6 @@
    - 741 + + 565 +
    - + - latestBlock, err := client.BlockByNumber(ctx, nil) +   + fmt.Printf(" Percentage: [%d]\n", record.LogPercentage)
    - 742 + + 566 +
    - + - require.NoError(t, err) +   + fmt.Printf(" MaxDeviation: [%.0f]\n", record.LogMaxDeviation)
    - 743 + + 567 +
    - + -
    +   + fmt.Printf(" FinalDeviation: [%.0f]\n", record.LogFinalDeviation)
    - 744 + + 568 +
    - + - count, ts, err = sc.GetCount(&bind.CallOpts{Pending: false}) + - + if !isReal {
    - 745 + + 569 +
    - + - require.NoError(t, err) + - + fmt.Printf(" *zeroBytes: [%d]\n", record.txZeroCount)
    - 746 + + 570 +
    - + - assert.Equal(t, latestIncrement.expectedCount.Uint64(), count.Uint64()) + - + fmt.Printf(" *nonZeroBytes: [%d]\n", record.txNonZeroCount)
    - 747 + + 571 +
    - + - assert.Equal(t, latestBlock.Time(), ts.Uint64()) + - + }
    - 748 + + 572 +
    - + -
    + - + fmt.Printf(" *realGasPrice: [%0.f]\n", record.realGasPrice)
    - 749 + + 573 +
    - + - time.Sleep(time.Second) +   + if showTxInfo {
    - 750 + + 574 +
    - + - } +   + fmt.Printf(" encoded: [%s]\n", record.encoded)
    - 751 + + 575 +
    - + +   }
    - 752 - -
    - + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/e2e/state_test.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - + - - + + + - - - - - - - - - - -
    -
    @@ -59,7 +59,7 @@
    +
    @@ -617,33 +543,30 @@
    - 59 + 617
      - for _, gacc := range testCase.GenesisAccounts { + fmt.Printf(" Tx fee avg...........: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumFee/stats.countGasFinal,
    - 60 + 618
      - genesisAccounts[gacc.Address] = gacc.Balance.Int + stats.sumFee/stats.countGasFinal/GWEI_DIV, stats.sumFee/stats.countGasFinal/ETH_DIV)
    - 61 + 619
      - } + }
    - 62 + 620
    - - require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.BlockNumber, genesisAccounts)) + if stats.countGasNoEGP > 0 {
    - 63 + + 621 +
    -   -
    + - + fmt.Printf(" Gas pri.avg noEGP....: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumGasNoEGP/stats.countGasNoEGP,
    - 64 + + 622 +
    -   - // Check initial root + - + stats.sumGasNoEGP/stats.countGasNoEGP/GWEI_DIV, stats.sumGasNoEGP/stats.countGasNoEGP/ETH_DIV)
    - 65 + + 623 +
    -   - require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot)) + - + }
    -
    @@ -82,7 +82,7 @@
    +
    + 624 + +
    + - + if stats.countGasNoEGP > 0 { +
    - 82 + + 625 +
    -   -
    + - + fmt.Printf(" Tx fee avg noEGP.....: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumFeeNoEGP/stats.countGasNoEGP, +
    +
    + 626 + +
    + - + stats.sumFeeNoEGP/stats.countGasNoEGP/GWEI_DIV, stats.sumFeeNoEGP/stats.countGasNoEGP/ETH_DIV)
    - 83 + + 627 +
    -   - st := opsman.State() + - + }
    - 84 + + 628 +
    -   -
    + - + fmt.Printf(" Diff fee EGP-noEGP...: [%.0f] (%.3f Gwei) (%.9f ETH)\n", stats.sumFee-stats.sumFeeNoEGP,
    - 85 + 629
    - - // Check leafs + (stats.sumFee-stats.sumFeeNoEGP)/GWEI_DIV, (stats.sumFee-stats.sumFeeNoEGP)/ETH_DIV)
    - 86 + + 630 +
    -   - l2Block, err := st.GetLastL2Block(ctx, nil) + - + fmt.Printf(" Loss count...........: [%.0f] (%.2f%%)\n", stats.totalLossCount, stats.totalLossCount/statsCount*100) // nolint:gomnd
    - 87 + + 631 +
    -   - require.NoError(t, err) + - + fmt.Printf(" Loss total.......: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.totalLoss, stats.totalLoss/GWEI_DIV, stats.totalLoss/ETH_DIV)
    - 88 + 632
      - for addrStr, leaf := range testCase.ExpectedNewLeafs { -
    -
    -
    + if stats.totalLossCount > 0 {
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 59 + + 633 +
    -   - for _, gacc := range testCase.GenesisAccounts { + - + fmt.Printf(" Loss average.....: [%.0f] (%.0f GWei) (%.9f ETH)\n", stats.totalLoss/stats.totalLossCount, stats.totalLoss/stats.totalLossCount/GWEI_DIV,
    - 60 + 634
      - genesisAccounts[gacc.Address] = gacc.Balance.Int + stats.totalLoss/stats.totalLossCount/ETH_DIV)
    - 61 + 635
      - } + }
    - 62 + + 636 +
    - + - require.NoError(t, opsman.SetGenesisAccountsBalance(genesisConfig.Genesis.RollupBlockNumber, genesisAccounts)) + - + fmt.Printf(" Real gas price total.: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumRealGas, stats.sumRealGas/GWEI_DIV, stats.sumRealGas/ETH_DIV)
    - 63 + 637
      -
    + }
    - 64 + 638
      - // Check initial root + }
    - 65 + 639
      - require.NoError(t, opsman.CheckVirtualRoot(testCase.ExpectedOldRoot)) +
    -
     
    -
    - 82 + 640
      -
    + // simulateConfig simulates scenario using received config
    - 83 + 641
      - st := opsman.State() + func simulateConfig(egp *egpLogRecord, cfg *egpConfig) {
    - 84 + 642
      -
    -
    -
    - 85 - -
    - + - // Check leaves + // L2 and user gas price
    - 86 + + 643 +
    -   - l2Block, err := st.GetLastL2Block(ctx, nil) + - + if !useRealL2GasPrice || !egp.LogEnabled {
    - 87 + + 644 +
    -   - require.NoError(t, err) + - + egp.LogL2GasPrice = egp.LogL1GasPrice * cfg.L2GasPriceSugFactor
    - 88 + + 645 +
    -   - for addrStr, leaf := range testCase.ExpectedNewLeafs { -
    -
    -
    + - + egp.LogGasPrice = egp.LogL2GasPrice
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + +
    -
    @@ -1,4 +1,4 @@
    - 1 + + 646 +
    - - DOCKERCOMPOSE := docker-compose -f docker-compose.yml + }
    - 2 + 647
      - DOCKERCOMPOSEAPPSEQ := zkevm-sequencer +
    - 3 + 648
      - DOCKERCOMPOSEAPPSEQV1TOV2 := zkevm-sequencer-v1tov2 + // Compute EGP
    - 4 + 649
      - DOCKERCOMPOSEAPPSEQSENDER := zkevm-sequence-sender + var err error
    -
    @@ -26,6 +26,7 @@
    +
    @@ -679,64 +602,43 @@
    - 26 + 679
      - DOCKERCOMPOSEZKPROVER := zkevm-prover + egp.LogValueFinal = egp.LogGasPrice
    - 27 + 680
      - DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db + }
    - 28 + 681
      - DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node + }
    - + + 682 -
    -   -
    +
    +
    + - + // Gas price effective percentage
    - 29 + + 683 +
    -   - DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover + - + egp.LogPercentage = calcEffectivePercentage(egp.LogGasPrice, egp.LogValueFinal)
    - 30 + 684
      - DOCKERCOMPOSENODEAPPROVE := zkevm-approve + } else {
    - 31 + 685
      - DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2 + egp.LogValueSecond = 0
    -
    @@ -62,6 +63,7 @@
    -
    - 62 + 686
    @@ -254199,72 +336845,57 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 63 + 687
      - RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB) + // Final gas: price signed
    - 64 + 688
      - RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE) -
    -
    - - -
    -   -
    + egp.LogValueFinal = egp.LogGasPrice
    - 65 + + 689 +
    -   - RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) + - + // Gas price effective percentage
    - 66 + + 690 +
    -   -
    + - + egp.LogPercentage = uint64(state.MaxEffectivePercentage)
    - 67 + 691
      - RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE) + }
    -
    @@ -101,6 +103,7 @@
    -
    - 101 + 692
    @@ -254273,858 +336904,832 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 102 + + 693 +
    -   - STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB) + - + // Real price paid by the user (to perform a double check)
    - 103 + + 694 +
    -   - STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE) -
    -
    - - -
    -   -
    + - + egp.realGasPrice = roundEffectiveGasPrice(egp.LogGasPrice, egp.LogPercentage)
    - 104 + + 695 +
    -   - STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) + - + }
    - 105 + + 696 +
    -   + -
    - 106 + + 697 +
    -   - STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE) + - + func calcEffectivePercentage(gasPrice float64, gasEffective float64) uint64 {
    -
    @@ -110,6 +113,9 @@
    -
    - 110 + + 698 +
    -   -
    + - + if gasPrice > 0 {
    - 111 + + 699 +
    -   - STOP := $(DOCKERCOMPOSE) down --remove-orphans + - + return uint64(((gasEffective*256)+gasPrice-1)/gasPrice - 1) // nolint:gomnd
    - 112 + 700
      -
    -
    -
    - - -
    -   -
    -
    -
    - - -
    -   -
    + } else {
    - + + 701 -
    -   -
    +
    +
    + - + return 0
    - 113 + 702
      - .PHONY: test-full-non-e2e + }
    - 114 + 703
      - test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions + }
    - 115 + 704
      - $(RUNSTATEDB) +
    -
    @@ -248,6 +254,17 @@
    -
    - 248 + + 705 +
    -   - docker logs $(DOCKERCOMPOSEZKPROVER) + - + func roundEffectiveGasPrice(gasPrice float64, pct uint64) float64 {
    - 249 + + 706 +
    -   - trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/... + - + return gasPrice / 256 * float64(pct+1) // nolint:gomnd
    - 250 + + 707 +
    -   -
    + - + }
    - + + 708 -
    -   +
    +
    + -
    - + + 709 -
    +
    +
      -
    + // calcEffectiveGasPrice calculates the effective gas price
    - + + 710 -
    +
    +
      -
    + func calcEffectiveGasPrice(gasUsed float64, tx *egpLogRecord, cfg *egpConfig) (float64, error) {
    - + + 711 -
    -   -
    +
    +
    + - + // Decode tx
    - + + 712 -
    -   -
    +
    +
    + - + rawBytes, err := decodeTx(tx)
    - + + 713 -
    -   -
    +
    +
    + - + if err != nil {
    - + + 714 -
    -   -
    +
    +
    + - + return 0, err
    - + + 715 -
    -   -
    +
    +
    + - + }
    - + + 716 -
    -   +
    +
    + -
    - + + 717 -
    -   -
    +
    +
    + - + // Zero and non zero bytes
    - + + 718 -
    -   -
    +
    +
    + - + txZeroBytes := uint64(bytes.Count(rawBytes, []byte{0}))
    - 251 + + 719 +
    -   - .PHONY: benchmark-sequencer-eth-transfers + - + txNonZeroBytes := uint64(len(rawBytes)) - txZeroBytes
    - 252 + + 720 +
    -   - benchmark-sequencer-eth-transfers: stop + - + tx.txZeroCount = txZeroBytes
    - 253 + + 721 +
    -   - $(RUNL1NETWORK) + - + tx.txNonZeroCount = txNonZeroBytes
    -
    @@ -364,7 +381,7 @@
    -
    - 364 + + 722 +
    -   - $(STOPZKPROVER) + - +
    - 365 + 723
      -
    + // Calculate break even gas price
    - 366 + 724
      - .PHONY: run-l1-explorer + var breakEvenGasPrice float64
    - 367 + 725
    - - run-l1-explorer: ## Runs L1 blockscan explorer + if gasUsed == ethTransferGasValue {
    - 368 + + 726 +
    -   - $(RUNEXPLORERL1DB) + - + // Transfer
    - 369 + + 727 +
    -   - $(RUNEXPLORERL1) + - + if cfg.EthTransferGasPrice != 0 {
    - 370 + + 728 +
    -   -
    + - + breakEvenGasPrice = float64(cfg.EthTransferGasPrice)
    -
    @@ -434,7 +451,7 @@
    -
    - 434 + + 729 +
    -   - .PHONY: stop-seqsender-v1tov2 + - + } else if cfg.EthTransferL1GasPriceFactor != 0 {
    - 435 + + 730 +
    -   - stop-seqsender-v1tov2: ## stops the sequencer sender + - + if tx.LogL1GasPrice == 0 {
    - 436 + + 731 +
    -   - $(STOPV1TOV2SEQUENCESENDER) + - + breakEvenGasPrice = 1
    - 437 + + 732 +
    - - + } else {
    - 438 + + 733 +
    -   - .PHONY: run-sync + - + breakEvenGasPrice = tx.LogL1GasPrice * cfg.EthTransferL1GasPriceFactor
    - 439 + + 734 +
    -   - run-sync: ## runs the synchronizer + - + }
    - 440 + + 735 +
    -   - $(RUNSYNC) + - + }
    -
    @@ -498,7 +515,7 @@
    -
    - 498 + + 736 +
    -   - .PHONY: stop-eth-tx-manager-v1tov2 + - + } else if gasUsed == 0 {
    - 499 + 737
      - stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service + breakEvenGasPrice = tx.LogGasPrice
    - 500 + 738
      - $(STOPV1TOV2ETHTXMANAGER) + } else {
    - 501 + + -
    - - - +
    +
    +   +
    - 502 + + -
    +
    +
      - .PHONY: run-agg +
    - 503 + + -
    +
    +
      - run-agg: ## Runs the aggregator service +
    - 504 + + -
    +
    +
      - $(RUNAGGREGATOR) +
    -
    @@ -540,7 +557,7 @@
    -
    - 540 + + -
    +
    +
      - $(RUNPERMISSIONLESSDB) +
    - 541 + + -
    +
    +
      - sleep 3 +
    - 542 + + -
    +
    +
      - $(RUNPERMISSIONLESSZKPROVER) +
    - 543 + + -
    - - - +
    +
    +   +
    - 544 + + -
    +
    +
     
    - 545 + + -
    +
    +
      - PHONY: stop-permissionless-dependencies +
    - 546 + + -
    +
    +
      - stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node +
    -
    @@ -629,7 +646,7 @@
    -
    - 629 + 739
      - go run ./scripts/init_network/main.go . + l2MinGasPrice := tx.LogL1GasPrice * cfg.L1GasPriceFactor
    - 630 + + -
    +
    +
     
    - 631 + + -
    +
    +
      - .PHONY: show-logs +
    - 632 + + -
    - - - show-logs: ## Show logs for running docker +
    +
    +   +
    - 633 + 740
      - $(DOCKERCOMPOSE) logs + totalTxPrice := gasUsed*l2MinGasPrice + float64((fixedBytesTx+txNonZeroBytes)*cfg.ByteGasCost+txZeroBytes*cfg.ZeroGasCost)*tx.LogL1GasPrice
    - 634 + 741
      -
    + breakEvenGasPrice = totalTxPrice / gasUsed * cfg.NetProfitFactor
    - 635 + 742
      - .PHONY: deploy-sc + }
    -
    @@ -669,7 +686,7 @@
    +
    @@ -744,7 +646,7 @@
    - 669 + 744
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=StateMock --filename=mock_state.go + // Calculate effective gas price
    - 670 + 745
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=txPool --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=PoolMock --filename=mock_pool.go + var ratioPriority float64
    - 671 + 746
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../sequencer --outpkg=sequencer --structname=DbTxMock --filename=mock_dbtx.go + if tx.LogGasPrice > tx.LogL2GasPrice {
    - 672 + 747
    - - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=etherman --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go + ratioPriority = tx.LogGasPrice / tx.LogL2GasPrice
    - 673 + 748
      -
    + } else {
    - 674 + 749
      - .PHONY: generate-mocks-sequencesender + ratioPriority = 1
    - 675 + 750
      - generate-mocks-sequencesender: ## Generates mocks for sequencesender , using mockery tool + }
    +
    +
    +
    +
    + + + - - - - - - - - + + + + + + + + + @@ -255149,162 +337754,182 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + - + + + + + + - - - - - - - - - - + - - - - - - - - - - @@ -255319,17 +337944,17 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -255402,6 +338012,16 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    + + + - - - - - - - - - - - - - - - - - - - - - + - - - - - - @@ -255693,43 +338283,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - @@ -255784,161 +338374,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -
    @@ -685,10 +702,12 @@
    +
     
    - 685 + 25
      - .PHONY: generate-mocks-synchronizer + )
    - 686 + 26
      - generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool +
    - 687 + 27
      - ## mocks for synchronizer + var (
    - 688 + + 28 +
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} + + + showErrors bool
    - 689 + + 29 +
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS} + + + showLosses bool
    - 690 + + 30 +
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethTxManager --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} + + + showReprocess bool
    - 691 + + 31 +
    - - - #export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../synchronizer --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS} + + + showDetail bool +
    +
    + 32 + +
    + + + showAlways bool +
    +
    + 33 + +
    + + + showOnlyCfg bool +
    +
    + + +
    +   +
    - 692 + 34
      - for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \ + )
    - 693 + 35
      - camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \ +
    - 694 + 36
      - echo $$camelcase ; \ + const (
    -
    @@ -697,7 +716,7 @@
    +
    + 37 + +
    + + + signatureBytes = 65 +
    - 697 + + 38 + +
    + + + effectivePctBytes = 1 +
    +
    + 39 + +
    + + + fixedBytesTx = signatureBytes + effectivePctBytes +
    +
    + -
    +
    +
     
    - 698 + 40
      - rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks + )
    - 699 + 41
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS} -
    -
    - 700 - -
    - - - +
    - 701 + 42
      - rm -Rf ../synchronizer/l2_sync/l2_shared/mocks + type egpConfig struct {
    - 702 + + 43 +
    -   - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS} + + + ByteGasCost uint64 // gas cost of 1 byte
    - 703 + + 44 +
    -   - + + + ZeroGasCost uint64 // gas cost of 1 byte zero
    -
    @@ -707,6 +726,9 @@
    +
    + 45 + +
    + + + NetProfitFactor float64 // L2 network profit factor +
    - 707 + + 46 +
    -   - rm -Rf ../synchronizer/actions/elderberry/mocks + + + L1GasPriceFactor float64 // L1 gas price factor
    - 708 + + 47 +
    -   - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} + + + L2GasPriceSugFactor float64 // L2 gas price suggester factor
    - 709 + + 48 +
    -   - + + + FinalDeviationPct uint64 // max final deviation percentage
    - + + 49 -
    -   -
    +
    +
    + + + MinGasPriceAllowed uint64 // min gas price allowed
    - + + 50 -
    -   -
    +
    +
    + + + L2GasPriceSugFactorPreEGP float64 // L2 gas price suggester factor (pre EGP)
    - 710 + 51
      - + }
    - 711 + 52
    @@ -255339,57 +337964,42 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 712 + 53
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} + type egpLogRecord struct {
    -
    @@ -723,7 +745,11 @@
    -
    - 723 + 54
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go + l2BlockNum uint64
    - 724 + 55
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go + l2BlockReceived time.Time
    - 725 + 56
      -
    -
    -
    - 726 - -
    - - - .PHONY: generate-mocks-aggregator + encoded string
    + 57 + +
    +   + missingLogInfo bool // Flag if egp_log field is empty +
    +
    @@ -255434,137 +338054,132 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 727 + 58
      - generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool + LogError string `json:"Error"`
    - 728 + 59
      - ## mocks for the aggregator tests + LogEnabled bool `json:"Enabled"`
    - 729 + 60
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go + LogL1GasPrice float64 `json:"L1GasPrice"` // L1 gas price
    -
    @@ -733,7 +759,7 @@
    +
     
    - 733 + 88
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go + totalLoss float64 // Total loss gas amount
    - 734 + 89
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go + sumGasFinal float64 // Accumulated sum of final gas (to get average)
    - 735 + 90
      -
    + countGasFinal float64 // Count number of accumulated (to get average)
    - 736 + + 91 +
    - - - .PHONY: generate-mocks-state + + + sumGasPreEGP float64 // Accumulated sum of gas without EGP
    - 737 + + 92 +
    -   - generate-mocks-state: ## Generates mocks for state , using mockery tool + + + countGasPreEGP float64 // Count number of accumulated pre EGP (to get average)
    - 738 + 93
      - ## mocks for the aggregator tests + sumFee float64
    - 739 + + 94 +
    -   - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter + + + sumFeePreEGP float64
    -
    @@ -745,6 +771,27 @@
    -
    - 745 + + -
    +
    +
      - run-benchmarks: run-db ## Runs benchmars +
    - 746 + 95
      - go test -bench=. ./state/tree + }
    - 747 + 96
    @@ -255573,73 +338188,48 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    -
    - - -
    -   -
    -
    -
    - + + 97 -
    +
    +
      -
    + func main() {
    - - -
    -   -
    -
    +
    +
     
    - + + 130 -
    +
    +
      -
    + Value: false,
    - + + 131 -
    +
    +
      -
    + },
    - + + 132 -
    +
    +
      -
    + &cli.BoolFlag{
    - + + 133 -
    +
    +
      -
    + Name: "showalways",
    - + + 134 -
    +
    +
      -
    + Usage: "show always full detailed record",
    - + + 135 -
    +
    +
      -
    + Value: false,
    - + + 136 -
    +
    +
      -
    + },
    - 748 + 137
      - .PHONY: compile-scs + &cli.StringFlag{
    - 749 + 138
      - compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml + Name: "cfg",
    - 750 + 139
      - go run ./scripts/cmd... compilesc --input ./contracts + Aliases: []string{"c"},
    -
    -
    -
    -
    - - - + - - - - - + - - - - - - - - @@ -255948,132 +338524,137 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - + + + @@ -256098,92 +338679,92 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - @@ -256193,172 +338774,72 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -256368,67 +338849,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + - - - @@ -256518,497 +339004,382 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -257018,77 +339389,57 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - - - - - - - - + - + + - - - - - - - - -
     
    - 1 - -
    - + - DOCKERCOMPOSE := docker compose -f docker-compose.yml -
    -
    - 2 + 145
      - DOCKERCOMPOSEAPPSEQ := zkevm-sequencer + Usage: "show only simulation results",
    - 3 + 146
      - DOCKERCOMPOSEAPPSEQV1TOV2 := zkevm-sequencer-v1tov2 + Value: false,
    - 4 + 147
      - DOCKERCOMPOSEAPPSEQSENDER := zkevm-sequence-sender + },
    -
     
    +
    + + +
    +   +
    +
    - 26 + + -
    +
    +
      - DOCKERCOMPOSEZKPROVER := zkevm-prover +
    - 27 + + -
    +
    +
      - DOCKERCOMPOSEPERMISSIONLESSDB := zkevm-permissionless-db +
    - 28 + + -
    +
    +
      - DOCKERCOMPOSEPERMISSIONLESSNODE := zkevm-permissionless-node +
    - 29 + + -
    - + - DOCKERCOMPOSEPERMISSIONLESSNODEDAC := zkevm-node-forced-DAC +
    +
    +   +
    - 30 + 148
      - DOCKERCOMPOSEPERMISSIONLESSZKPROVER := zkevm-permissionless-prover + &cli.StringFlag{
    - 31 + 149
      - DOCKERCOMPOSENODEAPPROVE := zkevm-approve + Name: "db",
    - 32 + 150
      - DOCKERCOMPOSENODEAPPROVEV1TOV2 := zkevm-approve-v1tov2 + Usage: "DB connection string: \"host=xxx port=xxx user=xxx dbname=xxx password=xxx\"",
    - 63 + 164
      -
    + // defaultConfig parses the default configuration values
    - 64 + 165
      - RUNPERMISSIONLESSDB := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSDB) + func defaultConfig() (*egpConfig, error) {
    - 65 + 166
      - RUNPERMISSIONLESSNODE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODE) + cfg := egpConfig{
    - 66 + + 167 +
    + - RUNPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC) + ByteGasCost: 16, // nolint:gomnd
    - 67 + + 168 +
    -   - RUNPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) + + + ZeroGasCost: 4, // nolint:gomnd
    - 68 + + 169 +
    -   -
    + + + NetProfitFactor: 1.0, // nolint:gomnd
    - 69 + + 170 +
    -   - RUNAPPROVE := $(DOCKERCOMPOSE) up -d $(DOCKERCOMPOSENODEAPPROVE) + + + L1GasPriceFactor: 0.25, // nolint:gomnd
    -
     
    -
    - 103 + + 171 +
    -   -
    + + + L2GasPriceSugFactor: 0.5, // nolint:gomnd
    - 104 + + 172 +
    -   - STOPPERMISSIONLESSDB := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSDB) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSDB) + + + FinalDeviationPct: 10, // nolint:gomnd
    - 105 + + 173 +
    -   - STOPPERMISSIONLESSNODE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODE) + + + MinGasPriceAllowed: 1000000000, // nolint:gomnd
    - 106 + + 174 +
    + - STOPPERMISSIONLESSNODEDAC := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSNODEDAC) + L2GasPriceSugFactorPreEGP: 0.1, // nolint:gomnd +
    +
    + + +
    +   +
    - 107 + 175
      - STOPPERMISSIONLESSZKPROVER := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSEPERMISSIONLESSZKPROVER) + }
    - 108 + 176
    @@ -256083,12 +338664,12 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 109 + 177
      - STOPAPPROVE := $(DOCKERCOMPOSE) stop $(DOCKERCOMPOSENODEAPPROVE) && $(DOCKERCOMPOSE) rm -f $(DOCKERCOMPOSENODEAPPROVE) + viper.SetConfigType("toml")
    - 113 + 242
      -
    + showDetail = ctx.Bool("showdetail")
    - 114 + 243
      - STOP := $(DOCKERCOMPOSE) down --remove-orphans + showAlways = ctx.Bool("showalways")
    - 115 + 244
      -
    + showOnlyCfg = ctx.Bool("onlycfg")
    - 116 + + -
    - + - RUNDACDB := docker-compose up -d zkevm-data-node-db +
    +
    +   +
    - 117 + + -
    - + - STOPDACDB := docker-compose stop zkevm-data-node-db && docker-compose rm -f zkevm-data-node-db +
    +
    +   +
    - 118 + + -
    - + +
    +
    +  
    - 119 + 245
      - .PHONY: test-full-non-e2e +
    - 120 + 246
      - test-full-non-e2e: stop ## Runs non-e2e tests checking race conditions + // Load simulation config file
    - 121 + 247
      - $(RUNSTATEDB) + var err error
    - 254 + 270
      - docker logs $(DOCKERCOMPOSEZKPROVER) +
    - 255 + 271
      - trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -failfast -race -v -p 1 -timeout 2000s ../ci/e2e-group11/... + // Query data
    - 256 + 272
      -
    -
    -
    - 257 - -
    - + - .PHONY: test-e2e-group-cdk-validium-1 -
    -
    - 258 - -
    - + - test-e2e-group-cdk-validium-1: stop ## Runs cdk-validium-1 e2e tests checking race conditions -
    -
    - 259 - -
    - + - $(RUNSTATEDB) -
    -
    - 260 - -
    - + - $(RUNPOOLDB) -
    -
    - 261 - -
    - + - $(RUNEVENTDB) -
    -
    - 262 - -
    - + - sleep 5 -
    -
    - 263 - -
    - + - $(RUNZKPROVER) -
    -
    - 264 - -
    - + - docker ps -a -
    -
    - 265 - -
    - + - docker logs $(DOCKERCOMPOSEZKPROVER) -
    -
    - 266 - -
    - + - trap '$(STOP)' EXIT; MallocNanoZone=0 go test -count=1 -race -v -p 1 -timeout 2000s ../ci/e2e-group-cdk-validium-1/... + query := fmt.Sprintf(`
    - 267 + + 273 +
    + -
    + select lb.received_at, t.l2_block_num, coalesce(t.egp_log::varchar,'') as egp_log, t.encoded
    - 268 + 274
      - .PHONY: benchmark-sequencer-eth-transfers + from state.transaction t
    - 269 + 275
      - benchmark-sequencer-eth-transfers: stop + join state.l2block lb on lb.block_num = t.l2_block_num
    - 270 + 276
      - $(RUNL1NETWORK) + where t.l2_block_num >= %d and t.l2_block_num <= %d`, fromBlock, toBlock)
    - 381 + 286
      - $(STOPZKPROVER) + logf("Starting from L2 block %d...", fromBlock)
    - 382 + 287
      -
    + var blockReceived time.Time
    - 383 + 288
      - .PHONY: run-l1-explorer + var l2Block uint64
    - 384 + 289
    + - run-l1-explorer: ## Runs L1 blockscan explorer + var egpLog, encoded string
    - 385 + + 290 +
    -   - $(RUNEXPLORERL1DB) + + + var stats, simulateStats egpStats
    - 386 + 291
      - $(RUNEXPLORERL1) + var timeFirst, timeLast time.Time +
    +
    + + +
    +   +
    - 387 + 292
    @@ -256436,79 +338927,74 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
     
    -
    - 451 + 293
      - .PHONY: stop-seqsender-v1tov2 + i := uint64(0)
    - 452 + 294
      - stop-seqsender-v1tov2: ## stops the sequencer sender + for rows.Next() {
    - 453 + 295
      - $(STOPV1TOV2SEQUENCESENDER) + // Fetch row
    - 454 + 296
    + -
    + err = rows.Scan(&blockReceived, &l2Block, &egpLog, &encoded)
    - 455 + 297
      - .PHONY: run-sync + if err != nil {
    - 456 + 298
      - run-sync: ## runs the synchronizer + logf("Error fetching row: %v", err)
    - 457 + 299
      - $(RUNSYNC) + return err
    - 515 + 318
      - .PHONY: stop-eth-tx-manager-v1tov2 + i++
    - 516 + 319
      - stop-eth-tx-manager-v1tov2: ## Stops the eth tx manager service +
    - 517 + 320
      - $(STOPV1TOV2ETHTXMANAGER) + // Transaction info
    - 518 + 321
    + -
    + egpData := egpLogRecord{
    - 519 + 322
      - .PHONY: run-agg + l2BlockReceived: blockReceived,
    - 520 + 323
      - run-agg: ## Runs the aggregator service + l2BlockNum: l2Block,
    - 521 + 324
      - $(RUNAGGREGATOR) + encoded: encoded,
    -
     
    -
    - 557 + + -
    +
    +
      - $(RUNPERMISSIONLESSDB) +
    - 558 + 325
      - sleep 3 + missingLogInfo: egpLog == "",
    - 559 + + -
    +
    +
      - $(RUNPERMISSIONLESSZKPROVER) +
    - 560 + + -
    - + +
    +
    +  
    - 561 + + -
    +
    +
     
    - 562 + 326
      - PHONY: stop-permissionless-dependencies + }
    - 563 + 327
      - stop-permissionless-dependencies: ## Stop the permissionless dependencies (db + prover) without the node +
    -
     
    -
    - 646 + 328
      - go run ./scripts/init_network/main.go . + // Check if EGP info is present
    - 647 + 329
      -
    + if egpLog != "" {
    - 648 + 330
      - .PHONY: show-logs + // Decode EGP log json
    - 649 + 331
    + - show-logs: ## Show logs for running docker -
    -
    - 650 - -
    -   - $(DOCKERCOMPOSE) logs -
    -
    - 651 - -
    -   -
    + err = json.Unmarshal([]byte(egpLog), &egpData)
    - 652 + 332
      - .PHONY: deploy-sc + if err != nil {
    -
     
    -
    - 686 + 333
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=StateMock --filename=mock_state.go + logf("Error decoding json from egp_log field: %v", err)
    - 687 + 334
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=txPool --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=PoolMock --filename=mock_pool.go + return err
    - 688 + 335
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../sequencer --outpkg=sequencer --structname=DbTxMock --filename=mock_dbtx.go -
    -
    - 689 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../sequencer --output=../sequencer --outpkg=sequencer --inpackage --structname=EthermanMock --filename=mock_etherman.go + }
    - 690 + + -
    +
    +
     
    - 691 + + -
    +
    +
      - .PHONY: generate-mocks-sequencesender +
    - 692 + + -
    +
    +
      - generate-mocks-sequencesender: ## Generates mocks for sequencesender , using mockery tool +
    -
     
    -
    - 702 + 336
      - .PHONY: generate-mocks-synchronizer + }
    - 703 + 337
      - generate-mocks-synchronizer: ## Generates mocks for synchronizer , using mockery tool +
    - 704 + 338
      - ## mocks for synchronizer -
    -
    - 705 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthermanFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} -
    -
    - 706 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StateFullInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=StateMock --filename=mock_state.go ${COMMON_MOCKERY_PARAMS} -
    -
    - 707 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=ethTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} + // Calculate stats
    - 708 + 339
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=PoolInterface --dir=../synchronizer/common/syncinterfaces --output=../synchronizer --outpkg=synchronizer --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS} -
    -
    - 709 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Factory --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientFactoryMock --filename=mock_datacommitteeclientfactory.go ${COMMON_MOCKERY_PARAMS} -
    -
    - 710 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Client --srcpkg=github.com/0xPolygon/cdk-data-availability/client --output=../synchronizer --outpkg=synchronizer --structname=dataCommitteeClientMock --filename=mock_datacommitteeclient.go ${COMMON_MOCKERY_PARAMS} -
    -
    - 711 - -
    -   - for i in l1RollupProducerInterface l1RollupConsumerInterface worker synchronizerProcessBlockRangeInterface workersInterface L1ParallelEthermanInterface; do \ + countStats(i, l2Block, &egpData, &stats, nil)
    - 712 + 340
      - camelcase=$$(echo $$i | sed 's/\([a-z0-9]\)\([A-Z]\)/\1_\2/g' | tr '[:upper:]' '[:lower:]') ; \ +
    - 713 + 341
      - echo $$camelcase ; \ + // Simulate using alternative config
    -
     
    -
    - 716 + 342
      -
    + if egpCfg != nil {
    - 717 + + 343 +
    -   - rm -Rf ../synchronizer/l2_sync/l2_sync_etrog/mocks + + + egpSimData := egpData
    - 718 + 344
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_sync_etrog --output ../synchronizer/l2_sync/l2_sync_etrog/mocks --outpkg mock_l2_sync_etrog ${COMMON_MOCKERY_PARAMS} + simulateConfig(&egpSimData, egpCfg)
    - 719 + 345
    + -
    + countStats(i, l2Block, &egpSimData, &simulateStats, egpCfg)
    - 720 + 346
      - rm -Rf ../synchronizer/l2_sync/l2_shared/mocks + }
    - 721 + 347
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l2_sync/l2_shared --output ../synchronizer/l2_sync/l2_shared/mocks --outpkg mock_l2_shared ${COMMON_MOCKERY_PARAMS} + }
    - 722 + 348
      - +
    - 726 + 353
      - rm -Rf ../synchronizer/actions/elderberry/mocks + logf("\nPERIOD [%.2f days]: %v ... %v", diff/24, timeFirst, timeLast) // nolint:gomnd
    - 727 + 354
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} + if !showOnlyCfg {
    - 728 + 355
      - -
    -
    - 729 - -
    - + - rm -Rf ../synchronizer/l1_check_block/mocks -
    -
    - 730 - -
    - + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/l1_check_block --output ../synchronizer/l1_check_block/mocks --outpkg mock_l1_check_block ${COMMON_MOCKERY_PARAMS} + logf("\nEGP REAL STATS:")
    - 731 + + 356 +
    + - + printStats(&stats)
    - 732 + 357
      - + }
    - 733 + 358
    @@ -257098,157 +339449,147 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 734 + 359
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} + // Print simulation stats results
    -
     
    -
    - 745 + 360
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go + if egpCfg != nil {
    - 746 + 361
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go + logf("\nEGP SIMULATION STATS:")
    - 747 + 362
      -
    + printStats(&simulateStats)
    - 748 + 363
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=dataAvailabilityProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=daMock --filename=mock_da.go + logf("PARAMS: byte[%d] zero[%d] netFactor[%.2f] L1factor[%.2f] L2sugFactor[%.2f] devPct[%d] minGas[%d] L2sugPreEGP[%.2f]", egpCfg.ByteGasCost,
    - 749 + + 364 +
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=stateMock --filename=mock_state.go + egpCfg.ZeroGasCost, egpCfg.NetProfitFactor, egpCfg.L1GasPriceFactor, egpCfg.L2GasPriceSugFactor, egpCfg.FinalDeviationPct, egpCfg.MinGasPriceAllowed, egpCfg.L2GasPriceSugFactorPreEGP)
    - 750 + + -
    - + +
    +
    +  
    - 751 + + -
    - + +
    +
    +  
    - 752 + + -
    - + - .PHONY: generate-mocks-aggregator +
    +
    +   +
    - 753 + + -
    +
    +
      - generate-mocks-aggregator: ## Generates mocks for aggregator , using mockery tool +
    - 754 + + -
    +
    +
      - ## mocks for the aggregator tests +
    - 755 + + -
    +
    +
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StateMock --filename=mock_state.go +
    -
     
    -
    - 759 + + -
    +
    +
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=aggregatorTxProfitabilityChecker --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProfitabilityCheckerMock --filename=mock_profitabilitychecker.go +
    - 760 + 365
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../aggregator/mocks --outpkg=mocks --structname=DbTxMock --filename=mock_dbtx.go + }
    - 761 + 366
    @@ -257257,377 +339598,368 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 762 + + 367 +
    - + - .PHONY: generate-mocks-state +   + return nil
    - 763 + 368
      - generate-mocks-state: ## Generates mocks for state , using mockery tool + }
    - 764 + 369
      - ## mocks for the aggregator tests +
    - 765 + 370
      - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=storage --dir=../state --output=../state/mocks --outpkg=mocks --structname=StorageMock --filename=mock_storage.go --disable-version-string --with-expecter + // countStats calculates and counts statistics for an EGP record
    -
     
    +
    + 371 + +
    + + + func countStats(i uint64, block uint64, egp *egpLogRecord, stats *egpStats, cfg *egpConfig) { +
    - 771 + + -
    +
    +
      - run-benchmarks: run-db ## Runs benchmars +
    - 772 + + -
    +
    +
      - go test -bench=. ./state/tree +
    - 773 + + -
    +
    +
     
    - 774 + + -
    - + - .PHONY: run-dac-db +
    +
    +   +
    - 775 + + -
    - + - run-dac-db: ## Suns the DAC DB +
    +
    +   +
    - 776 + + -
    - + - $(RUNDACDB) +
    +
    +   +
    - 777 + + -
    - + +
    +
    +  
    - 778 + + 372 +
    - + - .PHONY: stop-dac-db +   + // Show record information
    - 779 + + 373 +
    - + - stop-dac-db: ## Stops the DAC DB +   + if showAlways {
    - 780 + + 374 +
    + - $(STOPDACDB) + printEgpLogRecord(egp, false)
    - 781 + + 375 +
    - + -
    +   + }
    - 782 + + 376 +
    - + - .PHONY: run-permissionless-dac +   +
    - 783 + + 377 +
    - + - run-permissionless-dac: ## Runs a permissionless node that is forced to sync through DAC +   + // Total transactions
    - 784 + +
     
    +
    + 383 +
    - + - $(RUNPERMISSIONLESSDB) +   + if showErrors {
    - 785 + + 384 +
    - + - sleep 1 +   + fmt.Printf("egp-error:#%d:(L2 block [%d] %v):%s\n", i, block, egp.l2BlockReceived, egp.LogError)
    - 786 + + 385 +
    - + - $(RUNPERMISSIONLESSZKPROVER) +   + if showDetail && !showAlways {
    - 787 + + 386 +
    + - $(RUNPERMISSIONLESSNODEDAC) + printEgpLogRecord(egp, false)
    - 788 + + 387 +
    - + -
    +   + }
    - 789 + + 388 +
    - + - .PHONY: stop-permissionless-dac +   + }
    - 790 + + 389 +
    - + - stop-permissionless-dac: ## Stops the permissionless node that is forced to sync through DAC +   + }
    - 791 + +
     
    +
    + 404 +
    - + - $(STOPPERMISSIONLESSNODEDAC) +   + if showReprocess {
    - 792 + + 405 +
    - + - $(STOPPERMISSIONLESSZKPROVER) +   + fmt.Printf("egp-reprocess:#%d:(L2 block [%d] %v)\n", i, block, egp.l2BlockReceived)
    - 793 + + 406 +
    - + - $(STOPPERMISSIONLESSDB) +   + if showDetail && !showAlways {
    - 794 + + 407 +
    + -
    + printEgpLogRecord(egp, false)
    - 795 + 408
      - .PHONY: compile-scs + }
    - 796 + 409
      - compile-scs: ## Compiles smart contracts, configuration in test/contracts/index.yaml + }
    - 797 + 410
      - go run ./scripts/cmd... compilesc --input ./contracts + }
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/operations/manager.go - RENAMED - -
    -
    -
    -
    - - - + @@ -257642,182 +339974,202 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + + + + + - - - - - - - - @@ -257980,125 +340332,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    - - -
    -
    @@ -46,6 +46,7 @@
    +
     
    - 46 + 430
      - DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d" + // Gas total and average
    - 47 + 431
      - DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e" + stats.countGasFinal++
    - 48 + 432
      - DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3" + stats.sumGasFinal += egp.LogValueFinal
    - 49 + 433
      - DefaultL1NetworkURL = "http://localhost:8545" +
    - 50 + 434
      - DefaultL1NetworkWebSocketURL = "ws://localhost:8546" + // Gas total and average without EGP
    - 51 + 435
      - DefaultL1ChainID uint64 = 1337 + var l2SugPreEGP float64
    -
    @@ -263,7 +264,6 @@
    +
     
    - 263 + 439
      - if confirmationLevel == PoolConfirmationLevel { + l2SugPreEGP = 0.1
    - 264 + 440
      - return nil, nil + }
    - 265 + 441
      - } +
    - 266 + + 442 +
    - - -
    + + + stats.countGasPreEGP++ +
    +
    + 443 + +
    + + + stats.sumGasPreEGP += egp.LogL1GasPrice * l2SugPreEGP +
    +
    + 444 + +
    + + + stats.sumFeePreEGP += egp.LogL1GasPrice * l2SugPreEGP * egp.LogGasUsedSecond
    - 267 + 445
      - l2BlockNumbers := make([]*big.Int, 0, len(sentTxs)) +
    - 268 + 446
      - for _, tx := range sentTxs { + // Loss
    - 269 + 447
      - // check transaction nonce against transaction reported L2 block number + if egp.LogValueFinal == egp.LogGasPrice {
    -
    @@ -662,3 +662,23 @@
    +
     
    - 662 + 463
      - panic(err) + info := fmt.Sprintf("reprocess=%t, final=%.0f, egp1=%.0f, egp2=%.0f, user=%.0f", egp.LogReprocess, egp.LogValueFinal, egp.LogGasUsedFirst, egp.LogGasUsedSecond, egp.LogGasPrice)
    - 663 + 464
      - } + fmt.Printf("egp-loss:#%d:(L2 block [%d] %v):loss=%.0f:info:%s\n", i, block, egp.l2BlockReceived, loss, info)
    - 664 + 465
      - } + if showDetail && !showAlways {
    - + + 466 -
    -   -
    +
    +
    + + + printEgpLogRecord(egp, false)
    - + + 467 -
    +
    +
      -
    + }
    - + + 468 -
    +
    +
      -
    + }
    - + + 469 -
    +
    +
      -
    + }
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -258146,485 +340379,212 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
     
    -
    - 46 - -
    -   - DefaultL1ZkEVMSmartContract = "0x8dAF17A20c9DBA35f005b6324F493785D239719d" -
    -
    - 47 - -
    -   - DefaultL1RollupManagerSmartContract = "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e" -
    -
    - 48 - -
    -   - DefaultL1PolSmartContract = "0x5FbDB2315678afecb367f032d93F642f64180aa3" -
    -
    - 49 - -
    - + - DefaultL1DataCommitteeContract = "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE" -
    -
    - 50 - -
    -   - DefaultL1NetworkURL = "http://localhost:8545" -
    -
    - 51 - -
    -   - DefaultL1NetworkWebSocketURL = "ws://localhost:8546" -
    -
    - 52 - -
    -   - DefaultL1ChainID uint64 = 1337 -
    -
    -
     
    -
    - 264 - -
    -   - if confirmationLevel == PoolConfirmationLevel { -
    -
    - 265 - -
    -   - return nil, nil -
    -
    - 266 - -
    -   - } -
    -
    @@ -258111,32 +340344,32 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 267 + 470
      - l2BlockNumbers := make([]*big.Int, 0, len(sentTxs)) + }
    - 268 + 471
      - for _, tx := range sentTxs { + }
    - 269 + 472
      - // check transaction nonce against transaction reported L2 block number +
    - 662 + 477
      - panic(err) + }
    - 663 + 478
      - } +
    - 664 + 479
      - } -
    -
    - 665 - -
    - + -
    -
    -
    - 666 - -
    - + - // StartDACDB starts the data availability node DB -
    -
    - 667 - -
    - + - func (m *Manager) StartDACDB() error { -
    -
    - 668 - -
    - + - return StartComponent("dac-db", func() (bool, error) { return true, nil }) -
    -
    - 669 - -
    - + - } -
    -
    - 670 - -
    - + -
    -
    -
    - 671 - -
    - + - // StopDACDB stops the data availability node DB -
    -
    - 672 - -
    - + - func (m *Manager) StopDACDB() error { -
    -
    - 673 - -
    - + - return StopComponent("dac-db") -
    -
    - 674 - -
    - + - } -
    -
    - 675 - -
    - + -
    -
    -
    - 676 - -
    - + - // StartPermissionlessNodeForcedToSYncThroughDAC starts a permissionless node that is froced to sync through the DAC -
    -
    - 677 - -
    - + - func (m *Manager) StartPermissionlessNodeForcedToSYncThroughDAC() error { -
    -
    - 678 - -
    - + - return StartComponent("permissionless-dac", func() (bool, error) { return true, nil }) -
    -
    - 679 - -
    - + - } -
    -
    - 680 - -
    - + -
    -
    -
    - 681 - -
    - + - // StopPermissionlessNodeForcedToSYncThroughDAC stops the permissionless node that is froced to sync through the DAC -
    -
    - 682 - -
    - + - func (m *Manager) StopPermissionlessNodeForcedToSYncThroughDAC() error { + // printEgpLogRecord prints values of egpLogRecord struct
    - 683 + + 480 +
    + - return StopComponent("permissionless-dac") + func printEgpLogRecord(record *egpLogRecord, showTxInfo bool) {
    - 684 + + 481 +
    + - } -
    -
    -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/test/scripts/batchsender/main.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - -
    -
    @@ -111,7 +111,7 @@
    -
    - 111 - -
    -   - return err + fmt.Printf("L2BlockNum: [%d]\n", record.l2BlockNum)
    - 112 + 482
      - } + fmt.Printf(" timestamp: [%v]\n", record.l2BlockReceived)
    - 113 + + -
    +
    +
     
    - 114 - -
    - - - ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config) -
    -
    - 115 - -
    -   - if err != nil { -
    -
    - 116 - -
    -   - return err -
    -
    - 117 - -
    -   - } -
    -
    -
    @@ -183,7 +183,7 @@
    -
    - 183 + 483
      - // send to L1 + fmt.Printf(" Error: [%s]\n", record.LogError)
    - 184 + 484
      - firstSequence := seqs[0] + fmt.Printf(" Enabled: [%t]\n", record.LogEnabled)
    - 185 + 485
      - lastSequence := seqs[len(seqs)-1] + fmt.Printf(" L1GasPrice: [%.0f]\n", record.LogL1GasPrice)
    - 186 - -
    - - - to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From) -
    +
    +
     
    - 187 + 496
      - if err != nil { + fmt.Printf(" Percentage: [%d]\n", record.LogPercentage)
    - 188 + 497
      - return err + fmt.Printf(" MaxDeviation: [%.0f]\n", record.LogMaxDeviation)
    - 189 + 498
      - } + fmt.Printf(" FinalDeviation: [%.0f]\n", record.LogFinalDeviation)
    -
    +
    + + +
    +   +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    -
     
    - 111 + + -
    +
    +
      - return err +
    - 112 + + -
    +
    +
      - } +
    - 113 + + -
    +
    +
     
    - 114 + + -
    - + - ethMan, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, nil, nil) +
    +
    +   +
    - 115 + 499
      - if err != nil { + if showTxInfo {
    - 116 + 500
      - return err + fmt.Printf(" encoded: [%s]\n", record.encoded)
    - 117 + 501
    @@ -258639,226 +340599,217 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 183 + 543
      - // send to L1 + fmt.Printf(" Tx fee avg...........: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumFee/stats.countGasFinal,
    - 184 + 544
      - firstSequence := seqs[0] + stats.sumFee/stats.countGasFinal/GWEI_DIV, stats.sumFee/stats.countGasFinal/ETH_DIV)
    - 185 + 545
      - lastSequence := seqs[len(seqs)-1] + }
    - 186 + 546
    + - to, data, err := ethMan.BuildSequenceBatchesTxData(auth.From, seqs, uint64(lastSequence.LastL2BLockTimestamp), firstSequence.BatchNumber, auth.From, nil) + if stats.countGasPreEGP > 0 {
    - 187 + + 547 +
    -   - if err != nil { + + + fmt.Printf(" Gas pri.avg preEGP...: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumGasPreEGP/stats.countGasPreEGP,
    - 188 + + 548 +
    -   - return err + + + stats.sumGasPreEGP/stats.countGasPreEGP/GWEI_DIV, stats.sumGasPreEGP/stats.countGasPreEGP/ETH_DIV)
    - 189 + + 549 +
    -   + + }
    -
    +
    + 550 + +
    + + + if stats.countGasPreEGP > 0 {
    - - -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/datastreamer/main.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    @@ -558,14 +558,13 @@
    - 558 + + 551 +
    -   - os.Exit(1) + + + fmt.Printf(" Tx fee avg preEGP....: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.sumFeePreEGP/stats.countGasPreEGP,
    - 559 + + 552 +
    -   - } + + + stats.sumFeePreEGP/stats.countGasPreEGP/GWEI_DIV, stats.sumFeePreEGP/stats.countGasPreEGP/ETH_DIV)
    - 560 + + 553 +
    -   -
    + + + }
    - 561 + + 554 +
    - - - client.FromEntry = cliCtx.Uint64("entry") + + + fmt.Printf(" Diff fee EGP-preEGP..: [%.0f] (%.3f Gwei) (%.9f ETH)\n", stats.sumFee-stats.sumFeePreEGP,
    - 562 + + 555 +
    - - - err = client.ExecCommand(datastreamer.CmdEntry) + + + (stats.sumFee-stats.sumFeePreEGP)/GWEI_DIV, (stats.sumFee-stats.sumFeePreEGP)/ETH_DIV)
    - 563 + + 556 +
    -   - if err != nil { + + + fmt.Printf(" Loss count.......: [%.0f] (%.2f%%)\n", stats.totalLossCount, stats.totalLossCount/statsCount*100) // nolint:gomnd
    - 564 + + 557 +
    -   - log.Error(err) + + + fmt.Printf(" Loss total.......: [%.0f] (%.3f GWei) (%.9f ETH)\n", stats.totalLoss, stats.totalLoss/GWEI_DIV, stats.totalLoss/ETH_DIV)
    - 565 + 558
      - os.Exit(1) + if stats.totalLossCount > 0 { +
    +
    + 559 + +
    + + + fmt.Printf(" Loss average.....: [%.0f] (%.0f GWei) (%.9f ETH)\n", stats.totalLoss/stats.totalLossCount, stats.totalLoss/stats.totalLossCount/GWEI_DIV,
    - 566 + 560
      - } + stats.totalLoss/stats.totalLossCount/ETH_DIV)
    - 567 + 561
      -
    + }
    - 568 + + -
    - - - printEntry(client.Entry) +
    +
    +   +
    - 569 + 562
      - return nil + }
    - 570 + 563
    @@ -258868,7 +340819,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 571 + 564
    @@ -258876,354 +340827,344 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0


    -
    @@ -597,35 +596,28 @@
    -
    - 597 + 565
      - Value: l2BlockNumber, + // simulateConfig simulates scenario using received config
    - 598 + 566
      - } + func simulateConfig(egp *egpLogRecord, cfg *egpConfig) {
    - 599 + 567
      -
    + // L2 and user gas price
    - 600 + + 568 +
    - - - client.FromBookmark = bookMark.Encode() + + + egp.LogL2GasPrice = egp.LogL1GasPrice * cfg.L2GasPriceSugFactor
    - 601 + + 569 +
    - - - err = client.ExecCommand(datastreamer.CmdBookmark) + + + egp.LogGasPrice = egp.LogL2GasPrice
    - 602 + + -
    +
    +
      - if err != nil { +
    - 603 + + -
    +
    +
      - log.Error(err) +
    - 604 + 570
      - os.Exit(1) +
    - 605 + 571
      - } + // Compute EGP
    - 606 + + 572 +
    - - -
    +   + var err error
    - 607 - -
    - - - firstEntry := client.Entry -
    +
    +
     
    - 608 + 602
      - printEntry(firstEntry) + egp.LogValueFinal = egp.LogGasPrice
    - 609 + 603
      -
    + }
    - 610 + + 604 +
    - - - client.FromEntry = firstEntry.Number + 1 +   + }
    - 611 + + -
    - - - err = client.ExecCommand(datastreamer.CmdEntry) +
    +
    +   +
    - 612 + + -
    +
    +
      - if err != nil { +
    - 613 + 605
      - log.Error(err) + } else {
    - 614 + 606
      - os.Exit(1) + egp.LogValueSecond = 0
    - 615 + 607
      - } +
    - 616 + + 608 +
    - - -
    +   + // Final gas: price signed
    - 617 + + 609 +
    - - - secondEntry := client.Entry +   + egp.LogValueFinal = egp.LogGasPrice
    - 618 + + -
    +
    +
      - printEntry(secondEntry) +
    - 619 + + -
    +
    +
     
    - 620 + 610
      - i := uint64(2) //nolint:gomnd + }
    - 621 + 611
      - for secondEntry.Type == state.EntryTypeL2Tx { +
    - 622 + + 612 +
    - - - client.FromEntry = firstEntry.Number + i + + + // Gas price effective percentage
    - 623 + + 613 +
    - - - err = client.ExecCommand(datastreamer.CmdEntry) + + + if egp.LogGasPrice > 0 {
    - 624 + + 614 +
    -   - if err != nil { + + + egp.LogPercentage = uint64(((egp.LogValueFinal*256)+egp.LogGasPrice-1)/egp.LogGasPrice - 1) // nolint:gomnd
    - 625 + + -
    +
    +
      - log.Error(err) +
    - 626 + + -
    +
    +
      - os.Exit(1) +
    - 627 + + -
    +
    +
      - } +
    - 628 + + -
    - - - secondEntry = client.Entry +
    +
    +   +
    - 629 + 615
      - printEntry(secondEntry) + } else {
    - 630 + + 616 +
    -   - i++ + + + egp.LogPercentage = 0
    - 631 + 617
    @@ -259231,58 +341172,44 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    -
    -
    -
    -
    - - - - - - - - - @@ -259296,138 +341223,133 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - - - - - - - - @@ -259441,43 +341363,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -259501,35 +341423,25 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - @@ -259602,292 +341514,307 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - -
    -
     
    -
    - 558 + 618
      - os.Exit(1) + }
    - 559 + 619
      - } +
    - 560 + + -
    +
    +
     
    - 561 + + -
    - + - entry, err := client.ExecCommandGetEntry(cliCtx.Uint64("entry")) +
    +
    +   +
    - 562 + + -
    +
    +
      - if err != nil { +
    - 563 + 620
      - log.Error(err) + // calcEffectiveGasPrice calculates the effective gas price
    - 564 + 621
      - os.Exit(1) + func calcEffectiveGasPrice(gasUsed float64, tx *egpLogRecord, cfg *egpConfig) (float64, error) {
    - 565 + + -
    +
    +
      - } +
    - 566 + + -
    +
    +
     
    - 567 + + -
    - + - printEntry(entry) +
    +
    +   +
    - 568 + + -
    +
    +
      - return nil +
    - 569 + + -
    +
    +
      - } +
    - 570 + + -
    +
    +
     
    -
     
    -
    - 596 + + -
    +
    +
      - Value: l2BlockNumber, +
    - 597 + + -
    +
    +
      - } +
    - 598 + + -
    +
    +
     
    - 599 + + -
    - + - firstEntry, err := client.ExecCommandGetBookmark(bookMark.Encode()) +
    +
    +   +
    - 600 + + -
    +
    +
      - if err != nil { +
    - 601 + 622
      - log.Error(err) + // Calculate break even gas price
    - 602 + 623
      - os.Exit(1) + var breakEvenGasPrice float64
    - 603 + + 624 +
    -   - } + + + if gasUsed == 0 {
    - 604 + + -
    +
    +
      - printEntry(firstEntry) +
    - 605 + + -
    +
    +
     
    - 606 - -
    - + - secondEntry, err := client.ExecCommandGetEntry(firstEntry.Number + 1) -
    -
    @@ -259541,43 +341453,43 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 607 + + -
    +
    +
      - if err != nil { +
    - 608 + + -
    +
    +
      - log.Error(err) +
    - 609 + + -
    +
    +
      - os.Exit(1) +
    - 610 + + -
    +
    +
      - } +
    - 611 + 625
      - printEntry(secondEntry) + breakEvenGasPrice = tx.LogGasPrice
    - 612 + 626
      -
    + } else {
    - 613 + + 627 +
    -   - i := uint64(2) //nolint:gomnd + + + // Decode tx
    - 614 + + 628 +
    -   - for secondEntry.Type == state.EntryTypeL2Tx { + + + rawBytes, err := decodeTx(tx)
    - 615 + + 629 +
    + - entry, err := client.ExecCommandGetEntry(firstEntry.Number + i) + if err != nil {
    - + + 630 -
    -   +
    +
    + + + return 0, err +
    +
    + 631 + +
    + + + } +
    +
    + 632 + +
    + +
    - 616 + + 633 +
    -   - if err != nil { + + + // Zero and non zero bytes
    - 617 + + 634 +
    -   - log.Error(err) + + + txZeroBytes := uint64(bytes.Count(rawBytes, []byte{0}))
    - 618 + + 635 +
    -   - os.Exit(1) + + + txNonZeroBytes := uint64(len(rawBytes)) - txZeroBytes
    - 619 + + 636 +
    -   - } + + +
    - 620 + + 637 +
    + - secondEntry = entry + // Calculates break even gas price
    - 621 + 638
      - printEntry(secondEntry) + l2MinGasPrice := tx.LogL1GasPrice * cfg.L1GasPriceFactor
    - 622 + + 639 +
    -   - i++ + + + if l2MinGasPrice < float64(cfg.MinGasPriceAllowed) {
    - 623 + + 640 +
    -   - } + + + l2MinGasPrice = float64(cfg.MinGasPriceAllowed)
    -
    +
    + 641 + +
    + + + }
    - - -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/genesis/genesisparser/genesisparser.go - RENAMED - -
    -
    -
    -
    - - - - - - - + - - - - - + +
    -
    @@ -16,32 +16,32 @@
    - 16 + 642
      -
    + totalTxPrice := gasUsed*l2MinGasPrice + float64((fixedBytesTx+txNonZeroBytes)*cfg.ByteGasCost+txZeroBytes*cfg.ZeroGasCost)*tx.LogL1GasPrice
    - 17 + 643
      - // GenesisTest2Actions change format from testvector to the used internaly + breakEvenGasPrice = totalTxPrice / gasUsed * cfg.NetProfitFactor
    - 18 + 644
      - func GenesisTest2Actions(accounts []GenesisAccountTest) []*state.GenesisAction { + }
    - 19 - -
    - - - leafs := make([]*state.GenesisAction, 0) -
    +
    +
     
    - 20 + 646
      -
    + // Calculate effective gas price
    - 21 + 647
      - for _, acc := range accounts { + var ratioPriority float64
    - 22 + 648
      - if len(acc.Balance) != 0 && acc.Balance != "0" { + if tx.LogGasPrice > tx.LogL2GasPrice {
    - 23 + + 649 +
    - - - leafs = append(leafs, &state.GenesisAction{ + + + ratioPriority = math.Round(tx.LogGasPrice / tx.LogL2GasPrice)
    - 24 + 650
      - Address: acc.Address, + } else {
    - 25 + 651
      - Type: int(merkletree.LeafTypeBalance), + ratioPriority = 1
    - 26 + 652
      - Value: acc.Balance, + }
    - 27 - -
    -   - }) +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/executor/main.go + RENAMED + +
    +
    +
    +
    + + + + + @@ -259906,27 +341833,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -259936,7 +341863,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -259946,7 +341873,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -259956,7 +341883,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -259976,27 +341903,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -260006,7 +341933,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260016,7 +341943,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260026,7 +341953,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260036,7 +341963,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260046,7 +341973,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260056,7 +341983,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260066,7 +341993,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260076,7 +342003,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -260086,62 +342013,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - - - - @@ -260160,377 +342032,385 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - - - - + + +
    +
    @@ -28,20 +28,20 @@
    @@ -259896,7 +341823,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

      - } + func main() {
      - if len(acc.Nonce) != 0 && acc.Nonce != "0" { + // Start containers
    + 30 +
    - - - leafs = append(leafs, &state.GenesisAction{ +   + defer func() {
    + 31 +
    -   - Address: acc.Address, + - + cmd := exec.Command("docker", "compose", "down", "--remove-orphans")
      - Type: int(merkletree.LeafTypeNonce), + if err := cmd.Run(); err != nil {
      - Value: acc.Nonce, + log.Errorf("Failed stop containers: %v", err)
      - }) + return
      - if len(acc.Bytecode) != 0 { + }()
    + 37 +
    - - - leafs = append(leafs, &state.GenesisAction{ +   + log.Info("Starting DB and prover")
    + 38 +
    -   - Address: acc.Address, + - + cmd := exec.Command("docker", "compose", "up", "-d", "executor-tool-db")
      - Type: int(merkletree.LeafTypeCode), + if out, err := cmd.CombinedOutput(); err != nil {
      - Bytecode: acc.Bytecode, + log.Errorf("Failed to star DB: %w. %v", err, out)
      - }) + return
      - } + }
      - for key, value := range acc.Storage { + time.Sleep(time.Second * waitForDBSeconds)
    - - leafs = append(leafs, &state.GenesisAction{ + cmd = exec.Command("docker", "compose", "up", "-d", "executor-tool-prover")
      - Address: acc.Address, + if out, err := cmd.CombinedOutput(); err != nil {
      - Type: int(merkletree.LeafTypeStorage), + log.Errorf("Failed to star prover: %v. %v", err, out)
      - StoragePosition: key, -
    -
    -
    @@ -49,5 +49,5 @@
    -
    - 49 - -
    -   - }) -
    -
    - 50 - -
    -   - } -
    -
    - 51 - -
    -   - } -
    -
    - 52 - -
    - - - return leafs -
    -
    - 53 - -
    -   - } + return
    - 16 - -
    -   -
    -
    -
    - 17 - -
    -   - // GenesisTest2Actions change format from testvector to the used internaly -
    -
    - 18 - -
    -   - func GenesisTest2Actions(accounts []GenesisAccountTest) []*state.GenesisAction { -
    -
    - 19 - -
    - + - leaves := make([]*state.GenesisAction, 0) -
    -
    - 20 + 28
      -
    + func main() {
    - 21 + 29
      - for _, acc := range accounts { + // Start containers
    - 22 + 30
      - if len(acc.Balance) != 0 && acc.Balance != "0" { + defer func() {
    - 23 + 31
    + - leaves = append(leaves, &state.GenesisAction{ + cmd := exec.Command("docker-compose", "down", "--remove-orphans")
    - 24 + 32
      - Address: acc.Address, + if err := cmd.Run(); err != nil {
    - 25 + 33
      - Type: int(merkletree.LeafTypeBalance), + log.Errorf("Failed stop containers: %v", err)
    - 26 + 34
      - Value: acc.Balance, + return
    - 27 + 35
      - }) + }
    - 28 + 36
      - } + }()
    - 29 + 37
      - if len(acc.Nonce) != 0 && acc.Nonce != "0" { + log.Info("Starting DB and prover")
    - 30 + 38
    + - leaves = append(leaves, &state.GenesisAction{ -
    -
    - 31 - -
    -   - Address: acc.Address, + cmd := exec.Command("docker-compose", "up", "-d", "executor-tool-db")
    - 32 + 39
      - Type: int(merkletree.LeafTypeNonce), + if out, err := cmd.CombinedOutput(); err != nil {
    - 33 + 40
      - Value: acc.Nonce, + log.Errorf("Failed to star DB: %w. %v", err, out)
    - 34 + 41
      - }) + return
    - 35 + 42
      - } + }
    - 36 + 43
      - if len(acc.Bytecode) != 0 { + time.Sleep(time.Second * waitForDBSeconds)
    - 37 + 44
    + - leaves = append(leaves, &state.GenesisAction{ + cmd = exec.Command("docker-compose", "up", "-d", "executor-tool-prover")
    - 38 + 45
      - Address: acc.Address, + if out, err := cmd.CombinedOutput(); err != nil {
    - 39 + 46
      - Type: int(merkletree.LeafTypeCode), + log.Errorf("Failed to star prover: %v. %v", err, out)
    - 40 + 47
      - Bytecode: acc.Bytecode, + return
    +
    +
    +
    +
    +
    +
    + + {/home/stefan/go/src/Polygon/zkevm-node → .}/tools/rlp/main.go + RENAMED + +
    +
    +
    +
    + + + + + - - - + + +
    +
    @@ -238,7 +238,7 @@
    +
    - 41 + 238
      - }) +
    - 42 + 239
      - } + // Extract coded txs.
    - 43 + 240
      - for key, value := range acc.Storage { + // Load contract ABI
    - 44 + + 241 +
    - + - leaves = append(leaves, &state.GenesisAction{ + - + abi, err := abi.JSON(strings.NewReader(etrogpolygonzkevm.EtrogpolygonzkevmABI))
    - 45 + 242
      - Address: acc.Address, + if err != nil {
    - 46 + 243
      - Type: int(merkletree.LeafTypeStorage), + log.Fatal("error reading smart contract abi: ", err)
    - 47 + 244
      - StoragePosition: key, + }
    +
    +
    +
    +
    + + + + + + + + + @@ -260815,6 +342695,81 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    } + + + + + + + + + + + + + + + + + + + + + + + +
     
    - 49 + 238
      - }) +
    - 50 + 239
      - } + // Extract coded txs.
    - 51 + 240
      - } + // Load contract ABI
    - 52 + 241
    + - return leaves + abi, err := abi.JSON(strings.NewReader(polygonzkevm.PolygonzkevmABI))
    - 53 + 242
      - } + if err != nil { +
    +
    + 243 + +
    +   + log.Fatal("error reading smart contract abi: ", err) +
    +
    + 244 + +
    +   + }
    +
    @@ -164,7 +164,7 @@
    +
    + 164 + +
    +   + stateTree = merkletree.NewStateTree(stateDBClient) +
    +
    + 165 + +
    +   + } +
    +
    + 166 + +
    +   +
    +
    +
    + 167 + +
    + - + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, nil, nil) +
    +
    + 168 + +
    +   + return st +
    +
    + 169 + +
    +   + } +
    +
    + 170 + +
    +   +
    +
    +
    @@ -260899,6 +342854,81 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    +
     
    +
    + 164 + +
    +   + stateTree = merkletree.NewStateTree(stateDBClient) +
    +
    + 165 + +
    +   + } +
    +
    + 166 + +
    +   +
    +
    +
    + 167 + +
    + + + st := state.NewState(stateCfg, stateDb, executorClient, stateTree, eventLog, nil) +
    +
    + 168 + +
    +   + return st +
    +
    + 169 + +
    +   + } +
    +
    + 170 + +
    +   +
    +
    +
    diff --git a/test/config/test.genesis.config.json b/test/config/test.genesis.config.json index 07e6ca839c..2646957eb6 100644 --- a/test/config/test.genesis.config.json +++ b/test/config/test.genesis.config.json @@ -6,16 +6,16 @@ "polTokenAddress": "0x5FbDB2315678afecb367f032d93F642f64180aa3", "polygonZkEVMGlobalExitRootAddress": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318" }, - "rollupCreationBlockNumber": 45, - "rollupManagerCreationBlockNumber": 40, - "root": "0x489e44072604e671274ea693d5309e797fb37a3e0d91e5b0f04639c251c05332", + "rollupCreationBlockNumber": 46, + "rollupManagerCreationBlockNumber": 41, + "root": "0xcc9ec17819f4ac7f282949ca8c379c4d3ee1b8b7908c51b9b405b6319af67b32", "genesis": [ { "contractName": "PolygonZkEVMDeployer", "balance": "0", "nonce": "4", - "address": "0xFbD07134824dDEa24E4ae414c18ecbFa98169A24", - "bytecode": "0x60806040526004361061006e575f3560e01c8063715018a61161004c578063715018a6146100e25780638da5cb5b146100f6578063e11ae6cb1461011f578063f2fde38b14610132575f80fd5b80632b79805a146100725780634a94d487146100875780636d07dbf81461009a575b5f80fd5b610085610080366004610908565b610151565b005b6100856100953660046109a2565b6101c2565b3480156100a5575f80fd5b506100b96100b43660046109f5565b610203565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ed575f80fd5b50610085610215565b348015610101575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff166100b9565b61008561012d366004610a15565b610228565b34801561013d575f80fd5b5061008561014c366004610a61565b61028e565b61015961034a565b5f6101658585856103ca565b90506101718183610527565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101ca61034a565b6101d583838361056a565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b905f90a1505050565b5f61020e8383610598565b9392505050565b61021d61034a565b6102265f6105a4565b565b61023061034a565b5f61023c8484846103ca565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b61029661034a565b73ffffffffffffffffffffffffffffffffffffffff811661033e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610347816105a4565b50565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610226576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610335565b5f83471015610435576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610335565b81515f0361049f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610335565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff811661020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610335565b606061020e83835f6040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c65640000815250610618565b6060610590848484604051806060016040528060298152602001610b0860299139610618565b949350505050565b5f61020e83833061072d565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610335565b5f808673ffffffffffffffffffffffffffffffffffffffff1685876040516106d29190610a9c565b5f6040518083038185875af1925050503d805f811461070c576040519150601f19603f3d011682016040523d82523d5f602084013e610711565b606091505b509150915061072287838387610756565b979650505050505050565b5f604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156107eb5782515f036107e45773ffffffffffffffffffffffffffffffffffffffff85163b6107e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610335565b5081610590565b61059083838151156108005781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103359190610ab7565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f830112610870575f80fd5b813567ffffffffffffffff8082111561088b5761088b610834565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108d1576108d1610834565b816040528381528660208588010111156108e9575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f805f806080858703121561091b575f80fd5b8435935060208501359250604085013567ffffffffffffffff80821115610940575f80fd5b61094c88838901610861565b93506060870135915080821115610961575f80fd5b5061096e87828801610861565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff8116811461099d575f80fd5b919050565b5f805f606084860312156109b4575f80fd5b6109bd8461097a565b9250602084013567ffffffffffffffff8111156109d8575f80fd5b6109e486828701610861565b925050604084013590509250925092565b5f8060408385031215610a06575f80fd5b50508035926020909101359150565b5f805f60608486031215610a27575f80fd5b8335925060208401359150604084013567ffffffffffffffff811115610a4b575f80fd5b610a5786828701610861565b9150509250925092565b5f60208284031215610a71575f80fd5b61020e8261097a565b5f5b83811015610a94578181015183820152602001610a7c565b50505f910152565b5f8251610aad818460208701610a7a565b9190910192915050565b602081525f8251806020840152610ad5816040850160208701610a7a565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220330b94dc698c4d290bf55c23f13b473cde6a6bae0030cb902de18af54e35839f64736f6c63430008140033", + "address": "0x51dbd54FCCb6b3A07738fd3E156D588e71f79973", + "bytecode": "0x6080604052600436106100705760003560e01c8063715018a61161004e578063715018a6146100e65780638da5cb5b146100fb578063e11ae6cb14610126578063f2fde38b1461013957600080fd5b80632b79805a146100755780634a94d4871461008a5780636d07dbf81461009d575b600080fd5b610088610083366004610927565b610159565b005b6100886100983660046109c7565b6101cb565b3480156100a957600080fd5b506100bd6100b8366004610a1e565b61020d565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b50610088610220565b34801561010757600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100bd565b610088610134366004610a40565b610234565b34801561014557600080fd5b50610088610154366004610a90565b61029b565b610161610357565b600061016e8585856103d8565b905061017a8183610537565b5060405173ffffffffffffffffffffffffffffffffffffffff821681527fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a15050505050565b6101d3610357565b6101de83838361057b565b506040517f25adb19089b6a549831a273acdf7908cff8b7ee5f551f8d1d37996cf01c5df5b90600090a1505050565b600061021983836105a9565b9392505050565b610228610357565b61023260006105b6565b565b61023c610357565b60006102498484846103d8565b60405173ffffffffffffffffffffffffffffffffffffffff821681529091507fba82f25fed02cd2a23d9f5d11c2ef588d22af5437cbf23bfe61d87257c480e4c9060200160405180910390a150505050565b6102a3610357565b73ffffffffffffffffffffffffffffffffffffffff811661034b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610354816105b6565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610232576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610342565b600083471015610444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e63650000006044820152606401610342565b81516000036104af576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f6044820152606401610342565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f79000000000000006044820152606401610342565b6060610219838360006040518060400160405280601e81526020017f416464726573733a206c6f772d6c6576656c2063616c6c206661696c6564000081525061062b565b60606105a1848484604051806060016040528060298152602001610b3d6029913961062b565b949350505050565b6000610219838330610744565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6060824710156106bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610342565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516106e69190610acf565b60006040518083038185875af1925050503d8060008114610723576040519150601f19603f3d011682016040523d82523d6000602084013e610728565b606091505b50915091506107398783838761076e565b979650505050505050565b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b606083156108045782516000036107fd5773ffffffffffffffffffffffffffffffffffffffff85163b6107fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610342565b50816105a1565b6105a183838151156108195781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103429190610aeb565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261088d57600080fd5b813567ffffffffffffffff808211156108a8576108a861084d565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156108ee576108ee61084d565b8160405283815286602085880101111561090757600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561093d57600080fd5b8435935060208501359250604085013567ffffffffffffffff8082111561096357600080fd5b61096f8883890161087c565b9350606087013591508082111561098557600080fd5b506109928782880161087c565b91505092959194509250565b803573ffffffffffffffffffffffffffffffffffffffff811681146109c257600080fd5b919050565b6000806000606084860312156109dc57600080fd5b6109e58461099e565b9250602084013567ffffffffffffffff811115610a0157600080fd5b610a0d8682870161087c565b925050604084013590509250925092565b60008060408385031215610a3157600080fd5b50508035926020909101359150565b600080600060608486031215610a5557600080fd5b8335925060208401359150604084013567ffffffffffffffff811115610a7a57600080fd5b610a868682870161087c565b9150509250925092565b600060208284031215610aa257600080fd5b6102198261099e565b60005b83811015610ac6578181015183820152602001610aae565b50506000910152565b60008251610ae1818460208701610aab565b9190910192915050565b6020815260008251806020840152610b0a816040850160208701610aab565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2063616c6c20776974682076616c7565206661696c6564a2646970667358221220964619cee0e0baf94c6f8763f013be157da5d54c89e5cff4a8caf4266e13f13a64736f6c63430008140033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266" } @@ -24,8 +24,8 @@ "contractName": "ProxyAdmin", "balance": "0", "nonce": "1", - "address": "0xfADB60b5059e31614e02083fF6C021a24C31c891", - "bytecode": "0x608060405260043610610079575f3560e01c80639623609d1161004c5780639623609d1461012357806399a88ec414610136578063f2fde38b14610155578063f3b7dead14610174575f80fd5b8063204e1c7a1461007d578063715018a6146100c55780637eff275e146100db5780638da5cb5b146100fa575b5f80fd5b348015610088575f80fd5b5061009c6100973660046105e8565b610193565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d0575f80fd5b506100d9610244565b005b3480156100e6575f80fd5b506100d96100f536600461060a565b610257565b348015610105575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff1661009c565b6100d961013136600461066e565b6102e0565b348015610141575f80fd5b506100d961015036600461060a565b610371565b348015610160575f80fd5b506100d961016f3660046105e8565b6103cd565b34801561017f575f80fd5b5061009c61018e3660046105e8565b610489565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b5f60405180830381855afa9150503d805f8114610215576040519150601f19603f3d011682016040523d82523d5f602084013e61021a565b606091505b509150915081610228575f80fd5b8080602001905181019061023c919061075b565b949350505050565b61024c6104d3565b6102555f610553565b565b61025f6104d3565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b5f604051808303815f87803b1580156102c6575f80fd5b505af11580156102d8573d5f803e3d5ffd5b505050505050565b6102e86104d3565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061033e9086908690600401610776565b5f604051808303818588803b158015610355575f80fd5b505af1158015610367573d5f803e3d5ffd5b5050505050505050565b6103796104d3565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102af565b6103d56104d3565b73ffffffffffffffffffffffffffffffffffffffff811661047d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61048681610553565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff166040516101dd907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b5f5473ffffffffffffffffffffffffffffffffffffffff163314610255576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610474565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff81168114610486575f80fd5b5f602082840312156105f8575f80fd5b8135610603816105c7565b9392505050565b5f806040838503121561061b575f80fd5b8235610626816105c7565b91506020830135610636816105c7565b809150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f805f60608486031215610680575f80fd5b833561068b816105c7565b9250602084013561069b816105c7565b9150604084013567ffffffffffffffff808211156106b7575f80fd5b818601915086601f8301126106ca575f80fd5b8135818111156106dc576106dc610641565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561072257610722610641565b8160405282815289602084870101111561073a575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f6020828403121561076b575f80fd5b8151610603816105c7565b73ffffffffffffffffffffffffffffffffffffffff831681525f602060408184015283518060408501525f5b818110156107be578581018301518582016060015282016107a2565b505f6060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea26469706673582212203083a4ccc2e42eed60bd19037f2efa77ed086dc7a5403f75bebb995dcba2221c64736f6c63430008140033", + "address": "0xe34Fe58DDa5b8c6D547E4857E987633aa86a5e90", + "bytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461012b57806399a88ec41461013e578063f2fde38b1461015e578063f3b7dead1461017e57600080fd5b8063204e1c7a14610080578063715018a6146100c95780637eff275e146100e05780638da5cb5b14610100575b600080fd5b34801561008c57600080fd5b506100a061009b366004610608565b61019e565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100d557600080fd5b506100de610255565b005b3480156100ec57600080fd5b506100de6100fb36600461062c565b610269565b34801561010c57600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff166100a0565b6100de610139366004610694565b6102f7565b34801561014a57600080fd5b506100de61015936600461062c565b61038c565b34801561016a57600080fd5b506100de610179366004610608565b6103e8565b34801561018a57600080fd5b506100a0610199366004610608565b6104a4565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907f5c60da1b00000000000000000000000000000000000000000000000000000000815260040190565b600060405180830381855afa9150503d8060008114610225576040519150601f19603f3d011682016040523d82523d6000602084013e61022a565b606091505b50915091508161023957600080fd5b8080602001905181019061024d9190610788565b949350505050565b61025d6104f0565b6102676000610571565b565b6102716104f0565b6040517f8f28397000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690638f283970906024015b600060405180830381600087803b1580156102db57600080fd5b505af11580156102ef573d6000803e3d6000fd5b505050505050565b6102ff6104f0565b6040517f4f1ef28600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841690634f1ef28690349061035590869086906004016107a5565b6000604051808303818588803b15801561036e57600080fd5b505af1158015610382573d6000803e3d6000fd5b5050505050505050565b6103946104f0565b6040517f3659cfe600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152831690633659cfe6906024016102c1565b6103f06104f0565b73ffffffffffffffffffffffffffffffffffffffff8116610498576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6104a181610571565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff166040516101ea907ff851a44000000000000000000000000000000000000000000000000000000000815260040190565b60005473ffffffffffffffffffffffffffffffffffffffff163314610267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161048f565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b73ffffffffffffffffffffffffffffffffffffffff811681146104a157600080fd5b60006020828403121561061a57600080fd5b8135610625816105e6565b9392505050565b6000806040838503121561063f57600080fd5b823561064a816105e6565b9150602083013561065a816105e6565b809150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156106a957600080fd5b83356106b4816105e6565b925060208401356106c4816105e6565b9150604084013567ffffffffffffffff808211156106e157600080fd5b818601915086601f8301126106f557600080fd5b81358181111561070757610707610665565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561074d5761074d610665565b8160405282815289602084870101111561076657600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60006020828403121561079a57600080fd5b8151610625816105e6565b73ffffffffffffffffffffffffffffffffffffffff8316815260006020604081840152835180604085015260005b818110156107ef578581018301518582016060015282016107d3565b5060006060828601015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010192505050939250505056fea2646970667358221220c9867ffac53151bdb1305d8f5e3e883cd83e5270c7ec09cdc24e837b2e65239064736f6c63430008140033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000000": "0x0000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f" } @@ -34,18 +34,18 @@ "contractName": "PolygonZkEVMBridge implementation", "balance": "0", "nonce": "1", - "address": "0x608484d3e94Fc775E3dCb06B0B48486c60A315e6", - "bytecode": "0x6080604052600436106101db575f3560e01c806383f24403116100fd578063ccaa2d1111610092578063ee25560b11610062578063ee25560b146105a9578063f5efcd79146105d4578063f811bff7146105f3578063fb57083414610612575f80fd5b8063ccaa2d111461053b578063cd5865791461055a578063d02103ca1461056d578063dbc1697614610595575f80fd5b8063bab161bf116100cd578063bab161bf146104b9578063be5831c7146104da578063c00f14ab146104fd578063cc4616321461051c575f80fd5b806383f244031461043d5780638ed7e3f21461045c578063aaa13cc21461047b578063b8b284d01461049a575f80fd5b80633cbc795b116101735780637843298b116101435780637843298b146103c257806379e2cf97146103e157806381b1c174146103f557806383c43a5514610429575f80fd5b80633cbc795b146103385780633e197043146103705780634b2f336d1461038f5780635ca1e165146103ae575f80fd5b806327aef4e8116101ae57806327aef4e81461026d5780632dfdf0b51461028e578063318aee3d146102b15780633c351e1014610319575f80fd5b806315064c96146101df5780632072f6c51461020d57806322e95f2c14610223578063240ff3781461025a575b5f80fd5b3480156101ea575f80fd5b506068546101f89060ff1681565b60405190151581526020015b60405180910390f35b348015610218575f80fd5b50610221610631565b005b34801561022e575f80fd5b5061024261023d366004612fb9565b610666565b6040516001600160a01b039091168152602001610204565b610221610268366004613040565b6106d0565b348015610278575f80fd5b50610281610759565b6040516102049190613102565b348015610299575f80fd5b506102a360535481565b604051908152602001610204565b3480156102bc575f80fd5b506102f56102cb36600461311b565b606b6020525f908152604090205463ffffffff81169064010000000090046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b03909116602083015201610204565b348015610324575f80fd5b50606d54610242906001600160a01b031681565b348015610343575f80fd5b50606d5461035b90600160a01b900463ffffffff1681565b60405163ffffffff9091168152602001610204565b34801561037b575f80fd5b506102a361038a366004613144565b6107e5565b34801561039a575f80fd5b50606f54610242906001600160a01b031681565b3480156103b9575f80fd5b506102a361088e565b3480156103cd575f80fd5b506102426103dc3660046131be565b61096a565b3480156103ec575f80fd5b50610221610993565b348015610400575f80fd5b5061024261040f366004613204565b606a6020525f90815260409020546001600160a01b031681565b348015610434575f80fd5b506102816109b4565b348015610448575f80fd5b506102a361045736600461322c565b6109d3565b348015610467575f80fd5b50606c54610242906001600160a01b031681565b348015610486575f80fd5b5061024261049536600461332d565b610aa8565b3480156104a5575f80fd5b506102216104b43660046133c3565b610be7565b3480156104c4575f80fd5b5060685461035b90610100900463ffffffff1681565b3480156104e5575f80fd5b5060685461035b90600160c81b900463ffffffff1681565b348015610508575f80fd5b5061028161051736600461311b565b610cc2565b348015610527575f80fd5b506101f8610536366004613441565b610d07565b348015610546575f80fd5b50610221610555366004613472565b610d8f565b610221610568366004613556565b6112c0565b348015610578575f80fd5b50606854610242906501000000000090046001600160a01b031681565b3480156105a0575f80fd5b5061022161172c565b3480156105b4575f80fd5b506102a36105c3366004613204565b60696020525f908152604090205481565b3480156105df575f80fd5b506102216105ee366004613472565b61175f565b3480156105fe575f80fd5b5061022161060d3660046135e6565b611a25565b34801561061d575f80fd5b506101f861062c366004613689565b611d40565b606c546001600160a01b0316331461065c57604051631736745960e31b815260040160405180910390fd5b610664611d57565b565b6040805160e084901b6001600160e01b031916602080830191909152606084901b6bffffffffffffffffffffffff1916602483015282516018818403018152603890920183528151918101919091205f908152606a90915220546001600160a01b03165b92915050565b60685460ff16156106f457604051630bc011ff60e21b815260040160405180910390fd5b341580159061070d5750606f546001600160a01b031615155b15610744576040517f6f625c4000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610752858534868686611db2565b5050505050565b606e8054610766906136ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610792906136ce565b80156107dd5780601f106107b4576101008083540402835291602001916107dd565b820191905f5260205f20905b8154815290600101906020018083116107c057829003601f168201915b505050505081565b6040517fff0000000000000000000000000000000000000000000000000000000000000060f889901b1660208201526001600160e01b031960e088811b821660218401526bffffffffffffffffffffffff19606089811b821660258601529188901b909216603984015285901b16603d82015260518101839052607181018290525f90609101604051602081830303815290604052805190602001209050979650505050505050565b6053545f90819081805b6020811015610961578083901c6001166001036108f557603381602081106108c2576108c2613706565b01546040805160208101929092528101859052606001604051602081830303815290604052805190602001209350610922565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806109599061372e565b915050610898565b50919392505050565b5f61098b848461097985611e7c565b61098286611f66565b61049587612047565b949350505050565b605354606854600160c81b900463ffffffff16101561066457610664612114565b60405180611ba00160405280611b668152602001613d80611b66913981565b5f83815b6020811015610a9f57600163ffffffff8516821c81169003610a4257848160208110610a0557610a05613706565b602002013582604051602001610a25929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a8d565b81858260208110610a5557610a55613706565b6020020135604051602001610a74929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a978161372e565b9150506109d7565b50949350505050565b6040516001600160e01b031960e087901b1660208201526bffffffffffffffffffffffff19606086901b1660248201525f9081906038016040516020818303038152906040528051906020012090505f60ff60f81b308360405180611ba00160405280611b668152602001613d80611b669139898989604051602001610b3093929190613746565b60408051601f1981840301815290829052610b4e929160200161377e565b60405160208183030381529060405280519060200120604051602001610bc394939291907fff0000000000000000000000000000000000000000000000000000000000000094909416845260609290921b6bffffffffffffffffffffffff191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610c0b57604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610c4d576040517fdde3cda700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606f54604051632770a7eb60e21b8152336004820152602481018690526001600160a01b0390911690639dc29fac906044015f604051808303815f87803b158015610c96575f80fd5b505af1158015610ca8573d5f803e3d5ffd5b50505050610cba868686868686611db2565b505050505050565b6060610ccd82611e7c565b610cd683611f66565b610cdf84612047565b604051602001610cf193929190613746565b6040516020818303038152906040529050919050565b6068545f908190610100900463ffffffff16158015610d2c575063ffffffff83166001145b15610d3e575063ffffffff8316610d66565b610d5364010000000063ffffffff85166137ac565b610d639063ffffffff86166137c3565b90505b600881901c5f90815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610db357604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610de3576040516302caf51760e11b815260040160405180910390fd5b610e168c8c8c8c8c610e115f8e8e8e8e8e8e8e604051610e049291906137d6565b60405180910390206107e5565b6121c2565b6001600160a01b038616610f6057606f546001600160a01b0316610efa575f6001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610e6c576020820181803683370190505b50604051610e7a91906137e5565b5f6040518083038185875af1925050503d805f8114610eb4576040519150601f19603f3d011682016040523d82523d5f602084013e610eb9565b606091505b5050905080610ef4576040517f6747a28800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50611256565b606f546040516340c10f1960e01b81526001600160a01b03868116600483015260248201869052909116906340c10f19906044015f604051808303815f87803b158015610f45575f80fd5b505af1158015610f57573d5f803e3d5ffd5b50505050611256565b606d546001600160a01b038781169116148015610f8e5750606d5463ffffffff888116600160a01b90920416145b15610fa5575f6001600160a01b0385168482610e42565b60685463ffffffff610100909104811690881603610fd657610fd16001600160a01b0387168585612354565b611256565b6040516001600160e01b031960e089901b1660208201526bffffffffffffffffffffffff19606088901b1660248201525f9060380160408051601f1981840301815291815281516020928301205f818152606a9093529120549091506001600160a01b0316806111f5575f6110808386868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506123d592505050565b6040516340c10f1960e01b81526001600160a01b03898116600483015260248201899052919250908216906340c10f19906044015f604051808303815f87803b1580156110cb575f80fd5b505af11580156110dd573d5f803e3d5ffd5b5050505080606a5f8581526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b5f836001600160a01b03166001600160a01b031681526020019081526020015f205f820151815f015f6101000a81548163ffffffff021916908363ffffffff1602179055506020820151815f0160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a8388886040516111e7959493929190613828565b60405180910390a150611253565b6040516340c10f1960e01b81526001600160a01b038781166004830152602482018790528216906340c10f19906044015f604051808303815f87803b15801561123c575f80fd5b505af115801561124e573d5f803e3d5ffd5b505050505b50505b604080518b815263ffffffff891660208201526001600160a01b0388811682840152861660608201526080810185905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a1505050505050505050505050565b60685460ff16156112e457604051630bc011ff60e21b815260040160405180910390fd5b6112ec612468565b60685463ffffffff61010090910481169088160361131d576040516302caf51760e11b815260040160405180910390fd5b5f806060876001600160a01b03881661141957883414611369576040517fb89240f500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611396906136ce565b80601f01602080910402602001604051908101604052809291908181526020018280546113c2906136ce565b801561140d5780601f106113e45761010080835404028352916020019161140d565b820191905f5260205f20905b8154815290600101906020018083116113f057829003601f168201915b505050505091506116a3565b3415611451576040517f798ee6f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606f546001600160a01b03908116908916036114c757604051632770a7eb60e21b8152336004820152602481018a90526001600160a01b03891690639dc29fac906044015f604051808303815f87803b1580156114ac575f80fd5b505af11580156114be573d5f803e3d5ffd5b505050506116a3565b6001600160a01b038089165f908152606b602090815260409182902082518084019093525463ffffffff811683526401000000009004909216918101829052901561157957604051632770a7eb60e21b8152336004820152602481018b90526001600160a01b038a1690639dc29fac906044015f604051808303815f87803b158015611551575f80fd5b505af1158015611563573d5f803e3d5ffd5b5050505080602001519450805f01519350611696565b851561158b5761158b898b89896124c1565b6040516370a0823160e01b81523060048201525f906001600160a01b038b16906370a0823190602401602060405180830381865afa1580156115cf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115f39190613860565b905061160a6001600160a01b038b1633308e612860565b6040516370a0823160e01b81523060048201525f906001600160a01b038c16906370a0823190602401602060405180830381865afa15801561164e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116729190613860565b905061167e8282613877565b6068548c9850610100900463ffffffff169650935050505b61169f89610cc2565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b5f84868e8e86886053546040516116e298979695949392919061388a565b60405180910390a16117086117035f85878f8f8789805190602001206107e5565b6128b1565b861561171657611716612114565b5050505061172360018055565b50505050505050565b606c546001600160a01b0316331461175757604051631736745960e31b815260040160405180910390fd5b6106646129b2565b60685460ff161561178357604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146117b3576040516302caf51760e11b815260040160405180910390fd5b6117d58c8c8c8c8c610e1160018e8e8e8e8e8e8e604051610e049291906137d6565b606f545f906001600160a01b031661188857846001600160a01b031684888a868660405160240161180994939291906138f3565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183e91906137e5565b5f6040518083038185875af1925050503d805f8114611878576040519150601f19603f3d011682016040523d82523d5f602084013e61187d565b606091505b505080915050611983565b606f546040516340c10f1960e01b81526001600160a01b03878116600483015260248201879052909116906340c10f19906044015f604051808303815f87803b1580156118d3575f80fd5b505af11580156118e5573d5f803e3d5ffd5b50505050846001600160a01b03168789858560405160240161190a94939291906138f3565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161193f91906137e5565b5f604051808303815f865af19150503d805f8114611978576040519150601f19603f3d011682016040523d82523d5f602084013e61197d565b606091505b50909150505b806119ba576040517f37e391c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080518c815263ffffffff8a1660208201526001600160a01b0389811682840152871660608201526080810186905290517f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d9181900360a00190a150505050505050505050505050565b5f54610100900460ff1615808015611a4357505f54600160ff909116105b80611a5c5750303b158015611a5c57505f5460ff166001145b611ad35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b5f805460ff191660011790558015611af4575f805461ff0019166101001790555b606880547fffffffffffffff000000000000000000000000000000000000000000000000ff1661010063ffffffff8a16027fffffffffffffff0000000000000000000000000000000000000000ffffffffff1617650100000000006001600160a01b038781169190910291909117909155606c805473ffffffffffffffffffffffffffffffffffffffff19168583161790558616611bcf5763ffffffff851615611bca576040517f1a874c1200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ceb565b606d805463ffffffff8716600160a01b027fffffffffffffffff0000000000000000000000000000000000000000000000009091166001600160a01b03891617179055606e611c1e8382613970565b50611cbd5f801b6012604051602001611ca991906060808252600d908201527f5772617070656420457468657200000000000000000000000000000000000000608082015260a0602082018190526004908201527f574554480000000000000000000000000000000000000000000000000000000060c082015260ff91909116604082015260e00190565b6040516020818303038152906040526123d5565b606f805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03929092169190911790555b611cf3612a22565b8015611723575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b5f81611d4d8686866109d3565b1495945050505050565b60685460ff1615611d7b57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a5497905f90a1565b60685463ffffffff610100909104811690871603611de3576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611e3799989796959493929190613a2c565b60405180910390a1611e6e6117036001606860019054906101000a900463ffffffff16338a8a8a8989604051610e049291906137d6565b8215610cba57610cba612114565b60408051600481526024810182526020810180516001600160e01b03167f06fdde030000000000000000000000000000000000000000000000000000000017905290516060915f9182916001600160a01b03861691611edb91906137e5565b5f60405180830381855afa9150503d805f8114611f13576040519150601f19603f3d011682016040523d82523d5f602084013e611f18565b606091505b509150915081611f5d576040518060400160405280600781526020017f4e4f5f4e414d450000000000000000000000000000000000000000000000000081525061098b565b61098b81612a94565b60408051600481526024810182526020810180516001600160e01b03167f95d89b410000000000000000000000000000000000000000000000000000000017905290516060915f9182916001600160a01b03861691611fc591906137e5565b5f60405180830381855afa9150503d805f8114611ffd576040519150601f19603f3d011682016040523d82523d5f602084013e612002565b606091505b509150915081611f5d576040518060400160405280600981526020017f4e4f5f53594d424f4c000000000000000000000000000000000000000000000081525061098b565b60408051600481526024810182526020810180516001600160e01b03167f313ce5670000000000000000000000000000000000000000000000000000000017905290515f91829182916001600160a01b038616916120a591906137e5565b5f60405180830381855afa9150503d805f81146120dd576040519150601f19603f3d011682016040523d82523d5f602084013e6120e2565b606091505b50915091508180156120f5575080516020145b61210057601261098b565b8080602001905181019061098b9190613a97565b6053546068805463ffffffff909216600160c81b027fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117908190556001600160a01b0365010000000000909104166333d6247d61217561088e565b6040518263ffffffff1660e01b815260040161219391815260200190565b5f604051808303815f87803b1580156121aa575f80fd5b505af11580156121bc573d5f803e3d5ffd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101207f257b36320000000000000000000000000000000000000000000000000000000090925260648101919091525f916501000000000090046001600160a01b03169063257b3632906084016020604051808303815f875af1158015612253573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122779190613860565b9050805f036122b1576040517e2f6fad00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80680100000000000000008716156122f5578691506122d3848a8489611d40565b6122f0576040516338105f3b60e21b815260040160405180910390fd5b61233f565b602087901c612305816001613ab2565b9150879250612320612318868c866109d3565b8a8389611d40565b61233d576040516338105f3b60e21b815260040160405180910390fd5b505b6123498282612c64565b505050505050505050565b6040516001600160a01b0383166024820152604481018290526123d09084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612d24565b505050565b5f8060405180611ba00160405280611b668152602001613d80611b6691398360405160200161240592919061377e565b6040516020818303038152906040529050838151602083015ff591506001600160a01b038216612461576040517fbefb092000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6002600154036124ba5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611aca565b6002600155565b5f6124cf6004828486613acf565b6124d891613af6565b90507f2afa5331000000000000000000000000000000000000000000000000000000006001600160e01b03198216016126b2575f80808080808061251f896004818d613acf565b81019061252c9190613b26565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461256c5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146125955760405163750643af60e01b815260040160405180910390fd5b8a85146125ce576040517f03fffc4b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b03167fd505accf000000000000000000000000000000000000000000000000000000001790529151918e169161266591906137e5565b5f604051808303815f865af19150503d805f811461269e576040519150601f19603f3d011682016040523d82523d5f602084013e6126a3565b606091505b50505050505050505050610752565b6001600160e01b031981166323f2ebc360e21b146126fc576040517fe282c0ba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f808080808080806127118a6004818e613acf565b81019061271e9190613b75565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146127605760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146127895760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f169161281091906137e5565b5f604051808303815f865af19150503d805f8114612849576040519150601f19603f3d011682016040523d82523d5f602084013e61284e565b606091505b50505050505050505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526121bc9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612399565b8060016128c060206002613cd3565b6128ca9190613877565b60535410612904576040517fef5ccf6600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f60535f81546129139061372e565b918290555090505f5b60208110156129a3578082901c60011660010361294f57826033826020811061294757612947613706565b015550505050565b6033816020811061296257612962613706565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061299b9061372e565b91505061291c565b506123d0613cde565b60018055565b60685460ff166129ee576040517f5386698100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b3905f90a1565b5f54610100900460ff16612a8c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611aca565b610664612e08565b60606040825110612ab357818060200190518101906106ca9190613cf2565b8151602003612c26575f5b602081108015612b055750828181518110612adb57612adb613706565b01602001517fff000000000000000000000000000000000000000000000000000000000000001615155b15612b1c5780612b148161372e565b915050612abe565b805f03612b5e57505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e4700000000000000000000000000006020820152919050565b5f8167ffffffffffffffff811115612b7857612b78613268565b6040519080825280601f01601f191660200182016040528015612ba2576020820181803683370190505b5090505f5b82811015612c1e57848181518110612bc157612bc1613706565b602001015160f81c60f81b828281518110612bde57612bde613706565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a90535080612c168161372e565b915050612ba7565b509392505050565b505060408051808201909152601281527f4e4f545f56414c49445f454e434f44494e470000000000000000000000000000602082015290565b919050565b6068545f90610100900463ffffffff16158015612c87575063ffffffff82166001145b15612c99575063ffffffff8216612cc1565b612cae64010000000063ffffffff84166137ac565b612cbe9063ffffffff85166137c3565b90505b600881901c5f8181526069602052604081208054600160ff861690811b91821892839055929091908183169003611723576040517f646cf55800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f612d78826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612e729092919063ffffffff16565b8051909150156123d05780806020019051810190612d969190613d64565b6123d05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611aca565b5f54610100900460ff166129ac5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401611aca565b606061098b84845f85855f80866001600160a01b03168587604051612e9791906137e5565b5f6040518083038185875af1925050503d805f8114612ed1576040519150601f19603f3d011682016040523d82523d5f602084013e612ed6565b606091505b5091509150612ee787838387612ef2565b979650505050505050565b60608315612f605782515f03612f59576001600160a01b0385163b612f595760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611aca565b508161098b565b61098b8383815115612f755781518083602001fd5b8060405162461bcd60e51b8152600401611aca9190613102565b803563ffffffff81168114612c5f575f80fd5b6001600160a01b0381168114612fb6575f80fd5b50565b5f8060408385031215612fca575f80fd5b612fd383612f8f565b91506020830135612fe381612fa2565b809150509250929050565b8015158114612fb6575f80fd5b5f8083601f84011261300b575f80fd5b50813567ffffffffffffffff811115613022575f80fd5b602083019150836020828501011115613039575f80fd5b9250929050565b5f805f805f60808688031215613054575f80fd5b61305d86612f8f565b9450602086013561306d81612fa2565b9350604086013561307d81612fee565b9250606086013567ffffffffffffffff811115613098575f80fd5b6130a488828901612ffb565b969995985093965092949392505050565b5f5b838110156130cf5781810151838201526020016130b7565b50505f910152565b5f81518084526130ee8160208601602086016130b5565b601f01601f19169290920160200192915050565b602081525f61311460208301846130d7565b9392505050565b5f6020828403121561312b575f80fd5b813561311481612fa2565b60ff81168114612fb6575f80fd5b5f805f805f805f60e0888a03121561315a575f80fd5b873561316581613136565b965061317360208901612f8f565b9550604088013561318381612fa2565b945061319160608901612f8f565b935060808801356131a181612fa2565b9699959850939692959460a0840135945060c09093013592915050565b5f805f606084860312156131d0575f80fd5b6131d984612f8f565b925060208401356131e981612fa2565b915060408401356131f981612fa2565b809150509250925092565b5f60208284031215613214575f80fd5b5035919050565b8061040081018310156106ca575f80fd5b5f805f610440848603121561323f575f80fd5b83359250613250856020860161321b565b915061325f6104208501612f8f565b90509250925092565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156132a5576132a5613268565b604052919050565b5f67ffffffffffffffff8211156132c6576132c6613268565b50601f01601f191660200190565b5f6132e66132e1846132ad565b61327c565b90508281528383830111156132f9575f80fd5b828260208301375f602084830101529392505050565b5f82601f83011261331e575f80fd5b613114838335602085016132d4565b5f805f805f60a08688031215613341575f80fd5b61334a86612f8f565b9450602086013561335a81612fa2565b9350604086013567ffffffffffffffff80821115613376575f80fd5b61338289838a0161330f565b94506060880135915080821115613397575f80fd5b506133a48882890161330f565b92505060808601356133b581613136565b809150509295509295909350565b5f805f805f8060a087890312156133d8575f80fd5b6133e187612f8f565b955060208701356133f181612fa2565b945060408701359350606087013561340881612fee565b9250608087013567ffffffffffffffff811115613423575f80fd5b61342f89828a01612ffb565b979a9699509497509295939492505050565b5f8060408385031215613452575f80fd5b61345b83612f8f565b915061346960208401612f8f565b90509250929050565b5f805f805f805f805f805f806109208d8f03121561348e575f80fd5b6134988e8e61321b565b9b506134a88e6104008f0161321b565b9a506108008d013599506108208d013598506108408d013597506134cf6108608e01612f8f565b96506134df6108808e0135612fa2565b6108808d013595506134f46108a08e01612f8f565b94506135046108c08e0135612fa2565b6108c08d013593506108e08d0135925067ffffffffffffffff6109008e0135111561352d575f80fd5b61353e8e6109008f01358f01612ffb565b81935080925050509295989b509295989b509295989b565b5f805f805f805f60c0888a03121561356c575f80fd5b61357588612f8f565b9650602088013561358581612fa2565b955060408801359450606088013561359c81612fa2565b935060808801356135ac81612fee565b925060a088013567ffffffffffffffff8111156135c7575f80fd5b6135d38a828b01612ffb565b989b979a50959850939692959293505050565b5f805f805f8060c087890312156135fb575f80fd5b61360487612f8f565b9550602087013561361481612fa2565b945061362260408801612f8f565b9350606087013561363281612fa2565b9250608087013561364281612fa2565b915060a087013567ffffffffffffffff81111561365d575f80fd5b8701601f8101891361366d575f80fd5b61367c898235602084016132d4565b9150509295509295509295565b5f805f80610460858703121561369d575f80fd5b843593506136ae866020870161321b565b92506136bd6104208601612f8f565b939692955092936104400135925050565b600181811c908216806136e257607f821691505b60208210810361370057634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f6001820161373f5761373f61371a565b5060010190565b606081525f61375860608301866130d7565b828103602084015261376a81866130d7565b91505060ff83166040830152949350505050565b5f835161378f8184602088016130b5565b8351908301906137a38183602088016130b5565b01949350505050565b80820281158282048414176106ca576106ca61371a565b808201808211156106ca576106ca61371a565b818382375f9101908152919050565b5f82516137f68184602087016130b5565b9190910192915050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b63ffffffff861681525f6001600160a01b03808716602084015280861660408401525060806060830152612ee7608083018486613800565b5f60208284031215613870575f80fd5b5051919050565b818103818111156106ca576106ca61371a565b5f61010060ff8b16835263ffffffff808b1660208501526001600160a01b03808b166040860152818a1660608601528089166080860152508660a08501528160c08501526138da828501876130d7565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff84166020820152606060408201525f613921606083018486613800565b9695505050505050565b601f8211156123d0575f81815260208120601f850160051c810160208610156139515750805b601f850160051c820191505b81811015610cba5782815560010161395d565b815167ffffffffffffffff81111561398a5761398a613268565b61399e8161399884546136ce565b8461392b565b602080601f8311600181146139d1575f84156139ba5750858301515b5f19600386901b1c1916600185901b178555610cba565b5f85815260208120601f198616915b828110156139ff578886015182559484019460019091019084016139e0565b5085821015613a1c57878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f61010060ff8c16835263ffffffff808c1660208501526001600160a01b03808c166040860152818b166060860152808a166080860152508760a08501528160c0850152613a7d8285018789613800565b925080851660e085015250509a9950505050505050505050565b5f60208284031215613aa7575f80fd5b815161311481613136565b63ffffffff8181168382160190808211156124615761246161371a565b5f8085851115613add575f80fd5b83861115613ae9575f80fd5b5050820193919092039150565b6001600160e01b03198135818116916004851015613b1e5780818660040360031b1b83161692505b505092915050565b5f805f805f805f60e0888a031215613b3c575f80fd5b8735613b4781612fa2565b96506020880135613b5781612fa2565b9550604088013594506060880135935060808801356131a181613136565b5f805f805f805f80610100898b031215613b8d575f80fd5b8835613b9881612fa2565b97506020890135613ba881612fa2565b965060408901359550606089013594506080890135613bc681612fee565b935060a0890135613bd681613136565b979a969950949793969295929450505060c08201359160e0013590565b600181815b80851115613c2d57815f1904821115613c1357613c1361371a565b80851615613c2057918102915b93841c9390800290613bf8565b509250929050565b5f82613c43575060016106ca565b81613c4f57505f6106ca565b8160018114613c655760028114613c6f57613c8b565b60019150506106ca565b60ff841115613c8057613c8061371a565b50506001821b6106ca565b5060208310610133831016604e8410600b8410161715613cae575081810a6106ca565b613cb88383613bf3565b805f1904821115613ccb57613ccb61371a565b029392505050565b5f6131148383613c35565b634e487b7160e01b5f52600160045260245ffd5b5f60208284031215613d02575f80fd5b815167ffffffffffffffff811115613d18575f80fd5b8201601f81018413613d28575f80fd5b8051613d366132e1826132ad565b818152856020838501011115613d4a575f80fd5b613d5b8260208301602086016130b5565b95945050505050565b5f60208284031215613d74575f80fd5b815161311481612fee56fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220432f6d6b4446edbe1f73c19fd2115454d5c35d8b03b98a74fd46724151d7672264736f6c63430008140033" + "address": "0x493732fB136a380920C390a85fc27d79C7b70756", + "bytecode": "0x6080604052600436106101a35760003560e01c806383f24403116100e2578063ccaa2d1111610085578063ccaa2d1114610511578063cd58657914610531578063d02103ca14610544578063dbc169761461056b578063ee25560b14610580578063f5efcd79146105ad578063f811bff7146105cd578063fb570834146105ed57600080fd5b806383f244031461040b5780638ed7e3f21461042b578063aaa13cc21461044b578063b8b284d01461046b578063bab161bf1461048b578063be5831c7146104ad578063c00f14ab146104d1578063cc461632146104f157600080fd5b80633cbc795b1161014a5780633cbc795b146102fd5780633e197043146103365780634b2f336d146103565780635ca1e165146103765780637843298b1461038b57806379e2cf97146103ab57806381b1c174146103c057806383c43a55146103f657600080fd5b806315064c96146101a85780632072f6c5146101d757806322e95f2c146101ee578063240ff3781461021b57806327aef4e81461022e5780632dfdf0b514610250578063318aee3d146102745780633c351e10146102dd575b600080fd5b3480156101b457600080fd5b506068546101c29060ff1681565b60405190151581526020015b60405180910390f35b3480156101e357600080fd5b506101ec61060d565b005b3480156101fa57600080fd5b5061020e610209366004612b65565b610642565b6040516101ce9190612b9c565b6101ec610229366004612c06565b610693565b34801561023a57600080fd5b50610243610703565b6040516101ce9190612ccf565b34801561025c57600080fd5b5061026660535481565b6040519081526020016101ce565b34801561028057600080fd5b506102b961028f366004612ce9565b606b6020526000908152604090205463ffffffff811690600160201b90046001600160a01b031682565b6040805163ffffffff90931683526001600160a01b039091166020830152016101ce565b3480156102e957600080fd5b50606d5461020e906001600160a01b031681565b34801561030957600080fd5b50606d5461032190600160a01b900463ffffffff1681565b60405163ffffffff90911681526020016101ce565b34801561034257600080fd5b50610266610351366004612d15565b610791565b34801561036257600080fd5b50606f5461020e906001600160a01b031681565b34801561038257600080fd5b5061026661081e565b34801561039757600080fd5b5061020e6103a6366004612d94565b6108fb565b3480156103b757600080fd5b506101ec610925565b3480156103cc57600080fd5b5061020e6103db366004612ddd565b606a602052600090815260409020546001600160a01b031681565b34801561040257600080fd5b50610243610946565b34801561041757600080fd5b50610266610426366004612e08565b610965565b34801561043757600080fd5b50606c5461020e906001600160a01b031681565b34801561045757600080fd5b5061020e610466366004612f12565b610a3b565b34801561047757600080fd5b506101ec610486366004612fad565b610b3d565b34801561049757600080fd5b5060685461032190610100900463ffffffff1681565b3480156104b957600080fd5b5060685461032190600160c81b900463ffffffff1681565b3480156104dd57600080fd5b506102436104ec366004612ce9565b610c04565b3480156104fd57600080fd5b506101c261050c36600461302f565b610c49565b34801561051d57600080fd5b506101ec61052c366004613062565b610cd2565b6101ec61053f36600461314d565b6111c7565b34801561055057600080fd5b5060685461020e90600160281b90046001600160a01b031681565b34801561057757600080fd5b506101ec611621565b34801561058c57600080fd5b5061026661059b366004612ddd565b60696020526000908152604090205481565b3480156105b957600080fd5b506101ec6105c8366004613062565b611654565b3480156105d957600080fd5b506101ec6105e83660046131e2565b6118ef565b3480156105f957600080fd5b506101c261060836600461328a565b611b62565b606c546001600160a01b0316331461063857604051631736745960e31b815260040160405180910390fd5b610640611b7a565b565b6000606a6000848460405160200161065b9291906132d2565b60408051601f19818403018152918152815160209283012083529082019290925201600020546001600160a01b031690505b92915050565b60685460ff16156106b757604051630bc011ff60e21b815260040160405180910390fd5b34158015906106d05750606f546001600160a01b031615155b156106ee576040516301bd897160e61b815260040160405180910390fd5b6106fc858534868686611bd6565b5050505050565b606e8054610710906132fc565b80601f016020809104026020016040519081016040528092919081815260200182805461073c906132fc565b80156107895780601f1061075e57610100808354040283529160200191610789565b820191906000526020600020905b81548152906001019060200180831161076c57829003601f168201915b505050505081565b6040516001600160f81b031960f889901b1660208201526001600160e01b031960e088811b821660218401526001600160601b0319606089811b821660258601529188901b909216603984015285901b16603d8201526051810183905260718101829052600090609101604051602081830303815290604052805190602001209050979650505050505050565b605354600090819081805b60208110156108f2578083901c600116600103610886576033816020811061085357610853613336565b015460408051602081019290925281018590526060016040516020818303038152906040528051906020012093506108b3565b60408051602081018690529081018390526060016040516020818303038152906040528051906020012093505b604080516020810184905290810183905260600160405160208183030381529060405280519060200120915080806108ea90613362565b915050610829565b50919392505050565b600061091d848461090b85611ca0565b61091486611d5f565b61046687611e17565b949350505050565b605354606854600160c81b900463ffffffff16101561064057610640611ecf565b60405180611ba00160405280611b668152602001613a7a611b66913981565b600083815b6020811015610a3257600163ffffffff8516821c811690036109d55784816020811061099857610998613336565b6020020135826040516020016109b8929190918252602082015260400190565b604051602081830303815290604052805190602001209150610a20565b818582602081106109e8576109e8613336565b6020020135604051602001610a07929190918252602082015260400190565b6040516020818303038152906040528051906020012091505b80610a2a81613362565b91505061096a565b50949350505050565b6000808686604051602001610a519291906132d2565b604051602081830303815290604052805190602001209050600060ff60f81b308360405180611ba00160405280611b668152602001613a7a611b669139898989604051602001610aa39392919061337b565b60408051601f1981840301815290829052610ac192916020016133b4565b60405160208183030381529060405280519060200120604051602001610b1994939291906001600160f81b031994909416845260609290921b6001600160601b03191660018401526015830152603582015260550190565b60408051808303601f19018152919052805160209091012098975050505050505050565b60685460ff1615610b6157604051630bc011ff60e21b815260040160405180910390fd5b606f546001600160a01b0316610b8a5760405163dde3cda760e01b815260040160405180910390fd5b606f54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac90610bbc90339088906004016133e3565b600060405180830381600087803b158015610bd657600080fd5b505af1158015610bea573d6000803e3d6000fd5b50505050610bfc868686868686611bd6565b505050505050565b6060610c0f82611ca0565b610c1883611d5f565b610c2184611e17565b604051602001610c339392919061337b565b6040516020818303038152906040529050919050565b6068546000908190610100900463ffffffff16158015610c6f575063ffffffff83166001145b15610c81575063ffffffff8316610ca8565b610c95600160201b63ffffffff85166133fc565b610ca59063ffffffff8616613413565b90505b600881901c600090815260696020526040902054600160ff9092169190911b908116149392505050565b60685460ff1615610cf657604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff8681166101009092041614610d26576040516302caf51760e11b815260040160405180910390fd5b610d5a8c8c8c8c8c610d5560008e8e8e8e8e8e8e604051610d48929190613426565b6040518091039020610791565b611f68565b6001600160a01b038616610e9257606f546001600160a01b0316610e295760006001600160a01b03851684825b6040519080825280601f01601f191660200182016040528015610db1576020820181803683370190505b50604051610dbf9190613436565b60006040518083038185875af1925050503d8060008114610dfc576040519150601f19603f3d011682016040523d82523d6000602084013e610e01565b606091505b5050905080610e2357604051630ce8f45160e31b815260040160405180910390fd5b5061117a565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990610e5b90879087906004016133e3565b600060405180830381600087803b158015610e7557600080fd5b505af1158015610e89573d6000803e3d6000fd5b5050505061117a565b606d546001600160a01b038781169116148015610ec05750606d5463ffffffff888116600160a01b90920416145b15610ed85760006001600160a01b0385168482610d87565b60685463ffffffff610100909104811690881603610f0957610f046001600160a01b03871685856120c7565b61117a565b60008787604051602001610f1e9291906132d2565b60408051601f1981840301815291815281516020928301206000818152606a9093529120549091506001600160a01b031680611116576000610f968386868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061212292505050565b6040516340c10f1960e01b81529091506001600160a01b038216906340c10f1990610fc7908a908a906004016133e3565b600060405180830381600087803b158015610fe157600080fd5b505af1158015610ff5573d6000803e3d6000fd5b5050505080606a600085815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060405180604001604052808b63ffffffff1681526020018a6001600160a01b0316815250606b6000836001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a81548163ffffffff021916908363ffffffff16021790555060208201518160000160046101000a8154816001600160a01b0302191690836001600160a01b031602179055509050507f490e59a1701b938786ac72570a1efeac994a3dbe96e2e883e19e902ace6e6a398a8a83888860405161110895949392919061347b565b60405180910390a150611177565b6040516340c10f1960e01b81526001600160a01b038216906340c10f199061114490899089906004016133e3565b600060405180830381600087803b15801561115e57600080fd5b505af1158015611172573d6000803e3d6000fd5b505050505b50505b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8a888887876040516111b19594939291906134b4565b60405180910390a1505050505050505050505050565b60685460ff16156111eb57604051630bc011ff60e21b815260040160405180910390fd5b6111f361219e565b60685463ffffffff610100909104811690881603611224576040516302caf51760e11b815260040160405180910390fd5b6000806060876001600160a01b03881661130a578834146112585760405163b89240f560e01b815260040160405180910390fd5b606d54606e80546001600160a01b0383169650600160a01b90920463ffffffff16945090611285906132fc565b80601f01602080910402602001604051908101604052809291908181526020018280546112b1906132fc565b80156112fe5780601f106112d3576101008083540402835291602001916112fe565b820191906000526020600020905b8154815290600101906020018083116112e157829003601f168201915b50505050509150611596565b34156113295760405163798ee6f160e01b815260040160405180910390fd5b606f546001600160a01b03908116908916036113a457604051632770a7eb60e21b81526001600160a01b03891690639dc29fac9061136d9033908d906004016133e3565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b50505050611596565b6001600160a01b038089166000908152606b602090815260409182902082518084019093525463ffffffff81168352600160201b9004909216918101829052901561145c57604051632770a7eb60e21b81526001600160a01b038a1690639dc29fac906114179033908e906004016133e3565b600060405180830381600087803b15801561143157600080fd5b505af1158015611445573d6000803e3d6000fd5b505050508060200151945080600001519350611589565b851561146e5761146e898b89896121f7565b6040516370a0823160e01b81526000906001600160a01b038b16906370a082319061149d903090600401612b9c565b602060405180830381865afa1580156114ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114de91906134e6565b90506114f56001600160a01b038b1633308e61253d565b6040516370a0823160e01b81526000906001600160a01b038c16906370a0823190611524903090600401612b9c565b602060405180830381865afa158015611541573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061156591906134e6565b905061157182826134ff565b6068548c9850610100900463ffffffff169650935050505b61159289610c04565b9250505b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b600084868e8e86886053546040516115d6989796959493929190613512565b60405180910390a16115fd6115f8600085878f8f878980519060200120610791565b612575565b861561160b5761160b611ecf565b5050505061161860018055565b50505050505050565b606c546001600160a01b0316331461164c57604051631736745960e31b815260040160405180910390fd5b610640612660565b60685460ff161561167857604051630bc011ff60e21b815260040160405180910390fd5b60685463ffffffff86811661010090920416146116a8576040516302caf51760e11b815260040160405180910390fd5b6116ca8c8c8c8c8c610d5560018e8e8e8e8e8e8e604051610d48929190613426565b606f546000906001600160a01b031661178157846001600160a01b031684888a86866040516024016116ff949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b179052516117349190613436565b60006040518083038185875af1925050503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b505080915050611883565b606f546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906117b390889088906004016133e3565b600060405180830381600087803b1580156117cd57600080fd5b505af11580156117e1573d6000803e3d6000fd5b50505050846001600160a01b031687898585604051602401611806949392919061357d565b60408051601f198184030181529181526020820180516001600160e01b0316630c035af960e11b1790525161183b9190613436565b6000604051808303816000865af19150503d8060008114611878576040519150601f19603f3d011682016040523d82523d6000602084013e61187d565b606091505b50909150505b806118a1576040516337e391c360e01b815260040160405180910390fd5b7f1df3f2a973a00d6635911755c260704e95e8a5876997546798770f76396fda4d8b898988886040516118d89594939291906134b4565b60405180910390a150505050505050505050505050565b600054610100900460ff161580801561190f5750600054600160ff909116105b806119295750303b158015611929575060005460ff166001145b6119915760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156119b4576000805461ff0019166101001790555b60688054610100600160c81b03191661010063ffffffff8a160265010000000000600160c81b03191617600160281b6001600160a01b038781169190910291909117909155606c80546001600160a01b0319168583161790558616611a3d5763ffffffff851615611a3857604051630d43a60960e11b815260040160405180910390fd5b611b0c565b606d805463ffffffff8716600160a01b026001600160c01b03199091166001600160a01b03891617179055606e611a7483826135fe565b50611aeb6000801b6012604051602001611ad791906060808252600d908201526c2bb930b83832b21022ba3432b960991b608082015260a060208201819052600490820152630ae8aa8960e31b60c082015260ff91909116604082015260e00190565b604051602081830303815290604052612122565b606f80546001600160a01b0319166001600160a01b03929092169190911790555b611b146126b8565b8015611618576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050505050565b600081611b70868686610965565b1495945050505050565b60685460ff1615611b9e57604051630bc011ff60e21b815260040160405180910390fd5b6068805460ff191660011790556040517f2261efe5aef6fedc1fd1550b25facc9181745623049c7901287030b9ad1a549790600090a1565b60685463ffffffff610100909104811690871603611c07576040516302caf51760e11b815260040160405180910390fd5b7f501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b6001606860019054906101000a900463ffffffff16338989898888605354604051611c5b999897969594939291906136bd565b60405180910390a1611c926115f86001606860019054906101000a900463ffffffff16338a8a8a8989604051610d48929190613426565b8215610bfc57610bfc611ecf565b60408051600481526024810182526020810180516001600160e01b03166306fdde0360e01b179052905160609160009182916001600160a01b03861691611ce79190613436565b600060405180830381855afa9150503d8060008114611d22576040519150601f19603f3d011682016040523d82523d6000602084013e611d27565b606091505b509150915081611d5657604051806040016040528060078152602001664e4f5f4e414d4560c81b81525061091d565b61091d816126e7565b60408051600481526024810182526020810180516001600160e01b03166395d89b4160e01b179052905160609160009182916001600160a01b03861691611da69190613436565b600060405180830381855afa9150503d8060008114611de1576040519150601f19603f3d011682016040523d82523d6000602084013e611de6565b606091505b509150915081611d5657604051806040016040528060098152602001681393d7d4d6535093d360ba1b81525061091d565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b1790529051600091829182916001600160a01b03861691611e5d9190613436565b600060405180830381855afa9150503d8060008114611e98576040519150601f19603f3d011682016040523d82523d6000602084013e611e9d565b606091505b5091509150818015611eb0575080516020145b611ebb57601261091d565b8080602001905181019061091d919061372a565b6053546068805463ffffffff909216600160c81b0263ffffffff60c81b1990921691909117908190556001600160a01b03600160281b909104166333d6247d611f1661081e565b6040518263ffffffff1660e01b8152600401611f3491815260200190565b600060405180830381600087803b158015611f4e57600080fd5b505af1158015611f62573d6000803e3d6000fd5b50505050565b606854604080516020808201879052818301869052825180830384018152606083019384905280519101206312bd9b1960e11b9092526064810191909152600091600160281b90046001600160a01b03169063257b3632906084016020604051808303816000875af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906134e6565b90508060000361202857604051622f6fad60e01b815260040160405180910390fd5b600080600160401b87161561206857869150612046848a8489611b62565b612063576040516338105f3b60e21b815260040160405180910390fd5b6120b2565b602087901c612078816001613747565b915087925061209361208b868c86610965565b8a8389611b62565b6120b0576040516338105f3b60e21b815260040160405180910390fd5b505b6120bc8282612875565b505050505050505050565b61211d8363a9059cbb60e01b84846040516024016120e69291906133e3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261291d565b505050565b60008060405180611ba00160405280611b668152602001613a7a611b669139836040516020016121539291906133b4565b6040516020818303038152906040529050838151602083016000f591506001600160a01b038216612197576040516305f7d84960e51b815260040160405180910390fd5b5092915050565b6002600154036121f05760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401611988565b6002600155565b60006122066004828486613764565b61220f9161378e565b9050632afa533160e01b6001600160e01b03198216016123a357600080808080808061223e896004818d613764565b81019061224b91906137be565b9650965096509650965096509650336001600160a01b0316876001600160a01b03161461228b5760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03861630146122b45760405163750643af60e01b815260040160405180910390fd5b8a85146122d4576040516303fffc4b60e01b815260040160405180910390fd5b604080516001600160a01b0389811660248301528881166044830152606482018890526084820187905260ff861660a483015260c4820185905260e48083018590528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b1790529151918e16916123529190613436565b6000604051808303816000865af19150503d806000811461238f576040519150601f19603f3d011682016040523d82523d6000602084013e612394565b606091505b505050505050505050506106fc565b6001600160e01b031981166323f2ebc360e21b146123d457604051637141605d60e11b815260040160405180910390fd5b6000808080808080806123ea8a6004818e613764565b8101906123f79190613812565b97509750975097509750975097509750336001600160a01b0316886001600160a01b0316146124395760405163912ecce760e01b815260040160405180910390fd5b6001600160a01b03871630146124625760405163750643af60e01b815260040160405180910390fd5b604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905286151560a483015260ff861660c483015260e482018590526101048083018590528351808403909101815261012490920183526020820180516001600160e01b03166323f2ebc360e21b1790529151918f16916124e99190613436565b6000604051808303816000865af19150503d8060008114612526576040519150601f19603f3d011682016040523d82523d6000602084013e61252b565b606091505b50505050505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611f629085906323b872dd60e01b906084016120e6565b80600161258460206002613979565b61258e91906134ff565b605354106125af576040516377ae67b360e11b815260040160405180910390fd5b60006053600081546125c090613362565b9182905550905060005b6020811015612651578082901c6001166001036125fd5782603382602081106125f5576125f5613336565b015550505050565b6033816020811061261057612610613336565b01546040805160208101929092528101849052606001604051602081830303815290604052805190602001209250808061264990613362565b9150506125ca565b5061211d613985565b60018055565b60685460ff1661268357604051635386698160e01b815260040160405180910390fd5b6068805460ff191690556040517f1e5e34eea33501aecf2ebec9fe0e884a40804275ea7fe10b2ba084c8374308b390600090a1565b600054610100900460ff166126df5760405162461bcd60e51b81526004016119889061399b565b6106406129ef565b60606040825110612706578180602001905181019061068d91906139e6565b81516020036128425760005b602081108015612741575082818151811061272f5761272f613336565b01602001516001600160f81b03191615155b15612758578061275081613362565b915050612712565b806000036127905750506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b6020820152919050565b6000816001600160401b038111156127aa576127aa612e47565b6040519080825280601f01601f1916602001820160405280156127d4576020820181803683370190505b50905060005b8281101561283a578481815181106127f4576127f4613336565b602001015160f81c60f81b82828151811061281157612811613336565b60200101906001600160f81b031916908160001a9053508061283281613362565b9150506127da565b509392505050565b50506040805180820190915260128152714e4f545f56414c49445f454e434f44494e4760701b602082015290565b919050565b606854600090610100900463ffffffff16158015612899575063ffffffff82166001145b156128ab575063ffffffff82166128d2565b6128bf600160201b63ffffffff84166133fc565b6128cf9063ffffffff8516613413565b90505b600881901c60008181526069602052604081208054600160ff861690811b9182189283905592909190818316900361161857604051630c8d9eab60e31b815260040160405180910390fd5b6000612972826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a169092919063ffffffff16565b80519091501561211d57808060200190518101906129909190613a5c565b61211d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401611988565b600054610100900460ff1661265a5760405162461bcd60e51b81526004016119889061399b565b606061091d848460008585600080866001600160a01b03168587604051612a3d9190613436565b60006040518083038185875af1925050503d8060008114612a7a576040519150601f19603f3d011682016040523d82523d6000602084013e612a7f565b606091505b5091509150612a9087838387612a9b565b979650505050505050565b60608315612b0a578251600003612b03576001600160a01b0385163b612b035760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611988565b508161091d565b61091d8383815115612b1f5781518083602001fd5b8060405162461bcd60e51b81526004016119889190612ccf565b803563ffffffff8116811461287057600080fd5b6001600160a01b0381168114612b6257600080fd5b50565b60008060408385031215612b7857600080fd5b612b8183612b39565b91506020830135612b9181612b4d565b809150509250929050565b6001600160a01b0391909116815260200190565b8015158114612b6257600080fd5b60008083601f840112612bd057600080fd5b5081356001600160401b03811115612be757600080fd5b602083019150836020828501011115612bff57600080fd5b9250929050565b600080600080600060808688031215612c1e57600080fd5b612c2786612b39565b94506020860135612c3781612b4d565b93506040860135612c4781612bb0565b925060608601356001600160401b03811115612c6257600080fd5b612c6e88828901612bbe565b969995985093965092949392505050565b60005b83811015612c9a578181015183820152602001612c82565b50506000910152565b60008151808452612cbb816020860160208601612c7f565b601f01601f19169290920160200192915050565b602081526000612ce26020830184612ca3565b9392505050565b600060208284031215612cfb57600080fd5b8135612ce281612b4d565b60ff81168114612b6257600080fd5b600080600080600080600060e0888a031215612d3057600080fd5b8735612d3b81612d06565b9650612d4960208901612b39565b95506040880135612d5981612b4d565b9450612d6760608901612b39565b93506080880135612d7781612b4d565b9699959850939692959460a0840135945060c09093013592915050565b600080600060608486031215612da957600080fd5b612db284612b39565b92506020840135612dc281612b4d565b91506040840135612dd281612b4d565b809150509250925092565b600060208284031215612def57600080fd5b5035919050565b80610400810183101561068d57600080fd5b60008060006104408486031215612e1e57600080fd5b83359250612e2f8560208601612df6565b9150612e3e6104208501612b39565b90509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e8557612e85612e47565b604052919050565b60006001600160401b03821115612ea657612ea6612e47565b50601f01601f191660200190565b6000612ec7612ec284612e8d565b612e5d565b9050828152838383011115612edb57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612f0357600080fd5b612ce283833560208501612eb4565b600080600080600060a08688031215612f2a57600080fd5b612f3386612b39565b94506020860135612f4381612b4d565b935060408601356001600160401b0380821115612f5f57600080fd5b612f6b89838a01612ef2565b94506060880135915080821115612f8157600080fd5b50612f8e88828901612ef2565b9250506080860135612f9f81612d06565b809150509295509295909350565b60008060008060008060a08789031215612fc657600080fd5b612fcf87612b39565b95506020870135612fdf81612b4d565b9450604087013593506060870135612ff681612bb0565b925060808701356001600160401b0381111561301157600080fd5b61301d89828a01612bbe565b979a9699509497509295939492505050565b6000806040838503121561304257600080fd5b61304b83612b39565b915061305960208401612b39565b90509250929050565b6000806000806000806000806000806000806109208d8f03121561308557600080fd5b61308f8e8e612df6565b9b5061309f8e6104008f01612df6565b9a506108008d013599506108208d013598506108408d013597506130c66108608e01612b39565b96506130d66108808e0135612b4d565b6108808d013595506130eb6108a08e01612b39565b94506130fb6108c08e0135612b4d565b6108c08d013593506108e08d013592506001600160401b036109008e0135111561312457600080fd5b6131358e6109008f01358f01612bbe565b81935080925050509295989b509295989b509295989b565b600080600080600080600060c0888a03121561316857600080fd5b61317188612b39565b9650602088013561318181612b4d565b955060408801359450606088013561319881612b4d565b935060808801356131a881612bb0565b925060a08801356001600160401b038111156131c357600080fd5b6131cf8a828b01612bbe565b989b979a50959850939692959293505050565b60008060008060008060c087890312156131fb57600080fd5b61320487612b39565b9550602087013561321481612b4d565b945061322260408801612b39565b9350606087013561323281612b4d565b9250608087013561324281612b4d565b915060a08701356001600160401b0381111561325d57600080fd5b8701601f8101891361326e57600080fd5b61327d89823560208401612eb4565b9150509295509295509295565b60008060008061046085870312156132a157600080fd5b843593506132b28660208701612df6565b92506132c16104208601612b39565b939692955092936104400135925050565b60e09290921b6001600160e01b031916825260601b6001600160601b031916600482015260180190565b600181811c9082168061331057607f821691505b60208210810361333057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016133745761337461334c565b5060010190565b60608152600061338e6060830186612ca3565b82810360208401526133a08186612ca3565b91505060ff83166040830152949350505050565b600083516133c6818460208801612c7f565b8351908301906133da818360208801612c7f565b01949350505050565b6001600160a01b03929092168252602082015260400190565b808202811582820484141761068d5761068d61334c565b8082018082111561068d5761068d61334c565b8183823760009101908152919050565b60008251613448818460208701612c7f565b9190910192915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff861681526001600160a01b03858116602083015284166040820152608060608201819052600090612a909083018486613452565b94855263ffffffff9390931660208501526001600160a01b039182166040850152166060830152608082015260a00190565b6000602082840312156134f857600080fd5b5051919050565b8181038181111561068d5761068d61334c565b60ff8916815263ffffffff88811660208301526001600160a01b03888116604084015287821660608401528616608083015260a0820185905261010060c0830181905260009161356484830187612ca3565b925080851660e085015250509998505050505050505050565b6001600160a01b038516815263ffffffff841660208201526060604082018190526000906135ae9083018486613452565b9695505050505050565b601f82111561211d57600081815260208120601f850160051c810160208610156135df5750805b601f850160051c820191505b81811015610bfc578281556001016135eb565b81516001600160401b0381111561361757613617612e47565b61362b8161362584546132fc565b846135b8565b602080601f83116001811461366057600084156136485750858301515b600019600386901b1c1916600185901b178555610bfc565b600085815260208120601f198616915b8281101561368f57888601518255948401946001909101908401613670565b50858210156136ad5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60ff8a16815263ffffffff89811660208301526001600160a01b03898116604084015288821660608401528716608083015260a0820186905261010060c083018190526000916137108483018789613452565b925080851660e085015250509a9950505050505050505050565b60006020828403121561373c57600080fd5b8151612ce281612d06565b63ffffffff8181168382160190808211156121975761219761334c565b6000808585111561377457600080fd5b8386111561378157600080fd5b5050820193919092039150565b6001600160e01b031981358181169160048510156137b65780818660040360031b1b83161692505b505092915050565b600080600080600080600060e0888a0312156137d957600080fd5b87356137e481612b4d565b965060208801356137f481612b4d565b955060408801359450606088013593506080880135612d7781612d06565b600080600080600080600080610100898b03121561382f57600080fd5b883561383a81612b4d565b9750602089013561384a81612b4d565b96506040890135955060608901359450608089013561386881612bb0565b935060a089013561387881612d06565b979a969950949793969295929450505060c08201359160e0013590565b600181815b808511156138d05781600019048211156138b6576138b661334c565b808516156138c357918102915b93841c939080029061389a565b509250929050565b6000826138e75750600161068d565b816138f45750600061068d565b816001811461390a576002811461391457613930565b600191505061068d565b60ff8411156139255761392561334c565b50506001821b61068d565b5060208310610133831016604e8410600b8410161715613953575081810a61068d565b61395d8383613895565b80600019048211156139715761397161334c565b029392505050565b6000612ce283836138d8565b634e487b7160e01b600052600160045260246000fd5b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156139f857600080fd5b81516001600160401b03811115613a0e57600080fd5b8201601f81018413613a1f57600080fd5b8051613a2d612ec282612e8d565b818152856020838501011115613a4257600080fd5b613a53826020830160208601612c7f565b95945050505050565b600060208284031215613a6e57600080fd5b8151612ce281612bb056fe6101006040523480156200001257600080fd5b5060405162001b6638038062001b6683398101604081905262000035916200028d565b82826003620000458382620003a1565b506004620000548282620003a1565b50503360c0525060ff811660e052466080819052620000739062000080565b60a052506200046d915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f620000ad6200012e565b805160209182012060408051808201825260018152603160f81b90840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b6060600380546200013f9062000312565b80601f01602080910402602001604051908101604052809291908181526020018280546200016d9062000312565b8015620001be5780601f106200019257610100808354040283529160200191620001be565b820191906000526020600020905b815481529060010190602001808311620001a057829003601f168201915b5050505050905090565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f057600080fd5b81516001600160401b03808211156200020d576200020d620001c8565b604051601f8301601f19908116603f01168101908282118183101715620002385762000238620001c8565b816040528381526020925086838588010111156200025557600080fd5b600091505b838210156200027957858201830151818301840152908201906200025a565b600093810190920192909252949350505050565b600080600060608486031215620002a357600080fd5b83516001600160401b0380821115620002bb57600080fd5b620002c987838801620001de565b94506020860151915080821115620002e057600080fd5b50620002ef86828701620001de565b925050604084015160ff811681146200030757600080fd5b809150509250925092565b600181811c908216806200032757607f821691505b6020821081036200034857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200039c57600081815260208120601f850160051c81016020861015620003775750805b601f850160051c820191505b81811015620003985782815560010162000383565b5050505b505050565b81516001600160401b03811115620003bd57620003bd620001c8565b620003d581620003ce845462000312565b846200034e565b602080601f8311600181146200040d5760008415620003f45750858301515b600019600386901b1c1916600185901b17855562000398565b600085815260208120601f198616915b828110156200043e578886015182559484019460019091019084016200041d565b50858210156200045d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c05160e0516116aa620004bc6000396000610237015260008181610307015281816105c001526106a70152600061053a015260008181610379015261050401526116aa6000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a457c2d71161008c578063d505accf11610066578063d505accf1461039b578063dd62ed3e146103ae578063ffa1ad74146103f457600080fd5b8063a457c2d71461034e578063a9059cbb14610361578063cd0d00961461037457600080fd5b806395d89b41116100bd57806395d89b41146102e75780639dc29fac146102ef578063a3c573eb1461030257600080fd5b806370a08231146102915780637ecebe00146102c757600080fd5b806330adf81f1161012f5780633644e515116101145780633644e51514610261578063395093511461026957806340c10f191461027c57600080fd5b806330adf81f14610209578063313ce5671461023057600080fd5b806318160ddd1161016057806318160ddd146101bd57806320606b70146101cf57806323b872dd146101f657600080fd5b806306fdde031461017c578063095ea7b31461019a575b600080fd5b610184610430565b60405161019191906113e4565b60405180910390f35b6101ad6101a8366004611479565b6104c2565b6040519015158152602001610191565b6002545b604051908152602001610191565b6101c17f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b6101ad6102043660046114a3565b6104dc565b6101c17f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610191565b6101c1610500565b6101ad610277366004611479565b61055c565b61028f61028a366004611479565b6105a8565b005b6101c161029f3660046114df565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101c16102d53660046114df565b60056020526000908152604090205481565b610184610680565b61028f6102fd366004611479565b61068f565b6103297f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610191565b6101ad61035c366004611479565b61075e565b6101ad61036f366004611479565b61082f565b6101c17f000000000000000000000000000000000000000000000000000000000000000081565b61028f6103a9366004611501565b61083d565b6101c16103bc366004611574565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101846040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525081565b60606003805461043f906115a7565b80601f016020809104026020016040519081016040528092919081815260200182805461046b906115a7565b80156104b85780601f1061048d576101008083540402835291602001916104b8565b820191906000526020600020905b81548152906001019060200180831161049b57829003601f168201915b5050505050905090565b6000336104d0818585610b73565b60019150505b92915050565b6000336104ea858285610d27565b6104f5858585610dfe565b506001949350505050565b60007f00000000000000000000000000000000000000000000000000000000000000004614610537576105324661106d565b905090565b507f000000000000000000000000000000000000000000000000000000000000000090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906104d090829086906105a3908790611629565b610b73565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610672576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d4272696467650000000000000000000000000000000060648201526084015b60405180910390fd5b61067c8282611135565b5050565b60606004805461043f906115a7565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610754576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603060248201527f546f6b656e577261707065643a3a6f6e6c794272696467653a204e6f7420506f60448201527f6c79676f6e5a6b45564d427269646765000000000000000000000000000000006064820152608401610669565b61067c8282611228565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610822576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610669565b6104f58286868403610b73565b6000336104d0818585610dfe565b834211156108cc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f546f6b656e577261707065643a3a7065726d69743a204578706972656420706560448201527f726d6974000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260056020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918a918a918a9190866109268361163c565b9091555060408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610991610500565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181528282528051602091820120600080855291840180845281905260ff89169284019290925260608301879052608083018690529092509060019060a0016020604051602081039080840390855afa158015610a55573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590610ad057508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f546f6b656e577261707065643a3a7065726d69743a20496e76616c696420736960448201527f676e6174757265000000000000000000000000000000000000000000000000006064820152608401610669565b610b678a8a8a610b73565b50505050505050505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610cb8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610df85781811015610deb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610669565b610df88484848403610b73565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610ea1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff8216610f44576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610ffa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610df8565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f611098610430565b8051602091820120604080518082018252600181527f310000000000000000000000000000000000000000000000000000000000000090840152805192830193909352918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66060820152608081018390523060a082015260c001604051602081830303815290604052805190602001209050919050565b73ffffffffffffffffffffffffffffffffffffffff82166111b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610669565b80600260008282546111c49190611629565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff82166112cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090205481811015611381576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610669565b73ffffffffffffffffffffffffffffffffffffffff83166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9101610d1a565b600060208083528351808285015260005b81811015611411578581018301518582016040015282016113f5565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461147457600080fd5b919050565b6000806040838503121561148c57600080fd5b61149583611450565b946020939093013593505050565b6000806000606084860312156114b857600080fd5b6114c184611450565b92506114cf60208501611450565b9150604084013590509250925092565b6000602082840312156114f157600080fd5b6114fa82611450565b9392505050565b600080600080600080600060e0888a03121561151c57600080fd5b61152588611450565b965061153360208901611450565b95506040880135945060608801359350608088013560ff8116811461155757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561158757600080fd5b61159083611450565b915061159e60208401611450565b90509250929050565b600181811c908216806115bb57607f821691505b6020821081036115f4577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104d6576104d66115fa565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361166d5761166d6115fa565b506001019056fea26469706673582212208d88fee561cff7120d381c345cfc534cef8229a272dc5809d4bbb685ad67141164736f6c63430008110033a2646970667358221220914f18d5b241f0d10b2ebc814aadeee338ad60bad704683e414dad415cb2e14d64736f6c63430008140033" }, { "contractName": "PolygonZkEVMBridge proxy", "balance": "340282366920938463463374607431768211455", "nonce": "1", - "address": "0xFe12ABaa190Ef0c8638Ee0ba9F828BF41368Ca0E", - "bytecode": "0x60806040526004361061005d575f3560e01c80635c60da1b116100425780635c60da1b146100a65780638f283970146100e3578063f851a440146101025761006c565b80633659cfe6146100745780634f1ef286146100935761006c565b3661006c5761006a610116565b005b61006a610116565b34801561007f575f80fd5b5061006a61008e366004610854565b610130565b61006a6100a136600461086d565b610178565b3480156100b1575f80fd5b506100ba6101eb565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100ee575f80fd5b5061006a6100fd366004610854565b610228565b34801561010d575f80fd5b506100ba610255565b61011e610282565b61012e610129610359565b610362565b565b610138610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d8160405180602001604052805f8152505f6103bf565b50565b61016d610116565b610180610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101e3576101de8383838080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250600192506103bf915050565b505050565b6101de610116565b5f6101f4610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610359565b905090565b610225610116565b90565b610230610380565b73ffffffffffffffffffffffffffffffffffffffff1633036101705761016d816103e9565b5f61025e610380565b73ffffffffffffffffffffffffffffffffffffffff16330361021d57610218610380565b61028a610380565b73ffffffffffffffffffffffffffffffffffffffff16330361012e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b5f61021861044a565b365f80375f80365f845af43d5f803e80801561037c573d5ff35b3d5ffd5b5f7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103c883610471565b5f825111806103d45750805b156101de576103e383836104bd565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610412610380565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a161016d816104e9565b5f7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103a3565b61047a816105f5565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606104e28383604051806060016040528060278152602001610977602791396106c0565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff811661058c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610350565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610350565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105af565b60605f808573ffffffffffffffffffffffffffffffffffffffff16856040516106e9919061090b565b5f60405180830381855af49150503d805f8114610721576040519150601f19603f3d011682016040523d82523d5f602084013e610726565b606091505b509150915061073786838387610741565b9695505050505050565b606083156107d65782515f036107cf5773ffffffffffffffffffffffffffffffffffffffff85163b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610350565b50816107e0565b6107e083836107e8565b949350505050565b8151156107f85781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103509190610926565b803573ffffffffffffffffffffffffffffffffffffffff8116811461084f575f80fd5b919050565b5f60208284031215610864575f80fd5b6104e28261082c565b5f805f6040848603121561087f575f80fd5b6108888461082c565b9250602084013567ffffffffffffffff808211156108a4575f80fd5b818601915086601f8301126108b7575f80fd5b8135818111156108c5575f80fd5b8760208285010111156108d6575f80fd5b6020830194508093505050509250925092565b5f5b838110156109035781810151838201526020016108eb565b50505f910152565b5f825161091c8184602087016108e9565b9190910192915050565b602081525f82518060208401526109448160408501602087016108e9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212202ac98acbfbb3d3ac1b74050e18c4e76db25a3ff2801ec69bf85d0c61414d502b64736f6c63430008140033", + "address": "0xB7098a13a48EcE087d3DA15b2D28eCE0f89819B8", + "bytecode": "0x60806040526004361061005e5760003560e01c80635c60da1b116100435780635c60da1b146100a85780638f283970146100e6578063f851a440146101065761006d565b80633659cfe6146100755780634f1ef286146100955761006d565b3661006d5761006b61011b565b005b61006b61011b565b34801561008157600080fd5b5061006b61009036600461086f565b610135565b61006b6100a336600461088a565b61017f565b3480156100b457600080fd5b506100bd6101f3565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100f257600080fd5b5061006b61010136600461086f565b610231565b34801561011257600080fd5b506100bd61025e565b61012361028c565b61013361012e610363565b61036d565b565b61013d610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816040518060200160405280600081525060006103d1565b50565b61017461011b565b610187610391565b73ffffffffffffffffffffffffffffffffffffffff1633036101eb576101e68383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250600192506103d1915050565b505050565b6101e661011b565b60006101fd610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610363565b905090565b61022e61011b565b90565b610239610391565b73ffffffffffffffffffffffffffffffffffffffff16330361017757610174816103fc565b6000610268610391565b73ffffffffffffffffffffffffffffffffffffffff16330361022657610221610391565b610294610391565b73ffffffffffffffffffffffffffffffffffffffff163303610133576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f7879207461726760648201527f6574000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b600061022161045d565b3660008037600080366000845af43d6000803e80801561038c573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b5473ffffffffffffffffffffffffffffffffffffffff16919050565b6103da83610485565b6000825111806103e75750805b156101e6576103f683836104d2565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f610425610391565b6040805173ffffffffffffffffffffffffffffffffffffffff928316815291841660208301520160405180910390a1610174816104fe565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6103b5565b61048e8161060a565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606104f7838360405180606001604052806027815260200161099f602791396106d5565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff81166105a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161035a565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b73ffffffffffffffffffffffffffffffffffffffff81163b6106ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e747261637400000000000000000000000000000000000000606482015260840161035a565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105c4565b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516106ff9190610931565b600060405180830381855af49150503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b50915091506107508683838761075a565b9695505050505050565b606083156107f05782516000036107e95773ffffffffffffffffffffffffffffffffffffffff85163b6107e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161035a565b50816107fa565b6107fa8383610802565b949350505050565b8151156108125781518083602001fd5b806040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161035a919061094d565b803573ffffffffffffffffffffffffffffffffffffffff8116811461086a57600080fd5b919050565b60006020828403121561088157600080fd5b6104f782610846565b60008060006040848603121561089f57600080fd5b6108a884610846565b9250602084013567ffffffffffffffff808211156108c557600080fd5b818601915086601f8301126108d957600080fd5b8135818111156108e857600080fd5b8760208285010111156108fa57600080fd5b6020830194508093505050509250925092565b60005b83811015610928578181015183820152602001610910565b50506000910152565b6000825161094381846020870161090d565b9190910192915050565b602081526000825180602084015261096c81604085016020870161090d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220701a0c26bdd76686e63fc3c65e4f28a20ba3ecc8a60246733c0627e679c9804e64736f6c63430008140033", "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", - "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000608484d3e94fc775e3dcb06b0b48486c60a315e6" + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", + "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000493732fb136a380920c390a85fc27d79c7b70756" } }, { @@ -53,7 +53,7 @@ "balance": "0", "nonce": "1", "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", - "bytecode": "0x608060405234801561000f575f80fd5b506004361061004a575f3560e01c806301fd90441461004e578063257b36321461006a57806333d6247d14610089578063a3c573eb1461009e575b5f80fd5b61005760015481565b6040519081526020015b60405180910390f35b61005761007836600461015e565b5f6020819052908152604090205481565b61009c61009736600461015e565b6100ea565b005b6100c57f000000000000000000000000fe12abaa190ef0c8638ee0ba9f828bf41368ca0e81565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610061565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000fe12abaa190ef0c8638ee0ba9f828bf41368ca0e1614610159576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b5f6020828403121561016e575f80fd5b503591905056fea26469706673582212205108c6c4f924146b736832a1bdf696e20d900450207b7452462368d150f2c71c64736f6c63430008140033" + "bytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806301fd904414610051578063257b36321461006d57806333d6247d1461008d578063a3c573eb146100a2575b600080fd5b61005a60015481565b6040519081526020015b60405180910390f35b61005a61007b366004610162565b60006020819052908152604090205481565b6100a061009b366004610162565b6100ee565b005b6100c97f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b881565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610064565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000b7098a13a48ece087d3da15b2d28ece0f89819b8161461015d576040517fb49365dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600155565b60006020828403121561017457600080fd5b503591905056fea2646970667358221220ea2171e2c85c8bff947affc409ef6fc6a8fe82fb8c174ddeda988651e595d66564736f6c63430008140033" }, { "contractName": "PolygonZkEVMGlobalExitRootL2 proxy", @@ -62,7 +62,7 @@ "address": "0xa40d5f56745a118d0906a34e69aec8c0db1cb8fa", "bytecode": "0x60806040523661001357610011610017565b005b6100115b61001f6101b7565b6001600160a01b0316336001600160a01b0316141561016f5760606001600160e01b031960003516631b2ce7f360e11b8114156100655761005e6101ea565b9150610167565b6001600160e01b0319811663278f794360e11b14156100865761005e610241565b6001600160e01b031981166308f2839760e41b14156100a75761005e610287565b6001600160e01b031981166303e1469160e61b14156100c85761005e6102b8565b6001600160e01b03198116635c60da1b60e01b14156100e95761005e6102f8565b60405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b815160208301f35b61017761030c565b565b606061019e83836040518060600160405280602781526020016108576027913961031c565b9392505050565b90565b6001600160a01b03163b151590565b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b60606101f4610394565b600061020336600481846106a2565b81019061021091906106e8565b905061022d8160405180602001604052806000815250600061039f565b505060408051602081019091526000815290565b606060008061025336600481846106a2565b8101906102609190610719565b915091506102708282600161039f565b604051806020016040528060008152509250505090565b6060610291610394565b60006102a036600481846106a2565b8101906102ad91906106e8565b905061022d816103cb565b60606102c2610394565b60006102cc6101b7565b604080516001600160a01b03831660208201529192500160405160208183030381529060405291505090565b6060610302610394565b60006102cc610422565b610177610317610422565b610431565b6060600080856001600160a01b0316856040516103399190610807565b600060405180830381855af49150503d8060008114610374576040519150601f19603f3d011682016040523d82523d6000602084013e610379565b606091505b509150915061038a86838387610455565b9695505050505050565b341561017757600080fd5b6103a8836104d3565b6000825111806103b55750805b156103c6576103c48383610179565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103f46101b7565b604080516001600160a01b03928316815291841660208301520160405180910390a161041f81610513565b50565b600061042c6105bc565b905090565b3660008037600080366000845af43d6000803e808015610450573d6000f35b3d6000fd5b606083156104c15782516104ba576001600160a01b0385163b6104ba5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161015e565b50816104cb565b6104cb83836105e4565b949350505050565b6104dc8161060e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105785760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b606482015260840161015e565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6101db565b8151156105f45781518083602001fd5b8060405162461bcd60e51b815260040161015e9190610823565b6001600160a01b0381163b61067b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b606482015260840161015e565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc61059b565b600080858511156106b257600080fd5b838611156106bf57600080fd5b5050820193919092039150565b80356001600160a01b03811681146106e357600080fd5b919050565b6000602082840312156106fa57600080fd5b61019e826106cc565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561072c57600080fd5b610735836106cc565b9150602083013567ffffffffffffffff8082111561075257600080fd5b818501915085601f83011261076657600080fd5b81358181111561077857610778610703565b604051601f8201601f19908116603f011681019083821181831017156107a0576107a0610703565b816040528281528860208487010111156107b957600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60005b838110156107f65781810151838201526020016107de565b838111156103c45750506000910152565b600082516108198184602087016107db565b9190910192915050565b60208152600082518060208401526108428160408501602087016107db565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122012bb4f564f73959a03513dc74fc3c6e40e8386e6f02c16b78d6db00ce0aa16af64736f6c63430008090033", "storage": { - "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000fadb60b5059e31614e02083ff6c021a24c31c891", + "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103": "0x000000000000000000000000e34fe58dda5b8c6d547e4857e987633aa86a5e90", "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc": "0x000000000000000000000000dc64a140aa3e981100a9beca4e685f962f0cf6c9" } }, @@ -71,7 +71,7 @@ "balance": "0", "nonce": "1", "address": "0x0165878A594ca255338adfa4d48449f69242Eb8F", - "bytecode": "0x6080604052600436106101bd575f3560e01c806364d62353116100f2578063b1c5f42711610092578063d547741f11610062578063d547741f1461063a578063e38335e514610659578063f23a6e611461066c578063f27a0c92146106b0575f80fd5b8063b1c5f4271461058d578063bc197c81146105ac578063c4d252f5146105f0578063d45c44351461060f575f80fd5b80638f61f4f5116100cd5780638f61f4f5146104c557806391d14854146104f8578063a217fddf14610547578063b08e51c01461055a575f80fd5b806364d62353146104685780638065657f146104875780638f2a0bb0146104a6575f80fd5b8063248a9ca31161015d57806331d507501161013857806331d50750146103b357806336568abe146103d25780633a6aae72146103f1578063584b153e14610449575f80fd5b8063248a9ca3146103375780632ab0f529146103655780632f2ff15d14610394575f80fd5b80630d3cf6fc116101985780630d3cf6fc1461025e578063134008d31461029157806313bc9f20146102a4578063150b7a02146102c3575f80fd5b806301d5062a146101c857806301ffc9a7146101e957806307bd02651461021d575f80fd5b366101c457005b5f80fd5b3480156101d3575f80fd5b506101e76101e2366004611bf6565b6106c4565b005b3480156101f4575f80fd5b50610208610203366004611c65565b610757565b60405190151581526020015b60405180910390f35b348015610228575f80fd5b506102507fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610214565b348015610269575f80fd5b506102507f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101e761029f366004611ca4565b6107b2565b3480156102af575f80fd5b506102086102be366004611d0b565b6108a7565b3480156102ce575f80fd5b506103066102dd366004611e28565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610214565b348015610342575f80fd5b50610250610351366004611d0b565b5f9081526020819052604090206001015490565b348015610370575f80fd5b5061020861037f366004611d0b565b5f908152600160208190526040909120541490565b34801561039f575f80fd5b506101e76103ae366004611e8c565b6108cc565b3480156103be575f80fd5b506102086103cd366004611d0b565b6108f5565b3480156103dd575f80fd5b506101e76103ec366004611e8c565b61090d565b3480156103fc575f80fd5b506104247f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610214565b348015610454575f80fd5b50610208610463366004611d0b565b6109c5565b348015610473575f80fd5b506101e7610482366004611d0b565b6109da565b348015610492575f80fd5b506102506104a1366004611ca4565b610aaa565b3480156104b1575f80fd5b506101e76104c0366004611ef7565b610ae8565b3480156104d0575f80fd5b506102507fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b348015610503575f80fd5b50610208610512366004611e8c565b5f9182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b348015610552575f80fd5b506102505f81565b348015610565575f80fd5b506102507ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b348015610598575f80fd5b506102506105a7366004611fa0565b610d18565b3480156105b7575f80fd5b506103066105c63660046120be565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b3480156105fb575f80fd5b506101e761060a366004611d0b565b610d5c565b34801561061a575f80fd5b50610250610629366004611d0b565b5f9081526001602052604090205490565b348015610645575f80fd5b506101e7610654366004611e8c565b610e56565b6101e7610667366004611fa0565b610e7a565b348015610677575f80fd5b50610306610686366004612161565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106bb575f80fd5b50610250611121565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc16106ee81611200565b5f6106fd898989898989610aaa565b9050610709818461120d565b5f817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a60405161074496959493929190612208565b60405180910390a3505050505050505050565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107ac57506107ac82611359565b92915050565b5f80527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661082e5761082e81336113ef565b5f61083d888888888888610aaa565b905061084981856114a6565b610855888888886115e2565b5f817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a60405161088c9493929190612252565b60405180910390a361089d816116e2565b5050505050505050565b5f818152600160205260408120546001811180156108c55750428111155b9392505050565b5f828152602081905260409020600101546108e681611200565b6108f0838361178a565b505050565b5f8181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109c18282611878565b5050565b5f818152600160208190526040822054610906565b333014610a69576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109ae565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b5f868686868686604051602001610ac696959493929190612208565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b1281611200565b888714610ba1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b888514610c30576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f610c418b8b8b8b8b8b8b8b610d18565b9050610c4d818461120d565b5f5b8a811015610d0a5780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610c8c57610c8c612291565b9050602002016020810190610ca191906122be565b8d8d86818110610cb357610cb3612291565b905060200201358c8c87818110610ccc57610ccc612291565b9050602002810190610cde91906122d7565b8c8b604051610cf296959493929190612208565b60405180910390a3610d0381612365565b9050610c4f565b505050505050505050505050565b5f8888888888888888604051602001610d38989796959493929190612447565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610d8681611200565b610d8f826109c5565b610e1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109ae565b5f828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b5f82815260208190526040902060010154610e7081611200565b6108f08383611878565b5f80527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610ef657610ef681336113ef565b878614610f85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b878414611014576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f6110258a8a8a8a8a8a8a8a610d18565b905061103181856114a6565b5f5b8981101561110b575f8b8b8381811061104e5761104e612291565b905060200201602081019061106391906122be565b90505f8a8a8481811061107857611078612291565b905060200201359050365f8a8a8681811061109557611095612291565b90506020028101906110a791906122d7565b915091506110b7848484846115e2565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b58868686866040516110ee9493929190612252565b60405180910390a3505050508061110490612365565b9050611033565b50611115816116e2565b50505050505050505050565b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16158015906111ef57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111cb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111ef919061250c565b156111f957505f90565b5060025490565b61120a81336113ef565b50565b611216826108f5565b156112a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109ae565b6112ab611121565b81101561133a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109ae565b611344814261252b565b5f928352600160205260409092209190915550565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107ac57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107ac565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109c15761142c8161192d565b61143783602061194c565b604051602001611448929190612560565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109ae916004016125e0565b6114af826108a7565b61153b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109ae565b80158061155657505f81815260016020819052604090912054145b6109c1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109ae565b5f8473ffffffffffffffffffffffffffffffffffffffff1684848460405161160b929190612630565b5f6040518083038185875af1925050503d805f8114611645576040519150601f19603f3d011682016040523d82523d5f602084013e61164a565b606091505b50509050806116db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109ae565b5050505050565b6116eb816108a7565b611777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109ae565b5f90815260016020819052604090912055565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109c1575f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905561181a3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109c1575f8281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107ac73ffffffffffffffffffffffffffffffffffffffff831660145b60605f61195a83600261263f565b61196590600261252b565b67ffffffffffffffff81111561197d5761197d611d22565b6040519080825280601f01601f1916602001820160405280156119a7576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f815181106119dd576119dd612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a3f57611a3f612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a9053505f611a7984600261263f565b611a8490600161252b565b90505b6001811115611b20577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611ac557611ac5612291565b1a60f81b828281518110611adb57611adb612291565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191690815f1a90535060049490941c93611b1981612656565b9050611a87565b5083156108c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109ae565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bac575f80fd5b919050565b5f8083601f840112611bc1575f80fd5b50813567ffffffffffffffff811115611bd8575f80fd5b602083019150836020828501011115611bef575f80fd5b9250929050565b5f805f805f805f60c0888a031215611c0c575f80fd5b611c1588611b89565b965060208801359550604088013567ffffffffffffffff811115611c37575f80fd5b611c438a828b01611bb1565b989b979a50986060810135976080820135975060a09091013595509350505050565b5f60208284031215611c75575f80fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108c5575f80fd5b5f805f805f8060a08789031215611cb9575f80fd5b611cc287611b89565b955060208701359450604087013567ffffffffffffffff811115611ce4575f80fd5b611cf089828a01611bb1565b979a9699509760608101359660809091013595509350505050565b5f60208284031215611d1b575f80fd5b5035919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611d9657611d96611d22565b604052919050565b5f82601f830112611dad575f80fd5b813567ffffffffffffffff811115611dc757611dc7611d22565b611df860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d4f565b818152846020838601011115611e0c575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215611e3b575f80fd5b611e4485611b89565b9350611e5260208601611b89565b925060408501359150606085013567ffffffffffffffff811115611e74575f80fd5b611e8087828801611d9e565b91505092959194509250565b5f8060408385031215611e9d575f80fd5b82359150611ead60208401611b89565b90509250929050565b5f8083601f840112611ec6575f80fd5b50813567ffffffffffffffff811115611edd575f80fd5b6020830191508360208260051b8501011115611bef575f80fd5b5f805f805f805f805f60c08a8c031215611f0f575f80fd5b893567ffffffffffffffff80821115611f26575f80fd5b611f328d838e01611eb6565b909b50995060208c0135915080821115611f4a575f80fd5b611f568d838e01611eb6565b909950975060408c0135915080821115611f6e575f80fd5b50611f7b8c828d01611eb6565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b5f805f805f805f8060a0898b031215611fb7575f80fd5b883567ffffffffffffffff80821115611fce575f80fd5b611fda8c838d01611eb6565b909a50985060208b0135915080821115611ff2575f80fd5b611ffe8c838d01611eb6565b909850965060408b0135915080821115612016575f80fd5b506120238b828c01611eb6565b999c989b509699959896976060870135966080013595509350505050565b5f82601f830112612050575f80fd5b8135602067ffffffffffffffff82111561206c5761206c611d22565b8160051b61207b828201611d4f565b9283528481018201928281019087851115612094575f80fd5b83870192505b848310156120b35782358252918301919083019061209a565b979650505050505050565b5f805f805f60a086880312156120d2575f80fd5b6120db86611b89565b94506120e960208701611b89565b9350604086013567ffffffffffffffff80821115612105575f80fd5b61211189838a01612041565b94506060880135915080821115612126575f80fd5b61213289838a01612041565b93506080880135915080821115612147575f80fd5b5061215488828901611d9e565b9150509295509295909350565b5f805f805f60a08688031215612175575f80fd5b61217e86611b89565b945061218c60208701611b89565b93506040860135925060608601359150608086013567ffffffffffffffff8111156121b5575f80fd5b61215488828901611d9e565b81835281816020850137505f602082840101525f60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a060408201525f61223d60a0830186886121c1565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152606060408201525f6122876060830184866121c1565b9695505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f602082840312156122ce575f80fd5b6108c582611b89565b5f8083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261230a575f80fd5b83018035915067ffffffffffffffff821115612324575f80fd5b602001915036819003821315611bef575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361239557612395612338565b5060010190565b8183525f6020808501808196508560051b81019150845f5b8781101561243a57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126123f2575f80fd5b8701858101903567ffffffffffffffff81111561240d575f80fd5b80360382131561241b575f80fd5b6124268682846121c1565b9a87019a95505050908401906001016123b4565b5091979650505050505050565b60a080825281018890525f8960c08301825b8b8110156124945773ffffffffffffffffffffffffffffffffffffffff61247f84611b89565b16825260209283019290910190600101612459565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8911156124cc575f80fd5b8860051b9150818a602083013701828103602090810160408501526124f4908201878961239c565b60608401959095525050608001529695505050505050565b5f6020828403121561251c575f80fd5b815180151581146108c5575f80fd5b808201808211156107ac576107ac612338565b5f5b83811015612558578181015183820152602001612540565b50505f910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f835161259781601785016020880161253e565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516125d481602884016020880161253e565b01602801949350505050565b602081525f82518060208401526125fe81604085016020870161253e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b818382375f9101908152919050565b80820281158282048414176107ac576107ac612338565b5f8161266457612664612338565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220e28ae7494480ab1c619fd775dc5ff665588c808a910d66178a982c2e7c76a1e664736f6c63430008140033", + "bytecode": "0x6080604052600436106101c65760003560e01c806364d62353116100f7578063b1c5f42711610095578063d547741f11610064578063d547741f14610661578063e38335e514610681578063f23a6e6114610694578063f27a0c92146106d957600080fd5b8063b1c5f427146105af578063bc197c81146105cf578063c4d252f514610614578063d45c44351461063457600080fd5b80638f61f4f5116100d15780638f61f4f5146104e157806391d1485414610515578063a217fddf14610566578063b08e51c01461057b57600080fd5b806364d62353146104815780638065657f146104a15780638f2a0bb0146104c157600080fd5b8063248a9ca31161016457806331d507501161013e57806331d50750146103c857806336568abe146103e85780633a6aae7214610408578063584b153e1461046157600080fd5b8063248a9ca3146103475780632ab0f529146103775780632f2ff15d146103a857600080fd5b80630d3cf6fc116101a05780630d3cf6fc1461026b578063134008d31461029f57806313bc9f20146102b2578063150b7a02146102d257600080fd5b806301d5062a146101d257806301ffc9a7146101f457806307bd02651461022957600080fd5b366101cd57005b600080fd5b3480156101de57600080fd5b506101f26101ed366004611c52565b6106ee565b005b34801561020057600080fd5b5061021461020f366004611cc7565b610783565b60405190151581526020015b60405180910390f35b34801561023557600080fd5b5061025d7fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e6381565b604051908152602001610220565b34801561027757600080fd5b5061025d7f5f58e3a2316349923ce3780f8d587db2d72378aed66a8261c916544fa6846ca581565b6101f26102ad366004611d09565b6107df565b3480156102be57600080fd5b506102146102cd366004611d75565b6108d7565b3480156102de57600080fd5b506103166102ed366004611e9a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610220565b34801561035357600080fd5b5061025d610362366004611d75565b60009081526020819052604090206001015490565b34801561038357600080fd5b50610214610392366004611d75565b6000908152600160208190526040909120541490565b3480156103b457600080fd5b506101f26103c3366004611f02565b6108fd565b3480156103d457600080fd5b506102146103e3366004611d75565b610927565b3480156103f457600080fd5b506101f2610403366004611f02565b610940565b34801561041457600080fd5b5061043c7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610220565b34801561046d57600080fd5b5061021461047c366004611d75565b6109f8565b34801561048d57600080fd5b506101f261049c366004611d75565b610a0e565b3480156104ad57600080fd5b5061025d6104bc366004611d09565b610ade565b3480156104cd57600080fd5b506101f26104dc366004611f73565b610b1d565b3480156104ed57600080fd5b5061025d7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc181565b34801561052157600080fd5b50610214610530366004611f02565b60009182526020828152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b34801561057257600080fd5b5061025d600081565b34801561058757600080fd5b5061025d7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f78381565b3480156105bb57600080fd5b5061025d6105ca366004612025565b610d4f565b3480156105db57600080fd5b506103166105ea36600461214e565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b34801561062057600080fd5b506101f261062f366004611d75565b610d94565b34801561064057600080fd5b5061025d61064f366004611d75565b60009081526001602052604090205490565b34801561066d57600080fd5b506101f261067c366004611f02565b610e8f565b6101f261068f366004612025565b610eb4565b3480156106a057600080fd5b506103166106af3660046121f8565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b3480156106e557600080fd5b5061025d611161565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc161071881611244565b6000610728898989898989610ade565b90506107348184611251565b6000817f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8b8b8b8b8b8a604051610770969594939291906122a6565b60405180910390a3505050505050505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806107d957506107d98261139e565b92915050565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff1661085c5761085c8133611435565b600061086c888888888888610ade565b905061087881856114ed565b6108848888888861162a565b6000817fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588a8a8a8a6040516108bc94939291906122f1565b60405180910390a36108cd8161172e565b5050505050505050565b6000818152600160205260408120546001811180156108f65750428111155b9392505050565b60008281526020819052604090206001015461091881611244565b61092283836117d7565b505050565b60008181526001602052604081205481905b1192915050565b73ffffffffffffffffffffffffffffffffffffffff811633146109ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6109f482826118c7565b5050565b6000818152600160208190526040822054610939565b333014610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f54696d656c6f636b436f6e74726f6c6c65723a2063616c6c6572206d7573742060448201527f62652074696d656c6f636b00000000000000000000000000000000000000000060648201526084016109e1565b60025460408051918252602082018390527f11c24f4ead16507c69ac467fbd5e4eed5fb5c699626d2cc6d66421df253886d5910160405180910390a1600255565b6000868686868686604051602001610afb969594939291906122a6565b6040516020818303038152906040528051906020012090509695505050505050565b7fb09aa5aeb3702cfd50b6b62bc4532604938f21248a27a1d5ca736082b6819cc1610b4781611244565b888714610bd6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b888514610c65576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b6000610c778b8b8b8b8b8b8b8b610d4f565b9050610c838184611251565b60005b8a811015610d415780827f4cf4410cc57040e44862ef0f45f3dd5a5e02db8eb8add648d4b0e236f1d07dca8e8e85818110610cc357610cc3612331565b9050602002016020810190610cd89190612360565b8d8d86818110610cea57610cea612331565b905060200201358c8c87818110610d0357610d03612331565b9050602002810190610d15919061237b565b8c8b604051610d29969594939291906122a6565b60405180910390a3610d3a8161240f565b9050610c86565b505050505050505050505050565b60008888888888888888604051602001610d709897969594939291906124f7565b60405160208183030381529060405280519060200120905098975050505050505050565b7ffd643c72710c63c0180259aba6b2d05451e3591a24e58b62239378085726f783610dbe81611244565b610dc7826109f8565b610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20636160448201527f6e6e6f742062652063616e63656c6c656400000000000000000000000000000060648201526084016109e1565b6000828152600160205260408082208290555183917fbaa1eb22f2a492ba1a5fea61b8df4d27c6c8b5f3971e63bb58fa14ff72eedb7091a25050565b600082815260208190526040902060010154610eaa81611244565b61092283836118c7565b600080527fdae2aa361dfd1ca020a396615627d436107c35eff9fe7738a3512819782d70696020527f5ba6852781629bcdcd4bdaa6de76d786f1c64b16acdac474e55bebc0ea157951547fd8aa0f3194971a2a116679f7c2090f6939c8d4e01a2a8d7e41d55e5351469e639060ff16610f3157610f318133611435565b878614610fc0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b87841461104f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f54696d656c6f636b436f6e74726f6c6c65723a206c656e677468206d69736d6160448201527f746368000000000000000000000000000000000000000000000000000000000060648201526084016109e1565b60006110618a8a8a8a8a8a8a8a610d4f565b905061106d81856114ed565b60005b8981101561114b5760008b8b8381811061108c5761108c612331565b90506020020160208101906110a19190612360565b905060008a8a848181106110b7576110b7612331565b9050602002013590503660008a8a868181106110d5576110d5612331565b90506020028101906110e7919061237b565b915091506110f78484848461162a565b84867fc2617efa69bab66782fa219543714338489c4e9e178271560a91b82c3f612b588686868660405161112e94939291906122f1565b60405180910390a350505050806111449061240f565b9050611070565b506111558161172e565b50505050505050505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff161580159061123257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166315064c966040518163ffffffff1660e01b8152600401602060405180830381865afa15801561120e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123291906125be565b1561123d5750600090565b5060025490565b61124e8133611435565b50565b61125a82610927565b156112e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20616c60448201527f7265616479207363686564756c6564000000000000000000000000000000000060648201526084016109e1565b6112ef611161565b81101561137e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a20696e73756666696369656e7460448201527f2064656c6179000000000000000000000000000000000000000000000000000060648201526084016109e1565b61138881426125e0565b6000928352600160205260409092209190915550565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806107d957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107d9565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f4576114738161197e565b61147e83602061199d565b60405160200161148f929190612617565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a00000000000000000000000000000000000000000000000000000000082526109e191600401612698565b6114f6826108d7565b611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b80158061159e5750600081815260016020819052604090912054145b6109f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f54696d656c6f636b436f6e74726f6c6c65723a206d697373696e67206465706560448201527f6e64656e6379000000000000000000000000000000000000000000000000000060648201526084016109e1565b60008473ffffffffffffffffffffffffffffffffffffffff168484846040516116549291906126e9565b60006040518083038185875af1925050503d8060008114611691576040519150601f19603f3d011682016040523d82523d6000602084013e611696565b606091505b5050905080611727576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603360248201527f54696d656c6f636b436f6e74726f6c6c65723a20756e6465726c79696e67207460448201527f72616e73616374696f6e2072657665727465640000000000000000000000000060648201526084016109e1565b5050505050565b611737816108d7565b6117c3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f54696d656c6f636b436f6e74726f6c6c65723a206f7065726174696f6e20697360448201527f206e6f742072656164790000000000000000000000000000000000000000000060648201526084016109e1565b600090815260016020819052604090912055565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff85168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556118693390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff16156109f45760008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60606107d973ffffffffffffffffffffffffffffffffffffffff831660145b606060006119ac8360026126f9565b6119b79060026125e0565b67ffffffffffffffff8111156119cf576119cf611d8e565b6040519080825280601f01601f1916602001820160405280156119f9576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611a3057611a30612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611a9357611a93612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611acf8460026126f9565b611ada9060016125e0565b90505b6001811115611b77577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611b1b57611b1b612331565b1a60f81b828281518110611b3157611b31612331565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611b7081612710565b9050611add565b5083156108f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109e1565b803573ffffffffffffffffffffffffffffffffffffffff81168114611c0457600080fd5b919050565b60008083601f840112611c1b57600080fd5b50813567ffffffffffffffff811115611c3357600080fd5b602083019150836020828501011115611c4b57600080fd5b9250929050565b600080600080600080600060c0888a031215611c6d57600080fd5b611c7688611be0565b965060208801359550604088013567ffffffffffffffff811115611c9957600080fd5b611ca58a828b01611c09565b989b979a50986060810135976080820135975060a09091013595509350505050565b600060208284031215611cd957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146108f657600080fd5b60008060008060008060a08789031215611d2257600080fd5b611d2b87611be0565b955060208701359450604087013567ffffffffffffffff811115611d4e57600080fd5b611d5a89828a01611c09565b979a9699509760608101359660809091013595509350505050565b600060208284031215611d8757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e0457611e04611d8e565b604052919050565b600082601f830112611e1d57600080fd5b813567ffffffffffffffff811115611e3757611e37611d8e565b611e6860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611dbd565b818152846020838601011115611e7d57600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611eb057600080fd5b611eb985611be0565b9350611ec760208601611be0565b925060408501359150606085013567ffffffffffffffff811115611eea57600080fd5b611ef687828801611e0c565b91505092959194509250565b60008060408385031215611f1557600080fd5b82359150611f2560208401611be0565b90509250929050565b60008083601f840112611f4057600080fd5b50813567ffffffffffffffff811115611f5857600080fd5b6020830191508360208260051b8501011115611c4b57600080fd5b600080600080600080600080600060c08a8c031215611f9157600080fd5b893567ffffffffffffffff80821115611fa957600080fd5b611fb58d838e01611f2e565b909b50995060208c0135915080821115611fce57600080fd5b611fda8d838e01611f2e565b909950975060408c0135915080821115611ff357600080fd5b506120008c828d01611f2e565b9a9d999c50979a969997986060880135976080810135975060a0013595509350505050565b60008060008060008060008060a0898b03121561204157600080fd5b883567ffffffffffffffff8082111561205957600080fd5b6120658c838d01611f2e565b909a50985060208b013591508082111561207e57600080fd5b61208a8c838d01611f2e565b909850965060408b01359150808211156120a357600080fd5b506120b08b828c01611f2e565b999c989b509699959896976060870135966080013595509350505050565b600082601f8301126120df57600080fd5b8135602067ffffffffffffffff8211156120fb576120fb611d8e565b8160051b61210a828201611dbd565b928352848101820192828101908785111561212457600080fd5b83870192505b848310156121435782358252918301919083019061212a565b979650505050505050565b600080600080600060a0868803121561216657600080fd5b61216f86611be0565b945061217d60208701611be0565b9350604086013567ffffffffffffffff8082111561219a57600080fd5b6121a689838a016120ce565b945060608801359150808211156121bc57600080fd5b6121c889838a016120ce565b935060808801359150808211156121de57600080fd5b506121eb88828901611e0c565b9150509295509295909350565b600080600080600060a0868803121561221057600080fd5b61221986611be0565b945061222760208701611be0565b93506040860135925060608601359150608086013567ffffffffffffffff81111561225157600080fd5b6121eb88828901611e0c565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8716815285602082015260a0604082015260006122dc60a08301868861225d565b60608301949094525060800152949350505050565b73ffffffffffffffffffffffffffffffffffffffff8516815283602082015260606040820152600061232760608301848661225d565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006020828403121561237257600080fd5b6108f682611be0565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126123b057600080fd5b83018035915067ffffffffffffffff8211156123cb57600080fd5b602001915036819003821315611c4b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612440576124406123e0565b5060010190565b81835260006020808501808196508560051b810191508460005b878110156124ea57828403895281357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18836030181126124a057600080fd5b8701858101903567ffffffffffffffff8111156124bc57600080fd5b8036038213156124cb57600080fd5b6124d686828461225d565b9a87019a9550505090840190600101612461565b5091979650505050505050565b60a0808252810188905260008960c08301825b8b8110156125455773ffffffffffffffffffffffffffffffffffffffff61253084611be0565b1682526020928301929091019060010161250a565b5083810360208501528881527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff89111561257e57600080fd5b8860051b9150818a602083013701828103602090810160408501526125a69082018789612447565b60608401959095525050608001529695505050505050565b6000602082840312156125d057600080fd5b815180151581146108f657600080fd5b808201808211156107d9576107d96123e0565b60005b8381101561260e5781810151838201526020016125f6565b50506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161264f8160178501602088016125f3565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161268c8160288401602088016125f3565b01602801949350505050565b60208152600082518060208401526126b78160408501602087016125f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b8183823760009101908152919050565b80820281158282048414176107d9576107d96123e0565b60008161271f5761271f6123e0565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019056fea2646970667358221220c474c39da3523b28ebfa5fd66c05b42d6ddcc4a57055483bdda32888b366016164736f6c63430008140033", "storage": { "0x0000000000000000000000000000000000000000000000000000000000000002": "0x0000000000000000000000000000000000000000000000000000000000000e10", "0xaedcc9e7897c0d335bdc5d92fe3a8b4f23727fe558cd1c19f332b28716a30559": "0x0000000000000000000000000000000000000000000000000000000000000001", @@ -89,7 +89,7 @@ "accountName": "keyless Deployer", "balance": "0", "nonce": "1", - "address": "0x694AB5383a002a4796f95530c14Cf0C25ec3EA03" + "address": "0x28BB4e66addE1f042B77E04cf7D3784C1dcDBbA3" }, { "accountName": "deployer", diff --git a/test/docker-compose.yml b/test/docker-compose.yml index 3094f6d509..c6c8043844 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -453,7 +453,7 @@ services: zkevm-mock-l1-network: container_name: zkevm-mock-l1-network - image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.14.3 + image: 0xpolygon/cdk-validium-contracts:elderberry-fork.9-geth1.13.11 ports: - 8545:8545 - 8546:8546 From d59718e7c6953f85408ce0186342ded5e0300aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 21 May 2024 16:04:02 +0200 Subject: [PATCH 21/21] Update the diff --- docs/diff/diff.html | 6205 +++++++++++++++++++++++++++++++++---------- 1 file changed, 4750 insertions(+), 1455 deletions(-) diff --git a/docs/diff/diff.html b/docs/diff/diff.html index c59138241b..f1e3ffa3b7 100644 --- a/docs/diff/diff.html +++ b/docs/diff/diff.html @@ -54,7 +54,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - Files changed (209) + Files changed (208) hide show
    @@ -66,8 +66,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator.go - +807 - -27 + +840 + -38 @@ -78,8 +78,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/aggregator/aggregator_test.go - +82 - -82 + +154 + -84 @@ -1835,18 +1835,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
  • - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - - +1 - -1 - - -
  • zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/synchronizer_test.go +21 - -16 + -17
  • @@ -2382,8 +2370,8 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    {/home/stefan/go/src/Polygon/zkevm-node → .}/test/Makefile - +62 - -40 + +66 + -44 @@ -3054,7 +3042,27 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -214,44 +229,813 @@
    +
    @@ -212,46 +227,819 @@
    + + + + 212 + + +
    +   + _, err = a.tryBuildFinalProof(ctx, prover, nil) +
    + + + + 213 + + +
    +   + if err != nil { +
    @@ -3066,6 +3074,56 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    log.Errorf("Error checking proofs to verify: %v", err)
    + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + 215 @@ -6059,16 +6117,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - -
    -   -
    -
    - - - -
    @@ -6707,23 +6755,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - + + 253 - -
    + +
      -
    + }
    - - + + 254 - -
    + +
      -
    + }
    @@ -8167,13 +8215,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 253 + + - -
    + +
      - } +
    @@ -8617,13 +8665,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 254 + + - -
    + +
      - } +
    @@ -11209,7 +11257,422 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -383,10 +1167,10 @@
    +
    @@ -285,41 +1073,41 @@
    + + + + 285 + + +
    +   +
    +
    + + + + 286 + + +
    +   + // isSynced checks if the state is synchronized with L1. If a batch number is +
    + + + + 287 + + +
    +   + // provided, it makes sure that the state is synced with that batch. +
    + + + + 288 + + +
    + - + func (a *Aggregator) isSynced(ctx context.Context, batchNum *uint64) bool { +
    + + + + 289 + + +
    +   + // get latest verified batch as seen by the synchronizer +
    + + + + 290 + + +
    +   + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) +
    + + + + 291 + + +
    +   + if err == state.ErrNotFound { +
    + + + + 292 + + +
    + - + return false +
    + + + + 293 + + +
    +   + } +
    + + + + 294 + + +
    +   + if err != nil { +
    + + + + 295 + + +
    +   + log.Warnf("Failed to get last consolidated batch: %v", err) +
    + + + + 296 + + +
    + - + return false +
    + + + + 297 + + +
    +   + } +
    + + + + 298 + + +
    +   +
    +
    + + + + 299 + + +
    +   + if lastVerifiedBatch == nil { +
    + + + + 300 + + +
    + - + return false +
    + + + + 301 + + +
    +   + } +
    + + + + 302 + + +
    +   +
    +
    + + + + 303 + + +
    +   + if batchNum != nil && lastVerifiedBatch.BatchNumber < *batchNum { +
    + + + + 304 + + +
    +   + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, waiting for batch: %d", lastVerifiedBatch.BatchNumber, batchNum) +
    + + + + 305 + + +
    + - + return false +
    + + + + 306 + + +
    +   + } +
    + + + + 307 + + +
    +   +
    +
    + + + + 308 + + +
    +   + // latest verified batch in L1 +
    + + + + 309 + + +
    +   + lastVerifiedEthBatchNum, err := a.Ethman.GetLatestVerifiedBatchNum() +
    + + + + 310 + + +
    +   + if err != nil { +
    + + + + 311 + + +
    +   + log.Warnf("Failed to get last eth batch, err: %v", err) +
    + + + + 312 + + +
    + - + return false +
    + + + + 313 + + +
    +   + } +
    + + + + 314 + + +
    +   +
    +
    + + + + 315 + + +
    +   + // check if L2 is synced with L1 +
    + + + + 316 + + +
    +   + if lastVerifiedBatch.BatchNumber < lastVerifiedEthBatchNum { +
    + + + + 317 + + +
    +   + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, lastVerifiedEthBatchNum: %d, waiting for batch", +
    + + + + 318 + + +
    +   + lastVerifiedBatch.BatchNumber, lastVerifiedEthBatchNum) +
    + + + + 319 + + +
    + - + return false +
    + + + + 320 + + +
    +   + } +
    + + + + 321 + + +
    +   +
    +
    + + + + 322 + + +
    + - + return true +
    + + + + 323 + + +
    +   + } +
    + + + + 324 + + +
    +   +
    +
    + + + + 325 + + +
    +   + func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*prover.InputProver, error) { +
    + + + + +
    @@ -383,10 +1171,10 @@
    @@ -11314,7 +11777,77 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -520,7 +1304,7 @@
    +
    @@ -513,19 +1301,37 @@
    + + + + 513 + + +
    +   +
    +
    + + + + 514 + + +
    +   + // wait for the synchronizer to catch up the verified batches +
    + + + + 515 + + +
    +   + log.Debug("A final proof has been sent, waiting for the network to be synced") +
    + + + + 516 + + +
    + - + for !a.isSynced(a.ctx, &proofBatchNumberFinal) { +
    + + + + 517 + + +
    + - + log.Info("Waiting for synchronizer to sync...") +
    + + + + 518 + + +
    + - + time.Sleep(a.cfg.RetryTime.Duration) +
    + + + + 519 + + +
    +   + } +
    @@ -11386,10 +11919,240 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    + + + 527 + + +
    +   + } +
    + + + + 528 + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + 529 + + +
    +   + func buildMonitoredTxID(batchNumber, batchNumberFinal uint64) string { +
    + + + + 530 + + +
    +   + return fmt.Sprintf(monitoredIDFormat, batchNumber, batchNumberFinal) +
    + + + + 531 + + +
    +   + } +
    + -
    @@ -536,7 +1320,7 @@
    +
    @@ -536,7 +1342,7 @@
    @@ -11940,6 +12703,26 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

     
    + + + 227 + + +
    +   + _, err = a.tryBuildFinalProof(ctx, prover, nil) +
    + + + + 228 + + +
    +   + if err != nil { +
    + 229 @@ -11951,9 +12734,59 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + 230 + +
    + + +
    +
    + + + + 231 + + +
    + + + if errors.Is(err, context.Canceled) { +
    + + + + 232 + + +
    + + + // the context was canceled, just continue, the loop will stop in the <-ctx.Done() case +
    + + + + 233 + + +
    + + + continue +
    + + + + 234 + + +
    + + + } +
    + + + + 235 +
      @@ -11962,7 +12795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 231 + 236
    @@ -11972,7 +12805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 232 + 237
    @@ -11982,7 +12815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 233 + 238
    @@ -11992,7 +12825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 234 + 239
    @@ -12002,7 +12835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 235 + 240
    @@ -12022,7 +12855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 236 + 241
    @@ -12032,7 +12865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 237 + 242
    @@ -12042,7 +12875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 238 + 243
    @@ -12052,7 +12885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 239 + 244
    @@ -12062,7 +12895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 240 + 245
    @@ -12072,7 +12905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 241 + 246
    @@ -12092,7 +12925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 242 + 247
    @@ -12102,7 +12935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 243 + 248
    @@ -12112,7 +12945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 244 + 249
    @@ -12122,7 +12955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 245 + 250
    @@ -12132,7 +12965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 246 + 251
    @@ -12142,7 +12975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 247 + 252
    @@ -12152,7 +12985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 248 + 253
    @@ -12162,7 +12995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 249 + 254
    @@ -12172,7 +13005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 250 + 255
    @@ -12182,7 +13015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 251 + 256
    @@ -12192,7 +13025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 252 + 257
    @@ -12202,7 +13035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 253 + 258
    @@ -12212,7 +13045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 254 + 259
    @@ -12222,7 +13055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 255 + 260
    @@ -12232,7 +13065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 256 + 261
    @@ -12242,7 +13075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 257 + 262
    @@ -12252,7 +13085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 258 + 263
    @@ -12262,7 +13095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 259 + 264
    @@ -12272,7 +13105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 260 + 265
    @@ -12282,7 +13115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 261 + 266
    @@ -12292,7 +13125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 262 + 267
    @@ -12302,7 +13135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 263 + 268
    @@ -12312,7 +13145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 264 + 269
    @@ -12322,7 +13155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 265 + 270
    @@ -12332,7 +13165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 266 + 271
    @@ -12342,7 +13175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 267 + 272
    @@ -12352,7 +13185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 268 + 273
    @@ -12362,7 +13195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 269 + 274
    @@ -12372,7 +13205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 270 + 275
    @@ -12382,7 +13215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 271 + 276
    @@ -12392,7 +13225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 272 + 277
    @@ -12402,7 +13235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 273 + 278
    @@ -12412,7 +13245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 274 + 279
    @@ -12422,7 +13255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 275 + 280
    @@ -12432,7 +13265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 276 + 281
    @@ -12442,7 +13275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 277 + 282
    @@ -12452,7 +13285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 278 + 283
    @@ -12462,7 +13295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 279 + 284
    @@ -12472,7 +13305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 280 + 285
    @@ -12482,7 +13315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 281 + 286
    @@ -12492,7 +13325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 282 + 287
    @@ -12502,7 +13335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 283 + 288
    @@ -12512,7 +13345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 284 + 289
    @@ -12522,7 +13355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 285 + 290
    @@ -12532,7 +13365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 286 + 291
    @@ -12542,7 +13375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 287 + 292
    @@ -12552,7 +13385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 288 + 293
    @@ -12562,7 +13395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 289 + 294
    @@ -12572,7 +13405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 290 + 295
    @@ -12582,7 +13415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 291 + 296
    @@ -12592,7 +13425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 292 + 297
    @@ -12602,7 +13435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 293 + 298
    @@ -12612,7 +13445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 294 + 299
    @@ -12622,7 +13455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 295 + 300
    @@ -12632,7 +13465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 296 + 301
    @@ -12642,7 +13475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 297 + 302
    @@ -12652,7 +13485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 298 + 303
    @@ -12662,7 +13495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 299 + 304
    @@ -12672,7 +13505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 300 + 305
    @@ -12682,7 +13515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 301 + 306
    @@ -12692,7 +13525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 302 + 307
    @@ -12702,7 +13535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 303 + 308
    @@ -12712,7 +13545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 304 + 309
    @@ -12722,7 +13555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 305 + 310
    @@ -12732,7 +13565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 306 + 311
    @@ -12742,7 +13575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 307 + 312
    @@ -12752,7 +13585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 308 + 313
    @@ -12762,7 +13595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 309 + 314
    @@ -12772,7 +13605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 310 + 315
    @@ -12782,7 +13615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 311 + 316
    @@ -12792,7 +13625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 312 + 317
    @@ -12802,7 +13635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 313 + 318
    @@ -12812,7 +13645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 314 + 319
    @@ -12822,7 +13655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 315 + 320
    @@ -12832,7 +13665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 316 + 321
    @@ -12842,7 +13675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 317 + 322
    @@ -12852,7 +13685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 318 + 323
    @@ -12862,7 +13695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 319 + 324
    @@ -12872,7 +13705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 320 + 325
    @@ -12882,7 +13715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 321 + 326
    @@ -12892,7 +13725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 322 + 327
    @@ -12902,7 +13735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 323 + 328
    @@ -12912,7 +13745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 324 + 329
    @@ -12922,7 +13755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 325 + 330
    @@ -12932,7 +13765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 326 + 331
    @@ -12942,7 +13775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 327 + 332
    @@ -12952,7 +13785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 328 + 333
    @@ -12962,7 +13795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 329 + 334
    @@ -12972,7 +13805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 330 + 335
    @@ -12982,7 +13815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 331 + 336
    @@ -12992,7 +13825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 332 + 337
    @@ -13002,7 +13835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 333 + 338
    @@ -13012,7 +13845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 334 + 339
    @@ -13022,7 +13855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 335 + 340
    @@ -13032,7 +13865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 336 + 341
    @@ -13042,7 +13875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 337 + 342
    @@ -13052,7 +13885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 338 + 343
    @@ -13062,7 +13895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 339 + 344
    @@ -13072,7 +13905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 340 + 345
    @@ -13082,7 +13915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 341 + 346
    @@ -13092,7 +13925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 342 + 347
    @@ -13102,7 +13935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 343 + 348
    @@ -13112,7 +13945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 344 + 349
    @@ -13122,7 +13955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 345 + 350
    @@ -13132,7 +13965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 346 + 351
    @@ -13142,7 +13975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 347 + 352
    @@ -13152,7 +13985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 348 + 353
    @@ -13162,7 +13995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 349 + 354
    @@ -13172,7 +14005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 350 + 355
    @@ -13182,7 +14015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 351 + 356
    @@ -13192,7 +14025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 352 + 357
    @@ -13202,7 +14035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 353 + 358
    @@ -13212,7 +14045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 354 + 359
    @@ -13222,7 +14055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 355 + 360
    @@ -13232,7 +14065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 356 + 361
    @@ -13242,7 +14075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 357 + 362
    @@ -13252,7 +14085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 358 + 363
    @@ -13262,7 +14095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 359 + 364
    @@ -13272,7 +14105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 360 + 365
    @@ -13282,7 +14115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 361 + 366
    @@ -13292,7 +14125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 362 + 367
    @@ -13302,7 +14135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 363 + 368
    @@ -13312,7 +14145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 364 + 369
    @@ -13322,7 +14155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 365 + 370
    @@ -13332,7 +14165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 366 + 371
    @@ -13342,7 +14175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 367 + 372
    @@ -13352,7 +14185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 368 + 373
    @@ -13362,7 +14195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 369 + 374
    @@ -13372,7 +14205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 370 + 375
    @@ -13382,7 +14215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 371 + 376
    @@ -13392,7 +14225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 372 + 377
    @@ -13402,7 +14235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 373 + 378
    @@ -13412,7 +14245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 374 + 379
    @@ -13422,7 +14255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 375 + 380
    @@ -13432,7 +14265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 376 + 381
    @@ -13442,7 +14275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 377 + 382
    @@ -13452,7 +14285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 378 + 383
    @@ -13462,7 +14295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 379 + 384
    @@ -13472,7 +14305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 380 + 385
    @@ -13482,7 +14315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 381 + 386
    @@ -13492,7 +14325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 382 + 387
    @@ -13502,7 +14335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 383 + 388
    @@ -13512,7 +14345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 384 + 389
    @@ -13522,7 +14355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 385 + 390
    @@ -13532,7 +14365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 386 + 391
    @@ -13542,7 +14375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 387 + 392
    @@ -13552,7 +14385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 388 + 393
    @@ -13562,7 +14395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 389 + 394
    @@ -13572,7 +14405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 390 + 395
    @@ -13582,7 +14415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 391 + 396
    @@ -13592,7 +14425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 392 + 397
    @@ -13602,7 +14435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 393 + 398
    @@ -13612,7 +14445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 394 + 399
    @@ -13622,7 +14455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 395 + 400
    @@ -13632,7 +14465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 396 + 401
    @@ -13642,7 +14475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 397 + 402
    @@ -13652,7 +14485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 398 + 403
    @@ -13662,7 +14495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 399 + 404
    @@ -13672,7 +14505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 400 + 405
    @@ -13682,7 +14515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 401 + 406
    @@ -13692,7 +14525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 402 + 407
    @@ -13702,7 +14535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 403 + 408
    @@ -13712,7 +14545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 404 + 409
    @@ -13722,7 +14555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 405 + 410
    @@ -13732,7 +14565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 406 + 411
    @@ -13742,7 +14575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 407 + 412
    @@ -13752,7 +14585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 408 + 413
    @@ -13762,7 +14595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 409 + 414
    @@ -13772,7 +14605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 410 + 415
    @@ -13782,7 +14615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 411 + 416
    @@ -13792,7 +14625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 412 + 417
    @@ -13802,7 +14635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 413 + 418
    @@ -13812,7 +14645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 414 + 419
    @@ -13822,7 +14655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 415 + 420
    @@ -13832,7 +14665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 416 + 421
    @@ -13842,7 +14675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 417 + 422
    @@ -13852,7 +14685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 418 + 423
    @@ -13862,7 +14695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 419 + 424
    @@ -13872,7 +14705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 420 + 425
    @@ -13882,7 +14715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 421 + 426
    @@ -13892,7 +14725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 422 + 427
    @@ -13902,7 +14735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 423 + 428
    @@ -13912,7 +14745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 424 + 429
    @@ -13922,7 +14755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 425 + 430
    @@ -13932,7 +14765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 426 + 431
    @@ -13942,7 +14775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 427 + 432
    @@ -13952,7 +14785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 428 + 433
    @@ -13962,7 +14795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 429 + 434
    @@ -13972,7 +14805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 430 + 435
    @@ -13982,7 +14815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 431 + 436
    @@ -13992,7 +14825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 432 + 437
    @@ -14002,7 +14835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 433 + 438
    @@ -14012,7 +14845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 434 + 439
    @@ -14022,7 +14855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 435 + 440
    @@ -14032,7 +14865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 436 + 441
    @@ -14042,7 +14875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 437 + 442
    @@ -14052,7 +14885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 438 + 443
    @@ -14062,7 +14895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 439 + 444
    @@ -14072,7 +14905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 440 + 445
    @@ -14082,7 +14915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 441 + 446
    @@ -14092,7 +14925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 442 + 447
    @@ -14102,7 +14935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 443 + 448
    @@ -14112,7 +14945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 444 + 449
    @@ -14122,7 +14955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 445 + 450
    @@ -14132,7 +14965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 446 + 451
    @@ -14142,7 +14975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 447 + 452
    @@ -14152,7 +14985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 448 + 453
    @@ -14162,7 +14995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 449 + 454
    @@ -14172,7 +15005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 450 + 455
    @@ -14182,7 +15015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 451 + 456
    @@ -14192,7 +15025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 452 + 457
    @@ -14202,7 +15035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 453 + 458
    @@ -14212,7 +15045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 454 + 459
    @@ -14222,7 +15055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 455 + 460
    @@ -14232,7 +15065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 456 + 461
    @@ -14242,7 +15075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 457 + 462
    @@ -14252,7 +15085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 458 + 463
    @@ -14262,7 +15095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 459 + 464
    @@ -14272,7 +15105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 460 + 465
    @@ -14282,7 +15115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 461 + 466
    @@ -14292,7 +15125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 462 + 467
    @@ -14302,7 +15135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 463 + 468
    @@ -14312,7 +15145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 464 + 469
    @@ -14322,7 +15155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 465 + 470
    @@ -14332,7 +15165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 466 + 471
    @@ -14342,7 +15175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 467 + 472
    @@ -14352,7 +15185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 468 + 473
    @@ -14362,7 +15195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 469 + 474
    @@ -14372,7 +15205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 470 + 475
    @@ -14382,7 +15215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 471 + 476
    @@ -14392,7 +15225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 472 + 477
    @@ -14402,7 +15235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 473 + 478
    @@ -14412,7 +15245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 474 + 479
    @@ -14422,7 +15255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 475 + 480
    @@ -14432,7 +15265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 476 + 481
    @@ -14442,7 +15275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 477 + 482
    @@ -14452,7 +15285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 478 + 483
    @@ -14462,7 +15295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 479 + 484
    @@ -14472,7 +15305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 480 + 485
    @@ -14482,7 +15315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 481 + 486
    @@ -14492,7 +15325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 482 + 487
    @@ -14502,7 +15335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 483 + 488
    @@ -14512,7 +15345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 484 + 489
    @@ -14522,7 +15355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 485 + 490
    @@ -14532,7 +15365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 486 + 491
    @@ -14542,7 +15375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 487 + 492
    @@ -14552,7 +15385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 488 + 493
    @@ -14562,7 +15395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 489 + 494
    @@ -14572,7 +15405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 490 + 495
    @@ -14582,7 +15415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 491 + 496
    @@ -14592,7 +15425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 492 + 497
    @@ -14602,47 +15435,37 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 493 - - -
    - + - for !a.isSynced(ctx, nil) { -
    - - - - 494 + 498
    + - log.Info("Waiting for synchronizer to sync...") + if err = a.waitForSynchronizerToSyncUp(ctx, nil); err != nil {
    - 495 + 499
    + - time.Sleep(a.cfg.RetryTime.Duration) + log.Warn("waiting for the synchronizer to sync up was canceled", err)
    - 496 + 500
    + - continue + return false, err
    - 497 + 501
    @@ -14652,7 +15475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 498 + 502
    @@ -14662,7 +15485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 499 + 503
    @@ -14672,7 +15495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 500 + 504
    @@ -14682,7 +15505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 501 + 505
    @@ -14692,7 +15515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 502 + 506
    @@ -14702,7 +15525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 503 + 507
    @@ -14712,7 +15535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 504 + 508
    @@ -14722,7 +15545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 505 + 509
    @@ -14732,7 +15555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 506 + 510
    @@ -14742,7 +15565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 507 + 511
    @@ -14752,7 +15575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 508 + 512
    @@ -14762,7 +15585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 509 + 513
    @@ -14772,7 +15595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 510 + 514
    @@ -14782,7 +15605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 511 + 515
    @@ -14792,7 +15615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 512 + 516
    @@ -14802,7 +15625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 513 + 517
    @@ -14812,7 +15635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 514 + 518
    @@ -14822,7 +15645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 515 + 519
    @@ -14832,7 +15655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 516 + 520
    @@ -14842,7 +15665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 517 + 521
    @@ -14852,7 +15675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 518 + 522
    @@ -14862,7 +15685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 519 + 523
    @@ -14872,7 +15695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 520 + 524
    @@ -14882,7 +15705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 521 + 525
    @@ -14892,7 +15715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 522 + 526
    @@ -14902,7 +15725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 523 + 527
    @@ -14912,7 +15735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 524 + 528
    @@ -14922,7 +15745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 525 + 529
    @@ -14932,7 +15755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 526 + 530
    @@ -14942,7 +15765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 527 + 531
    @@ -14952,7 +15775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 528 + 532
    @@ -14962,7 +15785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 529 + 533
    @@ -14972,7 +15795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 530 + 534
    @@ -14982,7 +15805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 531 + 535
    @@ -14992,7 +15815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 532 + 536
    @@ -15002,7 +15825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 533 + 537
    @@ -15012,7 +15835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 534 + 538
    @@ -15022,7 +15845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 535 + 539
    @@ -15032,7 +15855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 536 + 540
    @@ -15042,7 +15865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 537 + 541
    @@ -15052,7 +15875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 538 + 542
    @@ -15062,7 +15885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 539 + 543
    @@ -15072,7 +15895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 540 + 544
    @@ -15082,7 +15905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 541 + 545
    @@ -15092,7 +15915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 542 + 546
    @@ -15102,7 +15925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 543 + 547
    @@ -15112,7 +15935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 544 + 548
    @@ -15122,7 +15945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 545 + 549
    @@ -15132,7 +15955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 546 + 550
    @@ -15142,7 +15965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 547 + 551
    @@ -15152,7 +15975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 548 + 552
    @@ -15162,7 +15985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 549 + 553
    @@ -15172,7 +15995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 550 + 554
    @@ -15182,7 +16005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 551 + 555
    @@ -15192,7 +16015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 552 + 556
    @@ -15202,7 +16025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 553 + 557
    @@ -15212,7 +16035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 554 + 558
    @@ -15222,7 +16045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 555 + 559
    @@ -15232,7 +16055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 556 + 560
    @@ -15242,7 +16065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 557 + 561
    @@ -15252,7 +16075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 558 + 562
    @@ -15262,7 +16085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 559 + 563
    @@ -15272,7 +16095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 560 + 564
    @@ -15282,7 +16105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 561 + 565
    @@ -15292,7 +16115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 562 + 566
    @@ -15302,7 +16125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 563 + 567
    @@ -15312,7 +16135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 564 + 568
    @@ -15322,7 +16145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 565 + 569
    @@ -15332,7 +16155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 566 + 570
    @@ -15342,7 +16165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 567 + 571
    @@ -15352,7 +16175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 568 + 572
    @@ -15362,7 +16185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 569 + 573
    @@ -15372,7 +16195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 570 + 574
    @@ -15382,7 +16205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 571 + 575
    @@ -15392,7 +16215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 572 + 576
    @@ -15402,7 +16225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 573 + 577
    @@ -15412,7 +16235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 574 + 578
    @@ -15422,7 +16245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 575 + 579
    @@ -15432,7 +16255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 576 + 580
    @@ -15442,7 +16265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 577 + 581
    @@ -15452,7 +16275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 578 + 582
    @@ -15462,7 +16285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 579 + 583
    @@ -15472,7 +16295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 580 + 584
    @@ -15482,7 +16305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 581 + 585
    @@ -15492,7 +16315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 582 + 586
    @@ -15502,7 +16325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 583 + 587
    @@ -15512,7 +16335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 584 + 588
    @@ -15522,7 +16345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 585 + 589
    @@ -15532,7 +16355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 586 + 590
    @@ -15542,7 +16365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 587 + 591
    @@ -15552,7 +16375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 588 + 592
    @@ -15562,7 +16385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 589 + 593
    @@ -15572,7 +16395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 590 + 594
    @@ -15582,7 +16405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 591 + 595
    @@ -15591,28 +16414,28 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 592 + + 596 - +
    - + +   }
    - - 593 + + 597 - +
    - + +   }
    - 594 + 598
    @@ -15622,7 +16445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 595 + 599
    @@ -15632,7 +16455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 596 + 600
    @@ -15642,7 +16465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 597 + 601
    @@ -15652,7 +16475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 598 + 602
    @@ -15662,7 +16485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 599 + 603
    @@ -15672,7 +16495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 600 + 604
    @@ -15682,7 +16505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 601 + 605
    @@ -15692,7 +16515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 602 + 606
    @@ -15702,7 +16525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 603 + 607
    @@ -15712,7 +16535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 604 + 608
    @@ -15722,7 +16545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 605 + 609
    @@ -15732,7 +16555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 606 + 610
    @@ -15742,7 +16565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 607 + 611
    @@ -15752,7 +16575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 608 + 612
    @@ -15762,7 +16585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 609 + 613
    @@ -15772,7 +16595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 610 + 614
    @@ -15782,7 +16605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 611 + 615
    @@ -15792,7 +16615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 612 + 616
    @@ -15802,7 +16625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 613 + 617
    @@ -15812,7 +16635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 614 + 618
    @@ -15822,7 +16645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 615 + 619
    @@ -15832,7 +16655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 616 + 620
    @@ -15842,7 +16665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 617 + 621
    @@ -15852,7 +16675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 618 + 622
    @@ -15862,7 +16685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 619 + 623
    @@ -15872,7 +16695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 620 + 624
    @@ -15882,7 +16705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 621 + 625
    @@ -15892,7 +16715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 622 + 626
    @@ -15902,7 +16725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 623 + 627
    @@ -15912,7 +16735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 624 + 628
    @@ -15922,7 +16745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 625 + 629
    @@ -15932,7 +16755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 626 + 630
    @@ -15942,7 +16765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 627 + 631
    @@ -15952,7 +16775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 628 + 632
    @@ -15962,7 +16785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 629 + 633
    @@ -15972,7 +16795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 630 + 634
    @@ -15982,7 +16805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 631 + 635
    @@ -15992,7 +16815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 632 + 636
    @@ -16002,7 +16825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 633 + 637
    @@ -16012,7 +16835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 634 + 638
    @@ -16022,7 +16845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 635 + 639
    @@ -16032,7 +16855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 636 + 640
    @@ -16042,7 +16865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 637 + 641
    @@ -16052,7 +16875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 638 + 642
    @@ -16062,7 +16885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 639 + 643
    @@ -16072,7 +16895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 640 + 644
    @@ -16082,7 +16905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 641 + 645
    @@ -16092,7 +16915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 642 + 646
    @@ -16102,7 +16925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 643 + 647
    @@ -16112,7 +16935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 644 + 648
    @@ -16122,7 +16945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 645 + 649
    @@ -16132,7 +16955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 646 + 650
    @@ -16142,7 +16965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 647 + 651
    @@ -16152,7 +16975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 648 + 652
    @@ -16162,7 +16985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 649 + 653
    @@ -16172,7 +16995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 650 + 654
    @@ -16182,7 +17005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 651 + 655
    @@ -16192,7 +17015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 652 + 656
    @@ -16202,7 +17025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 653 + 657
    @@ -16212,7 +17035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 654 + 658
    @@ -16222,7 +17045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 655 + 659
    @@ -16232,7 +17055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 656 + 660
    @@ -16242,7 +17065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 657 + 661
    @@ -16252,7 +17075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 658 + 662
    @@ -16262,7 +17085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 659 + 663
    @@ -16272,7 +17095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 660 + 664
    @@ -16282,7 +17105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 661 + 665
    @@ -16292,7 +17115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 662 + 666
    @@ -16302,7 +17125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 663 + 667
    @@ -16312,7 +17135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 664 + 668
    @@ -16322,7 +17145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 665 + 669
    @@ -16332,7 +17155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 666 + 670
    @@ -16342,7 +17165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 667 + 671
    @@ -16352,7 +17175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 668 + 672
    @@ -16362,7 +17185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 669 + 673
    @@ -16372,7 +17195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 670 + 674
    @@ -16382,7 +17205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 671 + 675
    @@ -16392,7 +17215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 672 + 676
    @@ -16402,7 +17225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 673 + 677
    @@ -16412,7 +17235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 674 + 678
    @@ -16422,7 +17245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 675 + 679
    @@ -16432,7 +17255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 676 + 680
    @@ -16442,7 +17265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 677 + 681
    @@ -16452,7 +17275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 678 + 682
    @@ -16462,7 +17285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 679 + 683
    @@ -16472,7 +17295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 680 + 684
    @@ -16482,7 +17305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 681 + 685
    @@ -16492,7 +17315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 682 + 686
    @@ -16502,7 +17325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 683 + 687
    @@ -16512,7 +17335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 684 + 688
    @@ -16522,7 +17345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 685 + 689
    @@ -16532,7 +17355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 686 + 690
    @@ -16542,7 +17365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 687 + 691
    @@ -16552,7 +17375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 688 + 692
    @@ -16562,7 +17385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 689 + 693
    @@ -16572,7 +17395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 690 + 694
    @@ -16582,7 +17405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 691 + 695
    @@ -16592,7 +17415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 692 + 696
    @@ -16602,7 +17425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 693 + 697
    @@ -16612,7 +17435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 694 + 698
    @@ -16622,7 +17445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 695 + 699
    @@ -16632,7 +17455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 696 + 700
    @@ -16642,7 +17465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 697 + 701
    @@ -16652,7 +17475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 698 + 702
    @@ -16662,7 +17485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 699 + 703
    @@ -16672,7 +17495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 700 + 704
    @@ -16682,7 +17505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 701 + 705
    @@ -16692,7 +17515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 702 + 706
    @@ -16702,7 +17525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 703 + 707
    @@ -16712,7 +17535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 704 + 708
    @@ -16722,7 +17545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 705 + 709
    @@ -16732,7 +17555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 706 + 710
    @@ -16742,7 +17565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 707 + 711
    @@ -16752,7 +17575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 708 + 712
    @@ -16762,7 +17585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 709 + 713
    @@ -16772,7 +17595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 710 + 714
    @@ -16782,7 +17605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 711 + 715
    @@ -16792,7 +17615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 712 + 716
    @@ -16802,7 +17625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 713 + 717
    @@ -16812,7 +17635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 714 + 718
    @@ -16822,7 +17645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 715 + 719
    @@ -16832,7 +17655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 716 + 720
    @@ -16842,7 +17665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 717 + 721
    @@ -16852,7 +17675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 718 + 722
    @@ -16862,7 +17685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 719 + 723
    @@ -16872,7 +17695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 720 + 724
    @@ -16882,7 +17705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 721 + 725
    @@ -16892,7 +17715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 722 + 726
    @@ -16902,7 +17725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 723 + 727
    @@ -16912,7 +17735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 724 + 728
    @@ -16922,7 +17745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 725 + 729
    @@ -16932,7 +17755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 726 + 730
    @@ -16942,7 +17765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 727 + 731
    @@ -16952,7 +17775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 728 + 732
    @@ -16962,7 +17785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 729 + 733
    @@ -16972,7 +17795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 730 + 734
    @@ -16982,7 +17805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 731 + 735
    @@ -16992,7 +17815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 732 + 736
    @@ -17002,7 +17825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 733 + 737
    @@ -17012,7 +17835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 734 + 738
    @@ -17022,7 +17845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 735 + 739
    @@ -17032,7 +17855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 736 + 740
    @@ -17042,7 +17865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 737 + 741
    @@ -17051,18 +17874,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 738 + + 742 - +
    -   + + }
    - 739 + 743
    @@ -17072,7 +17895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 740 + 744
    @@ -17082,7 +17905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 741 + 745
    @@ -17092,7 +17915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 742 + 746
    @@ -17102,7 +17925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 743 + 747
    @@ -17112,7 +17935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 744 + 748
    @@ -17122,7 +17945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 745 + 749
    @@ -17132,7 +17955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 746 + 750
    @@ -17142,7 +17965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 747 + 751
    @@ -17152,7 +17975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 748 + 752
    @@ -17162,7 +17985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 749 + 753
    @@ -17172,7 +17995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 750 + 754
    @@ -17182,7 +18005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 751 + 755
    @@ -17192,7 +18015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 752 + 756
    @@ -17202,7 +18025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 753 + 757
    @@ -17212,7 +18035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 754 + 758
    @@ -17222,7 +18045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 755 + 759
    @@ -17232,7 +18055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 756 + 760
    @@ -17242,7 +18065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 757 + 761
    @@ -17252,7 +18075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 758 + 762
    @@ -17262,7 +18085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 759 + 763
    @@ -17272,7 +18095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 760 + 764
    @@ -17282,7 +18105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 761 + 765
    @@ -17292,7 +18115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 762 + 766
    @@ -17302,7 +18125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 763 + 767
    @@ -17312,7 +18135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 764 + 768
    @@ -17322,7 +18145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 765 + 769
    @@ -17332,7 +18155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 766 + 770
    @@ -17342,7 +18165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 767 + 771
    @@ -17352,7 +18175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 768 + 772
    @@ -17362,7 +18185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 769 + 773
    @@ -17372,7 +18195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 770 + 774
    @@ -17382,7 +18205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 771 + 775
    @@ -17392,7 +18215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 772 + 776
    @@ -17402,7 +18225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 773 + 777
    @@ -17412,7 +18235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 774 + 778
    @@ -17422,7 +18245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 775 + 779
    @@ -17432,7 +18255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 776 + 780
    @@ -17442,7 +18265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 777 + 781
    @@ -17452,7 +18275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 778 + 782
    @@ -17462,7 +18285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 779 + 783
    @@ -17472,7 +18295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 780 + 784
    @@ -17482,7 +18305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 781 + 785
    @@ -17492,7 +18315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 782 + 786
    @@ -17501,18 +18324,18 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 783 + + 787 - +
    -   + + }
    - 784 + 788
    @@ -17522,7 +18345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 785 + 789
    @@ -17532,7 +18355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 786 + 790
    @@ -17542,7 +18365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 787 + 791
    @@ -17552,7 +18375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 788 + 792
    @@ -17562,7 +18385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 789 + 793
    @@ -17572,7 +18395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 790 + 794
    @@ -17582,7 +18405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 791 + 795
    @@ -17592,7 +18415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 792 + 796
    @@ -17602,7 +18425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 793 + 797
    @@ -17612,7 +18435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 794 + 798
    @@ -17622,7 +18445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 795 + 799
    @@ -17632,7 +18455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 796 + 800
    @@ -17642,7 +18465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 797 + 801
    @@ -17652,7 +18475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 798 + 802
    @@ -17662,7 +18485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 799 + 803
    @@ -17672,7 +18495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 800 + 804
    @@ -17682,7 +18505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 801 + 805
    @@ -17692,7 +18515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 802 + 806
    @@ -17702,7 +18525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 803 + 807
    @@ -17712,7 +18535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 804 + 808
    @@ -17722,7 +18545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 805 + 809
    @@ -17732,7 +18555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 806 + 810
    @@ -17742,7 +18565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 807 + 811
    @@ -17752,7 +18575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 808 + 812
    @@ -17762,7 +18585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 809 + 813
    @@ -17772,7 +18595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 810 + 814
    @@ -17782,7 +18605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 811 + 815
    @@ -17792,7 +18615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 812 + 816
    @@ -17802,7 +18625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 813 + 817
    @@ -17812,7 +18635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 814 + 818
    @@ -17822,7 +18645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 815 + 819
    @@ -17832,7 +18655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 816 + 820
    @@ -17842,7 +18665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 817 + 821
    @@ -17852,7 +18675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 818 + 822
    @@ -17862,7 +18685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 819 + 823
    @@ -17872,7 +18695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 820 + 824
    @@ -17882,7 +18705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 821 + 825
    @@ -17892,7 +18715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 822 + 826
    @@ -17902,7 +18725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 823 + 827
    @@ -17912,7 +18735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 824 + 828
    @@ -17922,7 +18745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 825 + 829
    @@ -17932,7 +18755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 826 + 830
    @@ -17942,7 +18765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 827 + 831
    @@ -17952,7 +18775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 828 + 832
    @@ -17962,7 +18785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 829 + 833
    @@ -17972,7 +18795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 830 + 834
    @@ -17982,7 +18805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 831 + 835
    @@ -17992,7 +18815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 832 + 836
    @@ -18002,7 +18825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 833 + 837
    @@ -18012,7 +18835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 834 + 838
    @@ -18022,7 +18845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 835 + 839
    @@ -18032,7 +18855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 836 + 840
    @@ -18042,7 +18865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 837 + 841
    @@ -18052,7 +18875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 838 + 842
    @@ -18062,7 +18885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 839 + 843
    @@ -18072,7 +18895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 840 + 844
    @@ -18082,7 +18905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 841 + 845
    @@ -18092,7 +18915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 842 + 846
    @@ -18102,7 +18925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 843 + 847
    @@ -18112,7 +18935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 844 + 848
    @@ -18122,7 +18945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 845 + 849
    @@ -18132,7 +18955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 846 + 850
    @@ -18142,7 +18965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 847 + 851
    @@ -18152,7 +18975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 848 + 852
    @@ -18162,7 +18985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 849 + 853
    @@ -18172,7 +18995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 850 + 854
    @@ -18182,7 +19005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 851 + 855
    @@ -18192,7 +19015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 852 + 856
    @@ -18202,7 +19025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 853 + 857
    @@ -18212,7 +19035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 854 + 858
    @@ -18222,7 +19045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 855 + 859
    @@ -18232,7 +19055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 856 + 860
    @@ -18242,7 +19065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 857 + 861
    @@ -18252,7 +19075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 858 + 862
    @@ -18262,7 +19085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 859 + 863
    @@ -18272,7 +19095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 860 + 864
    @@ -18282,7 +19105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 861 + 865
    @@ -18292,7 +19115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 862 + 866
    @@ -18302,7 +19125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 863 + 867
    @@ -18312,7 +19135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 864 + 868
    @@ -18322,7 +19145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 865 + 869
    @@ -18332,7 +19155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 866 + 870
    @@ -18342,7 +19165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 867 + 871
    @@ -18352,7 +19175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 868 + 872
    @@ -18362,7 +19185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 869 + 873
    @@ -18372,7 +19195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 870 + 874
    @@ -18382,7 +19205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 871 + 875
    @@ -18392,7 +19215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 872 + 876
    @@ -18402,7 +19225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 873 + 877
    @@ -18412,7 +19235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 874 + 878
    @@ -18422,7 +19245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 875 + 879
    @@ -18432,7 +19255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 876 + 880
    @@ -18442,7 +19265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 877 + 881
    @@ -18452,7 +19275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 878 + 882
    @@ -18462,7 +19285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 879 + 883
    @@ -18472,7 +19295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 880 + 884
    @@ -18482,7 +19305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 881 + 885
    @@ -18492,7 +19315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 882 + 886
    @@ -18502,7 +19325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 883 + 887
    @@ -18512,7 +19335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 884 + 888
    @@ -18522,7 +19345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 885 + 889
    @@ -18532,7 +19355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 886 + 890
    @@ -18542,7 +19365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 887 + 891
    @@ -18552,7 +19375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 888 + 892
    @@ -18562,7 +19385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 889 + 893
    @@ -18572,7 +19395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 890 + 894
    @@ -18582,7 +19405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 891 + 895
    @@ -18592,7 +19415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 892 + 896
    @@ -18602,7 +19425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 893 + 897
    @@ -18612,7 +19435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 894 + 898
    @@ -18622,7 +19445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 895 + 899
    @@ -18632,7 +19455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 896 + 900
    @@ -18642,7 +19465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 897 + 901
    @@ -18652,7 +19475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 898 + 902
    @@ -18662,7 +19485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 899 + 903
    @@ -18672,7 +19495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 900 + 904
    @@ -18682,7 +19505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 901 + 905
    @@ -18692,7 +19515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 902 + 906
    @@ -18702,7 +19525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 903 + 907
    @@ -18712,7 +19535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 904 + 908
    @@ -18722,7 +19545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 905 + 909
    @@ -18732,7 +19555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 906 + 910
    @@ -18742,7 +19565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 907 + 911
    @@ -18752,7 +19575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 908 + 912
    @@ -18762,7 +19585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 909 + 913
    @@ -18772,7 +19595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 910 + 914
    @@ -18782,7 +19605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 911 + 915
    @@ -18792,7 +19615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 912 + 916
    @@ -18802,7 +19625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 913 + 917
    @@ -18812,7 +19635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 914 + 918
    @@ -18822,7 +19645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 915 + 919
    @@ -18832,7 +19655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 916 + 920
    @@ -18842,7 +19665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 917 + 921
    @@ -18852,7 +19675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 918 + 922
    @@ -18862,7 +19685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 919 + 923
    @@ -18872,7 +19695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 920 + 924
    @@ -18882,7 +19705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 921 + 925
    @@ -18892,7 +19715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 922 + 926
    @@ -18902,7 +19725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 923 + 927
    @@ -18912,7 +19735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 924 + 928
    @@ -18922,7 +19745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 925 + 929
    @@ -18932,7 +19755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 926 + 930
    @@ -18942,7 +19765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 927 + 931
    @@ -18952,7 +19775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 928 + 932
    @@ -18962,7 +19785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 929 + 933
    @@ -18972,7 +19795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 930 + 934
    @@ -18982,7 +19805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 931 + 935
    @@ -18992,7 +19815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 932 + 936
    @@ -19002,7 +19825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 933 + 937
    @@ -19012,7 +19835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 934 + 938
    @@ -19022,7 +19845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 935 + 939
    @@ -19032,7 +19855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 936 + 940
    @@ -19042,7 +19865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 937 + 941
    @@ -19052,7 +19875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 938 + 942
    @@ -19062,7 +19885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 939 + 943
    @@ -19072,7 +19895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 940 + 944
    @@ -19082,7 +19905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 941 + 945
    @@ -19092,7 +19915,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 942 + 946
    @@ -19102,7 +19925,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 943 + 947
    @@ -19112,7 +19935,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 944 + 948
    @@ -19122,7 +19945,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 945 + 949
    @@ -19132,7 +19955,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 946 + 950
    @@ -19142,7 +19965,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 947 + 951
    @@ -19152,7 +19975,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 948 + 952
    @@ -19162,7 +19985,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 949 + 953
    @@ -19172,7 +19995,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 950 + 954
    @@ -19182,7 +20005,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 951 + 955
    @@ -19192,7 +20015,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 952 + 956
    @@ -19202,7 +20025,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 953 + 957
    @@ -19212,7 +20035,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 954 + 958
    @@ -19222,7 +20045,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 955 + 959
    @@ -19232,7 +20055,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 956 + 960
    @@ -19242,7 +20065,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 957 + 961
    @@ -19252,7 +20075,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 958 + 962
    @@ -19262,7 +20085,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 959 + 963
    @@ -19272,7 +20095,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 960 + 964
    @@ -19282,7 +20105,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 961 + 965
    @@ -19292,7 +20115,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 962 + 966
    @@ -19302,7 +20125,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 963 + 967
    @@ -19312,7 +20135,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 964 + 968
    @@ -19322,7 +20145,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 965 + 969
    @@ -19332,7 +20155,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 966 + 970
    @@ -19342,7 +20165,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 967 + 971
    @@ -19352,7 +20175,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 968 + 972
    @@ -19362,7 +20185,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 969 + 973
    @@ -19372,7 +20195,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 970 + 974
    @@ -19382,7 +20205,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 971 + 975
    @@ -19392,7 +20215,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 972 + 976
    @@ -19402,7 +20225,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 973 + 977
    @@ -19412,7 +20235,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 974 + 978
    @@ -19422,7 +20245,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 975 + 979
    @@ -19432,7 +20255,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 976 + 980
    @@ -19442,7 +20265,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 977 + 981
    @@ -19452,7 +20275,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 978 + 982
    @@ -19462,7 +20285,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 979 + 983
    @@ -19472,7 +20295,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 980 + 984
    @@ -19482,7 +20305,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 981 + 985
    @@ -19492,7 +20315,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 982 + 986
    @@ -19502,7 +20325,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 983 + 987
    @@ -19512,7 +20335,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 984 + 988
    @@ -19522,7 +20345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 985 + 989
    @@ -19532,7 +20355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 986 + 990
    @@ -19542,7 +20365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 987 + 991
    @@ -19552,7 +20375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 988 + 992
    @@ -19562,7 +20385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 989 + 993
    @@ -19572,7 +20395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 990 + 994
    @@ -19582,7 +20405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 991 + 995
    @@ -19592,7 +20415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 992 + 996
    @@ -19602,7 +20425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 993 + 997
    @@ -19612,7 +20435,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 994 + 998
    @@ -19622,7 +20445,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 995 + 999
    @@ -19632,7 +20455,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 996 + 1000
    @@ -19642,7 +20465,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 997 + 1001
    @@ -19652,7 +20475,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 998 + 1002
    @@ -19662,7 +20485,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 999 + 1003
    @@ -19672,7 +20495,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1000 + 1004
    @@ -19682,7 +20505,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1001 + 1005
    @@ -19692,7 +20515,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1002 + 1006
    @@ -19702,7 +20525,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1003 + 1007
    @@ -19712,7 +20535,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1004 + 1008
    @@ -19722,7 +20545,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1005 + 1009
    @@ -19732,7 +20555,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1006 + 1010
    @@ -19742,7 +20565,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1007 + 1011
    @@ -19752,7 +20575,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1008 + 1012
    @@ -19762,7 +20585,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1009 + 1013
    @@ -19772,7 +20595,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1010 + 1014
    @@ -19782,7 +20605,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1011 + 1015
    @@ -19792,7 +20615,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1012 + 1016
    @@ -19802,7 +20625,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1013 + 1017
    @@ -19812,7 +20635,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1014 + 1018
    @@ -19822,7 +20645,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1015 + 1019
    @@ -19832,7 +20655,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1016 + 1020
    @@ -19842,7 +20665,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1017 + 1021
    @@ -19852,7 +20675,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1018 + 1022
    @@ -19862,7 +20685,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1019 + 1023
    @@ -19872,7 +20695,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1020 + 1024
    @@ -19882,7 +20705,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1021 + 1025
    @@ -19892,7 +20715,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1022 + 1026
    @@ -19902,7 +20725,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1023 + 1027
    @@ -19912,7 +20735,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1024 + 1028
    @@ -19922,7 +20745,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1025 + 1029
    @@ -19932,7 +20755,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1026 + 1030
    @@ -19942,7 +20765,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1027 + 1031
    @@ -19952,7 +20775,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1028 + 1032
    @@ -19962,7 +20785,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1029 + 1033
    @@ -19972,7 +20795,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1030 + 1034
    @@ -19982,7 +20805,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1031 + 1035
    @@ -19992,7 +20815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1032 + 1036
    @@ -20002,7 +20825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1033 + 1037
    @@ -20012,7 +20835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1034 + 1038
    @@ -20022,7 +20845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1035 + 1039
    @@ -20032,7 +20855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1036 + 1040
    @@ -20042,7 +20865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1037 + 1041
    @@ -20052,7 +20875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1038 + 1042
    @@ -20062,7 +20885,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1039 + 1043
    @@ -20072,7 +20895,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1040 + 1044
    @@ -20082,7 +20905,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1041 + 1045
    @@ -20097,7 +20920,422 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1167 + 1073 + + +
    +   +
    +
    + + + + 1074 + + +
    +   + // isSynced checks if the state is synchronized with L1. If a batch number is +
    + + + + 1075 + + +
    +   + // provided, it makes sure that the state is synced with that batch. +
    + + + + 1076 + + +
    + + + func (a *Aggregator) isSynced(ctx context.Context, batchNum *uint64) (bool, error) { +
    + + + + 1077 + + +
    +   + // get latest verified batch as seen by the synchronizer +
    + + + + 1078 + + +
    +   + lastVerifiedBatch, err := a.State.GetLastVerifiedBatch(ctx, nil) +
    + + + + 1079 + + +
    +   + if err == state.ErrNotFound { +
    + + + + 1080 + + +
    + + + return false, nil +
    + + + + 1081 + + +
    +   + } +
    + + + + 1082 + + +
    +   + if err != nil { +
    + + + + 1083 + + +
    +   + log.Warnf("Failed to get last consolidated batch: %v", err) +
    + + + + 1084 + + +
    + + + return false, err +
    + + + + 1085 + + +
    +   + } +
    + + + + 1086 + + +
    +   +
    +
    + + + + 1087 + + +
    +   + if lastVerifiedBatch == nil { +
    + + + + 1088 + + +
    + + + return false, nil +
    + + + + 1089 + + +
    +   + } +
    + + + + 1090 + + +
    +   +
    +
    + + + + 1091 + + +
    +   + if batchNum != nil && lastVerifiedBatch.BatchNumber < *batchNum { +
    + + + + 1092 + + +
    +   + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, waiting for batch: %d", lastVerifiedBatch.BatchNumber, batchNum) +
    + + + + 1093 + + +
    + + + return false, nil +
    + + + + 1094 + + +
    +   + } +
    + + + + 1095 + + +
    +   +
    +
    + + + + 1096 + + +
    +   + // latest verified batch in L1 +
    + + + + 1097 + + +
    +   + lastVerifiedEthBatchNum, err := a.Ethman.GetLatestVerifiedBatchNum() +
    + + + + 1098 + + +
    +   + if err != nil { +
    + + + + 1099 + + +
    +   + log.Warnf("Failed to get last eth batch, err: %v", err) +
    + + + + 1100 + + +
    + + + return false, err +
    + + + + 1101 + + +
    +   + } +
    + + + + 1102 + + +
    +   +
    +
    + + + + 1103 + + +
    +   + // check if L2 is synced with L1 +
    + + + + 1104 + + +
    +   + if lastVerifiedBatch.BatchNumber < lastVerifiedEthBatchNum { +
    + + + + 1105 + + +
    +   + log.Infof("Waiting for the state to be synced, lastVerifiedBatchNum: %d, lastVerifiedEthBatchNum: %d, waiting for batch", +
    + + + + 1106 + + +
    +   + lastVerifiedBatch.BatchNumber, lastVerifiedEthBatchNum) +
    + + + + 1107 + + +
    + + + return false, nil +
    + + + + 1108 + + +
    +   + } +
    + + + + 1109 + + +
    +   +
    +
    + + + + 1110 + + +
    + + + return true, nil +
    + + + + 1111 + + +
    +   + } +
    + + + + 1112 + + +
    +   +
    +
    + + + + 1113 + + +
    +   + func (a *Aggregator) buildInputProver(ctx context.Context, batchToVerify *state.Batch) (*prover.InputProver, error) { +
    + + + + +
     
    + + + + 1171
    @@ -20107,7 +21345,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1168 + 1172
    @@ -20117,7 +21355,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1169 + 1173
    @@ -20127,7 +21365,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1170 + 1174
    @@ -20137,7 +21375,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1171 + 1175
    @@ -20147,7 +21385,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1172 + 1176
    @@ -20157,7 +21395,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1173 + 1177
    @@ -20167,7 +21405,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1174 + 1178
    @@ -20177,7 +21415,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1175 + 1179
    @@ -20187,7 +21425,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1176 + 1180
    @@ -20202,7 +21440,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1304 + 1301
    @@ -20212,8 +21450,78 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + 1302 + + +
    +   + // wait for the synchronizer to catch up the verified batches +
    + + + + 1303 + + +
    +   + log.Debug("A final proof has been sent, waiting for the network to be synced") +
    + + + + 1304 + + +
    + + + if err := a.waitForSynchronizerToSyncUp(a.ctx, &proofBatchNumberFinal); err != nil { +
    + + + 1305 + +
    + + + log.Warn("waiting for the synchronizer to sync up was canceled", err) +
    + + + + 1306 + + +
    + + + return +
    + + + + 1307 + + +
    +   + } +
    + + + + 1308 + + +
    +   +
    +
    + + + + 1309 +
      @@ -20222,7 +21530,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1306 + 1310
    @@ -20232,7 +21540,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1307 + 1311
    @@ -20242,7 +21550,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1308 + 1312
    @@ -20252,7 +21560,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1309 + 1313
    @@ -20262,7 +21570,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1310 + 1314
    @@ -20270,6 +21578,236 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    }
    + + + 1315 + + +
    +   + } +
    + + + + 1316 + + +
    +   +
    +
    + + + + 1317 + + +
    + + + func (a *Aggregator) waitForSynchronizerToSyncUp(ctx context.Context, batchNum *uint64) error { +
    + + + + 1318 + + +
    + + + for { +
    + + + + 1319 + + +
    + + + log.Info("waiting for the synchronizer to sync...") +
    + + + + 1320 + + +
    + + + synced, err := a.isSynced(ctx, batchNum) +
    + + + + 1321 + + +
    + + + if err != nil && errors.Is(err, context.Canceled) { +
    + + + + 1322 + + +
    + + + // if context is canceled, stop the loop, since it will never +
    + + + + 1323 + + +
    + + + // be able to execute properly and break in this case, and we will be stuck in it forever +
    + + + + 1324 + + +
    + + + return err +
    + + + + 1325 + + +
    + + + } +
    + + + + 1326 + + +
    + + +
    +
    + + + + 1327 + + +
    + + + if synced { +
    + + + + 1328 + + +
    + + + return nil +
    + + + + 1329 + + +
    + + + } +
    + + + + 1330 + + +
    + + +
    +
    + + + + 1331 + + +
    + + + time.Sleep(a.cfg.RetryTime.Duration) +
    + + + + 1332 + + +
    + + + } +
    + + + + 1333 + + +
    + + + } +
    + + + + 1334 + + +
    + + +
    +
    + + + + 1335 + + +
    +   + func buildMonitoredTxID(batchNumber, batchNumberFinal uint64) string { +
    + + + + 1336 + + +
    +   + return fmt.Sprintf(monitoredIDFormat, batchNumber, batchNumberFinal) +
    + + + + 1337 + + +
    +   + } +
    + @@ -20277,7 +21815,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1320 + 1342
    @@ -20287,7 +21825,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1321 + 1343
    @@ -20297,7 +21835,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1322 + 1344
    @@ -20307,7 +21845,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1323 + 1345
    @@ -20317,7 +21855,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1324 + 1346
    @@ -20327,7 +21865,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1325 + 1347
    @@ -20337,7 +21875,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1326 + 1348
    @@ -25569,6 +27107,811 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    + + + +
    @@ -1450,9 +1450,79 @@
    + + + + 1450 + + +
    +   + tc.setup(m, &a) +
    + + + + 1451 + + +
    +   + } +
    + + + + 1452 + + +
    +   +
    +
    + + + + 1453 + + +
    + - + synced := a.isSynced(a.ctx, tc.batchNum) +
    + + + + 1454 + + +
    + - +
    +
    + + + + 1455 + + +
    +   + assert.Equal(tc.synced, synced) +
    + + + + 1456 + + +
    +   + }) +
    + + + + 1457 + + +
    +   + } +
    + + + + 1458 + + +
    +   + } +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + + + + + + +
    +   +
    +
    + @@ -30778,6 +33121,811 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    a.ctx, a.exit = context.WithCancel(aggregatorCtx)
    + + + +
     
    + + + + 1450 + + +
    +   + tc.setup(m, &a) +
    + + + + 1451 + + +
    +   + } +
    + + + + 1452 + + +
    +   +
    +
    + + + + 1453 + + +
    + + + synced, _ := a.isSynced(a.ctx, tc.batchNum) +
    + + + + + + +
    +   +
    +
    + + + + 1454 + + +
    +   + assert.Equal(tc.synced, synced) +
    + + + + 1455 + + +
    +   + }) +
    + + + + 1456 + + +
    +   + } +
    + + + + 1457 + + +
    +   + } +
    + + + + 1458 + + +
    + + +
    +
    + + + + 1459 + + +
    + + + func TestWaitForSynchronizerToSyncUp(t *testing.T) { +
    + + + + 1460 + + +
    + + + t.Parallel() +
    + + + + 1461 + + +
    + + +
    +
    + + + + 1462 + + +
    + + + cfg := Config{} +
    + + + + 1463 + + +
    + + + batchNum := uint64(42) +
    + + + + 1464 + + +
    + + + testCases := []struct { +
    + + + + 1465 + + +
    + + + name string +
    + + + + 1466 + + +
    + + + setup func(mox, *Aggregator) +
    + + + + 1467 + + +
    + + + batchNum *uint64 +
    + + + + 1468 + + +
    + + + synced bool +
    + + + + 1469 + + +
    + + + }{ +
    + + + + 1470 + + +
    + + + { +
    + + + + 1471 + + +
    + + + name: "state context canceled", +
    + + + + 1472 + + +
    + + + synced: false, +
    + + + + 1473 + + +
    + + + batchNum: &batchNum, +
    + + + + 1474 + + +
    + + + setup: func(m mox, a *Aggregator) { +
    + + + + 1475 + + +
    + + + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(nil, context.Canceled).Once() +
    + + + + 1476 + + +
    + + + }, +
    + + + + 1477 + + +
    + + + }, +
    + + + + 1478 + + +
    + + + { +
    + + + + 1479 + + +
    + + + name: "ok after multiple iterations", +
    + + + + 1480 + + +
    + + + synced: true, +
    + + + + 1481 + + +
    + + + batchNum: &batchNum, +
    + + + + 1482 + + +
    + + + setup: func(m mox, a *Aggregator) { +
    + + + + 1483 + + +
    + + + latestVerifiedBatch := state.VerifiedBatch{BatchNumber: batchNum} +
    + + + + 1484 + + +
    + + + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(nil, nil).Once() +
    + + + + 1485 + + +
    + + + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&latestVerifiedBatch, nil).Once() +
    + + + + 1486 + + +
    + + + m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNum, nil).Once() +
    + + + + 1487 + + +
    + + + }, +
    + + + + 1488 + + +
    + + + }, +
    + + + + 1489 + + +
    + + + { +
    + + + + 1490 + + +
    + + + name: "ok with batch number", +
    + + + + 1491 + + +
    + + + synced: true, +
    + + + + 1492 + + +
    + + + batchNum: &batchNum, +
    + + + + 1493 + + +
    + + + setup: func(m mox, a *Aggregator) { +
    + + + + 1494 + + +
    + + + latestVerifiedBatch := state.VerifiedBatch{BatchNumber: batchNum} +
    + + + + 1495 + + +
    + + + m.stateMock.On("GetLastVerifiedBatch", mock.Anything, nil).Return(&latestVerifiedBatch, nil).Once() +
    + + + + 1496 + + +
    + + + m.etherman.On("GetLatestVerifiedBatchNum").Return(batchNum, nil).Once() +
    + + + + 1497 + + +
    + + + }, +
    + + + + 1498 + + +
    + + + }, +
    + + + + 1499 + + +
    + + + } +
    + + + + 1500 + + +
    + + + for _, tc := range testCases { +
    + + + + 1501 + + +
    + + + t.Run(tc.name, func(t *testing.T) { +
    + + + + 1502 + + +
    + + + stateMock := mocks.NewStateMock(t) +
    + + + + 1503 + + +
    + + + ethTxManager := mocks.NewEthTxManager(t) +
    + + + + 1504 + + +
    + + + etherman := mocks.NewEtherman(t) +
    + + + + 1505 + + +
    + + + proverMock := mocks.NewProverMock(t) +
    + + + + 1506 + + +
    + + + a, err := New(cfg, stateMock, ethTxManager, etherman, nil, nil) +
    + + + + 1507 + + +
    + + + require.NoError(t, err) +
    + + + + 1508 + + +
    + + + aggregatorCtx := context.WithValue(context.Background(), "owner", "aggregator") //nolint:staticcheck +
    + + + + 1509 + + +
    + + + a.ctx, a.exit = context.WithCancel(aggregatorCtx) +
    + + + + 1510 + + +
    + + + m := mox{ +
    + + + + 1511 + + +
    + + + stateMock: stateMock, +
    + + + + 1512 + + +
    + + + ethTxManager: ethTxManager, +
    + + + + 1513 + + +
    + + + etherman: etherman, +
    + + + + 1514 + + +
    + + + proverMock: proverMock, +
    + + + + 1515 + + +
    + + + } +
    + + + + 1516 + + +
    + + + if tc.setup != nil { +
    + + + + 1517 + + +
    + + + tc.setup(m, &a) +
    + + + + 1518 + + +
    + + + } +
    + + + + 1519 + + +
    + + +
    +
    + + + + 1520 + + +
    + + + err = a.waitForSynchronizerToSyncUp(a.ctx, tc.batchNum) +
    + + + + 1521 + + +
    + + + if tc.synced { +
    + + + + 1522 + + +
    + + + assert.NoError(t, err) +
    + + + + 1523 + + +
    + + + } else { +
    + + + + 1524 + + +
    + + + assert.Error(t, err) +
    + + + + 1525 + + +
    + + + } +
    + + + + 1526 + + +
    + + + }) +
    + + + + 1527 + + +
    + + + } +
    + + + + 1528 + + +
    + + + } +
    + @@ -267442,471 +270590,288 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - 45 - - -
    -   - // ProcessBatchResponse represents the response of a batch process. -
    - - - - 46 - - -
    -   - type ProcessBatchResponse struct { -
    - - - - 47 - - -
    -   - NewStateRoot common.Hash -
    - - - - -
     
    - - - - 51 - - -
    -   - UsedZkCounters ZKCounters -
    - - - - 52 - - -
    -   - ReservedZkCounters ZKCounters -
    - - - - 53 - - -
    -   - // TransactionResponses_V1 []*ProcessTransactionResponse -
    - - - - 54 - - -
    - + - BlockResponses []*ProcessBlockResponse -
    - - - - 55 - - -
    - + - ExecutorError error -
    - - - - 56 - - -
    - + - ReadWriteAddresses map[common.Address]*InfoReadWrite -
    - - - - 57 - - -
    - + - IsRomLevelError bool -
    - - - - 58 - - -
    - + - IsExecutorLevelError bool -
    - - - - 59 - - -
    - + - IsRomOOCError bool -
    - - - - 60 - - -
    - + - FlushID uint64 -
    - - - - 61 - - -
    - + - StoredFlushID uint64 -
    - - - - 62 - - -
    - + - ProverID string -
    - - - - 63 - - -
    - + - GasUsed_V2 uint64 -
    - - - - 64 - - -
    - + - SMTKeys_V2 []merkletree.Key -
    - - - - 65 - - -
    - + - ProgramKeys_V2 []merkletree.Key -
    - - - - 66 - - -
    - + - ForkID uint64 -
    - - - - 67 - - -
    - + - InvalidBatch_V2 bool -
    - - - - 68 - - -
    - + - RomError_V2 error -
    - - - - - - -
    -   -
    -
    - - - - - - -
    -   -
    -
    - - - - + + 45 - -
    + +
      -
    + // ProcessBatchResponse represents the response of a batch process.
    - - + + 46 - -
    + +
      -
    + type ProcessBatchResponse struct {
    - 69 + 47
      - } + NewStateRoot common.Hash
    + + + +
     
    + - 70 + 51
      -
    + UsedZkCounters ZKCounters
    - 71 + 52
      - // ProcessBlockResponse represents the response of a block + ReservedZkCounters ZKCounters
    - - - -
    -
    -
    -
    -
    -
    - - {/home/stefan/go/src/Polygon/zkevm-node → .}/synchronizer/actions/check_l2block.go - RENAMED - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - -
    -
    @@ -101,7 +101,7 @@
    -
    - 101 + 53
      - trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber))) + // TransactionResponses_V1 []*ProcessTransactionResponse
    - 102 + + 54 +
    -   - if err != nil { + + + BlockResponses []*ProcessBlockResponse
    - 103 + + 55 +
    -   - log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error()) + + + ExecutorError error
    - 104 + + 56 +
    - - - return nil, nil, nil + + + ReadWriteAddresses map[common.Address]*InfoReadWrite
    - 105 + + 57 +
    -   - } + + + IsRomLevelError bool
    - 106 + + 58 +
    -   - return localL2Block, trustedL2Block, nil + + + IsExecutorLevelError bool
    - 107 + + 59 +
    -   - } + + + IsRomOOCError bool
    -
    + + + 60 + + +
    + + + FlushID uint64
    -
    -
    - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -299165,7 +302130,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -299201,7 +302166,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + @@ -300359,7 +303399,82 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -313911,33 +317126,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - @@ -313997,7 +317202,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -314011,23 +317216,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -314041,13 +317246,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - @@ -314071,23 +317276,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -315810,9 +319015,69 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -315874,6 +319179,26 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=GasPricer --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ethGasStationMock --filename=mock_ethgasstation.go + + + + + + - - @@ -315915,23 +319240,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - @@ -315961,7 +319286,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    @@ -315987,36 +319312,6 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - - - - - - - - - - - - -
    -
     
    - 101 + + 61 +
    -   - trustedL2Block, err := p.trustedClient.BlockByNumber(ctx, big.NewInt(int64(blockNumber))) + + + StoredFlushID uint64
    - 102 + + 62 +
    -   - if err != nil { + + + ProverID string
    - 103 + + 63 +
    -   - log.Errorf("checkL2block: Error getting L2Block %d from the Trusted RPC. err:%s", blockNumber, err.Error()) + + + GasUsed_V2 uint64
    - 104 + 64
    + - return nil, nil, err + SMTKeys_V2 []merkletree.Key +
    +
    + 65 + +
    + + + ProgramKeys_V2 []merkletree.Key +
    +
    + 66 + +
    + + + ForkID uint64 +
    +
    + 67 + +
    + + + InvalidBatch_V2 bool +
    +
    + 68 + +
    + + + RomError_V2 error +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    + + +
    +   +
    - 105 + 69
      - } + }
    - 106 + 70
      - return localL2Block, trustedL2Block, nil +
    - 107 + 71
      - } + // ProcessBlockResponse represents the response of a block
    - - BlockNumber: uint64(0), + BlockNumber: uint64(0),
    -
    @@ -226,7 +225,7 @@
    +
    @@ -170,7 +169,6 @@
    +
    + 170 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 171 + +
    +   + Return(uint64(7), nil). +
    +
    + 172 + +
    +   + Maybe() +
    +
    + 173 + +
    + - +
    +
    +
    + 174 + +
    +   + m.State. +
    +
    + 175 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 176 + +
    +   + Return(lastBlock0, nil). +
    +
    +
    @@ -226,7 +224,7 @@
    @@ -299276,7 +302316,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -397,7 +396,7 @@
    +
    @@ -397,7 +395,7 @@
    @@ -299351,7 +302391,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -490,7 +489,7 @@
    +
    @@ -490,7 +488,7 @@
    @@ -299426,7 +302466,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -659,7 +658,7 @@
    +
    @@ -659,7 +657,7 @@
    @@ -299501,7 +302541,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -761,11 +760,9 @@
    +
    @@ -761,11 +759,9 @@
    @@ -299616,7 +302656,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -925,7 +922,7 @@
    +
    @@ -925,7 +921,7 @@
    @@ -299691,7 +302731,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -1245,7 +1242,7 @@
    +
    @@ -1245,7 +1241,7 @@
    @@ -299766,7 +302806,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -1459,7 +1456,7 @@
    +
    @@ -1459,7 +1455,7 @@
    @@ -299841,7 +302881,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -1741,7 +1738,7 @@
    +
    @@ -1741,7 +1737,7 @@
    @@ -299916,7 +302956,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -2017,13 +2014,16 @@
    +
    @@ -2017,13 +2013,16 @@
    @@ -300081,7 +303121,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -2129,6 +2129,11 @@
    +
    @@ -2129,6 +2128,11 @@
    @@ -300319,7 +303359,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + - RollupBlockNumber: uint64(0), + RollupBlockNumber: uint64(123456),
    - 225 + 169 + +
    +   + On("GetForkIDByBatchNumber", mock.Anything). +
    +
    + 170 + +
    +   + Return(uint64(7), nil). +
    +
    + 171 + +
    +   + Maybe() +
    +
    + + +
    +   +
    +
    +
    + 172 + +
    +   + m.State. +
    +
    + 173 + +
    +   + On("GetLastBlock", ctx, m.DbTx). +
    +
    + 174 + +
    +   + Return(lastBlock0, nil). +
    +
    +
     
    +
    + 224
    @@ -300369,7 +303484,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 226 + 225
    @@ -300379,7 +303494,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 227 + 226
    @@ -300389,7 +303504,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 228 + 227
    @@ -300399,7 +303514,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 229 + 228
    @@ -300409,7 +303524,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 230 + 229
    @@ -300419,7 +303534,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 231 + 230
    @@ -300434,7 +303549,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 396 + 395
    @@ -300444,7 +303559,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 397 + 396
    @@ -300454,7 +303569,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 398 + 397
    @@ -300464,7 +303579,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 399 + 398
    @@ -300474,7 +303589,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 400 + 399
    @@ -300484,7 +303599,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 401 + 400
    @@ -300494,7 +303609,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 402 + 401
    @@ -300509,7 +303624,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 489 + 488
    @@ -300519,7 +303634,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 490 + 489
    @@ -300529,7 +303644,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 491 + 490
    @@ -300539,7 +303654,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 492 + 491
    @@ -300549,7 +303664,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 493 + 492
    @@ -300559,7 +303674,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 494 + 493
    @@ -300569,7 +303684,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 495 + 494
    @@ -300584,7 +303699,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 658 + 657
    @@ -300594,7 +303709,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 659 + 658
    @@ -300604,7 +303719,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 660 + 659
    @@ -300614,7 +303729,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 661 + 660
    @@ -300624,7 +303739,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 662 + 661
    @@ -300634,7 +303749,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 663 + 662
    @@ -300644,7 +303759,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 664 + 663
    @@ -300659,7 +303774,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 760 + 759
    @@ -300669,7 +303784,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 761 + 760
    @@ -300679,7 +303794,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 762 + 761
    @@ -300689,7 +303804,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 763 + 762
    @@ -300699,7 +303814,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 764 + 763
    @@ -300709,7 +303824,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 765 + 764
    @@ -300739,7 +303854,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 766 + 765
    @@ -300749,7 +303864,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 767 + 766
    @@ -300759,7 +303874,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 768 + 767
    @@ -300774,7 +303889,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 922 + 921
    @@ -300784,7 +303899,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 923 + 922
    @@ -300794,7 +303909,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 924 + 923
    @@ -300804,7 +303919,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 925 + 924
    @@ -300814,7 +303929,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 926 + 925
    @@ -300824,7 +303939,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 927 + 926
    @@ -300834,7 +303949,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 928 + 927
    @@ -300849,7 +303964,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1242 + 1241
    @@ -300859,7 +303974,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1243 + 1242
    @@ -300869,7 +303984,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1244 + 1243
    @@ -300879,7 +303994,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1245 + 1244
    @@ -300889,7 +304004,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1246 + 1245
    @@ -300899,7 +304014,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1247 + 1246
    @@ -300909,7 +304024,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1248 + 1247
    @@ -300924,7 +304039,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1456 + 1455
    @@ -300934,7 +304049,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1457 + 1456
    @@ -300944,7 +304059,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1458 + 1457
    @@ -300954,7 +304069,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1459 + 1458
    @@ -300964,7 +304079,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1460 + 1459
    @@ -300974,7 +304089,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1461 + 1460
    @@ -300984,7 +304099,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1462 + 1461
    @@ -300999,7 +304114,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1738 + 1737
    @@ -301009,7 +304124,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1739 + 1738
    @@ -301019,7 +304134,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1740 + 1739
    @@ -301029,7 +304144,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1741 + 1740
    @@ -301039,7 +304154,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1742 + 1741
    @@ -301049,7 +304164,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1743 + 1742
    @@ -301059,7 +304174,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 1744 + 1743
    @@ -301074,7 +304189,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2014 + 2013
    @@ -301084,7 +304199,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2015 + 2014
    @@ -301094,7 +304209,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2016 + 2015
    @@ -301104,7 +304219,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2017 + 2016
    @@ -301114,7 +304229,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2018 + 2017
    @@ -301124,7 +304239,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2019 + 2018
    @@ -301134,7 +304249,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2020 + 2019
    @@ -301144,7 +304259,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2021 + 2020
    @@ -301154,7 +304269,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2022 + 2021
    @@ -301164,7 +304279,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2023 + 2022
    @@ -301174,7 +304289,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2024 + 2023
    @@ -301184,7 +304299,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2025 + 2024
    @@ -301194,7 +304309,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2026 + 2025
    @@ -301204,7 +304319,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2027 + 2026
    @@ -301214,7 +304329,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2028 + 2027
    @@ -301224,7 +304339,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2029 + 2028
    @@ -301239,7 +304354,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2129 + 2128
    @@ -301249,7 +304364,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2130 + 2129
    @@ -301259,7 +304374,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2131 + 2130
    @@ -301269,7 +304384,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2132 + 2131
    @@ -301279,7 +304394,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2133 + 2132
    @@ -301289,7 +304404,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2134 + 2133
    @@ -301299,7 +304414,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2135 + 2134
    @@ -301309,7 +304424,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2136 + 2135
    @@ -301319,7 +304434,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2137 + 2136
    @@ -301329,7 +304444,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2138 + 2137
    @@ -301339,7 +304454,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 2139 + 2138
    @@ -313783,7 +316898,7 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -712,7 +716,7 @@
    +
    @@ -712,13 +716,13 @@
    @@ -313846,9 +316961,69 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + 718 +
    + - + +
    +
    + 719 + +
    +   + rm -Rf ../synchronizer/common/syncinterfaces/mocks +
    +
    + 720 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/common/syncinterfaces --output ../synchronizer/common/syncinterfaces/mocks --outpkg mock_syncinterfaces ${COMMON_MOCKERY_PARAMS} +
    +
    + 721 + +
    + - + +
    +
    + 722 + +
    +   + rm -Rf ../synchronizer/actions/elderberry/mocks +
    +
    + 723 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} +
    +
    + 724 +
      @@ -313858,16 +317033,56 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    -
    @@ -732,23 +736,20 @@
    +
    @@ -728,27 +732,24 @@
    - 732 + 728 + +
    +   + +
    +
    + 729 + +
    +   +
    +
    +
    + 730
      - .PHONY: generate-mocks-etherman + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} +
    +
    + 731 + +
    + - + +
    +
    + 732 + +
    + - + .PHONY: generate-mocks-etherman
    + 737 +
    -   + -
    + 738 +
    - - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ChainReader --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ChainReaderMock --filename=mock_chainreader.go ${COMMON_MOCKERY_PARAMS} -
    -
    - - -
    -   -
    + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ChainReader --srcpkg=github.com/ethereum/go-ethereum --output=../etherman --outpkg=etherman --structname=ChainReaderMock --filename=mock_chainreader.go ${COMMON_MOCKERY_PARAMS}
    - - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=stateMock --filename=mock_state_test.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=stateMock --filename=mock_state_test.go ${COMMON_MOCKERY_PARAMS}
    + 744 +
    - - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go ${COMMON_MOCKERY_PARAMS}
    + 745 +
    - - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS}
    + 747 +
    - - rm -Rf ../etherman/mockseth + rm -Rf ../etherman/mockseth
    + 750 +
    - - +  
    + 751 +
    - - .PHONY: generate-mocks-aggregator + .PHONY: generate-mocks-aggregator
    + 722 +
    + + +
    +
    +
    + 723 + +
    +   + rm -Rf ../synchronizer/common/syncinterfaces/mocks +
    +
    + 724 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/common/syncinterfaces --output ../synchronizer/common/syncinterfaces/mocks --outpkg mock_syncinterfaces ${COMMON_MOCKERY_PARAMS} +
    +
    + 725 + +
    + + +
    +
    +
    + 726 + +
    +   + rm -Rf ../synchronizer/actions/elderberry/mocks +
    +
    + 727 + +
    +   + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../synchronizer/actions/elderberry --output ../synchronizer/actions/elderberry/mocks --outpkg mock_elderberry ${COMMON_MOCKERY_PARAMS} +
    +
    + 728 +
      @@ -315826,12 +319091,52 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - 736 + 732 + +
    +   + +
    +
    + 733 + +
    +   +
    +
    +
    + 734
      - .PHONY: generate-mocks-etherman + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Tx --srcpkg=github.com/jackc/pgx/v4 --output=../synchronizer/mocks --structname=DbTxMock --filename=mock_dbtx.go ${COMMON_MOCKERY_PARAMS} +
    +
    + 735 + +
    + + +
    +
    +
    + 736 + +
    + + + .PHONY: generate-mocks-etherman
    + + +
    +   +
    +
    +
    + + +
    +   +
    +
    +
    741 @@ -315885,13 +319210,13 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    + 742 +
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=ethermanMock --filename=mock_etherman_test.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../ethtxmanager --output=../ethtxmanager --outpkg=ethtxmanager --structname=ethermanMock --filename=mock_etherman_test.go
    + 745 +
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=poolInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=poolMock --filename=mock_pool.go
    + 746 +
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ethermanInterface --dir=../gasprice --output=../gasprice --outpkg=gasprice --structname=ethermanMock --filename=mock_etherman.go
    + - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=stateMock --filename=mock_state.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=stateProvider --dir=../etherman --output=../etherman --outpkg=etherman --structname=stateMock --filename=mock_state.go
    - -
    -   -
    -
    -
    - 751 - -
    -   -
    -
    -
    - 752 - -
    - + - .PHONY: generate-mocks-aggregator -
    -
    -
    @@ -316035,23 +319330,23 @@

    zkEVM node vs CDK validium node

    zkevm-node version: v0.6.0

    - + + 751 -
    +
    +
     
    - + + 752 -
    -   -
    +
    +
    + + + .PHONY: generate-mocks-aggregator